Function
Handle AJAX deactivation of extension licenses.
tml_admin_ajax_deactivate_extension_license( )
Source
function tml_admin_ajax_deactivate_extension_license() {
if ( ! check_ajax_referer( 'theme-my-login-licenses-options', '_wpnonce', false ) ) {
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string verbatim (see wp-includes/class-wp-customize-manager.php), not a TML-specific string.
tml_send_ajax_error( __( 'There was an authentication problem. Please reload and try again.' ) );
}
$extension = tml_get_extension( tml_get_request_value( 'extension', 'post' ) );
if ( ! $extension ) {
tml_send_ajax_error( __( 'Invalid extension.', 'theme-my-login' ) );
}
if ( ! current_user_can( 'manage_options' ) ) {
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain -- reusing WP core's translated string verbatim (see wp-admin/options-general.php), not a TML-specific string.
tml_send_ajax_error( __( 'Sorry, you are not allowed to manage options for this site.' ) );
}
$response = tml_deactivate_extension_license( $extension );
if ( is_wp_error( $response ) ) {
tml_send_ajax_error( $response->get_error_message() );
}
$extension->set_license_status();
tml_send_ajax_success( __( 'Inactive', 'theme-my-login' ) );
}
Uses
Changelog
| Version | Description |
|---|---|
| 7.1 | Introduced. |