Merge pull request #1064 from ultimatemember/development/2.4.3

Development/2.4.3
This commit is contained in:
Nikita Sinelnikov
2022-08-15 14:42:39 +03:00
committed by GitHub
27 changed files with 775 additions and 223 deletions
+48 -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,8 +1674,53 @@ 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' ) );
exit( wp_redirect( $url ) );
$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',
'awaiting_email_confirmation',
'inactive',
'rejected',
'pending_dot', // not real status key, just for the transient
'unassigned', // not real status key, just for the transient
);
foreach ( $statuses as $status ) {
delete_transient( "um_count_users_{$status}" );
}
do_action( 'um_flush_user_status_cache' );
$url = add_query_arg(
array(
'page' => 'ultimatemember',
'update' => 'cleared_status_cache',
),
admin_url( 'admin.php' )
);
wp_redirect( $url );
exit;
}
+1 -1
View File
@@ -121,7 +121,7 @@ if ( ! class_exists( 'um\admin\core\Admin_Menu' ) ) {
return;
}
$count = UM()->user()->get_pending_users_count();
$count = UM()->query()->get_pending_users_count();
if ( is_array( $menu ) ) {
foreach ( $menu as $key => $menu_item ) {
if ( 0 === strpos( $menu_item[0], _x( 'Users', 'Admin menu name' ) ) ) {
+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>',
+2 -1
View File
@@ -411,7 +411,8 @@ if ( ! class_exists( 'um\admin\core\Admin_Users' ) ) {
'rejected' => __( 'Rejected', 'ultimate-member' ),
);
UM()->query()->count_users_by_status( 'unassigned' );
// set default statuses if not already done
UM()->setup()->set_default_user_status();
foreach ( $status as $k => $v ) {
if ( isset( $_REQUEST['um_status'] ) && sanitize_key( $_REQUEST['um_status'] ) === $k ) {
+44
View File
@@ -0,0 +1,44 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function um_upgrade_phone_fields250() {
UM()->admin()->check_ajax_nonce();
um_maybe_unset_time_limit();
$forms_query = new \WP_Query;
$forms = $forms_query->query( array(
'post_type' => 'um_form',
'posts_per_page' => -1,
'fields' => 'ids',
) );
foreach ( $forms as $form_id ) {
$forms_fields = get_post_meta( $form_id, '_um_custom_fields', true );
if ( ! is_array( $forms_fields ) ) {
continue;
}
$need_update = false;
foreach ( $forms_fields as $key => &$field ) {
if ( in_array( $key, array( 'phone_number', 'mobile_number' ), true ) ) {
$field['type'] = 'tel';
$need_update = true;
}
}
if ( $need_update ) {
update_post_meta( $form_id, '_um_custom_fields', $forms_fields );
}
}
// remove cached option with users count, don't create separate AJAX upgrade for that
delete_option( 'um_cached_users_queue' );
// delete temporarily option for fields upgrade
update_option( 'um_last_version_upgrade', '2.5.0' );
wp_send_json_success( array( 'message' => __( 'Phone Number and Mobile Number fields have been successfully updated.', 'ultimate-member' ) ) );
}
+5
View File
@@ -0,0 +1,5 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit;
return array(
'phone_fields250' => 'phone_fields250',
);
+30
View File
@@ -0,0 +1,30 @@
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?>
<script type="text/javascript">
jQuery( document ).ready( function() {
um_add_upgrade_log( '<?php echo esc_js( __( 'Updated phone number fields in the UM Forms fields...', 'ultimate-member' ) ) ?>' );
jQuery.ajax({
url: wp.ajax.settings.url,
type: 'POST',
dataType: 'json',
data: {
action: 'um_phone_fields250',
nonce: um_admin_scripts.nonce
},
success: function( response ) {
if ( typeof response.data.message != 'undefined' ) {
um_add_upgrade_log( response.data.message );
//switch to the next package
um_run_upgrade();
} else {
um_wrong_ajax();
}
},
error: function() {
um_something_wrong();
}
});
});
</script>
+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>