@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | use Wordlift\Post\Post_Adapter; |
33 | 33 | // If this file is called directly, abort. |
34 | 34 | if ( ! defined( 'WPINC' ) ) { |
35 | - die; |
|
35 | + die; |
|
36 | 36 | } |
37 | 37 | define( |
38 | - 'WORDLIFT_PLUGIN_FILE', |
|
39 | - __FILE__ |
|
38 | + 'WORDLIFT_PLUGIN_FILE', |
|
39 | + __FILE__ |
|
40 | 40 | ); |
41 | 41 | define( 'WORDLIFT_VERSION', '3.41.0-dev' ); |
42 | 42 | |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @since 3.33.6 |
51 | 51 | */ |
52 | 52 | if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
53 | - return; |
|
53 | + return; |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
@@ -79,33 +79,33 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function activate_wordlift() { |
81 | 81 | |
82 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
82 | + $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
83 | 83 | |
84 | - $log->info( 'Activating WordLift...' ); |
|
84 | + $log->info( 'Activating WordLift...' ); |
|
85 | 85 | |
86 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
87 | - Wordlift_Activator::activate(); |
|
86 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
87 | + Wordlift_Activator::activate(); |
|
88 | 88 | |
89 | - /** |
|
90 | - * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
91 | - * |
|
92 | - * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
93 | - * @since 3.19.2 |
|
94 | - */ |
|
95 | - Wordlift_Http_Api::activate(); |
|
96 | - |
|
97 | - // Ensure the post type is registered before flushing the rewrite rules. |
|
98 | - Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
99 | - flush_rewrite_rules(); |
|
100 | - /** |
|
101 | - * @since 3.27.7 |
|
102 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
103 | - */ |
|
104 | - Top_Entities::activate(); |
|
89 | + /** |
|
90 | + * Tell the {@link Wordlift_Http_Api} class that we're activating, to let it run activation tasks. |
|
91 | + * |
|
92 | + * @see https://github.com/insideout10/wordlift-plugin/issues/820 related issue. |
|
93 | + * @since 3.19.2 |
|
94 | + */ |
|
95 | + Wordlift_Http_Api::activate(); |
|
96 | + |
|
97 | + // Ensure the post type is registered before flushing the rewrite rules. |
|
98 | + Wordlift_Entity_Post_Type_Service::get_instance()->register(); |
|
99 | + flush_rewrite_rules(); |
|
100 | + /** |
|
101 | + * @since 3.27.7 |
|
102 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
103 | + */ |
|
104 | + Top_Entities::activate(); |
|
105 | 105 | |
106 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
107 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
108 | - } |
|
106 | + if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
107 | + wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
108 | + } |
|
109 | 109 | |
110 | 110 | } |
111 | 111 | |
@@ -115,23 +115,23 @@ discard block |
||
115 | 115 | */ |
116 | 116 | function deactivate_wordlift() { |
117 | 117 | |
118 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
119 | - Wordlift_Deactivator::deactivate(); |
|
120 | - Wordlift_Http_Api::deactivate(); |
|
121 | - Ttl_Cache_Cleaner::deactivate(); |
|
122 | - /** |
|
123 | - * @since 3.27.7 |
|
124 | - * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
125 | - */ |
|
126 | - Top_Entities::deactivate(); |
|
127 | - /** |
|
128 | - * @since 3.27.8 |
|
129 | - * Remove notification flag on deactivation. |
|
130 | - */ |
|
131 | - Key_Validation_Notice::remove_notification_flag(); |
|
132 | - flush_rewrite_rules(); |
|
133 | - |
|
134 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
118 | + require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
119 | + Wordlift_Deactivator::deactivate(); |
|
120 | + Wordlift_Http_Api::deactivate(); |
|
121 | + Ttl_Cache_Cleaner::deactivate(); |
|
122 | + /** |
|
123 | + * @since 3.27.7 |
|
124 | + * @see https://github.com/insideout10/wordlift-plugin/issues/1214 |
|
125 | + */ |
|
126 | + Top_Entities::deactivate(); |
|
127 | + /** |
|
128 | + * @since 3.27.8 |
|
129 | + * Remove notification flag on deactivation. |
|
130 | + */ |
|
131 | + Key_Validation_Notice::remove_notification_flag(); |
|
132 | + flush_rewrite_rules(); |
|
133 | + |
|
134 | + wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
@@ -154,84 +154,84 @@ discard block |
||
154 | 154 | * @since 1.0.0 |
155 | 155 | */ |
156 | 156 | function run_wordlift() { |
157 | - /** |
|
158 | - * Filter: wl_feature__enable__widgets. |
|
159 | - * |
|
160 | - * @param bool whether the widgets needed to be registered, defaults to true. |
|
161 | - * |
|
162 | - * @return bool |
|
163 | - * @since 3.27.6 |
|
164 | - */ |
|
165 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
166 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
167 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
168 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
169 | - } |
|
170 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
171 | - |
|
172 | - /** |
|
173 | - * Filter: wl_feature__enable__analysis |
|
174 | - * |
|
175 | - * @param bool Whether to send api request to analysis or not |
|
176 | - * |
|
177 | - * @return bool |
|
178 | - * @since 3.27.6 |
|
179 | - */ |
|
180 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
181 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
182 | - } else { |
|
183 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
184 | - } |
|
185 | - |
|
186 | - $plugin = new Wordlift(); |
|
187 | - $plugin->run(); |
|
188 | - |
|
189 | - // Initialize the TTL Cache Cleaner. |
|
190 | - new Ttl_Cache_Cleaner(); |
|
191 | - |
|
192 | - // Load the new Post Adapter. |
|
193 | - new Post_Adapter(); |
|
194 | - |
|
195 | - // Load the API Data Hooks. |
|
196 | - new Api_Data_Hooks(); |
|
197 | - |
|
198 | - add_action( |
|
199 | - 'plugins_loaded', |
|
200 | - function () { |
|
201 | - // All features from registry should be initialized here. |
|
202 | - $features_registry = Features_Registry::get_instance(); |
|
203 | - $features_registry->initialize_all_features(); |
|
204 | - }, |
|
205 | - 5 |
|
206 | - ); |
|
207 | - |
|
208 | - add_action( |
|
209 | - 'plugins_loaded', |
|
210 | - // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
211 | - function () use ( $plugin ) { |
|
212 | - |
|
213 | - new Wordlift_Products_Navigator_Shortcode_REST(); |
|
214 | - |
|
215 | - // Register the Dataset module, requires `$api_service`. |
|
216 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
217 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
218 | - |
|
219 | - /* |
|
157 | + /** |
|
158 | + * Filter: wl_feature__enable__widgets. |
|
159 | + * |
|
160 | + * @param bool whether the widgets needed to be registered, defaults to true. |
|
161 | + * |
|
162 | + * @return bool |
|
163 | + * @since 3.27.6 |
|
164 | + */ |
|
165 | + if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
166 | + add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
167 | + add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
168 | + add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
169 | + } |
|
170 | + add_filter( 'widget_text', 'do_shortcode' ); |
|
171 | + |
|
172 | + /** |
|
173 | + * Filter: wl_feature__enable__analysis |
|
174 | + * |
|
175 | + * @param bool Whether to send api request to analysis or not |
|
176 | + * |
|
177 | + * @return bool |
|
178 | + * @since 3.27.6 |
|
179 | + */ |
|
180 | + if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
181 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
182 | + } else { |
|
183 | + add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
184 | + } |
|
185 | + |
|
186 | + $plugin = new Wordlift(); |
|
187 | + $plugin->run(); |
|
188 | + |
|
189 | + // Initialize the TTL Cache Cleaner. |
|
190 | + new Ttl_Cache_Cleaner(); |
|
191 | + |
|
192 | + // Load the new Post Adapter. |
|
193 | + new Post_Adapter(); |
|
194 | + |
|
195 | + // Load the API Data Hooks. |
|
196 | + new Api_Data_Hooks(); |
|
197 | + |
|
198 | + add_action( |
|
199 | + 'plugins_loaded', |
|
200 | + function () { |
|
201 | + // All features from registry should be initialized here. |
|
202 | + $features_registry = Features_Registry::get_instance(); |
|
203 | + $features_registry->initialize_all_features(); |
|
204 | + }, |
|
205 | + 5 |
|
206 | + ); |
|
207 | + |
|
208 | + add_action( |
|
209 | + 'plugins_loaded', |
|
210 | + // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
|
211 | + function () use ( $plugin ) { |
|
212 | + |
|
213 | + new Wordlift_Products_Navigator_Shortcode_REST(); |
|
214 | + |
|
215 | + // Register the Dataset module, requires `$api_service`. |
|
216 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
217 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
218 | + |
|
219 | + /* |
|
220 | 220 | * Require the Entity annotation cleanup module. |
221 | 221 | * |
222 | 222 | * @since 3.34.6 |
223 | 223 | */ |
224 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
224 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
225 | 225 | |
226 | - /* |
|
226 | + /* |
|
227 | 227 | * Import LOD entities. |
228 | 228 | * |
229 | 229 | * @since 3.35.0 |
230 | 230 | */ |
231 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
231 | + require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
232 | 232 | |
233 | - } |
|
234 | - ); |
|
233 | + } |
|
234 | + ); |
|
235 | 235 | |
236 | 236 | } |
237 | 237 | |
@@ -245,45 +245,45 @@ discard block |
||
245 | 245 | */ |
246 | 246 | function wordlift_plugin_autoload_register() { |
247 | 247 | |
248 | - spl_autoload_register( |
|
249 | - function ( $class_name ) { |
|
248 | + spl_autoload_register( |
|
249 | + function ( $class_name ) { |
|
250 | 250 | |
251 | - // Bail out if these are not our classes. |
|
252 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
253 | - return false; |
|
254 | - } |
|
251 | + // Bail out if these are not our classes. |
|
252 | + if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
253 | + return false; |
|
254 | + } |
|
255 | 255 | |
256 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
256 | + $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
257 | 257 | |
258 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
258 | + preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
259 | 259 | |
260 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
261 | - $file = 'class-' . $matches[2] . '.php'; |
|
260 | + $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
261 | + $file = 'class-' . $matches[2] . '.php'; |
|
262 | 262 | |
263 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
263 | + $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
264 | 264 | |
265 | - if ( ! file_exists( $full_path ) ) { |
|
266 | - return false; |
|
267 | - } |
|
265 | + if ( ! file_exists( $full_path ) ) { |
|
266 | + return false; |
|
267 | + } |
|
268 | 268 | |
269 | - require_once $full_path; |
|
269 | + require_once $full_path; |
|
270 | 270 | |
271 | - return true; |
|
272 | - } |
|
273 | - ); |
|
271 | + return true; |
|
272 | + } |
|
273 | + ); |
|
274 | 274 | |
275 | 275 | } |
276 | 276 | |
277 | 277 | function wl_block_categories( $categories ) { |
278 | - return array_merge( |
|
279 | - $categories, |
|
280 | - array( |
|
281 | - array( |
|
282 | - 'slug' => 'wordlift', |
|
283 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
284 | - ), |
|
285 | - ) |
|
286 | - ); |
|
278 | + return array_merge( |
|
279 | + $categories, |
|
280 | + array( |
|
281 | + array( |
|
282 | + 'slug' => 'wordlift', |
|
283 | + 'title' => __( 'WordLift', 'wordlift' ), |
|
284 | + ), |
|
285 | + ) |
|
286 | + ); |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | /** |
@@ -291,19 +291,19 @@ discard block |
||
291 | 291 | * this has to be removed when removing the legacy fields from the ui. |
292 | 292 | */ |
293 | 293 | function wl_enqueue_leaflet( $in_footer = false ) { |
294 | - // Leaflet. |
|
295 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
296 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
294 | + // Leaflet. |
|
295 | + wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
296 | + wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
297 | 297 | } |
298 | 298 | |
299 | 299 | add_filter( 'block_categories', 'wl_block_categories', 10 ); |
300 | 300 | |
301 | 301 | // Temporary fix for a typo in WooCommerce Extension. |
302 | 302 | add_filter( |
303 | - 'wl_feature__enable__dataset', |
|
304 | - function ( $value ) { |
|
305 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
306 | - } |
|
303 | + 'wl_feature__enable__dataset', |
|
304 | + function ( $value ) { |
|
305 | + return apply_filters( 'wl_features__enable__dataset', $value ); |
|
306 | + } |
|
307 | 307 | ); |
308 | 308 | |
309 | 309 | require_once __DIR__ . '/modules/food-kg/load.php'; |
@@ -312,26 +312,26 @@ discard block |
||
312 | 312 | require_once __DIR__ . '/modules/include-exclude-push-config/load.php'; |
313 | 313 | |
314 | 314 | add_action( |
315 | - 'update_plugins_adthrive.wordlift.io', |
|
316 | - function ( $update, $plugin_data, $plugin_file ) { |
|
317 | - // Bail out if it's not our plugin. |
|
318 | - $update_uri = $plugin_data['UpdateURI']; |
|
319 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
320 | - return $update; |
|
321 | - } |
|
322 | - |
|
323 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
324 | - |
|
325 | - if ( is_wp_error( $response ) ) { |
|
326 | - return $update; |
|
327 | - } |
|
328 | - |
|
329 | - try { |
|
330 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
331 | - } catch ( Exception $e ) { |
|
332 | - return $update; |
|
333 | - } |
|
334 | - }, |
|
335 | - 10, |
|
336 | - 3 |
|
315 | + 'update_plugins_adthrive.wordlift.io', |
|
316 | + function ( $update, $plugin_data, $plugin_file ) { |
|
317 | + // Bail out if it's not our plugin. |
|
318 | + $update_uri = $plugin_data['UpdateURI']; |
|
319 | + if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
320 | + return $update; |
|
321 | + } |
|
322 | + |
|
323 | + $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
324 | + |
|
325 | + if ( is_wp_error( $response ) ) { |
|
326 | + return $update; |
|
327 | + } |
|
328 | + |
|
329 | + try { |
|
330 | + return json_decode( wp_remote_retrieve_body( $response ) ); |
|
331 | + } catch ( Exception $e ) { |
|
332 | + return $update; |
|
333 | + } |
|
334 | + }, |
|
335 | + 10, |
|
336 | + 3 |
|
337 | 337 | ); |
@@ -31,29 +31,29 @@ discard block |
||
31 | 31 | use Wordlift\Features\Features_Registry; |
32 | 32 | use Wordlift\Post\Post_Adapter; |
33 | 33 | // If this file is called directly, abort. |
34 | -if ( ! defined( 'WPINC' ) ) { |
|
34 | +if ( ! defined('WPINC')) { |
|
35 | 35 | die; |
36 | 36 | } |
37 | 37 | define( |
38 | 38 | 'WORDLIFT_PLUGIN_FILE', |
39 | 39 | __FILE__ |
40 | 40 | ); |
41 | -define( 'WORDLIFT_VERSION', '3.41.0-dev' ); |
|
41 | +define('WORDLIFT_VERSION', '3.41.0-dev'); |
|
42 | 42 | |
43 | -require_once plugin_dir_path( __FILE__ ) . '/libraries/action-scheduler/action-scheduler.php'; |
|
44 | -require_once __DIR__ . '/modules/common/load.php'; |
|
45 | -require_once __DIR__ . '/modules/include-exclude/load.php'; |
|
43 | +require_once plugin_dir_path(__FILE__).'/libraries/action-scheduler/action-scheduler.php'; |
|
44 | +require_once __DIR__.'/modules/common/load.php'; |
|
45 | +require_once __DIR__.'/modules/include-exclude/load.php'; |
|
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Filter to disable WLP on any request, defaults to true. |
49 | 49 | * |
50 | 50 | * @since 3.33.6 |
51 | 51 | */ |
52 | -if ( ! apply_filters( 'wl_is_enabled', true ) ) { |
|
52 | +if ( ! apply_filters('wl_is_enabled', true)) { |
|
53 | 53 | return; |
54 | 54 | } |
55 | 55 | |
56 | -require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload.php'; |
|
56 | +require_once plugin_dir_path(__FILE__).'vendor/autoload.php'; |
|
57 | 57 | |
58 | 58 | /* |
59 | 59 | * We introduce the WordLift autoloader, since we start using classes in namespaces, i.e. Wordlift\Http. |
@@ -63,15 +63,15 @@ discard block |
||
63 | 63 | wordlift_plugin_autoload_register(); |
64 | 64 | |
65 | 65 | // Include WordLift constants. |
66 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift-constants.php'; |
|
66 | +require_once plugin_dir_path(__FILE__).'wordlift-constants.php'; |
|
67 | 67 | |
68 | 68 | // Load modules. |
69 | -require_once plugin_dir_path( __FILE__ ) . 'modules/core/wordlift-core.php'; |
|
69 | +require_once plugin_dir_path(__FILE__).'modules/core/wordlift-core.php'; |
|
70 | 70 | |
71 | -require_once plugin_dir_path( __FILE__ ) . 'deprecations.php'; |
|
71 | +require_once plugin_dir_path(__FILE__).'deprecations.php'; |
|
72 | 72 | |
73 | 73 | // Load early to enable/disable features. |
74 | -require_once plugin_dir_path( __FILE__ ) . 'wordlift/features/index.php'; |
|
74 | +require_once plugin_dir_path(__FILE__).'wordlift/features/index.php'; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * The code that runs during plugin activation. |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | */ |
80 | 80 | function activate_wordlift() { |
81 | 81 | |
82 | - $log = Wordlift_Log_Service::get_logger( 'activate_wordlift' ); |
|
82 | + $log = Wordlift_Log_Service::get_logger('activate_wordlift'); |
|
83 | 83 | |
84 | - $log->info( 'Activating WordLift...' ); |
|
84 | + $log->info('Activating WordLift...'); |
|
85 | 85 | |
86 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-activator.php'; |
|
86 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-activator.php'; |
|
87 | 87 | Wordlift_Activator::activate(); |
88 | 88 | |
89 | 89 | /** |
@@ -103,8 +103,8 @@ discard block |
||
103 | 103 | */ |
104 | 104 | Top_Entities::activate(); |
105 | 105 | |
106 | - if ( ! wp_next_scheduled( 'wl_daily_cron' ) ) { |
|
107 | - wp_schedule_event( time(), 'daily', 'wl_daily_cron' ); |
|
106 | + if ( ! wp_next_scheduled('wl_daily_cron')) { |
|
107 | + wp_schedule_event(time(), 'daily', 'wl_daily_cron'); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | function deactivate_wordlift() { |
117 | 117 | |
118 | - require_once plugin_dir_path( __FILE__ ) . 'includes/class-wordlift-deactivator.php'; |
|
118 | + require_once plugin_dir_path(__FILE__).'includes/class-wordlift-deactivator.php'; |
|
119 | 119 | Wordlift_Deactivator::deactivate(); |
120 | 120 | Wordlift_Http_Api::deactivate(); |
121 | 121 | Ttl_Cache_Cleaner::deactivate(); |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | Key_Validation_Notice::remove_notification_flag(); |
132 | 132 | flush_rewrite_rules(); |
133 | 133 | |
134 | - wp_clear_scheduled_hook( 'wl_daily_cron' ); |
|
134 | + wp_clear_scheduled_hook('wl_daily_cron'); |
|
135 | 135 | |
136 | 136 | } |
137 | 137 | |
138 | -register_activation_hook( __FILE__, 'activate_wordlift' ); |
|
139 | -register_deactivation_hook( __FILE__, 'deactivate_wordlift' ); |
|
138 | +register_activation_hook(__FILE__, 'activate_wordlift'); |
|
139 | +register_deactivation_hook(__FILE__, 'deactivate_wordlift'); |
|
140 | 140 | |
141 | 141 | /** |
142 | 142 | * The core plugin class that is used to define internationalization, |
143 | 143 | * admin-specific hooks, and public-facing site hooks. |
144 | 144 | */ |
145 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wordlift.php'; |
|
145 | +require plugin_dir_path(__FILE__).'includes/class-wordlift.php'; |
|
146 | 146 | |
147 | 147 | /** |
148 | 148 | * Begins execution of the plugin. |
@@ -162,12 +162,12 @@ discard block |
||
162 | 162 | * @return bool |
163 | 163 | * @since 3.27.6 |
164 | 164 | */ |
165 | - if ( apply_filters( 'wl_feature__enable__widgets', true ) ) { |
|
166 | - add_action( 'widgets_init', 'wl_register_chord_widget' ); |
|
167 | - add_action( 'widgets_init', 'wl_register_geo_widget' ); |
|
168 | - add_action( 'widgets_init', 'wl_register_timeline_widget' ); |
|
165 | + if (apply_filters('wl_feature__enable__widgets', true)) { |
|
166 | + add_action('widgets_init', 'wl_register_chord_widget'); |
|
167 | + add_action('widgets_init', 'wl_register_geo_widget'); |
|
168 | + add_action('widgets_init', 'wl_register_timeline_widget'); |
|
169 | 169 | } |
170 | - add_filter( 'widget_text', 'do_shortcode' ); |
|
170 | + add_filter('widget_text', 'do_shortcode'); |
|
171 | 171 | |
172 | 172 | /** |
173 | 173 | * Filter: wl_feature__enable__analysis |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @return bool |
178 | 178 | * @since 3.27.6 |
179 | 179 | */ |
180 | - if ( apply_filters( 'wl_feature__enable__analysis', true ) ) { |
|
181 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_action' ); |
|
180 | + if (apply_filters('wl_feature__enable__analysis', true)) { |
|
181 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_action'); |
|
182 | 182 | } else { |
183 | - add_action( 'wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action' ); |
|
183 | + add_action('wp_ajax_wl_analyze', 'wl_ajax_analyze_disabled_action'); |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | $plugin = new Wordlift(); |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | add_action( |
199 | 199 | 'plugins_loaded', |
200 | - function () { |
|
200 | + function() { |
|
201 | 201 | // All features from registry should be initialized here. |
202 | 202 | $features_registry = Features_Registry::get_instance(); |
203 | 203 | $features_registry->initialize_all_features(); |
@@ -208,27 +208,27 @@ discard block |
||
208 | 208 | add_action( |
209 | 209 | 'plugins_loaded', |
210 | 210 | // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable |
211 | - function () use ( $plugin ) { |
|
211 | + function() use ($plugin) { |
|
212 | 212 | |
213 | 213 | new Wordlift_Products_Navigator_Shortcode_REST(); |
214 | 214 | |
215 | 215 | // Register the Dataset module, requires `$api_service`. |
216 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/dataset/index.php'; |
|
217 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/shipping-data/index.php'; |
|
216 | + require_once plugin_dir_path(__FILE__).'wordlift/dataset/index.php'; |
|
217 | + require_once plugin_dir_path(__FILE__).'wordlift/shipping-data/index.php'; |
|
218 | 218 | |
219 | 219 | /* |
220 | 220 | * Require the Entity annotation cleanup module. |
221 | 221 | * |
222 | 222 | * @since 3.34.6 |
223 | 223 | */ |
224 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/cleanup/index.php'; |
|
224 | + require_once plugin_dir_path(__FILE__).'wordlift/cleanup/index.php'; |
|
225 | 225 | |
226 | 226 | /* |
227 | 227 | * Import LOD entities. |
228 | 228 | * |
229 | 229 | * @since 3.35.0 |
230 | 230 | */ |
231 | - require_once plugin_dir_path( __FILE__ ) . 'wordlift/lod-import/index.php'; |
|
231 | + require_once plugin_dir_path(__FILE__).'wordlift/lod-import/index.php'; |
|
232 | 232 | |
233 | 233 | } |
234 | 234 | ); |
@@ -246,23 +246,23 @@ discard block |
||
246 | 246 | function wordlift_plugin_autoload_register() { |
247 | 247 | |
248 | 248 | spl_autoload_register( |
249 | - function ( $class_name ) { |
|
249 | + function($class_name) { |
|
250 | 250 | |
251 | 251 | // Bail out if these are not our classes. |
252 | - if ( 0 !== strpos( $class_name, 'Wordlift\\' ) ) { |
|
252 | + if (0 !== strpos($class_name, 'Wordlift\\')) { |
|
253 | 253 | return false; |
254 | 254 | } |
255 | 255 | |
256 | - $class_name_lc = strtolower( str_replace( '_', '-', $class_name ) ); |
|
256 | + $class_name_lc = strtolower(str_replace('_', '-', $class_name)); |
|
257 | 257 | |
258 | - preg_match( '|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches ); |
|
258 | + preg_match('|^(?:(.*)\\\\)?(.+?)$|', $class_name_lc, $matches); |
|
259 | 259 | |
260 | - $path = str_replace( '\\', DIRECTORY_SEPARATOR, $matches[1] ); |
|
261 | - $file = 'class-' . $matches[2] . '.php'; |
|
260 | + $path = str_replace('\\', DIRECTORY_SEPARATOR, $matches[1]); |
|
261 | + $file = 'class-'.$matches[2].'.php'; |
|
262 | 262 | |
263 | - $full_path = plugin_dir_path( __FILE__ ) . $path . DIRECTORY_SEPARATOR . $file; |
|
263 | + $full_path = plugin_dir_path(__FILE__).$path.DIRECTORY_SEPARATOR.$file; |
|
264 | 264 | |
265 | - if ( ! file_exists( $full_path ) ) { |
|
265 | + if ( ! file_exists($full_path)) { |
|
266 | 266 | return false; |
267 | 267 | } |
268 | 268 | |
@@ -274,13 +274,13 @@ discard block |
||
274 | 274 | |
275 | 275 | } |
276 | 276 | |
277 | -function wl_block_categories( $categories ) { |
|
277 | +function wl_block_categories($categories) { |
|
278 | 278 | return array_merge( |
279 | 279 | $categories, |
280 | 280 | array( |
281 | 281 | array( |
282 | 282 | 'slug' => 'wordlift', |
283 | - 'title' => __( 'WordLift', 'wordlift' ), |
|
283 | + 'title' => __('WordLift', 'wordlift'), |
|
284 | 284 | ), |
285 | 285 | ) |
286 | 286 | ); |
@@ -290,45 +290,45 @@ discard block |
||
290 | 290 | * This function is created temporarily to handle the legacy library, |
291 | 291 | * this has to be removed when removing the legacy fields from the ui. |
292 | 292 | */ |
293 | -function wl_enqueue_leaflet( $in_footer = false ) { |
|
293 | +function wl_enqueue_leaflet($in_footer = false) { |
|
294 | 294 | // Leaflet. |
295 | - wp_enqueue_style( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.css', array(), '1.6.0' ); |
|
296 | - wp_enqueue_script( 'wl-leaflet', plugin_dir_url( __FILE__ ) . 'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer ); |
|
295 | + wp_enqueue_style('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.css', array(), '1.6.0'); |
|
296 | + wp_enqueue_script('wl-leaflet', plugin_dir_url(__FILE__).'js/leaflet/leaflet.js', array(), '1.6.0', $in_footer); |
|
297 | 297 | } |
298 | 298 | |
299 | -add_filter( 'block_categories', 'wl_block_categories', 10 ); |
|
299 | +add_filter('block_categories', 'wl_block_categories', 10); |
|
300 | 300 | |
301 | 301 | // Temporary fix for a typo in WooCommerce Extension. |
302 | 302 | add_filter( |
303 | 303 | 'wl_feature__enable__dataset', |
304 | - function ( $value ) { |
|
305 | - return apply_filters( 'wl_features__enable__dataset', $value ); |
|
304 | + function($value) { |
|
305 | + return apply_filters('wl_features__enable__dataset', $value); |
|
306 | 306 | } |
307 | 307 | ); |
308 | 308 | |
309 | -require_once __DIR__ . '/modules/food-kg/load.php'; |
|
310 | -require_once __DIR__ . '/modules/acf4so/load.php'; |
|
311 | -require_once __DIR__ . '/modules/pods/load.php'; |
|
312 | -require_once __DIR__ . '/modules/include-exclude-push-config/load.php'; |
|
309 | +require_once __DIR__.'/modules/food-kg/load.php'; |
|
310 | +require_once __DIR__.'/modules/acf4so/load.php'; |
|
311 | +require_once __DIR__.'/modules/pods/load.php'; |
|
312 | +require_once __DIR__.'/modules/include-exclude-push-config/load.php'; |
|
313 | 313 | |
314 | 314 | add_action( |
315 | 315 | 'update_plugins_adthrive.wordlift.io', |
316 | - function ( $update, $plugin_data, $plugin_file ) { |
|
316 | + function($update, $plugin_data, $plugin_file) { |
|
317 | 317 | // Bail out if it's not our plugin. |
318 | 318 | $update_uri = $plugin_data['UpdateURI']; |
319 | - if ( 'wordlift/wordlift.php' !== $plugin_file || ! isset( $update_uri ) ) { |
|
319 | + if ('wordlift/wordlift.php' !== $plugin_file || ! isset($update_uri)) { |
|
320 | 320 | return $update; |
321 | 321 | } |
322 | 322 | |
323 | - $response = wp_remote_get( "$update_uri?nocache=" . time() ); |
|
323 | + $response = wp_remote_get("$update_uri?nocache=".time()); |
|
324 | 324 | |
325 | - if ( is_wp_error( $response ) ) { |
|
325 | + if (is_wp_error($response)) { |
|
326 | 326 | return $update; |
327 | 327 | } |
328 | 328 | |
329 | 329 | try { |
330 | - return json_decode( wp_remote_retrieve_body( $response ) ); |
|
331 | - } catch ( Exception $e ) { |
|
330 | + return json_decode(wp_remote_retrieve_body($response)); |
|
331 | + } catch (Exception $e) { |
|
332 | 332 | return $update; |
333 | 333 | } |
334 | 334 | }, |
@@ -5,41 +5,41 @@ |
||
5 | 5 | * @package test_cases\lock |
6 | 6 | */ |
7 | 7 | class ActionScheduler_OptionLock_Test extends ActionScheduler_UnitTestCase { |
8 | - public function test_instance() { |
|
9 | - $lock = ActionScheduler::lock(); |
|
10 | - $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
11 | - $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
12 | - } |
|
8 | + public function test_instance() { |
|
9 | + $lock = ActionScheduler::lock(); |
|
10 | + $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
11 | + $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
12 | + } |
|
13 | 13 | |
14 | - public function test_is_locked() { |
|
15 | - $lock = ActionScheduler::lock(); |
|
16 | - $lock_type = md5( rand() ); |
|
14 | + public function test_is_locked() { |
|
15 | + $lock = ActionScheduler::lock(); |
|
16 | + $lock_type = md5( rand() ); |
|
17 | 17 | |
18 | - $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
18 | + $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
19 | 19 | |
20 | - $lock->set( $lock_type ); |
|
21 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
22 | - } |
|
20 | + $lock->set( $lock_type ); |
|
21 | + $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
22 | + } |
|
23 | 23 | |
24 | - public function test_set() { |
|
25 | - $lock = ActionScheduler::lock(); |
|
26 | - $lock_type = md5( rand() ); |
|
24 | + public function test_set() { |
|
25 | + $lock = ActionScheduler::lock(); |
|
26 | + $lock_type = md5( rand() ); |
|
27 | 27 | |
28 | - $lock->set( $lock_type ); |
|
29 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
30 | - } |
|
28 | + $lock->set( $lock_type ); |
|
29 | + $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
30 | + } |
|
31 | 31 | |
32 | - public function test_get_expiration() { |
|
33 | - $lock = ActionScheduler::lock(); |
|
34 | - $lock_type = md5( rand() ); |
|
32 | + public function test_get_expiration() { |
|
33 | + $lock = ActionScheduler::lock(); |
|
34 | + $lock_type = md5( rand() ); |
|
35 | 35 | |
36 | - $lock->set( $lock_type ); |
|
36 | + $lock->set( $lock_type ); |
|
37 | 37 | |
38 | - $expiration = $lock->get_expiration( $lock_type ); |
|
39 | - $current_time = time(); |
|
38 | + $expiration = $lock->get_expiration( $lock_type ); |
|
39 | + $current_time = time(); |
|
40 | 40 | |
41 | - $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
42 | - $this->assertGreaterThan( $current_time, $expiration ); |
|
43 | - $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
44 | - } |
|
41 | + $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
42 | + $this->assertGreaterThan( $current_time, $expiration ); |
|
43 | + $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
44 | + } |
|
45 | 45 | } |
@@ -7,39 +7,39 @@ |
||
7 | 7 | class ActionScheduler_OptionLock_Test extends ActionScheduler_UnitTestCase { |
8 | 8 | public function test_instance() { |
9 | 9 | $lock = ActionScheduler::lock(); |
10 | - $this->assertInstanceOf( 'ActionScheduler_Lock', $lock ); |
|
11 | - $this->assertInstanceOf( 'ActionScheduler_OptionLock', $lock ); |
|
10 | + $this->assertInstanceOf('ActionScheduler_Lock', $lock); |
|
11 | + $this->assertInstanceOf('ActionScheduler_OptionLock', $lock); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | public function test_is_locked() { |
15 | 15 | $lock = ActionScheduler::lock(); |
16 | - $lock_type = md5( rand() ); |
|
16 | + $lock_type = md5(rand()); |
|
17 | 17 | |
18 | - $this->assertFalse( $lock->is_locked( $lock_type ) ); |
|
18 | + $this->assertFalse($lock->is_locked($lock_type)); |
|
19 | 19 | |
20 | - $lock->set( $lock_type ); |
|
21 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
20 | + $lock->set($lock_type); |
|
21 | + $this->assertTrue($lock->is_locked($lock_type)); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | public function test_set() { |
25 | 25 | $lock = ActionScheduler::lock(); |
26 | - $lock_type = md5( rand() ); |
|
26 | + $lock_type = md5(rand()); |
|
27 | 27 | |
28 | - $lock->set( $lock_type ); |
|
29 | - $this->assertTrue( $lock->is_locked( $lock_type ) ); |
|
28 | + $lock->set($lock_type); |
|
29 | + $this->assertTrue($lock->is_locked($lock_type)); |
|
30 | 30 | } |
31 | 31 | |
32 | 32 | public function test_get_expiration() { |
33 | 33 | $lock = ActionScheduler::lock(); |
34 | - $lock_type = md5( rand() ); |
|
34 | + $lock_type = md5(rand()); |
|
35 | 35 | |
36 | - $lock->set( $lock_type ); |
|
36 | + $lock->set($lock_type); |
|
37 | 37 | |
38 | - $expiration = $lock->get_expiration( $lock_type ); |
|
38 | + $expiration = $lock->get_expiration($lock_type); |
|
39 | 39 | $current_time = time(); |
40 | 40 | |
41 | - $this->assertGreaterThanOrEqual( 0, $expiration ); |
|
42 | - $this->assertGreaterThan( $current_time, $expiration ); |
|
43 | - $this->assertLessThan( $current_time + MINUTE_IN_SECONDS + 1, $expiration ); |
|
41 | + $this->assertGreaterThanOrEqual(0, $expiration); |
|
42 | + $this->assertGreaterThan($current_time, $expiration); |
|
43 | + $this->assertLessThan($current_time + MINUTE_IN_SECONDS + 1, $expiration); |
|
44 | 44 | } |
45 | 45 | } |
@@ -15,62 +15,62 @@ |
||
15 | 15 | * @group migration |
16 | 16 | */ |
17 | 17 | class Controller_Test extends ActionScheduler_UnitTestCase { |
18 | - /** |
|
19 | - * Test to ensure the Migration Controller will schedule the migration. |
|
20 | - */ |
|
21 | - public function test_schedules_migration() { |
|
22 | - as_unschedule_action( Scheduler::HOOK ); |
|
23 | - Controller::instance()->schedule_migration(); |
|
18 | + /** |
|
19 | + * Test to ensure the Migration Controller will schedule the migration. |
|
20 | + */ |
|
21 | + public function test_schedules_migration() { |
|
22 | + as_unschedule_action( Scheduler::HOOK ); |
|
23 | + Controller::instance()->schedule_migration(); |
|
24 | 24 | |
25 | - $this->assertTrue( |
|
26 | - as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
27 | - 'Confirm that the Migration Controller scheduled the migration.' |
|
28 | - ); |
|
25 | + $this->assertTrue( |
|
26 | + as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
27 | + 'Confirm that the Migration Controller scheduled the migration.' |
|
28 | + ); |
|
29 | 29 | |
30 | - as_unschedule_action( Scheduler::HOOK ); |
|
31 | - } |
|
30 | + as_unschedule_action( Scheduler::HOOK ); |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * Test to ensure that if an essential table is missing, the Migration |
|
35 | - * Controller will not schedule a migration. |
|
36 | - * |
|
37 | - * @see https://github.com/woocommerce/action-scheduler/issues/653 |
|
38 | - */ |
|
39 | - public function test_migration_not_scheduled_if_tables_are_missing() { |
|
40 | - as_unschedule_action( Scheduler::HOOK ); |
|
41 | - $this->rename_claims_table(); |
|
42 | - Controller::instance()->schedule_migration(); |
|
33 | + /** |
|
34 | + * Test to ensure that if an essential table is missing, the Migration |
|
35 | + * Controller will not schedule a migration. |
|
36 | + * |
|
37 | + * @see https://github.com/woocommerce/action-scheduler/issues/653 |
|
38 | + */ |
|
39 | + public function test_migration_not_scheduled_if_tables_are_missing() { |
|
40 | + as_unschedule_action( Scheduler::HOOK ); |
|
41 | + $this->rename_claims_table(); |
|
42 | + Controller::instance()->schedule_migration(); |
|
43 | 43 | |
44 | - $this->assertFalse( |
|
45 | - as_next_scheduled_action( Scheduler::HOOK ), |
|
46 | - 'When required tables are missing, the migration will not be scheduled.' |
|
47 | - ); |
|
44 | + $this->assertFalse( |
|
45 | + as_next_scheduled_action( Scheduler::HOOK ), |
|
46 | + 'When required tables are missing, the migration will not be scheduled.' |
|
47 | + ); |
|
48 | 48 | |
49 | - $this->restore_claims_table_name(); |
|
50 | - } |
|
49 | + $this->restore_claims_table_name(); |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Rename the claims table, so that it cannot be used by the library. |
|
54 | - */ |
|
55 | - private function rename_claims_table() { |
|
56 | - global $wpdb; |
|
57 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
58 | - $modified_table_name = $normal_table_name . 'x'; |
|
52 | + /** |
|
53 | + * Rename the claims table, so that it cannot be used by the library. |
|
54 | + */ |
|
55 | + private function rename_claims_table() { |
|
56 | + global $wpdb; |
|
57 | + $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
58 | + $modified_table_name = $normal_table_name . 'x'; |
|
59 | 59 | |
60 | - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
61 | - $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
62 | - } |
|
60 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
61 | + $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Restore the expected name of the claims table, so that it can be used by the library |
|
66 | - * and any further tests. |
|
67 | - */ |
|
68 | - private function restore_claims_table_name() { |
|
69 | - global $wpdb; |
|
70 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
71 | - $modified_table_name = $normal_table_name . 'x'; |
|
64 | + /** |
|
65 | + * Restore the expected name of the claims table, so that it can be used by the library |
|
66 | + * and any further tests. |
|
67 | + */ |
|
68 | + private function restore_claims_table_name() { |
|
69 | + global $wpdb; |
|
70 | + $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
71 | + $modified_table_name = $normal_table_name . 'x'; |
|
72 | 72 | |
73 | - // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
74 | - $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
75 | - } |
|
73 | + // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
|
74 | + $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
75 | + } |
|
76 | 76 | } |
@@ -19,15 +19,15 @@ discard block |
||
19 | 19 | * Test to ensure the Migration Controller will schedule the migration. |
20 | 20 | */ |
21 | 21 | public function test_schedules_migration() { |
22 | - as_unschedule_action( Scheduler::HOOK ); |
|
22 | + as_unschedule_action(Scheduler::HOOK); |
|
23 | 23 | Controller::instance()->schedule_migration(); |
24 | 24 | |
25 | 25 | $this->assertTrue( |
26 | - as_next_scheduled_action( Scheduler::HOOK ) > 0, |
|
26 | + as_next_scheduled_action(Scheduler::HOOK) > 0, |
|
27 | 27 | 'Confirm that the Migration Controller scheduled the migration.' |
28 | 28 | ); |
29 | 29 | |
30 | - as_unschedule_action( Scheduler::HOOK ); |
|
30 | + as_unschedule_action(Scheduler::HOOK); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | /** |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | * @see https://github.com/woocommerce/action-scheduler/issues/653 |
38 | 38 | */ |
39 | 39 | public function test_migration_not_scheduled_if_tables_are_missing() { |
40 | - as_unschedule_action( Scheduler::HOOK ); |
|
40 | + as_unschedule_action(Scheduler::HOOK); |
|
41 | 41 | $this->rename_claims_table(); |
42 | 42 | Controller::instance()->schedule_migration(); |
43 | 43 | |
44 | 44 | $this->assertFalse( |
45 | - as_next_scheduled_action( Scheduler::HOOK ), |
|
45 | + as_next_scheduled_action(Scheduler::HOOK), |
|
46 | 46 | 'When required tables are missing, the migration will not be scheduled.' |
47 | 47 | ); |
48 | 48 | |
@@ -54,11 +54,11 @@ discard block |
||
54 | 54 | */ |
55 | 55 | private function rename_claims_table() { |
56 | 56 | global $wpdb; |
57 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
58 | - $modified_table_name = $normal_table_name . 'x'; |
|
57 | + $normal_table_name = $wpdb->prefix.Schema::CLAIMS_TABLE; |
|
58 | + $modified_table_name = $normal_table_name.'x'; |
|
59 | 59 | |
60 | 60 | // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
61 | - $wpdb->query( "RENAME TABLE {$normal_table_name} TO {$modified_table_name}" ); |
|
61 | + $wpdb->query("RENAME TABLE {$normal_table_name} TO {$modified_table_name}"); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,10 +67,10 @@ discard block |
||
67 | 67 | */ |
68 | 68 | private function restore_claims_table_name() { |
69 | 69 | global $wpdb; |
70 | - $normal_table_name = $wpdb->prefix . Schema::CLAIMS_TABLE; |
|
71 | - $modified_table_name = $normal_table_name . 'x'; |
|
70 | + $normal_table_name = $wpdb->prefix.Schema::CLAIMS_TABLE; |
|
71 | + $modified_table_name = $normal_table_name.'x'; |
|
72 | 72 | |
73 | 73 | // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared |
74 | - $wpdb->query( "RENAME TABLE {$modified_table_name} TO {$normal_table_name}" ); |
|
74 | + $wpdb->query("RENAME TABLE {$modified_table_name} TO {$normal_table_name}"); |
|
75 | 75 | } |
76 | 76 | } |
@@ -6,44 +6,44 @@ |
||
6 | 6 | */ |
7 | 7 | abstract class ActionScheduler_Store_Deprecated { |
8 | 8 | |
9 | - /** |
|
10 | - * Mark an action that failed to fetch correctly as failed. |
|
11 | - * |
|
12 | - * @since 2.2.6 |
|
13 | - * |
|
14 | - * @param int $action_id The ID of the action. |
|
15 | - */ |
|
16 | - public function mark_failed_fetch_action( $action_id ) { |
|
17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
18 | - self::$store->mark_failure( $action_id ); |
|
19 | - } |
|
9 | + /** |
|
10 | + * Mark an action that failed to fetch correctly as failed. |
|
11 | + * |
|
12 | + * @since 2.2.6 |
|
13 | + * |
|
14 | + * @param int $action_id The ID of the action. |
|
15 | + */ |
|
16 | + public function mark_failed_fetch_action( $action_id ) { |
|
17 | + _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
18 | + self::$store->mark_failure( $action_id ); |
|
19 | + } |
|
20 | 20 | |
21 | - /** |
|
22 | - * Add base hooks |
|
23 | - * |
|
24 | - * @since 2.2.6 |
|
25 | - */ |
|
26 | - protected static function hook() { |
|
27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
28 | - } |
|
21 | + /** |
|
22 | + * Add base hooks |
|
23 | + * |
|
24 | + * @since 2.2.6 |
|
25 | + */ |
|
26 | + protected static function hook() { |
|
27 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Remove base hooks |
|
32 | - * |
|
33 | - * @since 2.2.6 |
|
34 | - */ |
|
35 | - protected static function unhook() { |
|
36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
37 | - } |
|
30 | + /** |
|
31 | + * Remove base hooks |
|
32 | + * |
|
33 | + * @since 2.2.6 |
|
34 | + */ |
|
35 | + protected static function unhook() { |
|
36 | + _deprecated_function( __METHOD__, '3.0.0' ); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Get the site's local time. |
|
41 | - * |
|
42 | - * @deprecated 2.1.0 |
|
43 | - * @return DateTimeZone |
|
44 | - */ |
|
45 | - protected function get_local_timezone() { |
|
46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
47 | - return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
48 | - } |
|
39 | + /** |
|
40 | + * Get the site's local time. |
|
41 | + * |
|
42 | + * @deprecated 2.1.0 |
|
43 | + * @return DateTimeZone |
|
44 | + */ |
|
45 | + protected function get_local_timezone() { |
|
46 | + _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
47 | + return ActionScheduler_TimezoneHelper::get_local_timezone(); |
|
48 | + } |
|
49 | 49 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | * |
14 | 14 | * @param int $action_id The ID of the action. |
15 | 15 | */ |
16 | - public function mark_failed_fetch_action( $action_id ) { |
|
17 | - _deprecated_function( __METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()' ); |
|
18 | - self::$store->mark_failure( $action_id ); |
|
16 | + public function mark_failed_fetch_action($action_id) { |
|
17 | + _deprecated_function(__METHOD__, '3.0.0', 'ActionScheduler_Store::mark_failure()'); |
|
18 | + self::$store->mark_failure($action_id); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * @since 2.2.6 |
25 | 25 | */ |
26 | 26 | protected static function hook() { |
27 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
27 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | * @since 2.2.6 |
34 | 34 | */ |
35 | 35 | protected static function unhook() { |
36 | - _deprecated_function( __METHOD__, '3.0.0' ); |
|
36 | + _deprecated_function(__METHOD__, '3.0.0'); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @return DateTimeZone |
44 | 44 | */ |
45 | 45 | protected function get_local_timezone() { |
46 | - _deprecated_function( __FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()' ); |
|
46 | + _deprecated_function(__FUNCTION__, '2.1.0', 'ActionScheduler_TimezoneHelper::set_local_timezone()'); |
|
47 | 47 | return ActionScheduler_TimezoneHelper::get_local_timezone(); |
48 | 48 | } |
49 | 49 | } |
@@ -4,7 +4,7 @@ |
||
4 | 4 | * Class ActionScheduler_NullLogEntry |
5 | 5 | */ |
6 | 6 | class ActionScheduler_NullLogEntry extends ActionScheduler_LogEntry { |
7 | - public function __construct( $action_id = '', $message = '' ) { |
|
7 | + public function __construct($action_id = '', $message = '') { |
|
8 | 8 | // nothing to see here |
9 | 9 | } |
10 | 10 | } |
@@ -4,8 +4,8 @@ |
||
4 | 4 | * Class ActionScheduler_NullLogEntry |
5 | 5 | */ |
6 | 6 | class ActionScheduler_NullLogEntry extends ActionScheduler_LogEntry { |
7 | - public function __construct( $action_id = '', $message = '' ) { |
|
8 | - // nothing to see here |
|
9 | - } |
|
7 | + public function __construct( $action_id = '', $message = '' ) { |
|
8 | + // nothing to see here |
|
9 | + } |
|
10 | 10 | } |
11 | 11 |
@@ -10,7 +10,7 @@ |
||
10 | 10 | * |
11 | 11 | * @param null $date The date & time to run the action. |
12 | 12 | */ |
13 | - public function __construct( DateTime $date = null ) { |
|
13 | + public function __construct(DateTime $date = null) { |
|
14 | 14 | $this->scheduled_date = null; |
15 | 15 | } |
16 | 16 |
@@ -5,25 +5,25 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_NullSchedule extends ActionScheduler_SimpleSchedule { |
7 | 7 | |
8 | - /** |
|
9 | - * Make the $date param optional and default to null. |
|
10 | - * |
|
11 | - * @param null $date The date & time to run the action. |
|
12 | - */ |
|
13 | - public function __construct( DateTime $date = null ) { |
|
14 | - $this->scheduled_date = null; |
|
15 | - } |
|
8 | + /** |
|
9 | + * Make the $date param optional and default to null. |
|
10 | + * |
|
11 | + * @param null $date The date & time to run the action. |
|
12 | + */ |
|
13 | + public function __construct( DateTime $date = null ) { |
|
14 | + $this->scheduled_date = null; |
|
15 | + } |
|
16 | 16 | |
17 | - /** |
|
18 | - * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
19 | - * |
|
20 | - * @return array |
|
21 | - */ |
|
22 | - public function __sleep() { |
|
23 | - return array(); |
|
24 | - } |
|
17 | + /** |
|
18 | + * This schedule has no scheduled DateTime, so we need to override the parent __sleep() |
|
19 | + * |
|
20 | + * @return array |
|
21 | + */ |
|
22 | + public function __sleep() { |
|
23 | + return array(); |
|
24 | + } |
|
25 | 25 | |
26 | - public function __wakeup() { |
|
27 | - $this->scheduled_date = null; |
|
28 | - } |
|
26 | + public function __wakeup() { |
|
27 | + $this->scheduled_date = null; |
|
28 | + } |
|
29 | 29 | } |
@@ -9,41 +9,41 @@ |
||
9 | 9 | */ |
10 | 10 | class ActionScheduler_OptionLock extends ActionScheduler_Lock { |
11 | 11 | |
12 | - /** |
|
13 | - * Set a lock using options for a given amount of time (60 seconds by default). |
|
14 | - * |
|
15 | - * Using an autoloaded option avoids running database queries or other resource intensive tasks |
|
16 | - * on frequently triggered hooks, like 'init' or 'shutdown'. |
|
17 | - * |
|
18 | - * For example, ActionScheduler_QueueRunner->maybe_dispatch_async_request() uses a lock to avoid |
|
19 | - * calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', |
|
20 | - * hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() |
|
21 | - * to find the current number of claims in the database. |
|
22 | - * |
|
23 | - * @param string $lock_type A string to identify different lock types. |
|
24 | - * @bool True if lock value has changed, false if not or if set failed. |
|
25 | - */ |
|
26 | - public function set( $lock_type ) { |
|
27 | - return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
28 | - } |
|
12 | + /** |
|
13 | + * Set a lock using options for a given amount of time (60 seconds by default). |
|
14 | + * |
|
15 | + * Using an autoloaded option avoids running database queries or other resource intensive tasks |
|
16 | + * on frequently triggered hooks, like 'init' or 'shutdown'. |
|
17 | + * |
|
18 | + * For example, ActionScheduler_QueueRunner->maybe_dispatch_async_request() uses a lock to avoid |
|
19 | + * calling ActionScheduler_QueueRunner->has_maximum_concurrent_batches() every time the 'shutdown', |
|
20 | + * hook is triggered, because that method calls ActionScheduler_QueueRunner->store->get_claim_count() |
|
21 | + * to find the current number of claims in the database. |
|
22 | + * |
|
23 | + * @param string $lock_type A string to identify different lock types. |
|
24 | + * @bool True if lock value has changed, false if not or if set failed. |
|
25 | + */ |
|
26 | + public function set( $lock_type ) { |
|
27 | + return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * If a lock is set, return the timestamp it was set to expiry. |
|
32 | - * |
|
33 | - * @param string $lock_type A string to identify different lock types. |
|
34 | - * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
|
35 | - */ |
|
36 | - public function get_expiration( $lock_type ) { |
|
37 | - return get_option( $this->get_key( $lock_type ) ); |
|
38 | - } |
|
30 | + /** |
|
31 | + * If a lock is set, return the timestamp it was set to expiry. |
|
32 | + * |
|
33 | + * @param string $lock_type A string to identify different lock types. |
|
34 | + * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
|
35 | + */ |
|
36 | + public function get_expiration( $lock_type ) { |
|
37 | + return get_option( $this->get_key( $lock_type ) ); |
|
38 | + } |
|
39 | 39 | |
40 | - /** |
|
41 | - * Get the key to use for storing the lock in the transient |
|
42 | - * |
|
43 | - * @param string $lock_type A string to identify different lock types. |
|
44 | - * @return string |
|
45 | - */ |
|
46 | - protected function get_key( $lock_type ) { |
|
47 | - return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
48 | - } |
|
40 | + /** |
|
41 | + * Get the key to use for storing the lock in the transient |
|
42 | + * |
|
43 | + * @param string $lock_type A string to identify different lock types. |
|
44 | + * @return string |
|
45 | + */ |
|
46 | + protected function get_key( $lock_type ) { |
|
47 | + return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
48 | + } |
|
49 | 49 | } |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * @param string $lock_type A string to identify different lock types. |
24 | 24 | * @bool True if lock value has changed, false if not or if set failed. |
25 | 25 | */ |
26 | - public function set( $lock_type ) { |
|
27 | - return update_option( $this->get_key( $lock_type ), time() + $this->get_duration( $lock_type ) ); |
|
26 | + public function set($lock_type) { |
|
27 | + return update_option($this->get_key($lock_type), time() + $this->get_duration($lock_type)); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | /** |
@@ -33,8 +33,8 @@ discard block |
||
33 | 33 | * @param string $lock_type A string to identify different lock types. |
34 | 34 | * @return bool|int False if no lock is set, otherwise the timestamp for when the lock is set to expire. |
35 | 35 | */ |
36 | - public function get_expiration( $lock_type ) { |
|
37 | - return get_option( $this->get_key( $lock_type ) ); |
|
36 | + public function get_expiration($lock_type) { |
|
37 | + return get_option($this->get_key($lock_type)); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | * @param string $lock_type A string to identify different lock types. |
44 | 44 | * @return string |
45 | 45 | */ |
46 | - protected function get_key( $lock_type ) { |
|
47 | - return sprintf( 'action_scheduler_lock_%s', $lock_type ); |
|
46 | + protected function get_key($lock_type) { |
|
47 | + return sprintf('action_scheduler_lock_%s', $lock_type); |
|
48 | 48 | } |
49 | 49 | } |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | /** |
23 | 23 | * @param DateTime $date The date & time to run the action. |
24 | 24 | */ |
25 | - public function __construct( DateTime $date ) { |
|
25 | + public function __construct(DateTime $date) { |
|
26 | 26 | $this->scheduled_date = $date; |
27 | 27 | } |
28 | 28 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | * @param DateTime $after |
40 | 40 | * @return DateTime |
41 | 41 | */ |
42 | - abstract protected function calculate_next( DateTime $after ); |
|
42 | + abstract protected function calculate_next(DateTime $after); |
|
43 | 43 | |
44 | 44 | /** |
45 | 45 | * Get the next date & time when this schedule should run after a given date & time. |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | * @param DateTime $after |
48 | 48 | * @return DateTime|null |
49 | 49 | */ |
50 | - public function get_next( DateTime $after ) { |
|
50 | + public function get_next(DateTime $after) { |
|
51 | 51 | $after = clone $after; |
52 | - if ( $after > $this->scheduled_date ) { |
|
53 | - $after = $this->calculate_next( $after ); |
|
52 | + if ($after > $this->scheduled_date) { |
|
53 | + $after = $this->calculate_next($after); |
|
54 | 54 | return $after; |
55 | 55 | } |
56 | 56 | return clone $this->scheduled_date; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | } |
78 | 78 | |
79 | 79 | public function __wakeup() { |
80 | - $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
81 | - unset( $this->scheduled_timestamp ); |
|
80 | + $this->scheduled_date = as_get_datetime_object($this->scheduled_timestamp); |
|
81 | + unset($this->scheduled_timestamp); |
|
82 | 82 | } |
83 | 83 | } |
@@ -5,80 +5,80 @@ |
||
5 | 5 | */ |
6 | 6 | abstract class ActionScheduler_Abstract_Schedule extends ActionScheduler_Schedule_Deprecated { |
7 | 7 | |
8 | - /** |
|
9 | - * The date & time the schedule is set to run. |
|
10 | - * |
|
11 | - * @var DateTime |
|
12 | - */ |
|
13 | - private $scheduled_date = null; |
|
8 | + /** |
|
9 | + * The date & time the schedule is set to run. |
|
10 | + * |
|
11 | + * @var DateTime |
|
12 | + */ |
|
13 | + private $scheduled_date = null; |
|
14 | 14 | |
15 | - /** |
|
16 | - * Timestamp equivalent of @see $this->scheduled_date |
|
17 | - * |
|
18 | - * @var int |
|
19 | - */ |
|
20 | - protected $scheduled_timestamp = null; |
|
15 | + /** |
|
16 | + * Timestamp equivalent of @see $this->scheduled_date |
|
17 | + * |
|
18 | + * @var int |
|
19 | + */ |
|
20 | + protected $scheduled_timestamp = null; |
|
21 | 21 | |
22 | - /** |
|
23 | - * @param DateTime $date The date & time to run the action. |
|
24 | - */ |
|
25 | - public function __construct( DateTime $date ) { |
|
26 | - $this->scheduled_date = $date; |
|
27 | - } |
|
22 | + /** |
|
23 | + * @param DateTime $date The date & time to run the action. |
|
24 | + */ |
|
25 | + public function __construct( DateTime $date ) { |
|
26 | + $this->scheduled_date = $date; |
|
27 | + } |
|
28 | 28 | |
29 | - /** |
|
30 | - * Check if a schedule should recur. |
|
31 | - * |
|
32 | - * @return bool |
|
33 | - */ |
|
34 | - abstract public function is_recurring(); |
|
29 | + /** |
|
30 | + * Check if a schedule should recur. |
|
31 | + * |
|
32 | + * @return bool |
|
33 | + */ |
|
34 | + abstract public function is_recurring(); |
|
35 | 35 | |
36 | - /** |
|
37 | - * Calculate when the next instance of this schedule would run based on a given date & time. |
|
38 | - * |
|
39 | - * @param DateTime $after |
|
40 | - * @return DateTime |
|
41 | - */ |
|
42 | - abstract protected function calculate_next( DateTime $after ); |
|
36 | + /** |
|
37 | + * Calculate when the next instance of this schedule would run based on a given date & time. |
|
38 | + * |
|
39 | + * @param DateTime $after |
|
40 | + * @return DateTime |
|
41 | + */ |
|
42 | + abstract protected function calculate_next( DateTime $after ); |
|
43 | 43 | |
44 | - /** |
|
45 | - * Get the next date & time when this schedule should run after a given date & time. |
|
46 | - * |
|
47 | - * @param DateTime $after |
|
48 | - * @return DateTime|null |
|
49 | - */ |
|
50 | - public function get_next( DateTime $after ) { |
|
51 | - $after = clone $after; |
|
52 | - if ( $after > $this->scheduled_date ) { |
|
53 | - $after = $this->calculate_next( $after ); |
|
54 | - return $after; |
|
55 | - } |
|
56 | - return clone $this->scheduled_date; |
|
57 | - } |
|
44 | + /** |
|
45 | + * Get the next date & time when this schedule should run after a given date & time. |
|
46 | + * |
|
47 | + * @param DateTime $after |
|
48 | + * @return DateTime|null |
|
49 | + */ |
|
50 | + public function get_next( DateTime $after ) { |
|
51 | + $after = clone $after; |
|
52 | + if ( $after > $this->scheduled_date ) { |
|
53 | + $after = $this->calculate_next( $after ); |
|
54 | + return $after; |
|
55 | + } |
|
56 | + return clone $this->scheduled_date; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Get the date & time the schedule is set to run. |
|
61 | - * |
|
62 | - * @return DateTime|null |
|
63 | - */ |
|
64 | - public function get_date() { |
|
65 | - return $this->scheduled_date; |
|
66 | - } |
|
59 | + /** |
|
60 | + * Get the date & time the schedule is set to run. |
|
61 | + * |
|
62 | + * @return DateTime|null |
|
63 | + */ |
|
64 | + public function get_date() { |
|
65 | + return $this->scheduled_date; |
|
66 | + } |
|
67 | 67 | |
68 | - /** |
|
69 | - * For PHP 5.2 compat, since DateTime objects can't be serialized |
|
70 | - * |
|
71 | - * @return array |
|
72 | - */ |
|
73 | - public function __sleep() { |
|
74 | - $this->scheduled_timestamp = $this->scheduled_date->getTimestamp(); |
|
75 | - return array( |
|
76 | - 'scheduled_timestamp', |
|
77 | - ); |
|
78 | - } |
|
68 | + /** |
|
69 | + * For PHP 5.2 compat, since DateTime objects can't be serialized |
|
70 | + * |
|
71 | + * @return array |
|
72 | + */ |
|
73 | + public function __sleep() { |
|
74 | + $this->scheduled_timestamp = $this->scheduled_date->getTimestamp(); |
|
75 | + return array( |
|
76 | + 'scheduled_timestamp', |
|
77 | + ); |
|
78 | + } |
|
79 | 79 | |
80 | - public function __wakeup() { |
|
81 | - $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
82 | - unset( $this->scheduled_timestamp ); |
|
83 | - } |
|
80 | + public function __wakeup() { |
|
81 | + $this->scheduled_date = as_get_datetime_object( $this->scheduled_timestamp ); |
|
82 | + unset( $this->scheduled_timestamp ); |
|
83 | + } |
|
84 | 84 | } |
@@ -15,35 +15,35 @@ |
||
15 | 15 | * @codeCoverageIgnore |
16 | 16 | */ |
17 | 17 | class LogMigrator { |
18 | - /** @var ActionScheduler_Logger */ |
|
19 | - private $source; |
|
18 | + /** @var ActionScheduler_Logger */ |
|
19 | + private $source; |
|
20 | 20 | |
21 | - /** @var ActionScheduler_Logger */ |
|
22 | - private $destination; |
|
21 | + /** @var ActionScheduler_Logger */ |
|
22 | + private $destination; |
|
23 | 23 | |
24 | - /** |
|
25 | - * ActionMigrator constructor. |
|
26 | - * |
|
27 | - * @param ActionScheduler_Logger $source_logger Source logger object. |
|
28 | - * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
|
29 | - */ |
|
30 | - public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
31 | - $this->source = $source_logger; |
|
32 | - $this->destination = $destination_Logger; |
|
33 | - } |
|
24 | + /** |
|
25 | + * ActionMigrator constructor. |
|
26 | + * |
|
27 | + * @param ActionScheduler_Logger $source_logger Source logger object. |
|
28 | + * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
|
29 | + */ |
|
30 | + public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
31 | + $this->source = $source_logger; |
|
32 | + $this->destination = $destination_Logger; |
|
33 | + } |
|
34 | 34 | |
35 | - /** |
|
36 | - * Migrate an action log. |
|
37 | - * |
|
38 | - * @param int $source_action_id Source logger object. |
|
39 | - * @param int $destination_action_id Destination logger object. |
|
40 | - */ |
|
41 | - public function migrate( $source_action_id, $destination_action_id ) { |
|
42 | - $logs = $this->source->get_logs( $source_action_id ); |
|
43 | - foreach ( $logs as $log ) { |
|
44 | - if ( $log->get_action_id() == $source_action_id ) { |
|
45 | - $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
46 | - } |
|
47 | - } |
|
48 | - } |
|
35 | + /** |
|
36 | + * Migrate an action log. |
|
37 | + * |
|
38 | + * @param int $source_action_id Source logger object. |
|
39 | + * @param int $destination_action_id Destination logger object. |
|
40 | + */ |
|
41 | + public function migrate( $source_action_id, $destination_action_id ) { |
|
42 | + $logs = $this->source->get_logs( $source_action_id ); |
|
43 | + foreach ( $logs as $log ) { |
|
44 | + if ( $log->get_action_id() == $source_action_id ) { |
|
45 | + $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
46 | + } |
|
47 | + } |
|
48 | + } |
|
49 | 49 | } |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param ActionScheduler_Logger $source_logger Source logger object. |
28 | 28 | * @param ActionScheduler_Logger $destination_Logger Destination logger object. |
29 | 29 | */ |
30 | - public function __construct( ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger ) { |
|
30 | + public function __construct(ActionScheduler_Logger $source_logger, ActionScheduler_Logger $destination_Logger) { |
|
31 | 31 | $this->source = $source_logger; |
32 | 32 | $this->destination = $destination_Logger; |
33 | 33 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | * @param int $source_action_id Source logger object. |
39 | 39 | * @param int $destination_action_id Destination logger object. |
40 | 40 | */ |
41 | - public function migrate( $source_action_id, $destination_action_id ) { |
|
42 | - $logs = $this->source->get_logs( $source_action_id ); |
|
43 | - foreach ( $logs as $log ) { |
|
44 | - if ( $log->get_action_id() == $source_action_id ) { |
|
45 | - $this->destination->log( $destination_action_id, $log->get_message(), $log->get_date() ); |
|
41 | + public function migrate($source_action_id, $destination_action_id) { |
|
42 | + $logs = $this->source->get_logs($source_action_id); |
|
43 | + foreach ($logs as $log) { |
|
44 | + if ($log->get_action_id() == $source_action_id) { |
|
45 | + $this->destination->log($destination_action_id, $log->get_message(), $log->get_date()); |
|
46 | 46 | } |
47 | 47 | } |
48 | 48 | } |