Commit 20349519 authored by Erick Hitter's avatar Erick Hitter
Browse files

PHPCS fixes

parent 2119fb4f
<?php <?php
/**
* Plugin's central class, responsible for loading its functionality when appropriate
*
* @package a8c_Cron_Control
*/
namespace Automattic\WP\Cron_Control; namespace Automattic\WP\Cron_Control;
/**
* Main class
*/
class Main extends Singleton { class Main extends Singleton {
/** /**
* PLUGIN SETUP * PLUGIN SETUP
...@@ -11,16 +19,16 @@ class Main extends Singleton { ...@@ -11,16 +19,16 @@ class Main extends Singleton {
* Register hooks * Register hooks
*/ */
protected function class_init() { protected function class_init() {
// Bail when plugin conditions aren't met // Bail when plugin conditions aren't met.
if ( ! defined( '\WP_CRON_CONTROL_SECRET' ) ) { if ( ! defined( '\WP_CRON_CONTROL_SECRET' ) ) {
add_action( 'admin_notices', array( $this, 'admin_notice' ) ); add_action( 'admin_notices', array( $this, 'admin_notice' ) );
return; return;
} }
// Load balance of plugin // Load balance of plugin.
$this->load_plugin_classes(); $this->load_plugin_classes();
// Block normal cron execution // Block normal cron execution.
$this->set_constants(); $this->set_constants();
$block_action = did_action( 'muplugins_loaded' ) ? 'plugins_loaded' : 'muplugins_loaded'; $block_action = did_action( 'muplugins_loaded' ) ? 'plugins_loaded' : 'muplugins_loaded';
...@@ -37,15 +45,15 @@ class Main extends Singleton { ...@@ -37,15 +45,15 @@ class Main extends Singleton {
* but we don't want to load it prematurely. * but we don't want to load it prematurely.
*/ */
private function load_plugin_classes() { private function load_plugin_classes() {
// Load event store and its dependencies // Load event store and its dependencies.
require __DIR__ . '/constants.php'; require __DIR__ . '/constants.php';
require __DIR__ . '/utils.php'; require __DIR__ . '/utils.php';
require __DIR__ . '/class-events-store.php'; require __DIR__ . '/class-events-store.php';
// Load dependencies for remaining classes // Load dependencies for remaining classes.
require __DIR__ . '/class-lock.php'; require __DIR__ . '/class-lock.php';
// Load remaining functionality // Load remaining functionality.
require __DIR__ . '/class-events.php'; require __DIR__ . '/class-events.php';
require __DIR__ . '/class-internal-events.php'; require __DIR__ . '/class-internal-events.php';
require __DIR__ . '/class-rest-api.php'; require __DIR__ . '/class-rest-api.php';
...@@ -81,12 +89,15 @@ class Main extends Singleton { ...@@ -81,12 +89,15 @@ class Main extends Singleton {
public function block_direct_cron() { public function block_direct_cron() {
if ( false !== stripos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) || false !== stripos( $_SERVER['SCRIPT_NAME'], '/wp-cron.php' ) ) { if ( false !== stripos( $_SERVER['REQUEST_URI'], '/wp-cron.php' ) || false !== stripos( $_SERVER['SCRIPT_NAME'], '/wp-cron.php' ) ) {
status_header( 403 ); status_header( 403 );
wp_send_json_error( new \WP_Error( 'forbidden', sprintf( __( 'Normal cron execution is blocked when the %s plugin is active.', 'automattic-cron-control' ), 'Cron Control' ) ), array( 'status' => 400, ) ); wp_send_json_error( new \WP_Error( 'forbidden', sprintf( __( 'Normal cron execution is blocked when the %s plugin is active.', 'automattic-cron-control' ), 'Cron Control' ) ), array( 'status' => 400 ) );
} }
} }
/** /**
* Block the `spawn_cron()` function * Block the `spawn_cron()` function
*
* @param array $spawn_cron_args Arguments used to trigger a wp-cron.php request.
* @return array
*/ */
public function block_spawn_cron( $spawn_cron_args ) { public function block_spawn_cron( $spawn_cron_args ) {
delete_transient( 'doing_cron' ); delete_transient( 'doing_cron' );
......
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