Function
Handle extension license activation and deactivation.
tml_admin_handle_extension_licenses( )
Source
function tml_admin_handle_extension_licenses() {
if ( ! tml_is_post_request() ) {
return;
}
if ( tml_get_request_value( 'option_page' ) !== 'theme-my-login-licenses' ) {
return;
}
check_admin_referer( 'theme-my-login-licenses-options' );
if ( ! current_user_can( 'manage_options' ) ) {
// phpcs:ignore WordPress.WP.I18n.MissingArgDomain, WordPress.Security.EscapeOutput.OutputNotEscaped -- reusing WP core's translated string verbatim (see wp-admin/options-general.php), not a TML-specific string.
wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
}
// Loop through all extensions
foreach ( tml_get_extensions() as $extension ) {
// Handle license activations
if ( isset( $_POST['tml_activate_license'][ $extension->get_name() ] ) ) {
$response = tml_activate_extension_license( $extension );
if ( $response ) {
if ( is_wp_error( $response ) ) {
$extension->set_license_status();
add_settings_error(
'tml_activate_license',
$response->get_error_code(),
$response->get_error_message()
);
} else {
$extension->set_license_status( $response );
}
}
}
// Handle license deactivations
if ( isset( $_POST['tml_deactivate_license'][ $extension->get_name() ] ) ) {
$response = tml_deactivate_extension_license( $extension );
if ( $response ) {
if ( is_wp_error( $response ) ) {
add_settings_error(
'tml_deactivate_license',
$response->get_error_code(),
$response->get_error_message()
);
} else {
$extension->set_license_status();
}
}
}
}
}
Uses
Changelog
| Version | Description |
|---|---|
| 7.0 | Introduced. |