- added separate button for the user statuses count cache clearing;

This commit is contained in:
Nikita Sinelnikov
2022-08-12 20:14:39 +03:00
parent f4f84bbd7e
commit 221e54f6ce
3 changed files with 49 additions and 9 deletions
+32 -2
View File
@@ -72,6 +72,7 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
add_filter( "{$prefix}plugin_action_links_" . um_plugin, array( &$this, 'plugin_links' ) );
add_action( 'um_admin_do_action__user_cache', array( &$this, 'user_cache' ) );
add_action( 'um_admin_do_action__user_status_cache', array( &$this, 'user_status_cache' ) );
add_action( 'um_admin_do_action__purge_temp', array( &$this, 'purge_temp' ) );
add_action( 'um_admin_do_action__manual_upgrades_request', array( &$this, 'manual_upgrades_request' ) );
add_action( 'um_admin_do_action__duplicate_form', array( &$this, 'duplicate_form' ) );
@@ -1673,6 +1674,28 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
$wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'um_cache_userdata_%'" );
$url = add_query_arg(
array(
'page' => 'ultimatemember',
'update' => 'cleared_cache',
),
admin_url( 'admin.php' )
);
wp_redirect( $url );
exit;
}
/**
* Clear all users statuses count cache
*
* @param $action
*/
function user_status_cache( $action ) {
if ( ! is_admin() || ! current_user_can( 'manage_options' ) ) {
die();
}
$statuses = array(
'approved',
'awaiting_admin_review',
@@ -1687,8 +1710,15 @@ if ( ! class_exists( 'um\admin\Admin' ) ) {
delete_transient( "um_count_users_{$status}" );
}
$url = add_query_arg( array( 'page' => 'ultimatemember', 'update' => 'cleared_cache' ), admin_url( 'admin.php' ) );
exit( wp_redirect( $url ) );
$url = add_query_arg(
array(
'page' => 'ultimatemember',
'update' => 'cleared_status_cache',
),
admin_url( 'admin.php' )
);
wp_redirect( $url );
exit;
}
+6 -2
View File
@@ -440,6 +440,10 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
$messages[0]['content'] = __( 'Your user cache is now removed.', 'ultimate-member' );
break;
case 'cleared_status_cache':
$messages[0]['content'] = __( 'Your user statuses cache is now removed.', 'ultimate-member' );
break;
case 'got_updates':
$messages[0]['content'] = __( 'You have the latest updates.', 'ultimate-member' );
break;
@@ -528,13 +532,13 @@ if ( ! class_exists( 'um\admin\core\Admin_Notices' ) ) {
continue;
if ( ( is_object( $license ) && 'inactive' == $license->license ) || 'inactive' == $license ) {
$arr_inactive_license_keys[ ] = $license->item_name;
$arr_inactive_license_keys[] = $license->item_name;
}
$invalid_license++;
}
if ( ! empty( $arr_inactive_license_keys ) ) {
if ( ! empty( $arr_inactive_license_keys ) ) {
$this->add_notice( 'license_key', array(
'class' => 'error',
'message' => '<p>' . sprintf( __( 'There are %d inactive %s license keys for this site. This site is not authorized to get plugin updates. You can active this site on <a href="%s">www.ultimatemember.com</a>.', 'ultimate-member' ), count( $arr_inactive_license_keys ) , ultimatemember_plugin_name, UM()->store_url ) . '</p>',
+11 -5
View File
@@ -1,5 +1,6 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $wpdb;
@@ -7,11 +8,16 @@ $count = $wpdb->get_var(
"SELECT COUNT( option_id )
FROM {$wpdb->options}
WHERE option_name LIKE 'um_cache_userdata_%'"
); ?>
);
?>
<p><?php _e( 'Run this task from time to time to keep your DB clean.', 'ultimate-member' ) ?></p>
<p>
<a href="<?php echo esc_url( add_query_arg( 'um_adm_action', 'user_cache' ) ); ?>" class="button">
<?php printf( __( 'Clear cache of %s users', 'ultimate-member' ), $count ) ?>
<?php echo esc_html( sprintf( __( 'Clear cache of %s users', 'ultimate-member' ), $count ) ); ?>
</a>
</p>
<a href="<?php echo esc_url( add_query_arg( 'um_adm_action', 'user_status_cache' ) ); ?>" class="button">
<?php esc_html_e( 'Clear user statuses cache', 'ultimate-member' ); ?>
</a>
</p>