Edit File by line
/home/barbar84/www/wp-inclu...
File: cron.php
[500] Fix | Delete
if ( ! $wp_error && is_wp_error( $pre ) ) {
[501] Fix | Delete
return false;
[502] Fix | Delete
}
[503] Fix | Delete
[504] Fix | Delete
return $pre;
[505] Fix | Delete
}
[506] Fix | Delete
[507] Fix | Delete
$crons = _get_cron_array();
[508] Fix | Delete
$key = md5( serialize( $args ) );
[509] Fix | Delete
unset( $crons[ $timestamp ][ $hook ][ $key ] );
[510] Fix | Delete
if ( empty( $crons[ $timestamp ][ $hook ] ) ) {
[511] Fix | Delete
unset( $crons[ $timestamp ][ $hook ] );
[512] Fix | Delete
}
[513] Fix | Delete
if ( empty( $crons[ $timestamp ] ) ) {
[514] Fix | Delete
unset( $crons[ $timestamp ] );
[515] Fix | Delete
}
[516] Fix | Delete
[517] Fix | Delete
return _set_cron_array( $crons, $wp_error );
[518] Fix | Delete
}
[519] Fix | Delete
[520] Fix | Delete
/**
[521] Fix | Delete
* Unschedules all events attached to the hook with the specified arguments.
[522] Fix | Delete
*
[523] Fix | Delete
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
[524] Fix | Delete
* value which evaluates to FALSE. For information about casting to booleans see the
[525] Fix | Delete
* {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
[526] Fix | Delete
* the `===` operator for testing the return value of this function.
[527] Fix | Delete
*
[528] Fix | Delete
* @since 2.1.0
[529] Fix | Delete
* @since 5.1.0 Return value modified to indicate success or failure,
[530] Fix | Delete
* {@see 'pre_clear_scheduled_hook'} filter added to short-circuit the function.
[531] Fix | Delete
* @since 5.7.0 The `$wp_error` parameter was added.
[532] Fix | Delete
*
[533] Fix | Delete
* @param string $hook Action hook, the execution of which will be unscheduled.
[534] Fix | Delete
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
[535] Fix | Delete
* Although not passed to a callback, these arguments are used to uniquely identify the
[536] Fix | Delete
* event, so they should be the same as those used when originally scheduling the event.
[537] Fix | Delete
* Default empty array.
[538] Fix | Delete
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
[539] Fix | Delete
* @return int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no
[540] Fix | Delete
* events were registered with the hook and arguments combination), false or WP_Error
[541] Fix | Delete
* if unscheduling one or more events fail.
[542] Fix | Delete
*/
[543] Fix | Delete
function wp_clear_scheduled_hook( $hook, $args = array(), $wp_error = false ) {
[544] Fix | Delete
// Backward compatibility.
[545] Fix | Delete
// Previously, this function took the arguments as discrete vars rather than an array like the rest of the API.
[546] Fix | Delete
if ( ! is_array( $args ) ) {
[547] Fix | Delete
_deprecated_argument( __FUNCTION__, '3.0.0', __( 'This argument has changed to an array to match the behavior of the other cron functions.' ) );
[548] Fix | Delete
$args = array_slice( func_get_args(), 1 ); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
[549] Fix | Delete
$wp_error = false;
[550] Fix | Delete
}
[551] Fix | Delete
[552] Fix | Delete
/**
[553] Fix | Delete
* Filter to preflight or hijack clearing a scheduled hook.
[554] Fix | Delete
*
[555] Fix | Delete
* Returning a non-null value will short-circuit the normal unscheduling
[556] Fix | Delete
* process, causing the function to return the filtered value instead.
[557] Fix | Delete
*
[558] Fix | Delete
* For plugins replacing wp-cron, return the number of events successfully
[559] Fix | Delete
* unscheduled (zero if no events were registered with the hook) or false
[560] Fix | Delete
* if unscheduling one or more events fails.
[561] Fix | Delete
*
[562] Fix | Delete
* @since 5.1.0
[563] Fix | Delete
* @since 5.7.0 The `$wp_error` parameter was added, and a `WP_Error` object can now be returned.
[564] Fix | Delete
*
[565] Fix | Delete
* @param null|int|false|WP_Error $pre Value to return instead. Default null to continue unscheduling the event.
[566] Fix | Delete
* @param string $hook Action hook, the execution of which will be unscheduled.
[567] Fix | Delete
* @param array $args Arguments to pass to the hook's callback function.
[568] Fix | Delete
* @param bool $wp_error Whether to return a WP_Error on failure.
[569] Fix | Delete
*/
[570] Fix | Delete
$pre = apply_filters( 'pre_clear_scheduled_hook', null, $hook, $args, $wp_error );
[571] Fix | Delete
[572] Fix | Delete
if ( null !== $pre ) {
[573] Fix | Delete
if ( $wp_error && false === $pre ) {
[574] Fix | Delete
return new WP_Error(
[575] Fix | Delete
'pre_clear_scheduled_hook_false',
[576] Fix | Delete
__( 'A plugin prevented the hook from being cleared.' )
[577] Fix | Delete
);
[578] Fix | Delete
}
[579] Fix | Delete
[580] Fix | Delete
if ( ! $wp_error && is_wp_error( $pre ) ) {
[581] Fix | Delete
return false;
[582] Fix | Delete
}
[583] Fix | Delete
[584] Fix | Delete
return $pre;
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
/*
[588] Fix | Delete
* This logic duplicates wp_next_scheduled().
[589] Fix | Delete
* It's required due to a scenario where wp_unschedule_event() fails due to update_option() failing,
[590] Fix | Delete
* and, wp_next_scheduled() returns the same schedule in an infinite loop.
[591] Fix | Delete
*/
[592] Fix | Delete
$crons = _get_cron_array();
[593] Fix | Delete
if ( empty( $crons ) ) {
[594] Fix | Delete
return 0;
[595] Fix | Delete
}
[596] Fix | Delete
[597] Fix | Delete
$results = array();
[598] Fix | Delete
$key = md5( serialize( $args ) );
[599] Fix | Delete
[600] Fix | Delete
foreach ( $crons as $timestamp => $cron ) {
[601] Fix | Delete
if ( isset( $cron[ $hook ][ $key ] ) ) {
[602] Fix | Delete
$results[] = wp_unschedule_event( $timestamp, $hook, $args, true );
[603] Fix | Delete
}
[604] Fix | Delete
}
[605] Fix | Delete
[606] Fix | Delete
$errors = array_filter( $results, 'is_wp_error' );
[607] Fix | Delete
$error = new WP_Error();
[608] Fix | Delete
[609] Fix | Delete
if ( $errors ) {
[610] Fix | Delete
if ( $wp_error ) {
[611] Fix | Delete
array_walk( $errors, array( $error, 'merge_from' ) );
[612] Fix | Delete
[613] Fix | Delete
return $error;
[614] Fix | Delete
}
[615] Fix | Delete
[616] Fix | Delete
return false;
[617] Fix | Delete
}
[618] Fix | Delete
[619] Fix | Delete
return count( $results );
[620] Fix | Delete
}
[621] Fix | Delete
[622] Fix | Delete
/**
[623] Fix | Delete
* Unschedules all events attached to the hook.
[624] Fix | Delete
*
[625] Fix | Delete
* Can be useful for plugins when deactivating to clean up the cron queue.
[626] Fix | Delete
*
[627] Fix | Delete
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
[628] Fix | Delete
* value which evaluates to FALSE. For information about casting to booleans see the
[629] Fix | Delete
* {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
[630] Fix | Delete
* the `===` operator for testing the return value of this function.
[631] Fix | Delete
*
[632] Fix | Delete
* @since 4.9.0
[633] Fix | Delete
* @since 5.1.0 Return value added to indicate success or failure.
[634] Fix | Delete
* @since 5.7.0 The `$wp_error` parameter was added.
[635] Fix | Delete
*
[636] Fix | Delete
* @param string $hook Action hook, the execution of which will be unscheduled.
[637] Fix | Delete
* @param bool $wp_error Optional. Whether to return a WP_Error on failure. Default false.
[638] Fix | Delete
* @return int|false|WP_Error On success an integer indicating number of events unscheduled (0 indicates no
[639] Fix | Delete
* events were registered on the hook), false or WP_Error if unscheduling fails.
[640] Fix | Delete
*/
[641] Fix | Delete
function wp_unschedule_hook( $hook, $wp_error = false ) {
[642] Fix | Delete
/**
[643] Fix | Delete
* Filter to preflight or hijack clearing all events attached to the hook.
[644] Fix | Delete
*
[645] Fix | Delete
* Returning a non-null value will short-circuit the normal unscheduling
[646] Fix | Delete
* process, causing the function to return the filtered value instead.
[647] Fix | Delete
*
[648] Fix | Delete
* For plugins replacing wp-cron, return the number of events successfully
[649] Fix | Delete
* unscheduled (zero if no events were registered with the hook) or false
[650] Fix | Delete
* if unscheduling one or more events fails.
[651] Fix | Delete
*
[652] Fix | Delete
* @since 5.1.0
[653] Fix | Delete
* @since 5.7.0 The `$wp_error` parameter was added, and a `WP_Error` object can now be returned.
[654] Fix | Delete
*
[655] Fix | Delete
* @param null|int|false|WP_Error $pre Value to return instead. Default null to continue unscheduling the hook.
[656] Fix | Delete
* @param string $hook Action hook, the execution of which will be unscheduled.
[657] Fix | Delete
* @param bool $wp_error Whether to return a WP_Error on failure.
[658] Fix | Delete
*/
[659] Fix | Delete
$pre = apply_filters( 'pre_unschedule_hook', null, $hook, $wp_error );
[660] Fix | Delete
[661] Fix | Delete
if ( null !== $pre ) {
[662] Fix | Delete
if ( $wp_error && false === $pre ) {
[663] Fix | Delete
return new WP_Error(
[664] Fix | Delete
'pre_unschedule_hook_false',
[665] Fix | Delete
__( 'A plugin prevented the hook from being cleared.' )
[666] Fix | Delete
);
[667] Fix | Delete
}
[668] Fix | Delete
[669] Fix | Delete
if ( ! $wp_error && is_wp_error( $pre ) ) {
[670] Fix | Delete
return false;
[671] Fix | Delete
}
[672] Fix | Delete
[673] Fix | Delete
return $pre;
[674] Fix | Delete
}
[675] Fix | Delete
[676] Fix | Delete
$crons = _get_cron_array();
[677] Fix | Delete
if ( empty( $crons ) ) {
[678] Fix | Delete
return 0;
[679] Fix | Delete
}
[680] Fix | Delete
[681] Fix | Delete
$results = array();
[682] Fix | Delete
foreach ( $crons as $timestamp => $args ) {
[683] Fix | Delete
if ( ! empty( $crons[ $timestamp ][ $hook ] ) ) {
[684] Fix | Delete
$results[] = count( $crons[ $timestamp ][ $hook ] );
[685] Fix | Delete
}
[686] Fix | Delete
unset( $crons[ $timestamp ][ $hook ] );
[687] Fix | Delete
[688] Fix | Delete
if ( empty( $crons[ $timestamp ] ) ) {
[689] Fix | Delete
unset( $crons[ $timestamp ] );
[690] Fix | Delete
}
[691] Fix | Delete
}
[692] Fix | Delete
[693] Fix | Delete
/*
[694] Fix | Delete
* If the results are empty (zero events to unschedule), no attempt
[695] Fix | Delete
* to update the cron array is required.
[696] Fix | Delete
*/
[697] Fix | Delete
if ( empty( $results ) ) {
[698] Fix | Delete
return 0;
[699] Fix | Delete
}
[700] Fix | Delete
[701] Fix | Delete
$set = _set_cron_array( $crons, $wp_error );
[702] Fix | Delete
[703] Fix | Delete
if ( true === $set ) {
[704] Fix | Delete
return array_sum( $results );
[705] Fix | Delete
}
[706] Fix | Delete
[707] Fix | Delete
return $set;
[708] Fix | Delete
}
[709] Fix | Delete
[710] Fix | Delete
/**
[711] Fix | Delete
* Retrieve a scheduled event.
[712] Fix | Delete
*
[713] Fix | Delete
* Retrieve the full event object for a given event, if no timestamp is specified the next
[714] Fix | Delete
* scheduled event is returned.
[715] Fix | Delete
*
[716] Fix | Delete
* @since 5.1.0
[717] Fix | Delete
*
[718] Fix | Delete
* @param string $hook Action hook of the event.
[719] Fix | Delete
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
[720] Fix | Delete
* Although not passed to a callback, these arguments are used to uniquely identify the
[721] Fix | Delete
* event, so they should be the same as those used when originally scheduling the event.
[722] Fix | Delete
* Default empty array.
[723] Fix | Delete
* @param int|null $timestamp Optional. Unix timestamp (UTC) of the event. If not specified, the next scheduled event
[724] Fix | Delete
* is returned. Default null.
[725] Fix | Delete
* @return object|false The event object. False if the event does not exist.
[726] Fix | Delete
*/
[727] Fix | Delete
function wp_get_scheduled_event( $hook, $args = array(), $timestamp = null ) {
[728] Fix | Delete
/**
[729] Fix | Delete
* Filter to preflight or hijack retrieving a scheduled event.
[730] Fix | Delete
*
[731] Fix | Delete
* Returning a non-null value will short-circuit the normal process,
[732] Fix | Delete
* returning the filtered value instead.
[733] Fix | Delete
*
[734] Fix | Delete
* Return false if the event does not exist, otherwise an event object
[735] Fix | Delete
* should be returned.
[736] Fix | Delete
*
[737] Fix | Delete
* @since 5.1.0
[738] Fix | Delete
*
[739] Fix | Delete
* @param null|false|object $pre Value to return instead. Default null to continue retrieving the event.
[740] Fix | Delete
* @param string $hook Action hook of the event.
[741] Fix | Delete
* @param array $args Array containing each separate argument to pass to the hook's callback function.
[742] Fix | Delete
* Although not passed to a callback, these arguments are used to uniquely identify
[743] Fix | Delete
* the event.
[744] Fix | Delete
* @param int|null $timestamp Unix timestamp (UTC) of the event. Null to retrieve next scheduled event.
[745] Fix | Delete
*/
[746] Fix | Delete
$pre = apply_filters( 'pre_get_scheduled_event', null, $hook, $args, $timestamp );
[747] Fix | Delete
if ( null !== $pre ) {
[748] Fix | Delete
return $pre;
[749] Fix | Delete
}
[750] Fix | Delete
[751] Fix | Delete
if ( null !== $timestamp && ! is_numeric( $timestamp ) ) {
[752] Fix | Delete
return false;
[753] Fix | Delete
}
[754] Fix | Delete
[755] Fix | Delete
$crons = _get_cron_array();
[756] Fix | Delete
if ( empty( $crons ) ) {
[757] Fix | Delete
return false;
[758] Fix | Delete
}
[759] Fix | Delete
[760] Fix | Delete
$key = md5( serialize( $args ) );
[761] Fix | Delete
[762] Fix | Delete
if ( ! $timestamp ) {
[763] Fix | Delete
// Get next event.
[764] Fix | Delete
$next = false;
[765] Fix | Delete
foreach ( $crons as $timestamp => $cron ) {
[766] Fix | Delete
if ( isset( $cron[ $hook ][ $key ] ) ) {
[767] Fix | Delete
$next = $timestamp;
[768] Fix | Delete
break;
[769] Fix | Delete
}
[770] Fix | Delete
}
[771] Fix | Delete
if ( ! $next ) {
[772] Fix | Delete
return false;
[773] Fix | Delete
}
[774] Fix | Delete
[775] Fix | Delete
$timestamp = $next;
[776] Fix | Delete
} elseif ( ! isset( $crons[ $timestamp ][ $hook ][ $key ] ) ) {
[777] Fix | Delete
return false;
[778] Fix | Delete
}
[779] Fix | Delete
[780] Fix | Delete
$event = (object) array(
[781] Fix | Delete
'hook' => $hook,
[782] Fix | Delete
'timestamp' => $timestamp,
[783] Fix | Delete
'schedule' => $crons[ $timestamp ][ $hook ][ $key ]['schedule'],
[784] Fix | Delete
'args' => $args,
[785] Fix | Delete
);
[786] Fix | Delete
[787] Fix | Delete
if ( isset( $crons[ $timestamp ][ $hook ][ $key ]['interval'] ) ) {
[788] Fix | Delete
$event->interval = $crons[ $timestamp ][ $hook ][ $key ]['interval'];
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
return $event;
[792] Fix | Delete
}
[793] Fix | Delete
[794] Fix | Delete
/**
[795] Fix | Delete
* Retrieve the next timestamp for an event.
[796] Fix | Delete
*
[797] Fix | Delete
* @since 2.1.0
[798] Fix | Delete
*
[799] Fix | Delete
* @param string $hook Action hook of the event.
[800] Fix | Delete
* @param array $args Optional. Array containing each separate argument to pass to the hook's callback function.
[801] Fix | Delete
* Although not passed to a callback, these arguments are used to uniquely identify the
[802] Fix | Delete
* event, so they should be the same as those used when originally scheduling the event.
[803] Fix | Delete
* Default empty array.
[804] Fix | Delete
* @return int|false The Unix timestamp of the next time the event will occur. False if the event doesn't exist.
[805] Fix | Delete
*/
[806] Fix | Delete
function wp_next_scheduled( $hook, $args = array() ) {
[807] Fix | Delete
$next_event = wp_get_scheduled_event( $hook, $args );
[808] Fix | Delete
if ( ! $next_event ) {
[809] Fix | Delete
return false;
[810] Fix | Delete
}
[811] Fix | Delete
[812] Fix | Delete
return $next_event->timestamp;
[813] Fix | Delete
}
[814] Fix | Delete
[815] Fix | Delete
/**
[816] Fix | Delete
* Sends a request to run cron through HTTP request that doesn't halt page loading.
[817] Fix | Delete
*
[818] Fix | Delete
* @since 2.1.0
[819] Fix | Delete
* @since 5.1.0 Return values added.
[820] Fix | Delete
*
[821] Fix | Delete
* @param int $gmt_time Optional. Unix timestamp (UTC). Default 0 (current time is used).
[822] Fix | Delete
* @return bool True if spawned, false if no events spawned.
[823] Fix | Delete
*/
[824] Fix | Delete
function spawn_cron( $gmt_time = 0 ) {
[825] Fix | Delete
if ( ! $gmt_time ) {
[826] Fix | Delete
$gmt_time = microtime( true );
[827] Fix | Delete
}
[828] Fix | Delete
[829] Fix | Delete
if ( defined( 'DOING_CRON' ) || isset( $_GET['doing_wp_cron'] ) ) {
[830] Fix | Delete
return false;
[831] Fix | Delete
}
[832] Fix | Delete
[833] Fix | Delete
/*
[834] Fix | Delete
* Get the cron lock, which is a Unix timestamp of when the last cron was spawned
[835] Fix | Delete
* and has not finished running.
[836] Fix | Delete
*
[837] Fix | Delete
* Multiple processes on multiple web servers can run this code concurrently,
[838] Fix | Delete
* this lock attempts to make spawning as atomic as possible.
[839] Fix | Delete
*/
[840] Fix | Delete
$lock = get_transient( 'doing_cron' );
[841] Fix | Delete
[842] Fix | Delete
if ( $lock > $gmt_time + 10 * MINUTE_IN_SECONDS ) {
[843] Fix | Delete
$lock = 0;
[844] Fix | Delete
}
[845] Fix | Delete
[846] Fix | Delete
// Don't run if another process is currently running it or more than once every 60 sec.
[847] Fix | Delete
if ( $lock + WP_CRON_LOCK_TIMEOUT > $gmt_time ) {
[848] Fix | Delete
return false;
[849] Fix | Delete
}
[850] Fix | Delete
[851] Fix | Delete
// Sanity check.
[852] Fix | Delete
$crons = wp_get_ready_cron_jobs();
[853] Fix | Delete
if ( empty( $crons ) ) {
[854] Fix | Delete
return false;
[855] Fix | Delete
}
[856] Fix | Delete
[857] Fix | Delete
$keys = array_keys( $crons );
[858] Fix | Delete
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
[859] Fix | Delete
return false;
[860] Fix | Delete
}
[861] Fix | Delete
[862] Fix | Delete
if ( defined( 'ALTERNATE_WP_CRON' ) && ALTERNATE_WP_CRON ) {
[863] Fix | Delete
if ( 'GET' !== $_SERVER['REQUEST_METHOD'] || defined( 'DOING_AJAX' ) || defined( 'XMLRPC_REQUEST' ) ) {
[864] Fix | Delete
return false;
[865] Fix | Delete
}
[866] Fix | Delete
[867] Fix | Delete
$doing_wp_cron = sprintf( '%.22F', $gmt_time );
[868] Fix | Delete
set_transient( 'doing_cron', $doing_wp_cron );
[869] Fix | Delete
[870] Fix | Delete
ob_start();
[871] Fix | Delete
wp_redirect( add_query_arg( 'doing_wp_cron', $doing_wp_cron, wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
[872] Fix | Delete
echo ' ';
[873] Fix | Delete
[874] Fix | Delete
// Flush any buffers and send the headers.
[875] Fix | Delete
wp_ob_end_flush_all();
[876] Fix | Delete
flush();
[877] Fix | Delete
[878] Fix | Delete
include_once ABSPATH . 'wp-cron.php';
[879] Fix | Delete
return true;
[880] Fix | Delete
}
[881] Fix | Delete
[882] Fix | Delete
// Set the cron lock with the current unix timestamp, when the cron is being spawned.
[883] Fix | Delete
$doing_wp_cron = sprintf( '%.22F', $gmt_time );
[884] Fix | Delete
set_transient( 'doing_cron', $doing_wp_cron );
[885] Fix | Delete
[886] Fix | Delete
/**
[887] Fix | Delete
* Filters the cron request arguments.
[888] Fix | Delete
*
[889] Fix | Delete
* @since 3.5.0
[890] Fix | Delete
* @since 4.5.0 The `$doing_wp_cron` parameter was added.
[891] Fix | Delete
*
[892] Fix | Delete
* @param array $cron_request_array {
[893] Fix | Delete
* An array of cron request URL arguments.
[894] Fix | Delete
*
[895] Fix | Delete
* @type string $url The cron request URL.
[896] Fix | Delete
* @type int $key The 22 digit GMT microtime.
[897] Fix | Delete
* @type array $args {
[898] Fix | Delete
* An array of cron request arguments.
[899] Fix | Delete
*
[900] Fix | Delete
* @type int $timeout The request timeout in seconds. Default .01 seconds.
[901] Fix | Delete
* @type bool $blocking Whether to set blocking for the request. Default false.
[902] Fix | Delete
* @type bool $sslverify Whether SSL should be verified for the request. Default false.
[903] Fix | Delete
* }
[904] Fix | Delete
* }
[905] Fix | Delete
* @param string $doing_wp_cron The unix timestamp of the cron lock.
[906] Fix | Delete
*/
[907] Fix | Delete
$cron_request = apply_filters(
[908] Fix | Delete
'cron_request',
[909] Fix | Delete
array(
[910] Fix | Delete
'url' => add_query_arg( 'doing_wp_cron', $doing_wp_cron, site_url( 'wp-cron.php' ) ),
[911] Fix | Delete
'key' => $doing_wp_cron,
[912] Fix | Delete
'args' => array(
[913] Fix | Delete
'timeout' => 0.01,
[914] Fix | Delete
'blocking' => false,
[915] Fix | Delete
/** This filter is documented in wp-includes/class-wp-http-streams.php */
[916] Fix | Delete
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
[917] Fix | Delete
),
[918] Fix | Delete
),
[919] Fix | Delete
$doing_wp_cron
[920] Fix | Delete
);
[921] Fix | Delete
[922] Fix | Delete
$result = wp_remote_post( $cron_request['url'], $cron_request['args'] );
[923] Fix | Delete
return ! is_wp_error( $result );
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
/**
[927] Fix | Delete
* Register _wp_cron() to run on the {@see 'wp_loaded'} action.
[928] Fix | Delete
*
[929] Fix | Delete
* If the {@see 'wp_loaded'} action has already fired, this function calls
[930] Fix | Delete
* _wp_cron() directly.
[931] Fix | Delete
*
[932] Fix | Delete
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
[933] Fix | Delete
* value which evaluates to FALSE. For information about casting to booleans see the
[934] Fix | Delete
* {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
[935] Fix | Delete
* the `===` operator for testing the return value of this function.
[936] Fix | Delete
*
[937] Fix | Delete
* @since 2.1.0
[938] Fix | Delete
* @since 5.1.0 Return value added to indicate success or failure.
[939] Fix | Delete
* @since 5.7.0 Functionality moved to _wp_cron() to which this becomes a wrapper.
[940] Fix | Delete
*
[941] Fix | Delete
* @return bool|int|void On success an integer indicating number of events spawned (0 indicates no
[942] Fix | Delete
* events needed to be spawned), false if spawning fails for one or more events or
[943] Fix | Delete
* void if the function registered _wp_cron() to run on the action.
[944] Fix | Delete
*/
[945] Fix | Delete
function wp_cron() {
[946] Fix | Delete
if ( did_action( 'wp_loaded' ) ) {
[947] Fix | Delete
return _wp_cron();
[948] Fix | Delete
}
[949] Fix | Delete
[950] Fix | Delete
add_action( 'wp_loaded', '_wp_cron', 20 );
[951] Fix | Delete
}
[952] Fix | Delete
[953] Fix | Delete
/**
[954] Fix | Delete
* Run scheduled callbacks or spawn cron for all scheduled events.
[955] Fix | Delete
*
[956] Fix | Delete
* Warning: This function may return Boolean FALSE, but may also return a non-Boolean
[957] Fix | Delete
* value which evaluates to FALSE. For information about casting to booleans see the
[958] Fix | Delete
* {@link https://www.php.net/manual/en/language.types.boolean.php PHP documentation}. Use
[959] Fix | Delete
* the `===` operator for testing the return value of this function.
[960] Fix | Delete
*
[961] Fix | Delete
* @since 5.7.0
[962] Fix | Delete
* @access private
[963] Fix | Delete
*
[964] Fix | Delete
* @return int|false On success an integer indicating number of events spawned (0 indicates no
[965] Fix | Delete
* events needed to be spawned), false if spawning fails for one or more events.
[966] Fix | Delete
*/
[967] Fix | Delete
function _wp_cron() {
[968] Fix | Delete
// Prevent infinite loops caused by lack of wp-cron.php.
[969] Fix | Delete
if ( strpos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) !== false || ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) ) {
[970] Fix | Delete
return 0;
[971] Fix | Delete
}
[972] Fix | Delete
[973] Fix | Delete
$crons = wp_get_ready_cron_jobs();
[974] Fix | Delete
if ( empty( $crons ) ) {
[975] Fix | Delete
return 0;
[976] Fix | Delete
}
[977] Fix | Delete
[978] Fix | Delete
$gmt_time = microtime( true );
[979] Fix | Delete
$keys = array_keys( $crons );
[980] Fix | Delete
if ( isset( $keys[0] ) && $keys[0] > $gmt_time ) {
[981] Fix | Delete
return 0;
[982] Fix | Delete
}
[983] Fix | Delete
[984] Fix | Delete
$schedules = wp_get_schedules();
[985] Fix | Delete
$results = array();
[986] Fix | Delete
foreach ( $crons as $timestamp => $cronhooks ) {
[987] Fix | Delete
if ( $timestamp > $gmt_time ) {
[988] Fix | Delete
break;
[989] Fix | Delete
}
[990] Fix | Delete
foreach ( (array) $cronhooks as $hook => $args ) {
[991] Fix | Delete
if ( isset( $schedules[ $hook ]['callback'] ) && ! call_user_func( $schedules[ $hook ]['callback'] ) ) {
[992] Fix | Delete
continue;
[993] Fix | Delete
}
[994] Fix | Delete
$results[] = spawn_cron( $gmt_time );
[995] Fix | Delete
break 2;
[996] Fix | Delete
}
[997] Fix | Delete
}
[998] Fix | Delete
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function