← All changes
|
vendor/woocommerce/action-scheduler/classes/abstracts/ActionScheduler.php
+36
-18
1.5.4
→
trunk
View file →
| @@ -4,16 +4,32 @@ | ||
| 4 | 4 | use Action_Scheduler\Migration\Controller; |
| 5 | 5 | |
| 6 | 6 | /** |
| 7 | 7 | * Class ActionScheduler |
| 8 | + * | |
| 8 | 9 | * @codeCoverageIgnore |
| 9 | 10 | */ |
| 10 | 11 | abstract class ActionScheduler { |
| 11 | - /** @var string */ | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * Plugin file path. | |
| 15 | + * | |
| 16 | + * @var string | |
| 17 | + */ | |
| 12 | 18 | private static $plugin_file = ''; |
| 13 | - /** @var ActionScheduler_ActionFactory */ | |
| 14 | - private static $factory = NULL; | |
| 15 | - /** @var bool */ | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * ActionScheduler_ActionFactory instance. | |
| 22 | + * | |
| 23 | + * @var ActionScheduler_ActionFactory | |
| 24 | + */ | |
| 25 | + private static $factory = null; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * Data store is initialized. | |
| 29 | + * | |
| 30 | + * @var bool | |
| 31 | + */ | |
| 16 | 32 | private static $data_store_initialized = false; |
| 17 | 33 | |
| 18 | 34 | /** |
| 19 | 35 | * Factory. |
| @@ -18,9 +34,9 @@ | ||
| 18 | 34 | /** |
| 19 | 35 | * Factory. |
| 20 | 36 | */ |
| 21 | 37 | public static function factory() { |
| 22 | - if ( !isset(self::$factory) ) { | |
| 38 | + if ( ! isset( self::$factory ) ) { | |
| 23 | 39 | self::$factory = new ActionScheduler_ActionFactory(); |
| 24 | 40 | } |
| 25 | 41 | return self::$factory; |
| 26 | 42 | } |
| @@ -61,29 +77,31 @@ | ||
| 61 | 77 | } |
| 62 | 78 | |
| 63 | 79 | /** |
| 64 | 80 | * Get the absolute system path to the plugin directory, or a file therein |
| 81 | + * | |
| 65 | 82 | * @static |
| 66 | 83 | * @param string $path Path relative to plugin directory. |
| 67 | 84 | * @return string |
| 68 | 85 | */ |
| 69 | 86 | public static function plugin_path( $path ) { |
| 70 | - $base = dirname(self::$plugin_file); | |
| 87 | + $base = dirname( self::$plugin_file ); | |
| 71 | 88 | if ( $path ) { |
| 72 | - return trailingslashit($base) . $path; | |
| 89 | + return trailingslashit( $base ) . $path; | |
| 73 | 90 | } else { |
| 74 | - return untrailingslashit($base); | |
| 91 | + return untrailingslashit( $base ); | |
| 75 | 92 | } |
| 76 | 93 | } |
| 77 | 94 | |
| 78 | 95 | /** |
| 79 | 96 | * Get the absolute URL to the plugin directory, or a file therein |
| 97 | + * | |
| 80 | 98 | * @static |
| 81 | 99 | * @param string $path Path relative to plugin directory. |
| 82 | 100 | * @return string |
| 83 | 101 | */ |
| 84 | 102 | public static function plugin_url( $path ) { |
| 85 | - return plugins_url($path, self::$plugin_file); | |
| 103 | + return plugins_url( $path, self::$plugin_file ); | |
| 86 | 104 | } |
| 87 | 105 | |
| 88 | 106 | /** |
| 89 | 107 | * Autoload. |
| @@ -114,9 +132,9 @@ | ||
| 114 | 132 | } elseif ( 'Schema' === substr( $class, -6 ) ) { |
| 115 | 133 | $dir = $classes_dir . 'schema' . $d; |
| 116 | 134 | } elseif ( strpos( $class, 'ActionScheduler' ) === 0 ) { |
| 117 | 135 | $segments = explode( '_', $class ); |
| 118 | - $type = isset( $segments[ 1 ] ) ? $segments[ 1 ] : ''; | |
| 136 | + $type = isset( $segments[1] ) ? $segments[1] : ''; | |
| 119 | 137 | |
| 120 | 138 | switch ( $type ) { |
| 121 | 139 | case 'WPCLI': |
| 122 | 140 | $dir = $classes_dir . 'WP_CLI' . $d; |
| @@ -142,9 +160,9 @@ | ||
| 142 | 160 | return; |
| 143 | 161 | } |
| 144 | 162 | |
| 145 | 163 | if ( file_exists( $dir . "{$class}.php" ) ) { |
| 146 | - include( $dir . "{$class}.php" ); | |
| 164 | + include $dir . "{$class}.php"; | |
| 147 | 165 | return; |
| 148 | 166 | } |
| 149 | 167 | } |
| 150 | 168 | |
| @@ -162,9 +180,9 @@ | ||
| 162 | 180 | * Fires in the early stages of Action Scheduler init hook. |
| 163 | 181 | */ |
| 164 | 182 | do_action( 'action_scheduler_pre_init' ); |
| 165 | 183 | |
| 166 | - require_once( self::plugin_path( 'functions.php' ) ); | |
| 184 | + require_once self::plugin_path( 'functions.php' ); | |
| 167 | 185 | ActionScheduler_DataController::init(); |
| 168 | 186 | |
| 169 | 187 | $store = self::store(); |
| 170 | 188 | $logger = self::logger(); |
| @@ -215,9 +233,9 @@ | ||
| 215 | 233 | do_action( 'action_scheduler_init' ); |
| 216 | 234 | } |
| 217 | 235 | |
| 218 | 236 | if ( apply_filters( 'action_scheduler_load_deprecated_functions', true ) ) { |
| 219 | - require_once( self::plugin_path( 'deprecated/functions.php' ) ); | |
| 237 | + require_once self::plugin_path( 'deprecated/functions.php' ); | |
| 220 | 238 | } |
| 221 | 239 | |
| 222 | 240 | if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 223 | 241 | WP_CLI::add_command( 'action-scheduler', 'ActionScheduler_WPCLI_Scheduler_command' ); |
| @@ -250,9 +268,9 @@ | ||
| 250 | 268 | /* translators: %s function name. */ |
| 251 | 269 | __( '%s() was called before the Action Scheduler data store was initialized', 'action-scheduler' ), |
| 252 | 270 | esc_attr( $function_name ) |
| 253 | 271 | ); |
| 254 | - _doing_it_wrong( $function_name, $message, '3.1.6' ); | |
| 272 | + _doing_it_wrong( esc_html( $function_name ), esc_html( $message ), '3.1.6' ); | |
| 255 | 273 | } |
| 256 | 274 | |
| 257 | 275 | return self::$data_store_initialized; |
| 258 | 276 | } |
| @@ -305,9 +323,9 @@ | ||
| 305 | 323 | 'Scheduler' => true, |
| 306 | 324 | ); |
| 307 | 325 | |
| 308 | 326 | $segments = explode( '_', $class ); |
| 309 | - $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; | |
| 327 | + $segment = isset( $segments[1] ) ? $segments[1] : $class; | |
| 310 | 328 | |
| 311 | 329 | return isset( $migration_segments[ $segment ] ) && $migration_segments[ $segment ]; |
| 312 | 330 | } |
| 313 | 331 | |
| @@ -327,9 +345,9 @@ | ||
| 327 | 345 | 'ProgressBar' => true, |
| 328 | 346 | ); |
| 329 | 347 | |
| 330 | 348 | $segments = explode( '_', $class ); |
| 331 | - $segment = isset( $segments[ 1 ] ) ? $segments[ 1 ] : $class; | |
| 349 | + $segment = isset( $segments[1] ) ? $segments[1] : $class; | |
| 332 | 350 | |
| 333 | 351 | return isset( $cli_segments[ $segment ] ) && $cli_segments[ $segment ]; |
| 334 | 352 | } |
| 335 | 353 | |
| @@ -336,9 +354,9 @@ | ||
| 336 | 354 | /** |
| 337 | 355 | * Clone. |
| 338 | 356 | */ |
| 339 | 357 | final public function __clone() { |
| 340 | - trigger_error('Singleton. No cloning allowed!', E_USER_ERROR); | |
| 358 | + trigger_error( 'Singleton. No cloning allowed!', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error | |
| 341 | 359 | } |
| 342 | 360 | |
| 343 | 361 | /** |
| 344 | 362 | * Wakeup. |
| @@ -343,9 +361,9 @@ | ||
| 343 | 361 | /** |
| 344 | 362 | * Wakeup. |
| 345 | 363 | */ |
| 346 | 364 | final public function __wakeup() { |
| 347 | - trigger_error('Singleton. No serialization allowed!', E_USER_ERROR); | |
| 365 | + trigger_error( 'Singleton. No serialization allowed!', E_USER_ERROR ); // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error | |
| 348 | 366 | } |
| 349 | 367 | |
| 350 | 368 | /** |
| 351 | 369 | * Construct. |