예제 #1
0
 public function setSections()
 {
     //---- Theme Option Here ----//
     $schedules = array();
     $wp_get_schedules = function_exists('wp_get_schedules') ? wp_get_schedules() : null;
     if (is_array($wp_get_schedules) && !empty($wp_get_schedules)) {
         foreach ($wp_get_schedules as $key => $value) {
             $schedules[$key] = $value['display'];
         }
     }
     // General settings
     $this->sections[] = array('title' => __('General', 'gazeta'), 'icon' => 'el-icon-website', 'desc' => null, 'fields' => array(array('id' => 'favicon', 'type' => 'media', 'url' => true, 'preview' => false, 'subtitle' => __('Upload any media using the WordPress native uploader', 'gazeta'), 'title' => __('Favicon', 'gazeta')), array('id' => 'sidebar', 'type' => 'image_select', 'title' => __('Blog Layout', 'gazeta'), 'options' => array('left-sidebar' => array('alt' => __('Left Sidebar', 'gazeta'), 'img' => ReduxFramework::$_url . 'assets/img/2cl.png'), 'right-sidebar' => array('alt' => __('Right Sidebar', 'gazeta'), 'img' => ReduxFramework::$_url . 'assets/img/2cr.png')), 'default' => 'right-sidebar', 'description' => __('Set the layout of the blog/category/archive/author/tag/search page, not for static page.', 'gazeta')), array('id' => 'transient', 'type' => 'checkbox', 'title' => __('Enable Transient', 'gazeta'), 'description' => __('Caching the Widget/Shortcode', 'gazeta'), 'default' => '0'), array('id' => 'transient_expiration', 'type' => 'text', 'title' => __('Transient Expiration', 'gazeta'), 'subtitle' => __('Set/update the expiration value of the transients.', 'gazeta'), 'validate' => 'numeric', 'description' => __('Time until expiration in seconds from now, or 0 for never expires. Ex: For one day, the expiration value would be: (60 * 60 * 24), all widgets and shortcodes will be cached with expiration is 300 seconds (mean is 5 minutes), you can set this value in the widget or the shortcode with the various values, example: <strong>[shortcode expiration="600"]</strong> or enter a general value in this option, this will effect to all Widgets and Shortcodes.', 'gazeta'), 'required' => array('transient', "=", '1')), array('id' => '404-page', 'type' => 'select', 'data' => 'pages', 'title' => __('404 Page', 'gazeta'), 'subtitle' => __('Choose the 404 Error Page.', 'gazeta'), 'description' => __('Or leave blank for default.', 'gazeta')), array('id' => 'viewing', 'type' => 'switch', 'title' => __('Viewing', 'gazeta'), 'subtitle' => __('Activating Post Viewing feature.', 'gazeta'), 'description' => __('On/Off will display/hide the View count number, this feature require Jetpack\'s Stats feature activated.', 'gazeta'), 'default' => 1), array('id' => 'custom_css', 'type' => 'ace_editor', 'title' => __('Custom CSS', 'gazeta'), 'subtitle' => __('Paste your CSS code here, no style tag.', 'gazeta'), 'mode' => 'css', 'theme' => 'monokai'), array('id' => 'custom_css_mobile', 'type' => 'ace_editor', 'title' => __('Mobile Custom CSS', 'gazeta'), 'subtitle' => __('Paste your CSS code here, no style tag, this CSS will effect to the site on Mobile.', 'gazeta'), 'mode' => 'css', 'theme' => 'monokai'), array('id' => 'custom_js', 'type' => 'ace_editor', 'title' => __('Custom JS', 'gazeta'), 'subtitle' => __('Paste your JS code here, no script tag, eg: alert(\'hello world\');', 'gazeta'), 'mode' => 'javascript', 'theme' => 'chrome'), array('id' => 'custom_js_mobile', 'type' => 'ace_editor', 'title' => __('Mobile Custom JS', 'gazeta'), 'subtitle' => __('Paste your JS code here, no script tag, this JS will effect to the site on Mobile eg: alert(\'hello world\');', 'gazeta'), 'mode' => 'javascript', 'theme' => 'chrome')));
     // Styling.
     $this->sections[] = array('title' => __('Styling', 'gazeta'), 'icon' => 'el-icon-th-list', 'desc' => null, 'fields' => array(array('id' => 'body', 'type' => 'typography', 'title' => __('Body', 'gazeta'), 'font-size' => false, 'color' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('body'), 'compiler' => array('body'), 'units' => 'px', 'default' => array('font-family' => 'Raleway', 'google' => true)), array('id' => 'menu', 'type' => 'typography', 'title' => __('Menu Item', 'gazeta'), 'font-size' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('header nav ul li a'), 'compiler' => array('header nav ul li a'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading', 'type' => 'typography', 'title' => __('Heading', 'gazeta'), 'font-size' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h1,h2,h3,h4,h5,h6'), 'compiler' => array('h1,h2,h3,h4,h5,h6'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading1', 'type' => 'typography', 'title' => __('Heading 1', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h1'), 'compiler' => array('h1'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading2', 'type' => 'typography', 'title' => __('Heading 2', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h2'), 'compiler' => array('h2'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading3', 'type' => 'typography', 'title' => __('Heading 3', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h3'), 'compiler' => array('h3'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading4', 'type' => 'typography', 'title' => __('Heading 4', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h4'), 'compiler' => array('h4'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading5', 'type' => 'typography', 'title' => __('Heading 5', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h5'), 'compiler' => array('h5'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'heading6', 'type' => 'typography', 'title' => __('Heading 6', 'gazeta'), 'color' => false, 'font-family' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('h6'), 'compiler' => array('h6'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'entry-title', 'type' => 'typography', 'title' => __('Entry Title', 'gazeta'), 'font-size' => false, 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('.entry-title, .entry-title a, .post-title a'), 'compiler' => array('.entry-title, .entry-title a, .post-title a'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'entry-content', 'type' => 'typography', 'title' => __('Entry Content', 'gazeta'), 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('div.entry-content p, p.entry-content'), 'compiler' => array('div.entry-content p, p.entry-content'), 'units' => 'px', 'default' => array('font-family' => 'Arial', 'google' => true)), array('id' => 'widget-heading-font', 'type' => 'typography', 'title' => __('Widget Heading Font', 'gazeta'), 'font-weight' => false, 'font-style' => false, 'subsets' => false, 'google' => true, 'subsets' => false, 'font-backup' => false, 'text-align' => false, 'line-height' => false, 'all_styles' => true, 'output' => array('.side-widget h5 span'), 'compiler' => array('.side-widget h5 span'), 'units' => 'px', 'default' => array('font-family' => 'Oswald', 'google' => true)), array('id' => 'widget_heading_wrapper_bg', 'type' => 'background', 'output' => array('.side-widget h5'), 'title' => __('Widget Wrapper Background', 'saturn'), 'subtitle' => __('Pick a background color for the Widget Heading.', 'saturn'), 'background-repeat' => false, 'background-attachment' => false, 'background-position' => false, 'background-image' => false, 'background-size' => false), array('id' => 'widget_heading_inner_bg', 'type' => 'background', 'output' => array('.side-widget h5 span'), 'title' => __('Widget Inner Background', 'saturn'), 'subtitle' => __('Pick a background color for the Widget Heading.', 'saturn'), 'background-repeat' => false, 'background-attachment' => false, 'background-position' => false, 'background-image' => false, 'background-size' => false), array('id' => 'widget_heading_color', 'type' => 'color', 'output' => array('.side-widget h5 span'), 'title' => __('Widget Heading Color', 'saturn'), 'subtitle' => __('Pick a color for the Widget Heading (default: #fff).', 'saturn'), 'validate' => 'color')));
     $header_field = array();
     $header_field[] = array('id' => 'top_bar', 'type' => 'checkbox', 'title' => __('Shows the Top Bar', 'gazeta'), 'default' => '1');
     $header_field[] = array('id' => 'header_current_time', 'type' => 'checkbox', 'title' => __('Current Datetime', 'gazeta'), 'subtitle' => __('Display current datetime', 'gazeta'), 'default' => '1');
     $header_field[] = array('id' => 'header_current_time_format', 'type' => 'text', 'title' => __('Datetime Format', 'gazeta'), 'subtitle' => __('Formatting Date and Time', 'gazeta'), 'description' => sprintf(__('Check <strong>%s</strong> for more info.', 'gazeta'), '<a href="http://codex.wordpress.org/Formatting_Date_and_Time">' . __('HERE', 'gazeta') . '</a>'), 'default' => 'l, F j, Y');
     $header_field[] = array('id' => 'header_weather', 'type' => 'checkbox', 'title' => __('Weather', 'gazeta'), 'subtitle' => __('Display the Weather Informations', 'gazeta'), 'default' => '0');
     $header_field[] = array('id' => 'header_weather_apikey', 'type' => 'text', 'title' => __('Wunderground API Key', 'gazeta'), 'subtitle' => __('A paid service of Wunderground.com', 'gazeta'), 'description' => sprintf(__('This Key can be found at %s, You would need to signup and register a key, <i>This featured may not work properly for some locations.</i>', 'gazeta'), '<a href="http://www.wunderground.com/weather/api/">' . __('HERE', 'gazeta') . '</a>'), 'required' => array('header_weather', "=", '1'));
     $header_field[] = array('id' => 'header_weather_location', 'type' => 'text', 'title' => __('Location', 'gazeta'), 'subtitle' => __('Getting this location\'s weather information', 'gazeta'), 'description' => sprintf(__('Or leave blank for getting visitor\'s location, the location is based on the IP address, here is %s', 'gazeta'), '<a target="_blank" href="http://ipinfo.io/">' . __('yours', 'gazeta') . '</a>'), 'required' => array('header_weather', "=", '1'));
     $header_field[] = array('id' => 'header_weather_expiration', 'type' => 'text', 'title' => __('Transient Expiration', 'gazeta'), 'subtitle' => __('Set/update the expiration value of the transients.', 'gazeta'), 'default' => 1200, 'required' => array('header_weather', "=", '1'));
     $socials_field = function_exists('gazeta_user_contactmethods') ? gazeta_user_contactmethods(array()) : '';
     if (is_array($socials_field)) {
         foreach ($socials_field as $key => $value) {
             $header_field[] = array('id' => 'header_social_' . $key, 'type' => 'text', 'title' => $value, 'subtitle' => sprintf(__('%s Profile Url', 'gazeta'), $value));
         }
     }
     // Header.
     $this->sections[] = array('title' => __('Header', 'gazeta'), 'icon' => 'el-icon-wrench', 'desc' => null, 'fields' => apply_filters('gazeta_theme_options/header_field_args', $header_field));
     // Footer.
     $this->sections[] = array('title' => __('Footer', 'gazeta'), 'icon' => 'el-icon-wrench', 'desc' => null, 'fields' => array(array('id' => 'footer-columns', 'type' => 'text', 'title' => __('Footer\'s Columns', 'gazeta'), 'subtitle' => __('Setting the Footer\'s widget columns.', 'gazeta'), 'validate' => 'numeric', 'default' => '4'), array('id' => 'credits', 'type' => 'textarea', 'title' => __('Footer Text', 'gazeta'), 'subtitle' => __('HTML Allowed', 'gazeta'), 'validate' => 'html', 'default' => sprintf(__('Copyright &copy; 2014 %s', 'gazeta'), get_bloginfo('name')))));
 }
예제 #2
0
	public static function add( $hook, $recurrence, $args = array() ) {
		$args      = array_slice( func_get_args(), 2 );
		$schedules = wp_get_schedules();
		if ( isset( $schedules[$recurrence] ) && ( $current = $schedules[$recurrence] ) ) {
			return wp_schedule_event( time() + $current['interval'], $recurrence, $hook, $args );
		}
	}
예제 #3
0
 function schedule_cron()
 {
     if (false === wp_next_scheduled('do_scheduled_async_scan')) {
         $schedules = wp_get_schedules();
         wp_schedule_event(time() + $schedules['vip-scanner-interval']['interval'], 'vip-scanner-interval', 'do_scheduled_async_scan');
     }
 }
예제 #4
0
 public function create_auto_cache_timeout($recurrance, $interval)
 {
     $exist_cronjob = false;
     $wpfc_timeout_number = 0;
     $crons = _get_cron_array();
     foreach ((array) $crons as $cron_key => $cron_value) {
         foreach ((array) $cron_value as $hook => $events) {
             if (preg_match("/^wp\\_fastest\\_cache(.*)/", $hook, $id)) {
                 if (!$id[1] || preg_match("/^\\_(\\d+)\$/", $id[1])) {
                     $wpfc_timeout_number++;
                     foreach ((array) $events as $event_key => $event) {
                         $schedules = wp_get_schedules();
                         if (isset($event["args"]) && isset($event["args"][0])) {
                             if ($event["args"][0] == '{"prefix":"all","content":"all"}') {
                                 if ($schedules[$event["schedule"]]["interval"] <= $interval) {
                                     $exist_cronjob = true;
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$exist_cronjob) {
         $args = array("prefix" => "all", "content" => "all");
         wp_schedule_event(time(), $recurrance, "wp_fastest_cache_" . $wpfc_timeout_number, array(json_encode($args)));
     }
 }
예제 #5
0
 /**
  * Register a cron task
  * @param string $cronActionName The name of the action that will be registered with wp-cron
  * @param string $callback The function to register with wp-cron
  * @param string $interval can only be one of the following: hourly, daily and twicedaily if no other custom intervals are registered. Defaults to daily
  * @return void
  */
 public static function registerCronTask($cronActionName, $callback, $interval = 'daily')
 {
     if (!is_callable($callback)) {
         return;
     }
     // if cron disabled -> run callback
     if (!self::canRegisterCronTask()) {
         self::registerTask($callback);
         return;
     }
     $interval = strtolower($interval);
     if (empty($interval)) {
         $interval = 'daily';
     } else {
         // check to see if the time interval is valid
         $timeIntervals = wp_get_schedules();
         if (!array_key_exists($interval, $timeIntervals)) {
             $interval = 'daily';
         }
     }
     // avoid duplicate crons
     add_action($cronActionName, $callback);
     if (!wp_next_scheduled($cronActionName)) {
         wp_schedule_event(time(), $interval, $cronActionName);
         array_push(self::$_cronTasks, $cronActionName);
     }
 }
예제 #6
0
 /**
  * Checks Cron setup, validates schedules, and reschedules events if necessary.
  *
  * @attaches-to `init` hook.
  *
  * @since 151220 Improving WP Cron setup and validation of schedules
  */
 public function checkCronSetup()
 {
     if (!get_transient('doing_cron') && $this->options['crons_setup'] < 1439005906 || $this->options['crons_setup_on_namespace'] !== __NAMESPACE__ || $this->options['crons_setup_with_cache_cleanup_schedule'] !== $this->options['cache_cleanup_schedule'] || $this->options['crons_setup_on_wp_with_schedules'] !== sha1(serialize(wp_get_schedules())) || !wp_next_scheduled('_cron_' . GLOBAL_NS . '_cleanup')) {
         wp_clear_scheduled_hook('_cron_' . GLOBAL_NS . '_cleanup');
         wp_schedule_event(time() + 60, $this->options['cache_cleanup_schedule'], '_cron_' . GLOBAL_NS . '_cleanup');
         $this->updateOptions(['crons_setup' => time(), 'crons_setup_on_namespace' => __NAMESPACE__, 'crons_setup_with_cache_cleanup_schedule' => $this->options['cache_cleanup_schedule'], 'crons_setup_on_wp_with_schedules' => sha1(serialize(wp_get_schedules()))]);
     }
 }
예제 #7
0
파일: admin.php 프로젝트: ajenta/vidtrial
 public function vidtrial_schedule_freq($val)
 {
     $schedules = wp_get_schedules();
     $valid = '"' . implode(', ', array_keys($schedules)) . '"';
     if (!array_key_exists($val, $schedules)) {
         throw new ValidationError(sprintf(__("Schedule must be one of the following: %s.", VIDTRIAL_TD), $valid));
     }
     return $val;
 }
예제 #8
0
 /**
  * Schedule the cron. The unschedule method is called to cancel the cron previously scheduled
  * and reschedule it if the interval has been changed
  *
  * @since 1.0
  */
 public function schedule_event()
 {
     $option = get_option('social_archiver');
     $interval = isset($option['twitter_cron_interval']) ? esc_attr($option['twitter_cron_interval']) : 'hourly';
     $schedules = wp_get_schedules();
     if (!isset($schedules[$interval])) {
         return;
     }
     $this->unschedule_event();
     wp_schedule_event(time() + $schedules[$interval]['interval'], $interval, self::$event_name);
 }
예제 #9
0
 public static function prettyCronInterval($interval)
 {
     $schedule_intervals = wp_get_schedules();
     foreach ($schedule_intervals as $interval_tag => $schedule_interval) {
         if ($interval == $schedule_interval['interval']) {
             return array($interval_tag, $schedule_interval['display']);
         }
     }
     return false;
     // Not found.
 }
 /**
  * Schedule internal jobs
  */
 public function schedule_internal_events()
 {
     $when = strtotime(sprintf('+%d seconds', JOB_QUEUE_WINDOW_IN_SECONDS));
     $schedules = wp_get_schedules();
     foreach ($this->internal_jobs as $job_args) {
         if (!wp_next_scheduled($job_args['action'])) {
             $interval = array_key_exists($job_args['schedule'], $schedules) ? $schedules[$job_args['schedule']]['interval'] : 0;
             $args = array('schedule' => $job_args['schedule'], 'args' => array(), 'interval' => $interval);
             Cron_Options_CPT::instance()->create_or_update_job($when, $job_args['action'], $args);
         }
     }
 }
예제 #11
0
function schedule_recurring_event($event)
{
    global $wpdb;
    $schedules = wp_get_schedules();
    $schedule = $event->schedule;
    $job = new Job();
    $job->hook = $event->hook;
    $job->site = get_current_blog_id();
    $job->start = $job->nextrun = $event->timestamp;
    $job->interval = $event->interval;
    $job->args = $event->args;
    $job->save();
}
예제 #12
0
파일: Cron.php 프로젝트: jasmun/Noco100
 /**
  * @return array
  */
 public static function getAllSchedules()
 {
     if (self::$_allSchedules === null) {
         $result = array();
         if (function_exists('wp_get_schedules')) {
             foreach (wp_get_schedules() as $k => $v) {
                 $result[$k] = $v['display'];
             }
         }
         self::$_allSchedules = $result;
     }
     return self::$_allSchedules;
 }
function spa_get_cron_data()
{
    $data = new stdClass();
    $data->cron = _get_cron_array();
    foreach ($data->cron as $time => $hooks) {
        foreach ($hooks as $hook => $items) {
            foreach ($items as $key => $item) {
                $data->cron[$time][$hook][$key]['date'] = date_i18n(SFDATES, $time) . ' - ' . date_i18n(SFTIMES, $time);
            }
        }
    }
    $data->schedules = wp_get_schedules();
    return $data;
}
function kt_cron_schedules_metabox_callback()
{
    $schedules = wp_get_schedules();
    if (KT::arrayIssetAndNotEmpty($schedules)) {
        echo "<ol>";
        foreach ($schedules as $key => $values) {
            if (KT::arrayIssetAndNotEmpty($values)) {
                $interval = KT::arrayTryGetValue($values, "interval");
                $display = KT::arrayTryGetValue($values, "display");
                echo "<li><b>{$key}</b> (<i>{$display}</i>) - {$interval} [s]</li>";
            }
        }
        echo "</ol>";
    }
}
 public function reschedule()
 {
     // NOTE
     // If cron previously registered was not in here
     // it will not be unscheduled now, but next time
     // it will be fired.
     foreach (array_keys($this->get_cron_job_list()) as $cron_id) {
         $this->unschedule($cron_id);
         $schedule_id = $this->backup()->settings()->get_cron_schedule($cron_id);
         $schedules = wp_get_schedules();
         if (isset($schedules[$schedule_id])) {
             $schedule_interval = $schedules[$schedule_id]['interval'];
             $completed_at = $this->backup()->settings()->get_cron_completed_at($cron_id);
             // First time backup should be made right now. Then each time an interval was passed.
             wp_schedule_event(max($completed_at + $schedule_interval, time()), $schedule_id, 'fw_backup_cron', array($cron_id));
         }
     }
 }
 /**
  * Runs upon plugin activation, registering our scheduled task used to process
  * batches of pending import record inserts/updates.
  */
 public function register_scheduled_task()
 {
     $schedules = wp_get_schedules();
     if (wp_next_scheduled(self::$scheduled_key)) {
         return;
     }
     /**
      * Filter the interval at which to process import records.
      *
      * By default a custom interval of ever 30mins is specified, however
      * other intervals such as "hourly", "twicedaily" and "daily" can
      * normally be substituted.
      *
      * @see wp_schedule_event()
      * @see 'cron_schedules'
      */
     $interval = apply_filters('tribe_aggregator_record_processor_interval', 'tribe-every15mins');
     wp_schedule_event(time(), $interval, self::$scheduled_key);
 }
예제 #17
0
 /**
  * List out all of the crons that can be run.
  *
  * ## EXAMPLES
  *
  * wp videopress list_crons
  */
 public function list_crons()
 {
     $scheduler = VideoPress_Scheduler::init();
     $crons = $scheduler->get_crons();
     $schedules = wp_get_schedules();
     if (count($crons) === 0) {
         WP_CLI::success(__('Found no available cron jobs.', 'jetpack'));
     } elseif (count($crons) === 1) {
         WP_CLI::success(__('Found 1 available cron job.', 'jetpack'));
     } else {
         WP_CLI::success(sprintf(__('Found %d available cron jobs.', 'jetpack'), count($crons)));
     }
     foreach ($crons as $cron_name => $cron) {
         $interval = isset($schedules[$cron['interval']]['display']) ? $schedules[$cron['interval']]['display'] : $cron['interval'];
         $runs_next = $scheduler->check_cron($cron_name);
         $status = $runs_next ? sprintf('Scheduled - Runs Next at %s GMT', gmdate('Y-m-d H:i:s', $runs_next)) : 'Not Scheduled';
         WP_CLI::log('Name: ' . $cron_name);
         WP_CLI::log('Method: ' . $cron['method']);
         WP_CLI::log('Interval: ' . $interval);
         WP_CLI::log('Status: ' . $status);
     }
 }
예제 #18
0
 /**
  * Create transient cache with background updates
  *
  * @param string $key unique transient key
  * @param callable $callback update function
  * @param string $recurrence how often the cache should be updated, default is 'hourly'
  *
  * @throws WpException
  */
 public static function create($key, $callback, $recurrence = 'hourly')
 {
     $key = sanitize_key($key);
     if (empty($key)) {
         throw new WpException('Invalid Transient key');
     }
     if (!Action::is_callable($callback)) {
         throw new WpException('Invalid Transient callback');
     }
     $schedules = wp_get_schedules();
     if (!isset($schedules[$recurrence])) {
         throw new WpException('Invalid Transient recurrence');
     }
     $cron_action_key = static::_get_cron_action_key($key);
     add_action($cron_action_key, function () use($key, $callback) {
         $value = Action::execute($callback);
         set_transient($key, $value, 0);
     });
     if (!wp_next_scheduled($cron_action_key)) {
         wp_schedule_event(time(), $recurrence, $cron_action_key);
     }
 }
 public function admin_init()
 {
     add_filter(sprintf('pre_update_option_%s', 'orbis_timesheets_email_frequency'), array($this, 'update_option_frequency'), 10, 2);
     // E-mail
     add_settings_section('orbis_timesheets_settings_general', __('General Settings', 'orbis_timesheets'), '__return_false', 'orbis_timesheets_settings');
     add_settings_field('orbis_timesheets_registration_limit_lower', __('Registration Limit Lower', 'orbis_timesheets'), array($this, 'input_select'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_general', array('label_for' => 'orbis_timesheets_registration_limit_lower', 'options' => array('0' => __('None', 'orbis_timesheets'), '1 day' => __('1 Day', 'orbis_timesheets'), '3 days' => __('3 Days', 'orbis_timesheets'), '1 week' => __('1 Week', 'orbis_timesheets'), '1 month' => __('1 Month', 'orbis_timesheets'))));
     register_setting('orbis_timesheets', 'orbis_timesheets_registration_limit_lower');
     // E-mail
     add_settings_section('orbis_timesheets_settings_email', __('E-mail Settings', 'orbis_timesheets'), '__return_false', 'orbis_timesheets_settings');
     $options = array('');
     foreach (wp_get_schedules() as $name => $schedule) {
         $options[$name] = $schedule['display'];
     }
     add_settings_field('orbis_timesheets_email_frequency', __('Frequency', 'orbis_timesheets'), array($this, 'input_select'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_email', array('label_for' => 'orbis_timesheets_email_frequency', 'options' => $options));
     add_settings_field('orbis_timesheets_email_time', __('Time', 'orbis_timesheets'), array($this, 'input_text'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_email', array('label_for' => 'orbis_timesheets_email_time', 'classes' => array()));
     add_settings_field('orbis_timesheets_emails_next_schedule', __('Next Schedule', 'orbis_timesheets'), array($this, 'next_schedule'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_email');
     add_settings_field('orbis_timesheets_email_subject', __('Subject', 'orbis_timesheets'), array($this, 'input_text'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_email', array('label_for' => 'orbis_timesheets_email_subject'));
     add_settings_field('orbis_timesheets_email_manually', __('E-mail Manually', 'orbis_timesheets'), array($this, 'button_email_manually'), 'orbis_timesheets_settings', 'orbis_timesheets_settings_email', array('label_for' => 'orbis_timesheets_email_subject'));
     register_setting('orbis_timesheets', 'orbis_timesheets_email_frequency');
     register_setting('orbis_timesheets', 'orbis_timesheets_email_time');
     register_setting('orbis_timesheets', 'orbis_timesheets_email_subject');
 }
예제 #20
0
파일: ajax.php 프로젝트: dannyoz/tls
 public function add_schedule()
 {
     $params = $_REQUEST;
     // Return error when noonce doesn't match
     if (!wp_verify_nonce($params['noonce'], 'add_schedule')) {
         die(json_encode(array('status' => 'error', 'details' => __('Sorry, wrong noonce.', 'acm'))));
     }
     if ($params['interval'] <= 0) {
         die(json_encode(array('status' => 'error', 'details' => __('Sorry, interval can\'t be less than 1 second.', 'acm'))));
     }
     if (is_numeric($params['name'])) {
         die(json_encode(array('status' => 'error', 'details' => __('Sorry, Schedule name can\'t be numeric.', 'acm'))));
     }
     // Get schedules from option and from WP
     $schedules_opt = get_option('acm_schedules', array());
     $schedules_arr = wp_get_schedules();
     $schedules = array_merge($schedules_opt, $schedules_arr);
     $params['name'] = strtolower(trim(str_replace(' ', '_', $params['name'])));
     foreach ($schedules as $name => $schedule) {
         // Return error when there is that schedule already
         if ($params['name'] == $name) {
             die(json_encode(array('status' => 'error', 'details' => sprintf(__('Sorry, there already is %s schedule.', 'acm'), $name))));
         }
         // Return error when there is schedule with the same interval
         if ($params['interval'] == $schedule['interval']) {
             die(json_encode(array('status' => 'error', 'details' => sprintf(__('Sorry, there already is schedule with %1$s seconds interval (%2$s).', 'acm'), $params['interval'], $name))));
         }
     }
     // Add new schedule
     $schedules_opt[$params['name']] = array('interval' => $params['interval'], 'display' => $params['display']);
     // Update option with new schedule
     update_option('acm_schedules', $schedules_opt);
     $li = '<li id="single-schedule-' . $params['name'] . '">' . $params['name'] . ' - ' . $params['display'] . ' <a data-confirm="' . sprintf(__('Are you sure you want to delete %s schedule?', 'acm'), $params['name']) . '" data-schedule="' . $params['name'] . '" data-noonce="' . wp_create_nonce('remove_schedule_' . $params['name']) . '" class="remove remove-schedule">Remove</a></li>';
     $select = '<option value="' . $params['name'] . '">' . $params['display'] . '</option>';
     die(json_encode(array('status' => 'success', 'li' => $li, 'select' => $select)));
 }
예제 #21
0
 /**
  * Configures CRON job events with WordPress®.
  *
  * @param array $cron_jobs An array of CRON jobs to configure.
  *
  * @return integer The number of new CRON jobs configured by this routine.
  *    Returns `0` if nothing was new (e.g. all CRONs already configured properly).
  *
  * @throws exception If invalid types are passed through arguments list.
  * @throws exception If any CRON job fails validation.
  */
 public function config($cron_jobs)
 {
     $this->check_arg_types('array', func_get_args());
     $schedules = array_keys(wp_get_schedules());
     $config = $this->©options->get('crons.config');
     $configurations = 0;
     // Initialize to zero.
     foreach ($cron_jobs as $_key => $_cron_job) {
         if (!is_array($_cron_job) || !$this->©string->is_not_empty($_cron_job['©class.method']) || substr_count($_cron_job['©class.method'], '©') !== 1 || substr_count($_cron_job['©class.method'], '.') !== 1 || !$this->©string->is_not_empty($_cron_job['schedule']) || !in_array($_cron_job['schedule'], $schedules, TRUE)) {
             throw $this->©exception($this->method(__FUNCTION__) . '#invalid_cron_job', get_defined_vars(), $this->__('Invalid CRON job (missing and/or invalid array keys).') . ' ' . sprintf($this->__('Got: `%1$s`.'), $this->©var->dump($_cron_job)));
         }
         $_key = $_cron_job['©class.method'];
         // Using this as: `$config[$_key]`.
         list($_cron_job['©class'], $_cron_job['method']) = explode('.', $_cron_job['©class.method'], 2);
         $_cron_job['event_hook'] = '_cron__' . $this->instance->plugin_root_ns_stub . '__' . trim($_cron_job['©class'], '©') . '__' . $_cron_job['method'];
         $this->add_action($_cron_job['event_hook'], $_cron_job['©class.method']);
         if (!empty($config[$_key]['last_config_time'])) {
             $_cron_job['last_config_time'] = (int) $config[$_key]['last_config_time'];
         } else {
             $_cron_job['last_config_time'] = 0;
         }
         if (!$_cron_job['last_config_time'] || $_cron_job['schedule'] !== $this->©string->is_not_empty_or($config[$_key]['schedule'], '')) {
             wp_clear_scheduled_hook($_cron_job['event_hook']);
             wp_schedule_event(time() + mt_rand(300, 18000), $_cron_job['schedule'], $_cron_job['event_hook']);
             $_cron_job['last_config_time'] = time();
             $config[$_key] = $_cron_job;
             $this->©options->update(array('crons.config' => $config));
             $configurations++;
             // Increment.
         }
     }
     unset($_key, $_cron_job);
     // Housekeeping.
     return $configurations;
     // If any.
 }
예제 #22
0
/**
 * wpsc_cron()
 *
 * Schedules wpsc worpress cron tasks
 *
 * @param none
 * @return void
 */
function wpsc_cron()
{
    $default_schedules = array('hourly', 'twicedaily', 'daily');
    /*
     * Create a cron event for each likely cron schedule.  The likely cron schedules
     * are the default WordPress cron intervals (hourly, twicedaily and daily are
     * defined in wordpress 3.5.1) and any cron schedules added by our plugin or
     * it's related plugins.  We recognize these by checking if the schedule
     * name is prefixed by 'wpsc_'.
     */
    foreach (wp_get_schedules() as $cron => $schedule) {
        if (in_array($cron, $default_schedules) || stripos($cron, 'wpsc_', 0) === 0) {
            if (!wp_next_scheduled("wpsc_{$cron}_cron_task")) {
                wp_schedule_event(time(), $cron, "wpsc_{$cron}_cron_task");
            }
        }
    }
}
예제 #23
0
 public function schedule_backup_database($interval)
 {
     $previous_time = wp_next_scheduled('updraft_backup_database');
     // Clear schedule so that we don't stack up scheduled backups
     wp_clear_scheduled_hook('updraft_backup_database');
     if ('manual' == $interval) {
         return 'manual';
     }
     $previous_interval = UpdraftPlus_Options::get_updraft_option('updraft_interval_database');
     $valid_schedules = wp_get_schedules();
     if (empty($valid_schedules[$interval])) {
         $interval = 'daily';
     }
     // Try to avoid changing the time is one was already scheduled. This is fairly conservative - we could do more, e.g. check if a backup already happened today.
     $default_time = $interval == $previous_interval && $previous_time > 0 ? $previous_time : time() + 120;
     $first_time = apply_filters('updraftplus_schedule_firsttime_db', $default_time);
     wp_schedule_event($first_time, $interval, 'updraft_backup_database');
     return $interval;
 }
예제 #24
0
        function wordbooker_blog_comment_options()
        {
            global $ol_flash, $wordbooker_settings, $_POST, $wp_rewrite, $user_ID, $wpdb, $blog_id, $wordbooker_user_settings_id;
            $checked_flag = array('on' => 'checked', 'off' => '');
            $fbcomment_colorscheme = array('dark' => 'Dark', 'light' => 'Light');
            echo "<b>" . __('Wordpress Comment handling Options', 'wordbooker') . "</b><br />";
            $scheds1['Never'] = array('interval' => 999999999, 'display' => __('Never ', 'wordbooker'));
            $scheds1['Manual'] = array('interval' => 999999999, 'display' => __('Manual Polling ', 'wordbooker'));
            $scheds2 = wp_get_schedules();
            $scheds = array_merge($scheds1, $scheds2);
            echo '<label for="wb_comment_cron">' . __('Process Comments  ', 'wordbooker') . ' :</label> <select id="wordbooker_comment_cron" name="wordbooker_settings[wordbooker_comment_cron]"  >';
            foreach (array_keys($scheds) as $ss) {
                if ($ss == $wordbooker_settings['wordbooker_comment_cron']) {
                    print '<option selected="yes" value="' . $ss . '" >' . $scheds[$ss]['display'] . '&nbsp;</option>';
                } else {
                    print '<option value="' . $ss . '" >' . $scheds[$ss]['display'] . '&nbsp;</option>';
                }
            }
            echo "</select> ";
            if ($wordbooker_settings['wordbooker_comment_cron'] != 'Never') {
                echo " &nbsp;&nbsp;(" . __("Next Scheduled fetch is in", 'wordbooker') . ' : ' . date('H:i', wp_next_scheduled('wb_comment_job') - time()) . ')';
            }
            echo '<br /><label for="wb_publish_comment_handling">' . __("Enable Comment processing", 'wordbooker') . ' : </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_handling]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_handling"]] . ' /><br />';
            echo '<label for="wb_import_comment">&nbsp;&nbsp;' . __("Disable Comment Importing", 'wordbooker') . ': </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_pul]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_pull"]] . '/> <br />';
            echo '<label for="wb_import_comment">&nbsp;&nbsp;' . __("Disable Comment Exporting", 'wordbooker') . ': </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_push]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_push"]] . '/> <br />';
            if (!isset($wordbooker_settings["wordbooker_comment_attribute"])) {
                $wordbooker_settings["wordbooker_comment_attribute"] = __("[Comment imported from blog]", 'wordbooker');
            }
            echo '<label for="wb_cooment_attribute">' . __('Comment Tag', 'wordbooker') . ' : </label>';
            echo '<INPUT NAME="wordbooker_settings[wordbooker_comment_attribute]" size=60 maxlength=240 value="' . stripslashes($wordbooker_settings["wordbooker_comment_attribute"]) . '"><br />';
            if (strlen($wordbooker_settings['wordbooker_comment_post_format']) < 2) {
                $wordbooker_settings['wordbooker_comment_post_format'] = "%tag%";
            }
            echo '<p class="DataForm"><label for="wb_cooment_post_format">' . __('Facebook Comment Structure', 'wordbooker') . ' : </label>';
            echo "<TEXTAREA NAME='wordbooker_settings[wordbooker_comment_post_format]' ROWS=8 COLS=60>" . stripslashes($wordbooker_settings["wordbooker_comment_post_format"]) . "</TEXTAREA><br /></p>";
            echo '<label for="wb_comment_email">' . __("Assign this email address to comments", 'wordbooker') . ' :</label>';
            echo ' <INPUT NAME="wordbooker_settings[wordbooker_comment_email]" size=60 maxlength=60 value="' . stripslashes($wordbooker_settings["wordbooker_comment_email"]) . '"> <br />';
            echo '<label for="wb_import_comment">' . __("Import Comments from Facebook for new Wordbooker Posts", 'wordbooker') . ': </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_get]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_get"]] . '/> <br />';
            echo '<label for="wb_publish_comment_push">' . __("Push Comments up to Facebook for new posts", 'wordbooker') . ' : </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_put]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_put"]] . ' /> <br />  ';
            echo '<label for="wb_publish_comment_approve">' . __("Auto Approve imported comments", 'wordbooker') . ' :</label> ';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_comment_approve]" ' . $checked_flag[$wordbooker_settings["wordbooker_comment_approve"]] . ' /><br />';
            if ($wordbooker_settings['wordbooker_comment_cron'] != 'Never') {
                echo '<br /><input type="submit" value="' . __("Run Comment Handling Now", 'wordbooker') . '" name="mcp" class="button-primary"  />';
            }
            echo "<hr><br /><b>" . __('Facebook Comment Box Options', 'wordbooker') . "</b><br /><br />";
            echo '<label for="wb_use_fb_comments">' . __("Enable Facebook Comment handling  ", 'wordbooker') . ' : </label> ';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_use_fb_comments]" ' . $checked_flag[$wordbooker_settings["wordbooker_use_fb_comments"]] . ' /> <br />';
            $fb_comment_location = array('bottom' => __('Created in line below post', 'wordbooker'), 'coded' => __('Defined by theme template', 'wordbooker'), 'tagged' => __('Defined by Tag in post', 'wordbooker'));
            echo '<label for="wb_comment_location">' . __('Comment placing ', 'wordbooker') . ' :</label> <select id="wordbooker_comment_location" name="wordbooker_settings[wordbooker_comment_location]"  >';
            foreach ($fb_comment_location as $i => $value) {
                if ($i == $wordbooker_settings['wordbooker_comment_location']) {
                    print '<option selected="yes" value="' . $i . '" >' . $fb_comment_location[$i] . '</option>';
                } else {
                    print '<option value="' . $i . '" >' . $fb_comment_location[$i] . '</option>';
                }
            }
            echo "</select><br />";
            echo '<label for="wb_comment_colorscheme">' . __('Comment Box - Colour Scheme', 'wordbooker') . ' :</label> <select id="wb_comment_colorscheme" name="wordbooker_settings[wb_comment_colorscheme]"  >';
            foreach ($fbcomment_colorscheme as $i => $value) {
                if ($i == $wordbooker_settings['wb_comment_colorscheme']) {
                    print '<option selected="yes" value="' . $i . '" >' . $fbcomment_colorscheme[$i] . '</option>';
                } else {
                    print '<option value="' . $i . '" >' . $fbcomment_colorscheme[$i] . '</option>';
                }
            }
            echo "</select><br />";
            echo '<label for="wb_use_fb_comments_admin">' . __("All Wordbooker users can moderate comments  ", 'wordbooker') . ' : </label> ';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_fb_comments_admin]" ' . $checked_flag[$wordbooker_settings["wordbooker_fb_comments_admin"]] . ' />
 <br />';
            if (!defined('WORDBOOKER_PREMIUM') || defined('WORDBOOKER_MULTI') && WORDBOOKER_MULTI == true) {
                echo '<label for="fb_comment_app_id">' . __("Use this Facebook Application ID for comment moderation", 'wordbooker') . ' :</label>';
                echo ' <INPUT NAME="wordbooker_settings[fb_comment_app_id]" size=20 maxlength=20 value="' . stripslashes($wordbooker_settings["fb_comment_app_id"]) . '"> <br />';
            }
            echo '<label for="fb_comment_app_id">' . __("Width of comment box", 'wordbooker') . ' :</label>';
            if (strlen($wordbooker_settings["fb_comment_box_size"]) <= 2) {
                $wordbooker_settings["fb_comment_box_size"] = 350;
            }
            if ($wordbooker_settings["fb_comment_box_size"] < 350) {
                $wordbooker_settings["fb_comment_box_size"] = 350;
            }
            echo ' <INPUT NAME="wordbooker_settings[fb_comment_box_size]" size=3 maxlength=3 value="' . stripslashes($wordbooker_settings["fb_comment_box_size"]) . '"> <br />';
            echo '<label for="fb_comment_count">' . __("Number of comments to display", 'wordbooker') . ' :</label>';
            if (strlen($wordbooker_settings["fb_comment_box_count"]) < 1) {
                $wordbooker_settings["fb_comment_box_count"] = 20;
            }
            if ($wordbooker_settings["fb_comment_box_count"] < 2) {
                $wordbooker_settings["fb_comment_box_count"] = 2;
            }
            echo ' <INPUT NAME="wordbooker_settings[fb_comment_box_count]" size=3 maxlength=3 value="' . stripslashes($wordbooker_settings["fb_comment_box_count"]) . '"> <br />';
            echo '<label for="wordbooker_comment_notify">' . __('Enable notification of new comments', 'wordbooker') . ' : </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[fb_comment_box_notify]" ' . $checked_flag[$wordbooker_settings["fb_comment_box_notify"]] . '><br />';
            echo '<label for="wordbooker_use_facebook_comments">' . __('Facebook comment handling should be enabled on new posts', 'wordbooker') . ' : </label>';
            echo '<INPUT TYPE=CHECKBOX NAME="wordbooker_settings[wordbooker_use_facebook_comments]" ' . $checked_flag[$wordbooker_settings["wordbooker_use_facebook_comments"]] . '><br />';
        }
예제 #25
0
				</p>
			
				<p style="width:23%;">
					<b>Cron time:</b><br/>
					<p class="dg_tw_horiz">
						<span class="description">Choose how much time must pass before load new items, use "never" to disable</span><br/>
						<select name="dg_tw_time_selected" id="dg_tw_time_selected">
							<option value="never"<?php 
if (isset($dg_tw_time['run']) && $dg_tw_time['run'] === 'never') {
    echo ' selected=selected';
}
?>
>never</option>
							
							<?php 
$recurrences = wp_get_schedules();
foreach ($recurrences as $slug => $recurrence) {
    ?>
									<option value="<?php 
    echo $slug;
    ?>
"<?php 
    if (isset($dg_tw_time['run']) && $dg_tw_time['run'] == $slug) {
        echo ' selected=selected';
    }
    ?>
><?php 
    echo $recurrence['display'];
    ?>
</option>
								<?php 
예제 #26
0
파일: settings.php 프로젝트: juslee/e27
 $this->subscribe2_options['sender'] = $sender;
 // send email for pages, private and password protected posts
 $this->subscribe2_options['stylesheet'] = $_POST['stylesheet'];
 $this->subscribe2_options['pages'] = $_POST['pages'];
 $this->subscribe2_options['password'] = $_POST['password'];
 $this->subscribe2_options['private'] = $_POST['private'];
 $this->subscribe2_options['stickies'] = $_POST['stickies'];
 $this->subscribe2_options['cron_order'] = $_POST['cron_order'];
 $this->subscribe2_options['tracking'] = $_POST['tracking'];
 // send per-post or digest emails
 $email_freq = $_POST['email_freq'];
 $scheduled_time = wp_next_scheduled('s2_digest_cron');
 if ($email_freq != $this->subscribe2_options['email_freq'] || $_POST['hour'] != date('H', $scheduled_time)) {
     $this->subscribe2_options['email_freq'] = $email_freq;
     wp_clear_scheduled_hook('s2_digest_cron');
     $scheds = (array) wp_get_schedules();
     $interval = isset($scheds[$email_freq]['interval']) ? (int) $scheds[$email_freq]['interval'] : 0;
     if ($interval == 0) {
         // if we are on per-post emails remove last_cron entry
         unset($this->subscribe2_options['last_s2cron']);
         unset($this->subscribe2_options['previous_s2cron']);
     } else {
         // if we are using digest schedule the event and prime last_cron as now
         $time = time() + $interval;
         $timestamp = mktime($_POST['hour'], 0, 0, date('m', $time), date('d', $time), date('Y', $time));
         while ($timestamp < time()) {
             // if we are trying to set the time in the past increment it forward
             // by the interval period until it is in the future
             $timestamp += $interval;
         }
         wp_schedule_event($timestamp, $email_freq, 's2_digest_cron');
예제 #27
0
/**
 * Run scheduled callbacks or spawn cron for all scheduled events.
 *
 * @since 2.1.0
 *
 * @return null When doesn't need to run Cron.
 */
function wp_cron()
{
    // Prevent infinite loops caused by lack of wp-cron.php
    if (strpos($_SERVER['REQUEST_URI'], '/wp-cron.php') !== false || defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
        return;
    }
    if (false === ($crons = _get_cron_array())) {
        return;
    }
    $local_time = microtime(true);
    $keys = array_keys($crons);
    if (isset($keys[0]) && $keys[0] > $local_time) {
        return;
    }
    $schedules = wp_get_schedules();
    foreach ($crons as $timestamp => $cronhooks) {
        if ($timestamp > $local_time) {
            break;
        }
        foreach ((array) $cronhooks as $hook => $args) {
            if (isset($schedules[$hook]['callback']) && !call_user_func($schedules[$hook]['callback'])) {
                continue;
            }
            spawn_cron($local_time);
            break 2;
        }
    }
}
예제 #28
0
function wp_cron() {
	$crons = _get_cron_array();
	
	if ( !is_array($crons) )
		return;

	$keys = array_keys( $crons );
	if ( isset($keys[0]) && $keys[0] > time() )
		return;

	$schedules = wp_get_schedules();
	foreach ( $crons as $timestamp => $cronhooks ) {
		if ( $timestamp > time() ) break;
		foreach ( $cronhooks as $hook => $args ) {
			if ( isset($schedules[$hook]['callback']) && !call_user_func( $schedules[$hook]['callback'] ) )
				continue;
			spawn_cron();
			break 2;
		}
	}
}
    public static function renderCron()
    {
        self::renderHeader('ServerInformationCron');
        $schedules = array('Backups' => 'mainwp_cron_last_backups', 'Backups continue' => 'mainwp_cron_last_backups_continue', 'Updates check' => 'mainwp_cron_last_updatescheck', 'Stats' => 'mainwp_cron_last_stats', 'Ping childs' => 'mainwp_cron_last_ping', 'Offline checks' => 'mainwp_cron_last_offlinecheck', 'Conflicts update' => 'mainwp_cron_last_cronconflicts');
        ?>
    <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0">
        <thead>
            <tr>
                <th scope="col" class="manage-column sorted" style=""><span><?php 
        _e('Schedule', 'mainwp');
        ?>
</span></th>
                <th scope="col" class="manage-column column-posts" style=""><span><?php 
        _e('Last run', 'mainwp');
        ?>
</span></th>
            </tr>
        </thead>
        <tbody>
            <?php 
        foreach ($schedules as $schedule => $option) {
            ?>
            <tr><td><?php 
            echo $schedule;
            ?>
</td><td><?php 
            echo get_option($option) === false || get_option($option) == 0 ? 'Never run' : MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp(get_option($option)));
            ?>
</td></tr>
            <?php 
        }
        ?>
        </tbody>
    </table>
        <br />
            <?php 
        $cron_array = _get_cron_array();
        $schedules = wp_get_schedules();
        ?>
    <table id="mainwp-table" class="wp-list-table widefat" cellspacing="0">
        <thead>
            <tr>
                <th scope="col" class="manage-column sorted" style=""><span><?php 
        _e('Next due', 'mainwp');
        ?>
</span></th>
                <th scope="col" class="manage-column column-posts" style=""><span><?php 
        _e('Schedule', 'mainwp');
        ?>
</span></th>
                <th scope="col" class="manage-column column-posts" style=""><span><?php 
        _e('Hook', 'mainwp');
        ?>
</span></th>
            </tr>
        </thead>
        <tbody id="the-sites-list" class="list:sites">
        <?php 
        foreach ($cron_array as $time => $cron) {
            foreach ($cron as $hook => $cron_info) {
                foreach ($cron_info as $key => $schedule) {
                    ?>
                    <tr><td><?php 
                    echo MainWPUtility::formatTimestamp(MainWPUtility::getTimestamp($time));
                    ?>
</td><td><?php 
                    echo isset($schedules[$schedule['schedule']]) ? $schedules[$schedule['schedule']]['display'] : '';
                    ?>
 </td><td><?php 
                    echo $hook;
                    ?>
</td></tr>
                    <?php 
                }
            }
        }
        ?>
        </tbody>
    </table>
        <?php 
        self::renderFooter('ServerInformationCron');
    }