Commit 7a54e352 authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS fixes

parent 2ff3fef2
<?php
/**
* Plugin utilities
*
* @package a8c_Cron_Control
*/
namespace Automattic\WP\Cron_Control;
......@@ -6,29 +11,33 @@ namespace Automattic\WP\Cron_Control;
* Produce a simplified version of the cron events array
*
* Also removes superfluous, non-event data that Core stores in the option
*
* @param array $events Core's cron events array.
* @param int $timestamp Optional. Return only events with this timestamp.
* @return array
*/
function collapse_events_array( $events, $timestamp = null ) {
$collapsed_events = array();
// Ensure an event is always returned
// Ensure an event is always returned.
if ( ! is_array( $events ) ) {
return $collapsed_events;
}
// Allow filtering to only events with a given timestamp
// Allow filtering to only events with a given timestamp.
if ( is_numeric( $timestamp ) ) {
if ( isset( $events[ $timestamp ] ) ) {
$_events = $events[ $timestamp ];
$events = array( $timestamp => $_events, );
$events = array( $timestamp => $_events );
unset( $_events );
} else {
return $collapsed_events;
}
}
// Collapse whatever events we have into an easier format to deal with
// Collapse whatever events we have into an easier format to deal with.
foreach ( $events as $timestamp => $timestamp_events ) {
// Skip non-event data that Core includes in the option
// Skip non-event data that Core includes in the option.
if ( ! is_numeric( $timestamp ) ) {
continue;
}
......@@ -54,13 +63,13 @@ function collapse_events_array( $events, $timestamp = null ) {
* We have occasion to check the request before Core has done so, such as when preparing the environment to run a cron job
*/
function parse_request() {
// Hold onto this as it won't change during the request
// Hold onto this as it won't change during the request.
static $parsed_request = null;
if ( is_array( $parsed_request ) ) {
return $parsed_request;
}
// Starting somewhere
// Starting somewhere.
$rewrite_index = 'index.php';
/**
......@@ -68,6 +77,7 @@ function parse_request() {
*
* References to $wp_rewrite->index were replaced with $rewrite_index, and whitespace updated, but otherwise, this is directly from WP::parse_request()
*/
// @codingStandardsIgnoreStart
$pathinfo = isset( $_SERVER['PATH_INFO'] ) ? $_SERVER['PATH_INFO'] : '';
list( $pathinfo ) = explode( '?', $pathinfo );
$pathinfo = str_replace( "%", "%25", $pathinfo );
......@@ -106,11 +116,12 @@ function parse_request() {
}
$requested_file = $req_uri;
// @codingStandardsIgnoreEnd
/**
* End what's borrowed from Core
*/
// Return array of data about the request
// Return array of data about the request.
$parsed_request = compact( 'requested_path', 'requested_file', 'self' );
return $parsed_request;
......@@ -124,7 +135,7 @@ function set_doing_cron() {
define( 'DOING_CRON', true );
}
// WP 4.8 introduced the `wp_doing_cron()` function and filter
// These can be used to override the `DOING_CRON` constant, which may cause problems for plugin's requests
// WP 4.8 introduced the `wp_doing_cron()` function and filter.
// These can be used to override the `DOING_CRON` constant, which may cause problems for plugin's requests.
add_filter( 'wp_doing_cron', '__return_true', 99999 );
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment