public function backup_now($cron_id)
 {
     /**
      * @var FW_Backup_Interface_Cron $cron
      */
     try {
         $cron = $this->service($cron_id, 'FW_Backup_Interface_Cron');
         // Ensure that storage service is workable
         $cron->get_storage()->ping();
         $post_id = $this->backup_create($cron);
         wp_schedule_single_event(time(), 'fw_backup_now', array($post_id));
         wp_cron();
         wp_redirect($this->url_backup_progress($post_id));
     } catch (FW_Backup_Exception $exception) {
         FW_Flash_Messages::add(uniqid(), $exception->getMessage(), 'error');
         wp_redirect($this->url_backup());
     }
     exit;
 }
{
    do_action('bb_shutdown');
}
register_shutdown_function('bb_shutdown_action_hook');
/**
 * Get details of the current user
 */
bb_current_user();
/**
 * Initialise CRON
 */
if (!function_exists('wp_schedule_single_event')) {
    require_once BACKPRESS_PATH . 'functions.wp-cron.php';
}
if (!defined('DOING_CRON') || !DOING_CRON) {
    wp_cron();
}
/**
 * The currently viewed page number
 */
$page = bb_get_uri_page();
/**
 * Initialisation complete API hook
 */
do_action('bb_init');
/**
 * Block user if they deserve it
 */
if (bb_is_user_logged_in() && bb_has_broken_pass()) {
    bb_block_current_user();
}
 /**
  * Ajax: "Near Realtime Assist"
  * Triggers internal cron at the scheduled time of publication for a particular post
  */
 public function tm_aj_trigger_cron($data_args)
 {
     $response = array();
     try {
         if (isset($_GET['token'])) {
             $token = $_GET['token'];
         } else {
             if (isset($data_args['token'])) {
                 $token = $data_args['token'];
             }
         }
         $this->sanitize_param($token);
         // only proceed if valid token
         if (true == $this->valid_token($token)) {
             if (is_array($_GET) && array_key_exists('post_id', $_GET)) {
                 $post_id = $_GET['post_id'];
             } else {
                 if (is_array($data_args) && array_key_exists('post_id', $data_args)) {
                     $post_id = $data_args['post_id'];
                 }
             }
             $this->sanitize_param($post_id);
             // purge any post caches
             $cache_flush_result = $this->cache_flush($post_id);
             if (defined('DISABLE_WP_CRON') && DISABLE_WP_CRON) {
                 // wp_cron is disabled
                 $wp_cron_response = 'disabled';
             } else {
                 // wp_cron can be executed, do it
                 $wp_cron_response = wp_cron() !== null ? true : false;
             }
             // if indication is wp_cron not run or disabled, force the issue //
             if ($wp_cron_response == false || $wp_cron_response == 'disabled') {
                 $publish_missed_schedule_posts_result = $this->publish_missed_schedule_posts($post_id);
             }
             // report the findings
             $response['wp_cron_was_run'] = $wp_cron_response;
             $response['cache_flush_result'] = $cache_flush_result;
             $response['publish_missed_schedule_posts_result'] = $publish_missed_schedule_posts_result;
             $response['server_time'] = time();
             $response['server_date'] = date('c');
             $response['gmt_offset'] = get_option('gmt_offset');
             $response['tz_abbrev'] = date('T');
         }
     } catch (Exception $e) {
         $response['error'] = $e->getMessage();
     }
     $this->respond_json_and_die($this->array_decode_entities($response));
 }
Beispiel #4
0
 public static function cron()
 {
     return wp_cron();
 }