PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.2
Elementor Website Builder – more than just a page builder v3.20.2
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | core/base/background-process/wp-background-process.php +9 -46 4.1.43.20.2 View file →
@@ -5,9 +5,9 @@
5 5 exit;
6 6 }
7 7
8 8 /**
9 - * Link https://github.com/A5hleyRich/wp-background-processing GPL v2.0.
9 + * https://github.com/A5hleyRich/wp-background-processing GPL v2.0
10 10 *
11 11 * WP Background Process
12 12 *
13 13 * @package WP-Background-Processing
@@ -65,10 +65,10 @@
65 65
66 66 $this->cron_hook_identifier = $this->identifier . '_cron';
67 67 $this->cron_interval_identifier = $this->identifier . '_cron_interval';
68 68
69 - add_action( $this->cron_hook_identifier, [ $this, 'handle_cron_healthcheck' ] );
70 - add_filter( 'cron_schedules', [ $this, 'schedule_cron_healthcheck' ] );
69 + add_action( $this->cron_hook_identifier, array( $this, 'handle_cron_healthcheck' ) );
70 + add_filter( 'cron_schedules', array( $this, 'schedule_cron_healthcheck' ) );
71 71 }
72 72
73 73 /**
74 74 * Dispatch
@@ -79,53 +79,13 @@
79 79 public function dispatch() {
80 80 // Schedule the cron healthcheck.
81 81 $this->schedule_event();
82 82
83 - // On admin page requests (not AJAX/cron), also process on shutdown as fallback.
84 - // This ensures background tasks run even if HTTP loopback requests are blocked.
85 - if ( is_admin() && ! wp_doing_ajax() && ! wp_doing_cron() ) {
86 - add_action( 'shutdown', [ $this, 'maybe_handle_on_shutdown' ], 0 );
87 - }
88 -
89 83 // Perform remote post.
90 84 return parent::dispatch();
91 85 }
92 86
93 87 /**
94 - * Maybe handle on shutdown
95 - *
96 - * Fallback handler for when HTTP loopback requests are blocked.
97 - * Flushes output to browser first, then processes the queue directly.
98 - *
99 - * @access public
100 - */
101 - public function maybe_handle_on_shutdown() {
102 - // Don't run if already processed via loopback or if queue is empty.
103 - if ( $this->is_process_running() ) {
104 - return;
105 - }
106 -
107 - if ( $this->is_queue_empty() ) {
108 - return;
109 - }
110 -
111 - // Flush output to browser so page loads immediately.
112 - if ( ob_get_level() ) {
113 - wp_ob_end_flush_all();
114 - }
115 -
116 - // Finish the request - browser gets response, PHP continues.
117 - if ( function_exists( 'fastcgi_finish_request' ) ) {
118 - fastcgi_finish_request();
119 - } elseif ( function_exists( 'litespeed_finish_request' ) ) {
120 - litespeed_finish_request();
121 - }
122 -
123 - // Process the queue directly.
124 - $this->handle();
125 - }
126 -
127 - /**
128 88 * Push to queue
129 89 *
130 90 * @param mixed $data Data.
131 91 *
@@ -191,9 +151,9 @@
191 151 *
192 152 * @return string
193 153 */
194 154 protected function generate_key( $length = 64 ) {
195 - $unique = md5( microtime() . wp_rand() );
155 + $unique = md5( microtime() . rand() );
196 156 $prepend = $this->identifier . '_batch_';
197 157
198 158 return substr( $prepend . $unique, 0, $length );
199 159 }
@@ -471,9 +431,9 @@
471 431 $interval = apply_filters( $this->identifier . '_cron_interval', $this->cron_interval );
472 432 }
473 433
474 434 // Adds every 5 minutes to the existing schedules.
475 - $schedules[ $this->identifier . '_cron_interval' ] = [
435 + $schedules[ $this->identifier . '_cron_interval' ] = array(
476 436 'interval' => MINUTE_IN_SECONDS * $interval,
477 437 'display' => sprintf(
478 438 /* translators: %d: Interval in minutes. */
479 439 esc_html__( 'Every %d minutes', 'elementor' ),
@@ -478,9 +438,9 @@
478 438 /* translators: %d: Interval in minutes. */
479 439 esc_html__( 'Every %d minutes', 'elementor' ),
480 440 $interval,
481 441 ),
482 - ];
442 + );
483 443
484 444 return $schedules;
485 445 }
486 446
@@ -530,8 +490,9 @@
530 490 /**
531 491 * Cancel Process
532 492 *
533 493 * Stop processing queue items, clear cronjob and delete batch.
494 + *
534 495 */
535 496 public function cancel_process() {
536 497 if ( ! $this->is_queue_empty() ) {
537 498 $batch = $this->get_batch();
@@ -539,8 +500,9 @@
539 500 $this->delete( $batch->key );
540 501
541 502 wp_clear_scheduled_hook( $this->cron_hook_identifier );
542 503 }
504 +
543 505 }
544 506
545 507 /**
546 508 * Task
@@ -554,5 +516,6 @@
554 516 *
555 517 * @return mixed
556 518 */
557 519 abstract protected function task( $item );
520 +
558 521 }