Passed
Push — master ( 60cf75...7ee9b2 )
by Brian
128:01 queued 122:23
created
vendor/ayecode/ayecode-connect-helper/ayecode-connect-helper.php 1 patch
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -1,271 +1,271 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if ( ! defined( 'ABSPATH' ) ) {
4
-	exit;
4
+    exit;
5 5
 }
6 6
 
7 7
 if ( ! class_exists( "AyeCode_Connect_Helper" ) ) {
8
-	/**
9
-	 * Allow the quick setup and connection of our AyeCode Connect plugin.
10
-	 *
11
-	 * Class AyeCode_Connect_Helper
12
-	 */
13
-	class AyeCode_Connect_Helper {
14
-
15
-		// Hold the version number
16
-		var $version = "1.0.3";
17
-
18
-		// Hold the default strings.
19
-		var $strings = array();
20
-
21
-		// Hold the default pages.
22
-		var $pages = array();
23
-
24
-		/**
25
-		 * The constructor.
26
-		 *
27
-		 * AyeCode_Connect_Helper constructor.
28
-		 *
29
-		 * @param array $strings
30
-		 * @param array $pages
31
-		 */
32
-		public function __construct( $strings = array(), $pages = array() ) {
33
-
34
-			// Only fire if not localhost and the current user has the right permissions.
35
-			if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
36
-
37
-
38
-				// set default strings
39
-				$default_strings = array(
40
-					'connect_title'     => __( "Thanks for choosing an AyeCode Product!" ),
41
-					'connect_external'  => __( "Please confirm you wish to connect your site?" ),
42
-					'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
43
-					'connect_button'    => __( "Connect Site" ),
44
-					'connecting_button' => __( "Connecting..." ),
45
-					'error_localhost'   => __( "This service will only work with a live domain, not a localhost." ),
46
-					'error'             => __( "Something went wrong, please refresh and try again." ),
47
-				);
48
-				$this->strings   = array_merge( $default_strings, $strings );
49
-
50
-
51
-				// set default pages
52
-				$default_pages = array();
53
-				$this->pages   = array_merge( $default_pages, $pages );
54
-
55
-				// maybe show connect site notice
56
-				add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
57
-
58
-				// add ajax action if not already added
59
-				if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
60
-					add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
61
-				}
62
-			}
63
-
64
-			// add ajax action if not already added
65
-			if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
66
-				add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
67
-			}
68
-
69
-		}
70
-
71
-		/**
72
-		 * Give a way to check we can connect via a external redirect.
73
-		 */
74
-		public function ayecode_connect_helper_installed(){
75
-			$active = array(
76
-				'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
77
-				'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
78
-				'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
79
-			);
80
-			wp_send_json_success( $active );
81
-			wp_die();
82
-		}
83
-
84
-		/**
85
-		 * Get slug from path
86
-		 *
87
-		 * @param  string $key
88
-		 *
89
-		 * @return string
90
-		 */
91
-		private function format_plugin_slug( $key ) {
92
-			$slug = explode( '/', $key );
93
-			$slug = explode( '.', end( $slug ) );
94
-
95
-			return $slug[0];
96
-		}
97
-
98
-		/**
99
-		 * Install and activate the AyeCode Connect Plugin
100
-		 */
101
-		public function ayecode_connect_install() {
102
-
103
-			// bail if localhost
104
-			if ( $this->is_localhost() ) {
105
-				wp_send_json_error( $this->strings['error_localhost'] );
106
-			}
107
-
108
-			// Explicitly clear the event.
109
-			wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
110
-
111
-			$success     = true;
112
-			$plugin_slug = "ayecode-connect";
113
-			if ( ! empty( $plugin_slug ) ) {
114
-				require_once( ABSPATH . 'wp-admin/includes/file.php' );
115
-				require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
116
-				require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
117
-				require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
118
-
119
-				WP_Filesystem();
120
-
121
-				$skin              = new Automatic_Upgrader_Skin;
122
-				$upgrader          = new WP_Upgrader( $skin );
123
-				$installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
124
-				$plugin_slug       = $plugin_slug;
125
-				$plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
126
-				$installed         = false;
127
-				$activate          = false;
128
-
129
-				// See if the plugin is installed already
130
-				if ( in_array( $plugin_slug, $installed_plugins ) ) {
131
-					$installed = true;
132
-					$activate  = ! is_plugin_active( $plugin );
133
-				}
134
-
135
-				// Install this thing!
136
-				if ( ! $installed ) {
137
-
138
-					// Suppress feedback
139
-					ob_start();
140
-
141
-					try {
142
-						$plugin_information = plugins_api( 'plugin_information', array(
143
-							'slug'   => $plugin_slug,
144
-							'fields' => array(
145
-								'short_description' => false,
146
-								'sections'          => false,
147
-								'requires'          => false,
148
-								'rating'            => false,
149
-								'ratings'           => false,
150
-								'downloaded'        => false,
151
-								'last_updated'      => false,
152
-								'added'             => false,
153
-								'tags'              => false,
154
-								'homepage'          => false,
155
-								'donate_link'       => false,
156
-								'author_profile'    => false,
157
-								'author'            => false,
158
-							),
159
-						) );
160
-
161
-						if ( is_wp_error( $plugin_information ) ) {
162
-							throw new Exception( $plugin_information->get_error_message() );
163
-						}
164
-
165
-						$package  = $plugin_information->download_link;
166
-						$download = $upgrader->download_package( $package );
167
-
168
-						if ( is_wp_error( $download ) ) {
169
-							throw new Exception( $download->get_error_message() );
170
-						}
171
-
172
-						$working_dir = $upgrader->unpack_package( $download, true );
173
-
174
-						if ( is_wp_error( $working_dir ) ) {
175
-							throw new Exception( $working_dir->get_error_message() );
176
-						}
177
-
178
-						$result = $upgrader->install_package( array(
179
-							'source'                      => $working_dir,
180
-							'destination'                 => WP_PLUGIN_DIR,
181
-							'clear_destination'           => false,
182
-							'abort_if_destination_exists' => false,
183
-							'clear_working'               => true,
184
-							'hook_extra'                  => array(
185
-								'type'   => 'plugin',
186
-								'action' => 'install',
187
-							),
188
-						) );
189
-
190
-						if ( is_wp_error( $result ) ) {
191
-							throw new Exception( $result->get_error_message() );
192
-						}
193
-
194
-						$activate = true;
195
-
196
-					} catch ( Exception $e ) {
197
-						$success = false;
198
-					}
199
-
200
-					// Discard feedback
201
-					ob_end_clean();
202
-				}
203
-
204
-				wp_clean_plugins_cache();
205
-
206
-				// Activate this thing
207
-				if ( $activate ) {
208
-					try {
209
-						$result = activate_plugin( $plugin );
210
-
211
-						if ( is_wp_error( $result ) ) {
212
-							$success = false;
213
-						} else {
214
-							$success = true;
215
-						}
216
-					} catch ( Exception $e ) {
217
-						$success = false;
218
-					}
219
-				}
220
-			}
221
-
222
-			if ( $success && function_exists( 'ayecode_connect_args' ) ) {
223
-				ayecode_connect();// init
224
-				$args        = ayecode_connect_args();
225
-				$client      = new AyeCode_Connect( $args );
226
-				$redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
227
-				$redirect    = $client->build_connect_url( $redirect_to );
228
-				wp_send_json_success( array( 'connect_url' => $redirect ) );
229
-			} else {
230
-				wp_send_json_error( $this->strings['error_localhost'] );
231
-			}
232
-			wp_die();
233
-		}
234
-
235
-		/**
236
-		 * Check if maybe localhost.
237
-		 *
238
-		 * @return bool
239
-		 */
240
-		public function is_localhost() {
241
-			$localhost = false;
242
-
243
-			$host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
244
-			$localhost_domains = array(
245
-				'localhost',
246
-				'localhost.localdomain',
247
-				'127.0.0.1',
248
-				'::1'
249
-			);
250
-
251
-			if ( in_array( $host, $localhost_domains ) ) {
252
-				$localhost = true;
253
-			}
254
-
255
-			return $localhost;
256
-		}
257
-
258
-		/**
259
-		 * Show notice to connect site.
260
-		 */
261
-		public function ayecode_connect_install_notice() {
262
-			if ( $this->maybe_show() ) {
263
-				$connect_title_string     = $this->strings['connect_title'];
264
-				$connect_external_string  = $this->strings['connect_external'];
265
-				$connect_string           = $this->strings['connect'];
266
-				$connect_button_string    = $this->strings['connect_button'];
267
-				$connecting_button_string = $this->strings['connecting_button'];
268
-				?>
8
+    /**
9
+     * Allow the quick setup and connection of our AyeCode Connect plugin.
10
+     *
11
+     * Class AyeCode_Connect_Helper
12
+     */
13
+    class AyeCode_Connect_Helper {
14
+
15
+        // Hold the version number
16
+        var $version = "1.0.3";
17
+
18
+        // Hold the default strings.
19
+        var $strings = array();
20
+
21
+        // Hold the default pages.
22
+        var $pages = array();
23
+
24
+        /**
25
+         * The constructor.
26
+         *
27
+         * AyeCode_Connect_Helper constructor.
28
+         *
29
+         * @param array $strings
30
+         * @param array $pages
31
+         */
32
+        public function __construct( $strings = array(), $pages = array() ) {
33
+
34
+            // Only fire if not localhost and the current user has the right permissions.
35
+            if ( ! $this->is_localhost() && current_user_can( 'manage_options' ) ) {
36
+
37
+
38
+                // set default strings
39
+                $default_strings = array(
40
+                    'connect_title'     => __( "Thanks for choosing an AyeCode Product!" ),
41
+                    'connect_external'  => __( "Please confirm you wish to connect your site?" ),
42
+                    'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s" ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", "</a>" ),
43
+                    'connect_button'    => __( "Connect Site" ),
44
+                    'connecting_button' => __( "Connecting..." ),
45
+                    'error_localhost'   => __( "This service will only work with a live domain, not a localhost." ),
46
+                    'error'             => __( "Something went wrong, please refresh and try again." ),
47
+                );
48
+                $this->strings   = array_merge( $default_strings, $strings );
49
+
50
+
51
+                // set default pages
52
+                $default_pages = array();
53
+                $this->pages   = array_merge( $default_pages, $pages );
54
+
55
+                // maybe show connect site notice
56
+                add_action( 'admin_notices', array( $this, 'ayecode_connect_install_notice' ) );
57
+
58
+                // add ajax action if not already added
59
+                if ( ! has_action( 'wp_ajax_ayecode_connect_helper' ) ) {
60
+                    add_action( 'wp_ajax_ayecode_connect_helper', array( $this, 'ayecode_connect_install' ) );
61
+                }
62
+            }
63
+
64
+            // add ajax action if not already added
65
+            if ( ! has_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed' ) ) {
66
+                add_action( 'wp_ajax_nopriv_ayecode_connect_helper_installed', array( $this, 'ayecode_connect_helper_installed' ) );
67
+            }
68
+
69
+        }
70
+
71
+        /**
72
+         * Give a way to check we can connect via a external redirect.
73
+         */
74
+        public function ayecode_connect_helper_installed(){
75
+            $active = array(
76
+                'gd'    =>  defined('GEODIRECTORY_VERSION') && version_compare(GEODIRECTORY_VERSION,'2.0.0.79','>') ? 1 : 0,
77
+                'uwp'    =>  defined('USERSWP_VERSION') && version_compare(USERSWP_VERSION,'1.2.1.5','>') ? 1 : 0,
78
+                'wpi'    =>  defined('WPINV_VERSION') && version_compare(WPINV_VERSION,'1.0.14','>') ? 1 : 0,
79
+            );
80
+            wp_send_json_success( $active );
81
+            wp_die();
82
+        }
83
+
84
+        /**
85
+         * Get slug from path
86
+         *
87
+         * @param  string $key
88
+         *
89
+         * @return string
90
+         */
91
+        private function format_plugin_slug( $key ) {
92
+            $slug = explode( '/', $key );
93
+            $slug = explode( '.', end( $slug ) );
94
+
95
+            return $slug[0];
96
+        }
97
+
98
+        /**
99
+         * Install and activate the AyeCode Connect Plugin
100
+         */
101
+        public function ayecode_connect_install() {
102
+
103
+            // bail if localhost
104
+            if ( $this->is_localhost() ) {
105
+                wp_send_json_error( $this->strings['error_localhost'] );
106
+            }
107
+
108
+            // Explicitly clear the event.
109
+            wp_clear_scheduled_hook( 'geodir_plugin_background_installer', func_get_args() );
110
+
111
+            $success     = true;
112
+            $plugin_slug = "ayecode-connect";
113
+            if ( ! empty( $plugin_slug ) ) {
114
+                require_once( ABSPATH . 'wp-admin/includes/file.php' );
115
+                require_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
116
+                require_once( ABSPATH . 'wp-admin/includes/class-wp-upgrader.php' );
117
+                require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
118
+
119
+                WP_Filesystem();
120
+
121
+                $skin              = new Automatic_Upgrader_Skin;
122
+                $upgrader          = new WP_Upgrader( $skin );
123
+                $installed_plugins = array_map( array( $this, 'format_plugin_slug' ), array_keys( get_plugins() ) );
124
+                $plugin_slug       = $plugin_slug;
125
+                $plugin            = $plugin_slug . '/' . $plugin_slug . '.php';
126
+                $installed         = false;
127
+                $activate          = false;
128
+
129
+                // See if the plugin is installed already
130
+                if ( in_array( $plugin_slug, $installed_plugins ) ) {
131
+                    $installed = true;
132
+                    $activate  = ! is_plugin_active( $plugin );
133
+                }
134
+
135
+                // Install this thing!
136
+                if ( ! $installed ) {
137
+
138
+                    // Suppress feedback
139
+                    ob_start();
140
+
141
+                    try {
142
+                        $plugin_information = plugins_api( 'plugin_information', array(
143
+                            'slug'   => $plugin_slug,
144
+                            'fields' => array(
145
+                                'short_description' => false,
146
+                                'sections'          => false,
147
+                                'requires'          => false,
148
+                                'rating'            => false,
149
+                                'ratings'           => false,
150
+                                'downloaded'        => false,
151
+                                'last_updated'      => false,
152
+                                'added'             => false,
153
+                                'tags'              => false,
154
+                                'homepage'          => false,
155
+                                'donate_link'       => false,
156
+                                'author_profile'    => false,
157
+                                'author'            => false,
158
+                            ),
159
+                        ) );
160
+
161
+                        if ( is_wp_error( $plugin_information ) ) {
162
+                            throw new Exception( $plugin_information->get_error_message() );
163
+                        }
164
+
165
+                        $package  = $plugin_information->download_link;
166
+                        $download = $upgrader->download_package( $package );
167
+
168
+                        if ( is_wp_error( $download ) ) {
169
+                            throw new Exception( $download->get_error_message() );
170
+                        }
171
+
172
+                        $working_dir = $upgrader->unpack_package( $download, true );
173
+
174
+                        if ( is_wp_error( $working_dir ) ) {
175
+                            throw new Exception( $working_dir->get_error_message() );
176
+                        }
177
+
178
+                        $result = $upgrader->install_package( array(
179
+                            'source'                      => $working_dir,
180
+                            'destination'                 => WP_PLUGIN_DIR,
181
+                            'clear_destination'           => false,
182
+                            'abort_if_destination_exists' => false,
183
+                            'clear_working'               => true,
184
+                            'hook_extra'                  => array(
185
+                                'type'   => 'plugin',
186
+                                'action' => 'install',
187
+                            ),
188
+                        ) );
189
+
190
+                        if ( is_wp_error( $result ) ) {
191
+                            throw new Exception( $result->get_error_message() );
192
+                        }
193
+
194
+                        $activate = true;
195
+
196
+                    } catch ( Exception $e ) {
197
+                        $success = false;
198
+                    }
199
+
200
+                    // Discard feedback
201
+                    ob_end_clean();
202
+                }
203
+
204
+                wp_clean_plugins_cache();
205
+
206
+                // Activate this thing
207
+                if ( $activate ) {
208
+                    try {
209
+                        $result = activate_plugin( $plugin );
210
+
211
+                        if ( is_wp_error( $result ) ) {
212
+                            $success = false;
213
+                        } else {
214
+                            $success = true;
215
+                        }
216
+                    } catch ( Exception $e ) {
217
+                        $success = false;
218
+                    }
219
+                }
220
+            }
221
+
222
+            if ( $success && function_exists( 'ayecode_connect_args' ) ) {
223
+                ayecode_connect();// init
224
+                $args        = ayecode_connect_args();
225
+                $client      = new AyeCode_Connect( $args );
226
+                $redirect_to = ! empty( $_POST['redirect_to'] ) ? esc_url_raw( $_POST['redirect_to'] ) : '';
227
+                $redirect    = $client->build_connect_url( $redirect_to );
228
+                wp_send_json_success( array( 'connect_url' => $redirect ) );
229
+            } else {
230
+                wp_send_json_error( $this->strings['error_localhost'] );
231
+            }
232
+            wp_die();
233
+        }
234
+
235
+        /**
236
+         * Check if maybe localhost.
237
+         *
238
+         * @return bool
239
+         */
240
+        public function is_localhost() {
241
+            $localhost = false;
242
+
243
+            $host              = isset( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '';
244
+            $localhost_domains = array(
245
+                'localhost',
246
+                'localhost.localdomain',
247
+                '127.0.0.1',
248
+                '::1'
249
+            );
250
+
251
+            if ( in_array( $host, $localhost_domains ) ) {
252
+                $localhost = true;
253
+            }
254
+
255
+            return $localhost;
256
+        }
257
+
258
+        /**
259
+         * Show notice to connect site.
260
+         */
261
+        public function ayecode_connect_install_notice() {
262
+            if ( $this->maybe_show() ) {
263
+                $connect_title_string     = $this->strings['connect_title'];
264
+                $connect_external_string  = $this->strings['connect_external'];
265
+                $connect_string           = $this->strings['connect'];
266
+                $connect_button_string    = $this->strings['connect_button'];
267
+                $connecting_button_string = $this->strings['connecting_button'];
268
+                ?>
269 269
 				<div class="notice notice-info acch-notice">
270 270
 					<span class="acch-float-left">
271 271
 						<svg width="61px" height="61px" viewBox="0 0 61 61" version="1.1"
@@ -304,8 +304,8 @@  discard block
 block discarded – undo
304 304
 						<h3 class="acch-title"><?php echo esc_attr( $connect_title_string ); ?></h3>
305 305
 					<p>
306 306
 						<?php
307
-						echo $connect_string;
308
-						?>
307
+                        echo $connect_string;
308
+                        ?>
309 309
 					</p>
310 310
 					</span>
311 311
 
@@ -318,9 +318,9 @@  discard block
 block discarded – undo
318 318
 				</div>
319 319
 
320 320
 				<?php
321
-				// only include the popup HTML if needed.
322
-				if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
323
-					?>
321
+                // only include the popup HTML if needed.
322
+                if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
323
+                    ?>
324 324
 					<div id="ayecode-connect-helper-external-confirm" style="display:none;">
325 325
 						<div class="noticex notice-info acch-notice" style="border: none;">
326 326
 					<span class="acch-float-left">
@@ -369,23 +369,23 @@  discard block
 block discarded – undo
369 369
 						</div>
370 370
 					</div>
371 371
 					<?php
372
-				}
373
-
374
-				// add required scripts
375
-				$this->script();
376
-			}
377
-		}
378
-
379
-		/**
380
-		 * Get the JS Script.
381
-		 */
382
-		public function script() {
383
-
384
-			// add thickbox if external request is requested
385
-			if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
386
-				add_thickbox();
387
-			}
388
-			?>
372
+                }
373
+
374
+                // add required scripts
375
+                $this->script();
376
+            }
377
+        }
378
+
379
+        /**
380
+         * Get the JS Script.
381
+         */
382
+        public function script() {
383
+
384
+            // add thickbox if external request is requested
385
+            if ( ! empty( $_REQUEST['external-connect-request'] ) ) {
386
+                add_thickbox();
387
+            }
388
+            ?>
389 389
 			<style>
390 390
 				.acch-title {
391 391
 					margin: 0;
@@ -454,43 +454,43 @@  discard block
 block discarded – undo
454 454
 
455 455
 
456 456
 				<?php
457
-				// add thickbox if external request is requested
458
-				if(! empty( $_REQUEST['external-connect-request'] )) {
459
-				?>
457
+                // add thickbox if external request is requested
458
+                if(! empty( $_REQUEST['external-connect-request'] )) {
459
+                ?>
460 460
 				jQuery(function () {
461 461
 					setTimeout(function () {
462 462
 						tb_show("AyeCode Connect", "?TB_inline?width=300&height=80&inlineId=ayecode-connect-helper-external-confirm");
463 463
 					}, 200);
464 464
 				});
465 465
 				<?php
466
-				}
467
-				?>
466
+                }
467
+                ?>
468 468
 
469 469
 			</script>
470 470
 			<?php
471
-		}
472
-
473
-		/**
474
-		 * Decide what pages to show on.
475
-		 *
476
-		 * @return bool
477
-		 */
478
-		public function maybe_show() {
479
-			$show = false;
480
-
481
-			// check if on a page set to show
482
-			if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
483
-
484
-				// check if not active and connected
485
-				if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
486
-					$show = true;
487
-				}
471
+        }
472
+
473
+        /**
474
+         * Decide what pages to show on.
475
+         *
476
+         * @return bool
477
+         */
478
+        public function maybe_show() {
479
+            $show = false;
480
+
481
+            // check if on a page set to show
482
+            if ( isset( $_REQUEST['page'] ) && in_array( $_REQUEST['page'], $this->pages ) ) {
483
+
484
+                // check if not active and connected
485
+                if ( ! defined( 'AYECODE_CONNECT_VERSION' ) || ! get_option( 'ayecode_connect_blog_token' ) ) {
486
+                    $show = true;
487
+                }
488 488
 
489
-			}
489
+            }
490 490
 
491
-			return $show;
492
-		}
491
+            return $show;
492
+        }
493 493
 
494
-	}
494
+    }
495 495
 
496 496
 }
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/functions.php 1 patch
Indentation   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * @return string The action ID.
14 14
  */
15 15
 function as_enqueue_async_action( $hook, $args = array(), $group = '' ) {
16
-	return ActionScheduler::factory()->async( $hook, $args, $group );
16
+    return ActionScheduler::factory()->async( $hook, $args, $group );
17 17
 }
18 18
 
19 19
 /**
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
  * @return string The job ID
28 28
  */
29 29
 function as_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
30
-	return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group );
30
+    return ActionScheduler::factory()->single( $hook, $args, $timestamp, $group );
31 31
 }
32 32
 
33 33
 /**
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @return string The job ID
43 43
  */
44 44
 function as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
45
-	return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group );
45
+    return ActionScheduler::factory()->recurring( $hook, $args, $timestamp, $interval_in_seconds, $group );
46 46
 }
47 47
 
48 48
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  * @return string The job ID
70 70
  */
71 71
 function as_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
72
-	return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group );
72
+    return ActionScheduler::factory()->cron( $hook, $args, $timestamp, $schedule, $group );
73 73
 }
74 74
 
75 75
 /**
@@ -89,20 +89,20 @@  discard block
 block discarded – undo
89 89
  * @return string The scheduled action ID if a scheduled action was found, or empty string if no matching action found.
90 90
  */
91 91
 function as_unschedule_action( $hook, $args = array(), $group = '' ) {
92
-	$params = array();
93
-	if ( is_array($args) ) {
94
-		$params['args'] = $args;
95
-	}
96
-	if ( !empty($group) ) {
97
-		$params['group'] = $group;
98
-	}
99
-	$job_id = ActionScheduler::store()->find_action( $hook, $params );
100
-
101
-	if ( ! empty( $job_id ) ) {
102
-		ActionScheduler::store()->cancel_action( $job_id );
103
-	}
104
-
105
-	return $job_id;
92
+    $params = array();
93
+    if ( is_array($args) ) {
94
+        $params['args'] = $args;
95
+    }
96
+    if ( !empty($group) ) {
97
+        $params['group'] = $group;
98
+    }
99
+    $job_id = ActionScheduler::store()->find_action( $hook, $params );
100
+
101
+    if ( ! empty( $job_id ) ) {
102
+        ActionScheduler::store()->cancel_action( $job_id );
103
+    }
104
+
105
+    return $job_id;
106 106
 }
107 107
 
108 108
 /**
@@ -113,19 +113,19 @@  discard block
 block discarded – undo
113 113
  * @param string $group
114 114
  */
115 115
 function as_unschedule_all_actions( $hook, $args = array(), $group = '' ) {
116
-	if ( empty( $args ) ) {
117
-		if ( ! empty( $hook ) && empty( $group ) ) {
118
-			ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook );
119
-			return;
120
-		}
121
-		if ( ! empty( $group ) && empty( $hook ) ) {
122
-			ActionScheduler_Store::instance()->cancel_actions_by_group( $group );
123
-			return;
124
-		}
125
-	}
126
-	do {
127
-		$unscheduled_action = as_unschedule_action( $hook, $args, $group );
128
-	} while ( ! empty( $unscheduled_action ) );
116
+    if ( empty( $args ) ) {
117
+        if ( ! empty( $hook ) && empty( $group ) ) {
118
+            ActionScheduler_Store::instance()->cancel_actions_by_hook( $hook );
119
+            return;
120
+        }
121
+        if ( ! empty( $group ) && empty( $hook ) ) {
122
+            ActionScheduler_Store::instance()->cancel_actions_by_group( $group );
123
+            return;
124
+        }
125
+    }
126
+    do {
127
+        $unscheduled_action = as_unschedule_action( $hook, $args, $group );
128
+    } while ( ! empty( $unscheduled_action ) );
129 129
 }
130 130
 
131 131
 /**
@@ -144,33 +144,33 @@  discard block
 block discarded – undo
144 144
  * @return int|bool The timestamp for the next occurrence of a pending scheduled action, true for an async or in-progress action or false if there is no matching action.
145 145
  */
146 146
 function as_next_scheduled_action( $hook, $args = NULL, $group = '' ) {
147
-	$params = array();
148
-	if ( is_array($args) ) {
149
-		$params['args'] = $args;
150
-	}
151
-	if ( !empty($group) ) {
152
-		$params['group'] = $group;
153
-	}
154
-
155
-	$params['status'] = ActionScheduler_Store::STATUS_RUNNING;
156
-	$job_id = ActionScheduler::store()->find_action( $hook, $params );
157
-	if ( ! empty( $job_id ) ) {
158
-		return true;
159
-	}
160
-
161
-	$params['status'] = ActionScheduler_Store::STATUS_PENDING;
162
-	$job_id = ActionScheduler::store()->find_action( $hook, $params );
163
-	if ( empty($job_id) ) {
164
-		return false;
165
-	}
166
-	$job = ActionScheduler::store()->fetch_action( $job_id );
167
-	$scheduled_date = $job->get_schedule()->get_date();
168
-	if ( $scheduled_date ) {
169
-		return (int) $scheduled_date->format( 'U' );
170
-	} elseif ( NULL === $scheduled_date ) { // pending async action with NullSchedule
171
-		return true;
172
-	}
173
-	return false;
147
+    $params = array();
148
+    if ( is_array($args) ) {
149
+        $params['args'] = $args;
150
+    }
151
+    if ( !empty($group) ) {
152
+        $params['group'] = $group;
153
+    }
154
+
155
+    $params['status'] = ActionScheduler_Store::STATUS_RUNNING;
156
+    $job_id = ActionScheduler::store()->find_action( $hook, $params );
157
+    if ( ! empty( $job_id ) ) {
158
+        return true;
159
+    }
160
+
161
+    $params['status'] = ActionScheduler_Store::STATUS_PENDING;
162
+    $job_id = ActionScheduler::store()->find_action( $hook, $params );
163
+    if ( empty($job_id) ) {
164
+        return false;
165
+    }
166
+    $job = ActionScheduler::store()->fetch_action( $job_id );
167
+    $scheduled_date = $job->get_schedule()->get_date();
168
+    if ( $scheduled_date ) {
169
+        return (int) $scheduled_date->format( 'U' );
170
+    } elseif ( NULL === $scheduled_date ) { // pending async action with NullSchedule
171
+        return true;
172
+    }
173
+    return false;
174 174
 }
175 175
 
176 176
 /**
@@ -196,30 +196,30 @@  discard block
 block discarded – undo
196 196
  * @return array
197 197
  */
198 198
 function as_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
199
-	$store = ActionScheduler::store();
200
-	foreach ( array('date', 'modified') as $key ) {
201
-		if ( isset($args[$key]) ) {
202
-			$args[$key] = as_get_datetime_object($args[$key]);
203
-		}
204
-	}
205
-	$ids = $store->query_actions( $args );
206
-
207
-	if ( $return_format == 'ids' || $return_format == 'int' ) {
208
-		return $ids;
209
-	}
210
-
211
-	$actions = array();
212
-	foreach ( $ids as $action_id ) {
213
-		$actions[$action_id] = $store->fetch_action( $action_id );
214
-	}
215
-
216
-	if ( $return_format == ARRAY_A ) {
217
-		foreach ( $actions as $action_id => $action_object ) {
218
-			$actions[$action_id] = get_object_vars($action_object);
219
-		}
220
-	}
221
-
222
-	return $actions;
199
+    $store = ActionScheduler::store();
200
+    foreach ( array('date', 'modified') as $key ) {
201
+        if ( isset($args[$key]) ) {
202
+            $args[$key] = as_get_datetime_object($args[$key]);
203
+        }
204
+    }
205
+    $ids = $store->query_actions( $args );
206
+
207
+    if ( $return_format == 'ids' || $return_format == 'int' ) {
208
+        return $ids;
209
+    }
210
+
211
+    $actions = array();
212
+    foreach ( $ids as $action_id ) {
213
+        $actions[$action_id] = $store->fetch_action( $action_id );
214
+    }
215
+
216
+    if ( $return_format == ARRAY_A ) {
217
+        foreach ( $actions as $action_id => $action_object ) {
218
+            $actions[$action_id] = get_object_vars($action_object);
219
+        }
220
+    }
221
+
222
+    return $actions;
223 223
 }
224 224
 
225 225
 /**
@@ -240,12 +240,12 @@  discard block
 block discarded – undo
240 240
  * @return ActionScheduler_DateTime
241 241
  */
242 242
 function as_get_datetime_object( $date_string = null, $timezone = 'UTC' ) {
243
-	if ( is_object( $date_string ) && $date_string instanceof DateTime ) {
244
-		$date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) );
245
-	} elseif ( is_numeric( $date_string ) ) {
246
-		$date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) );
247
-	} else {
248
-		$date = new ActionScheduler_DateTime( $date_string, new DateTimeZone( $timezone ) );
249
-	}
250
-	return $date;
243
+    if ( is_object( $date_string ) && $date_string instanceof DateTime ) {
244
+        $date = new ActionScheduler_DateTime( $date_string->format( 'Y-m-d H:i:s' ), new DateTimeZone( $timezone ) );
245
+    } elseif ( is_numeric( $date_string ) ) {
246
+        $date = new ActionScheduler_DateTime( '@' . $date_string, new DateTimeZone( $timezone ) );
247
+    } else {
248
+        $date = new ActionScheduler_DateTime( $date_string, new DateTimeZone( $timezone ) );
249
+    }
250
+    return $date;
251 251
 }
Please login to merge, or discard this patch.
action-scheduler/deprecated/ActionScheduler_AdminView_Deprecated.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -10,138 +10,138 @@
 block discarded – undo
10 10
  */
11 11
 class ActionScheduler_AdminView_Deprecated {
12 12
 
13
-	public function action_scheduler_post_type_args( $args ) {
14
-		_deprecated_function( __METHOD__, '2.0.0' );
15
-		return $args;
16
-	}
13
+    public function action_scheduler_post_type_args( $args ) {
14
+        _deprecated_function( __METHOD__, '2.0.0' );
15
+        return $args;
16
+    }
17 17
 
18
-	/**
19
-	 * Customise the post status related views displayed on the Scheduled Actions administration screen.
20
-	 *
21
-	 * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
22
-	 * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
23
-	 */
24
-	public function list_table_views( $views ) {
25
-		_deprecated_function( __METHOD__, '2.0.0' );
26
-		return $views;
27
-	}
18
+    /**
19
+     * Customise the post status related views displayed on the Scheduled Actions administration screen.
20
+     *
21
+     * @param array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
22
+     * @return array $views An associative array of views and view labels which can be used to filter the 'scheduled-action' posts displayed on the Scheduled Actions administration screen.
23
+     */
24
+    public function list_table_views( $views ) {
25
+        _deprecated_function( __METHOD__, '2.0.0' );
26
+        return $views;
27
+    }
28 28
 
29
-	/**
30
-	 * Do not include the "Edit" action for the Scheduled Actions administration screen.
31
-	 *
32
-	 * Hooked to the 'bulk_actions-edit-action-scheduler' filter.
33
-	 *
34
-	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
35
-	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
36
-	 */
37
-	public function bulk_actions( $actions ) {
38
-		_deprecated_function( __METHOD__, '2.0.0' );
39
-		return $actions;
40
-	}
29
+    /**
30
+     * Do not include the "Edit" action for the Scheduled Actions administration screen.
31
+     *
32
+     * Hooked to the 'bulk_actions-edit-action-scheduler' filter.
33
+     *
34
+     * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
35
+     * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
36
+     */
37
+    public function bulk_actions( $actions ) {
38
+        _deprecated_function( __METHOD__, '2.0.0' );
39
+        return $actions;
40
+    }
41 41
 
42
-	/**
43
-	 * Completely customer the columns displayed on the Scheduled Actions administration screen.
44
-	 *
45
-	 * Because we can't filter the content of the default title and date columns, we need to recreate our own
46
-	 * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content().
47
-	 *
48
-	 * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
49
-	 * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
50
-	 */
51
-	public function list_table_columns( $columns ) {
52
-		_deprecated_function( __METHOD__, '2.0.0' );
53
-		return $columns;
54
-	}
42
+    /**
43
+     * Completely customer the columns displayed on the Scheduled Actions administration screen.
44
+     *
45
+     * Because we can't filter the content of the default title and date columns, we need to recreate our own
46
+     * custom columns for displaying those post fields. For the column content, @see self::list_table_column_content().
47
+     *
48
+     * @param array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
49
+     * @return array $columns An associative array of columns that are use for the table on the Scheduled Actions administration screen.
50
+     */
51
+    public function list_table_columns( $columns ) {
52
+        _deprecated_function( __METHOD__, '2.0.0' );
53
+        return $columns;
54
+    }
55 55
 
56
-	/**
57
-	 * Make our custom title & date columns use defaulting title & date sorting.
58
-	 *
59
-	 * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
60
-	 * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
61
-	 */
62
-	public static function list_table_sortable_columns( $columns ) {
63
-		_deprecated_function( __METHOD__, '2.0.0' );
64
-		return $columns;
65
-	}
56
+    /**
57
+     * Make our custom title & date columns use defaulting title & date sorting.
58
+     *
59
+     * @param array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
60
+     * @return array $columns An associative array of columns that can be used to sort the table on the Scheduled Actions administration screen.
61
+     */
62
+    public static function list_table_sortable_columns( $columns ) {
63
+        _deprecated_function( __METHOD__, '2.0.0' );
64
+        return $columns;
65
+    }
66 66
 
67
-	/**
68
-	 * Print the content for our custom columns.
69
-	 *
70
-	 * @param string $column_name The key for the column for which we should output our content.
71
-	 * @param int $post_id The ID of the 'scheduled-action' post for which this row relates.
72
-	 */
73
-	public static function list_table_column_content( $column_name, $post_id ) {
74
-		_deprecated_function( __METHOD__, '2.0.0' );
75
-	}
67
+    /**
68
+     * Print the content for our custom columns.
69
+     *
70
+     * @param string $column_name The key for the column for which we should output our content.
71
+     * @param int $post_id The ID of the 'scheduled-action' post for which this row relates.
72
+     */
73
+    public static function list_table_column_content( $column_name, $post_id ) {
74
+        _deprecated_function( __METHOD__, '2.0.0' );
75
+    }
76 76
 
77
-	/**
78
-	 * Hide the inline "Edit" action for all 'scheduled-action' posts.
79
-	 *
80
-	 * Hooked to the 'post_row_actions' filter.
81
-	 *
82
-	 * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
83
-	 * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
84
-	 */
85
-	public static function row_actions( $actions, $post ) {
86
-		_deprecated_function( __METHOD__, '2.0.0' );
87
-		return $actions;
88
-	}
77
+    /**
78
+     * Hide the inline "Edit" action for all 'scheduled-action' posts.
79
+     *
80
+     * Hooked to the 'post_row_actions' filter.
81
+     *
82
+     * @param array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
83
+     * @return array $actions An associative array of actions which can be performed on the 'scheduled-action' post type.
84
+     */
85
+    public static function row_actions( $actions, $post ) {
86
+        _deprecated_function( __METHOD__, '2.0.0' );
87
+        return $actions;
88
+    }
89 89
 
90
-	/**
91
-	 * Run an action when triggered from the Action Scheduler administration screen.
92
-	 *
93
-	 * @codeCoverageIgnore
94
-	 */
95
-	public static function maybe_execute_action() {
96
-		_deprecated_function( __METHOD__, '2.0.0' );
97
-	}
90
+    /**
91
+     * Run an action when triggered from the Action Scheduler administration screen.
92
+     *
93
+     * @codeCoverageIgnore
94
+     */
95
+    public static function maybe_execute_action() {
96
+        _deprecated_function( __METHOD__, '2.0.0' );
97
+    }
98 98
 
99
-	/**
100
-	 * Convert an interval of seconds into a two part human friendly string.
101
-	 *
102
-	 * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
103
-	 * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
104
-	 * further to display two degrees of accuracy.
105
-	 *
106
-	 * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
107
-	 *
108
-	 * @param int $interval A interval in seconds.
109
-	 * @return string A human friendly string representation of the interval.
110
-	 */
111
-	public static function admin_notices() {
112
-		_deprecated_function( __METHOD__, '2.0.0' );
113
-	}
99
+    /**
100
+     * Convert an interval of seconds into a two part human friendly string.
101
+     *
102
+     * The WordPress human_time_diff() function only calculates the time difference to one degree, meaning
103
+     * even if an action is 1 day and 11 hours away, it will display "1 day". This funciton goes one step
104
+     * further to display two degrees of accuracy.
105
+     *
106
+     * Based on Crontrol::interval() function by Edward Dale: https://wordpress.org/plugins/wp-crontrol/
107
+     *
108
+     * @param int $interval A interval in seconds.
109
+     * @return string A human friendly string representation of the interval.
110
+     */
111
+    public static function admin_notices() {
112
+        _deprecated_function( __METHOD__, '2.0.0' );
113
+    }
114 114
 
115
-	/**
116
-	 * Filter search queries to allow searching by Claim ID (i.e. post_password).
117
-	 *
118
-	 * @param string $orderby MySQL orderby string.
119
-	 * @param WP_Query $query Instance of a WP_Query object
120
-	 * @return string MySQL orderby string.
121
-	 */
122
-	public function custom_orderby( $orderby, $query ){
123
-		_deprecated_function( __METHOD__, '2.0.0' );
124
-	}
115
+    /**
116
+     * Filter search queries to allow searching by Claim ID (i.e. post_password).
117
+     *
118
+     * @param string $orderby MySQL orderby string.
119
+     * @param WP_Query $query Instance of a WP_Query object
120
+     * @return string MySQL orderby string.
121
+     */
122
+    public function custom_orderby( $orderby, $query ){
123
+        _deprecated_function( __METHOD__, '2.0.0' );
124
+    }
125 125
 
126
-	/**
127
-	 * Filter search queries to allow searching by Claim ID (i.e. post_password).
128
-	 *
129
-	 * @param string $search MySQL search string.
130
-	 * @param WP_Query $query Instance of a WP_Query object
131
-	 * @return string MySQL search string.
132
-	 */
133
-	public function search_post_password( $search, $query ) {
134
-		_deprecated_function( __METHOD__, '2.0.0' );
135
-	}
126
+    /**
127
+     * Filter search queries to allow searching by Claim ID (i.e. post_password).
128
+     *
129
+     * @param string $search MySQL search string.
130
+     * @param WP_Query $query Instance of a WP_Query object
131
+     * @return string MySQL search string.
132
+     */
133
+    public function search_post_password( $search, $query ) {
134
+        _deprecated_function( __METHOD__, '2.0.0' );
135
+    }
136 136
 
137
-	/**
138
-	 * Change messages when a scheduled action is updated.
139
-	 *
140
-	 * @param  array $messages
141
-	 * @return array
142
-	 */
143
-	public function post_updated_messages( $messages ) {
144
-		_deprecated_function( __METHOD__, '2.0.0' );
145
-		return $messages;
146
-	}
137
+    /**
138
+     * Change messages when a scheduled action is updated.
139
+     *
140
+     * @param  array $messages
141
+     * @return array
142
+     */
143
+    public function post_updated_messages( $messages ) {
144
+        _deprecated_function( __METHOD__, '2.0.0' );
145
+        return $messages;
146
+    }
147 147
 }
148 148
\ No newline at end of file
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/deprecated/functions.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
  * @return string The job ID
20 20
  */
21 21
 function wc_schedule_single_action( $timestamp, $hook, $args = array(), $group = '' ) {
22
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
23
-	return as_schedule_single_action( $timestamp, $hook, $args, $group );
22
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_single_action()' );
23
+    return as_schedule_single_action( $timestamp, $hook, $args, $group );
24 24
 }
25 25
 
26 26
 /**
@@ -37,8 +37,8 @@  discard block
 block discarded – undo
37 37
  * @return string The job ID
38 38
  */
39 39
 function wc_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args = array(), $group = '' ) {
40
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
41
-	return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
40
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_recurring_action()' );
41
+    return as_schedule_recurring_action( $timestamp, $interval_in_seconds, $hook, $args, $group );
42 42
 }
43 43
 
44 44
 /**
@@ -65,8 +65,8 @@  discard block
 block discarded – undo
65 65
  * @return string The job ID
66 66
  */
67 67
 function wc_schedule_cron_action( $timestamp, $schedule, $hook, $args = array(), $group = '' ) {
68
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
69
-	return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
68
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_schedule_cron_action()' );
69
+    return as_schedule_cron_action( $timestamp, $schedule, $hook, $args, $group );
70 70
 }
71 71
 
72 72
 /**
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
  * @deprecated 2.1.0
80 80
  */
81 81
 function wc_unschedule_action( $hook, $args = array(), $group = '' ) {
82
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
83
-	as_unschedule_action( $hook, $args, $group );
82
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_unschedule_action()' );
83
+    as_unschedule_action( $hook, $args, $group );
84 84
 }
85 85
 
86 86
 /**
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
  * @return int|bool The timestamp for the next occurrence, or false if nothing was found
94 94
  */
95 95
 function wc_next_scheduled_action( $hook, $args = NULL, $group = '' ) {
96
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
97
-	return as_next_scheduled_action( $hook, $args, $group );
96
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_next_scheduled_action()' );
97
+    return as_next_scheduled_action( $hook, $args, $group );
98 98
 }
99 99
 
100 100
 /**
@@ -121,6 +121,6 @@  discard block
 block discarded – undo
121 121
  * @return array
122 122
  */
123 123
 function wc_get_scheduled_actions( $args = array(), $return_format = OBJECT ) {
124
-	_deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
125
-	return as_get_scheduled_actions( $args, $return_format );
124
+    _deprecated_function( __FUNCTION__, '2.1.0', 'as_get_scheduled_actions()' );
125
+    return as_get_scheduled_actions( $args, $return_format );
126 126
 }
Please login to merge, or discard this patch.
action-scheduler/deprecated/ActionScheduler_Schedule_Deprecated.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -5,25 +5,25 @@
 block discarded – undo
5 5
  */
6 6
 abstract class ActionScheduler_Schedule_Deprecated implements ActionScheduler_Schedule {
7 7
 
8
-	/**
9
-	 * Get the date & time this schedule was created to run, or calculate when it should be run
10
-	 * after a given date & time.
11
-	 *
12
-	 * @param DateTime $after
13
-	 *
14
-	 * @return DateTime|null
15
-	 */
16
-	public function next( DateTime $after = NULL ) {
17
-		if ( empty( $after ) ) {
18
-			$return_value       = $this->get_date();
19
-			$replacement_method = 'get_date()';
20
-		} else {
21
-			$return_value       = $this->get_next( $after );
22
-			$replacement_method = 'get_next( $after )';
23
-		}
8
+    /**
9
+     * Get the date & time this schedule was created to run, or calculate when it should be run
10
+     * after a given date & time.
11
+     *
12
+     * @param DateTime $after
13
+     *
14
+     * @return DateTime|null
15
+     */
16
+    public function next( DateTime $after = NULL ) {
17
+        if ( empty( $after ) ) {
18
+            $return_value       = $this->get_date();
19
+            $replacement_method = 'get_date()';
20
+        } else {
21
+            $return_value       = $this->get_next( $after );
22
+            $replacement_method = 'get_next( $after )';
23
+        }
24 24
 
25
-		_deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method );
25
+        _deprecated_function( __METHOD__, '3.0.0', __CLASS__ . '::' . $replacement_method );
26 26
 
27
-		return $return_value;
28
-	}
27
+        return $return_value;
28
+    }
29 29
 }
Please login to merge, or discard this patch.
libraries/action-scheduler/deprecated/ActionScheduler_Store_Deprecated.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -6,44 +6,44 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
deprecated/ActionScheduler_Abstract_QueueRunner_Deprecated.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,23 +5,23 @@
 block discarded – undo
5 5
  */
6 6
 abstract class ActionScheduler_Abstract_QueueRunner_Deprecated {
7 7
 
8
-	/**
9
-	 * Get the maximum number of seconds a batch can run for.
10
-	 *
11
-	 * @deprecated 2.1.1
12
-	 * @return int The number of seconds.
13
-	 */
14
-	protected function get_maximum_execution_time() {
15
-		_deprecated_function( __METHOD__, '2.1.1', 'ActionScheduler_Abstract_QueueRunner::get_time_limit()' );
8
+    /**
9
+     * Get the maximum number of seconds a batch can run for.
10
+     *
11
+     * @deprecated 2.1.1
12
+     * @return int The number of seconds.
13
+     */
14
+    protected function get_maximum_execution_time() {
15
+        _deprecated_function( __METHOD__, '2.1.1', 'ActionScheduler_Abstract_QueueRunner::get_time_limit()' );
16 16
 
17
-		$maximum_execution_time = 30;
17
+        $maximum_execution_time = 30;
18 18
 
19
-		// Apply deprecated filter
20
-		if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) {
21
-			_deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' );
22
-			$maximum_execution_time = apply_filters( 'action_scheduler_maximum_execution_time', $maximum_execution_time );
23
-		}
19
+        // Apply deprecated filter
20
+        if ( has_filter( 'action_scheduler_maximum_execution_time' ) ) {
21
+            _deprecated_function( 'action_scheduler_maximum_execution_time', '2.1.1', 'action_scheduler_queue_runner_time_limit' );
22
+            $maximum_execution_time = apply_filters( 'action_scheduler_maximum_execution_time', $maximum_execution_time );
23
+        }
24 24
 
25
-		return absint( $maximum_execution_time );
26
-	}
25
+        return absint( $maximum_execution_time );
26
+    }
27 27
 }
Please login to merge, or discard this patch.
includes/libraries/action-scheduler/action-scheduler.php 1 patch
Indentation   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -27,27 +27,27 @@
 block discarded – undo
27 27
 
28 28
 if ( ! function_exists( 'action_scheduler_register_3_dot_1_dot_4' ) ) {
29 29
 
30
-	if ( ! class_exists( 'ActionScheduler_Versions' ) ) {
31
-		require_once( 'classes/ActionScheduler_Versions.php' );
32
-		add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
33
-	}
30
+    if ( ! class_exists( 'ActionScheduler_Versions' ) ) {
31
+        require_once( 'classes/ActionScheduler_Versions.php' );
32
+        add_action( 'plugins_loaded', array( 'ActionScheduler_Versions', 'initialize_latest_version' ), 1, 0 );
33
+    }
34 34
 
35
-	add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_1_dot_4', 0, 0 );
35
+    add_action( 'plugins_loaded', 'action_scheduler_register_3_dot_1_dot_4', 0, 0 );
36 36
 
37
-	function action_scheduler_register_3_dot_1_dot_4() {
38
-		$versions = ActionScheduler_Versions::instance();
39
-		$versions->register( '3.1.4', 'action_scheduler_initialize_3_dot_1_dot_4' );
40
-	}
37
+    function action_scheduler_register_3_dot_1_dot_4() {
38
+        $versions = ActionScheduler_Versions::instance();
39
+        $versions->register( '3.1.4', 'action_scheduler_initialize_3_dot_1_dot_4' );
40
+    }
41 41
 
42
-	function action_scheduler_initialize_3_dot_1_dot_4() {
43
-		require_once( 'classes/abstracts/ActionScheduler.php' );
44
-		ActionScheduler::init( __FILE__ );
45
-	}
42
+    function action_scheduler_initialize_3_dot_1_dot_4() {
43
+        require_once( 'classes/abstracts/ActionScheduler.php' );
44
+        ActionScheduler::init( __FILE__ );
45
+    }
46 46
 
47
-	// Support usage in themes - load this version if no plugin has loaded a version yet.
48
-	if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) {
49
-		action_scheduler_initialize_3_dot_1_dot_4();
50
-		do_action( 'action_scheduler_pre_theme_init' );
51
-		ActionScheduler_Versions::initialize_latest_version();
52
-	}
47
+    // Support usage in themes - load this version if no plugin has loaded a version yet.
48
+    if ( did_action( 'plugins_loaded' ) && ! class_exists( 'ActionScheduler' ) ) {
49
+        action_scheduler_initialize_3_dot_1_dot_4();
50
+        do_action( 'action_scheduler_pre_theme_init' );
51
+        ActionScheduler_Versions::initialize_latest_version();
52
+    }
53 53
 }
Please login to merge, or discard this patch.
libraries/action-scheduler/classes/ActionScheduler_FatalErrorMonitor.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -4,52 +4,52 @@
 block discarded – undo
4 4
  * Class ActionScheduler_FatalErrorMonitor
5 5
  */
6 6
 class ActionScheduler_FatalErrorMonitor {
7
-	/** @var ActionScheduler_ActionClaim */
8
-	private $claim = NULL;
9
-	/** @var ActionScheduler_Store */
10
-	private $store = NULL;
11
-	private $action_id = 0;
7
+    /** @var ActionScheduler_ActionClaim */
8
+    private $claim = NULL;
9
+    /** @var ActionScheduler_Store */
10
+    private $store = NULL;
11
+    private $action_id = 0;
12 12
 
13
-	public function __construct( ActionScheduler_Store $store ) {
14
-		$this->store = $store;
15
-	}
13
+    public function __construct( ActionScheduler_Store $store ) {
14
+        $this->store = $store;
15
+    }
16 16
 
17
-	public function attach( ActionScheduler_ActionClaim $claim ) {
18
-		$this->claim = $claim;
19
-		add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
20
-		add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 );
21
-		add_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0, 0 );
22
-		add_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0, 0 );
23
-		add_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0, 0 );
24
-	}
17
+    public function attach( ActionScheduler_ActionClaim $claim ) {
18
+        $this->claim = $claim;
19
+        add_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
20
+        add_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0, 1 );
21
+        add_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0, 0 );
22
+        add_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0, 0 );
23
+        add_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0, 0 );
24
+    }
25 25
 
26
-	public function detach() {
27
-		$this->claim = NULL;
28
-		$this->untrack_action();
29
-		remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
30
-		remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 );
31
-		remove_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0 );
32
-		remove_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0 );
33
-		remove_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0 );
34
-	}
26
+    public function detach() {
27
+        $this->claim = NULL;
28
+        $this->untrack_action();
29
+        remove_action( 'shutdown', array( $this, 'handle_unexpected_shutdown' ) );
30
+        remove_action( 'action_scheduler_before_execute', array( $this, 'track_current_action' ), 0 );
31
+        remove_action( 'action_scheduler_after_execute',  array( $this, 'untrack_action' ), 0 );
32
+        remove_action( 'action_scheduler_execution_ignored',  array( $this, 'untrack_action' ), 0 );
33
+        remove_action( 'action_scheduler_failed_execution',  array( $this, 'untrack_action' ), 0 );
34
+    }
35 35
 
36
-	public function track_current_action( $action_id ) {
37
-		$this->action_id = $action_id;
38
-	}
36
+    public function track_current_action( $action_id ) {
37
+        $this->action_id = $action_id;
38
+    }
39 39
 
40
-	public function untrack_action() {
41
-		$this->action_id = 0;
42
-	}
40
+    public function untrack_action() {
41
+        $this->action_id = 0;
42
+    }
43 43
 
44
-	public function handle_unexpected_shutdown() {
45
-		if ( $error = error_get_last() ) {
46
-			if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
47
-				if ( !empty($this->action_id) ) {
48
-					$this->store->mark_failure( $this->action_id );
49
-					do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
50
-				}
51
-			}
52
-			$this->store->release_claim( $this->claim );
53
-		}
54
-	}
44
+    public function handle_unexpected_shutdown() {
45
+        if ( $error = error_get_last() ) {
46
+            if ( in_array( $error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR, E_RECOVERABLE_ERROR ) ) ) {
47
+                if ( !empty($this->action_id) ) {
48
+                    $this->store->mark_failure( $this->action_id );
49
+                    do_action( 'action_scheduler_unexpected_shutdown', $this->action_id, $error );
50
+                }
51
+            }
52
+            $this->store->release_claim( $this->claim );
53
+        }
54
+    }
55 55
 }
Please login to merge, or discard this patch.