public/wordpress/wp-content/plugins/theme-my-login/includes/extensions.php
/**
 * Activate an extension license.
 *
 * @since 7.0
 *
 * @param string|Theme_My_Login_Extension $extension The extension name or object.
 * @return bool|string|WP_Error The license status on success, false if the
 *                              extension doesn't exist or WP_Error on failure.
 */
Activate an extension license.

@param string|Theme_My_Login_Extension $extension The extension name or object.
@return bool|string|WP_Error The license status on success, false if the
extension doesn't exist or WP_Error on failure.
Activate an extension license . @param string|Theme_My_Login_Extension $extension The extension name or object . @return bool|string|WP_Error The license status on success false if the extension doesn ' t exist or WP_Error on failure .
function tml_activate_extension_license( $extension ) {
	if ( ! $extension = tml_get_extension( $extension ) ) {
		return false;
	}
	$response = tml_extension_api_call( $extension->get_store_url(), array(
		'edd_action' => 'activate_license',
		'license'    => $extension->get_license_key(),
		'item_id'    => $extension->get_item_id(),
	) );
	if ( empty( $response ) ) {
		return new WP_Error( 'http_error', __( 'An error occurred, please try again.', 'theme-my-login' ) );
	}
	if ( false === $response->success ) {
		switch ( $response->error ) {
			case 'expired' :
				$message = sprintf(
					__( 'Your license key expired on %s.', 'theme_my_login' ),
					date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
				);
				break;
			case 'revoked' :
				$message = __( 'Your license key has been disabled.', 'theme-my-login' );
				break;
			case 'missing' :
			case 'item_name_mismatch' :
				$message = __( 'Invalid license.', 'theme-my-login' );
				break;
			case 'invalid' :
			case 'site_inactive' :
				$message = __( 'Your license is not active for this URL.', 'theme-my-login' );
				break;
			case 'no_activations_left':
				$message = __( 'Your license key has reached its activation limit.', 'theme-my-login' );
				break;
			default :
				$message = __( 'An error occurred, please try again.', 'theme-my-login' );
				break;
		}
		return new WP_Error( $response->error, $message );
	}
	return $response->license;
}
function tml_activate_extension_license ( $ extension ) { if ( ! $ extension = tml_get_extension ( $ extension ) ) { return false ; } $ response = tml_extension_api_call ( $ extension -> get_store_url ( ) , array ( 'edd_action' => 'activate_license' , 'license' => $ extension -> get_license_key ( ) , 'item_id' => $ extension -> get_item_id ( ) , ) ) ; if ( empty ( $ response ) ) { return new WP_Error ( 'http_error' , __ ( 'An error occurred, please try again.' , 'theme-my-login' ) ) ; } if ( false === $ response -> success ) { switch ( $ response -> error ) { case 'expired' : $ message = sprintf ( __ ( 'Your license key expired on %s.' , 'theme_my_login' ) , date_i18n ( get_option ( 'date_format' ) , strtotime ( $ license_data -> expires , current_time ( 'timestamp' ) ) ) ) ; break ; case 'revoked' : $ message = __ ( 'Your license key has been disabled.' , 'theme-my-login' ) ; break ; case 'missing' : case 'item_name_mismatch' : $ message = __ ( 'Invalid license.' , 'theme-my-login' ) ; break ; case 'invalid' : case 'site_inactive' : $ message = __ ( 'Your license is not active for this URL.' , 'theme-my-login' ) ; break ; case 'no_activations_left' : $ message = __ ( 'Your license key has reached its activation limit.' , 'theme-my-login' ) ; break ; default : $ message = __ ( 'An error occurred, please try again.' , 'theme-my-login' ) ; break ; } return new WP_Error ( $ response -> error , $ message ) ; } return $ response -> license ; }
Activate an extension license.
Activate an extension license .