Automattic\WP\Cron_Control\Lock::get_lock_value PHP Метод

get_lock_value() публичный статический Метод

Retrieve a lock from cache
public static get_lock_value ( $lock )
    public static function get_lock_value($lock)
    {
        return (int) wp_cache_get(self::get_key($lock), null, true);
    }

Usage Example

 /**
  * Retrieve a lock's current value, or reset it
  */
 private function get_reset_lock($args, $assoc_args, $lock_name, $lock_limit, $lock_description)
 {
     // Output information about the lock
     \WP_CLI::line($lock_description . "\n");
     \WP_CLI::line(sprintf(__('Maximum: %s', 'automattic-cron-control'), number_format_i18n($lock_limit)) . "\n");
     // Reset requested
     if (isset($assoc_args['reset'])) {
         \WP_CLI::warning(__('Resetting lock...', 'automattic-cron-control') . "\n");
         $lock = \Automattic\WP\Cron_Control\Lock::get_lock_value($lock_name);
         $timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp($lock_name);
         \WP_CLI::line(sprintf(__('Previous value: %s', 'automattic-cron-control'), number_format_i18n($lock)));
         \WP_CLI::line(sprintf(__('Previously modified: %s GMT', 'automattic-cron-control'), date(TIME_FORMAT, $timestamp)) . "\n");
         \WP_CLI::confirm(sprintf(__('Are you sure you want to reset this lock?', 'automattic-cron-control')));
         \WP_CLI::line('');
         \Automattic\WP\Cron_Control\Lock::reset_lock($lock_name);
         \WP_CLI::success(__('Lock reset', 'automattic-cron-control') . "\n");
         \WP_CLI::line(__('New lock values:', 'automattic-cron-control'));
     }
     // Output lock state
     $lock = \Automattic\WP\Cron_Control\Lock::get_lock_value($lock_name);
     $timestamp = \Automattic\WP\Cron_Control\Lock::get_lock_timestamp($lock_name);
     \WP_CLI::line(sprintf(__('Current value: %s', 'automattic-cron-control'), number_format_i18n($lock)));
     \WP_CLI::line(sprintf(__('Last modified: %s GMT', 'automattic-cron-control'), date(TIME_FORMAT, $timestamp)));
 }