@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <!-- Pane 6 content --> |
2 | 2 | <script type="text/html" id="page-5"> |
3 | 3 | <h2 class="page-title"> |
4 | - <?php esc_html_e( 'Publisher', 'wordlift' ); ?> |
|
4 | + <?php esc_html_e('Publisher', 'wordlift'); ?> |
|
5 | 5 | </h2> |
6 | 6 | |
7 | 7 | <p class="page-txt"> |
8 | - <?php esc_html_e( 'Are you going to publish as an individual or as a company?', 'wordlift' ); ?> |
|
8 | + <?php esc_html_e('Are you going to publish as an individual or as a company?', 'wordlift'); ?> |
|
9 | 9 | </p> |
10 | 10 | |
11 | 11 | <div class="radio-wrapper"> |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | <span class="radio"><span class="check"></span></span> |
21 | 21 | |
22 | 22 | <span class="label"> |
23 | - <?php esc_html_e( 'Personal', 'wordlift' ); ?> |
|
23 | + <?php esc_html_e('Personal', 'wordlift'); ?> |
|
24 | 24 | </span> |
25 | 25 | </label> |
26 | 26 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | <span class="radio"><span class="check"></span></span> |
36 | 36 | |
37 | 37 | <span class="label"> |
38 | - <?php esc_html_e( 'Company', 'wordlift' ); ?> |
|
38 | + <?php esc_html_e('Company', 'wordlift'); ?> |
|
39 | 39 | </span> |
40 | 40 | </label> |
41 | 41 | </div> |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | value="" |
48 | 48 | autocomplete="off" |
49 | 49 | class="untouched invalid" |
50 | - placeholder="<?php esc_attr_e( "What's your name?", 'wordlift' ); ?>" |
|
50 | + placeholder="<?php esc_attr_e("What's your name?", 'wordlift'); ?>" |
|
51 | 51 | > |
52 | 52 | |
53 | 53 | <div data-wl-logo="wl-logo"> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | class="add-logo" |
66 | 66 | href="javascript:void(0);" |
67 | 67 | > |
68 | - <?php esc_html_e( 'Add your logo', 'wordlift' ); ?> |
|
68 | + <?php esc_html_e('Add your logo', 'wordlift'); ?> |
|
69 | 69 | </a> |
70 | 70 | </div> |
71 | 71 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | type="submit" |
75 | 75 | id="btn-finish" |
76 | 76 | class="wl-default-action" |
77 | - value="<?php esc_attr_e( 'Finish', 'wordlift' ); ?>" |
|
77 | + value="<?php esc_attr_e('Finish', 'wordlift'); ?>" |
|
78 | 78 | > |
79 | 79 | </div> |
80 | 80 | </script> |
@@ -18,63 +18,63 @@ |
||
18 | 18 | */ |
19 | 19 | abstract class Wordlift_Install { |
20 | 20 | |
21 | - /** |
|
22 | - * A {@link Wordlift_Log_Service} instance. |
|
23 | - * |
|
24 | - * @since 3.18.0 |
|
25 | - * @access private |
|
26 | - * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
27 | - */ |
|
28 | - protected $log; |
|
21 | + /** |
|
22 | + * A {@link Wordlift_Log_Service} instance. |
|
23 | + * |
|
24 | + * @since 3.18.0 |
|
25 | + * @access private |
|
26 | + * @var \Wordlift_Log_Service $log A {@link Wordlift_Log_Service} instance. |
|
27 | + */ |
|
28 | + protected $log; |
|
29 | 29 | |
30 | - /** |
|
31 | - * The default install version. Overridden by the installation packages. |
|
32 | - * |
|
33 | - * @since 3.18.0 |
|
34 | - * @access protected |
|
35 | - * @var string $version The install version. |
|
36 | - */ |
|
37 | - protected static $version = '0.0.0'; |
|
30 | + /** |
|
31 | + * The default install version. Overridden by the installation packages. |
|
32 | + * |
|
33 | + * @since 3.18.0 |
|
34 | + * @access protected |
|
35 | + * @var string $version The install version. |
|
36 | + */ |
|
37 | + protected static $version = '0.0.0'; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Wordlift_Install_Service constructor. |
|
41 | - * |
|
42 | - * @since 3.18.0 |
|
43 | - */ |
|
44 | - public function __construct() { |
|
39 | + /** |
|
40 | + * Wordlift_Install_Service constructor. |
|
41 | + * |
|
42 | + * @since 3.18.0 |
|
43 | + */ |
|
44 | + public function __construct() { |
|
45 | 45 | |
46 | - $this->log = Wordlift_Log_Service::get_logger( get_class( $this ) ); |
|
46 | + $this->log = Wordlift_Log_Service::get_logger( get_class( $this ) ); |
|
47 | 47 | |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * Return the current version of the installation. |
|
52 | - * |
|
53 | - * @since 3.18.0 |
|
54 | - */ |
|
55 | - public function get_version() { |
|
56 | - return static::$version; |
|
57 | - } |
|
50 | + /** |
|
51 | + * Return the current version of the installation. |
|
52 | + * |
|
53 | + * @since 3.18.0 |
|
54 | + */ |
|
55 | + public function get_version() { |
|
56 | + return static::$version; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * Run the install procedure. This function must be implemented by superclasses. |
|
61 | - * |
|
62 | - * @since 3.18.0 |
|
63 | - * |
|
64 | - * @return mixed The result. |
|
65 | - */ |
|
66 | - abstract public function install(); |
|
59 | + /** |
|
60 | + * Run the install procedure. This function must be implemented by superclasses. |
|
61 | + * |
|
62 | + * @since 3.18.0 |
|
63 | + * |
|
64 | + * @return mixed The result. |
|
65 | + */ |
|
66 | + abstract public function install(); |
|
67 | 67 | |
68 | - /** |
|
69 | - * A custom procedure run by the caller to determine whether the install procedure must be run. |
|
70 | - * |
|
71 | - * @since 3.20.0 |
|
72 | - * |
|
73 | - * @return bool True if the procedure must run. |
|
74 | - */ |
|
75 | - public function must_install() { |
|
68 | + /** |
|
69 | + * A custom procedure run by the caller to determine whether the install procedure must be run. |
|
70 | + * |
|
71 | + * @since 3.20.0 |
|
72 | + * |
|
73 | + * @return bool True if the procedure must run. |
|
74 | + */ |
|
75 | + public function must_install() { |
|
76 | 76 | |
77 | - return false; |
|
78 | - } |
|
77 | + return false; |
|
78 | + } |
|
79 | 79 | |
80 | 80 | } |
@@ -43,7 +43,7 @@ |
||
43 | 43 | */ |
44 | 44 | public function __construct() { |
45 | 45 | |
46 | - $this->log = Wordlift_Log_Service::get_logger( get_class( $this ) ); |
|
46 | + $this->log = Wordlift_Log_Service::get_logger(get_class($this)); |
|
47 | 47 | |
48 | 48 | } |
49 | 49 |
@@ -16,23 +16,23 @@ |
||
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_19_5 extends Wordlift_Install { |
18 | 18 | |
19 | - /** |
|
20 | - * {@inheritdoc} |
|
21 | - */ |
|
22 | - protected static $version = '3.19.5'; |
|
19 | + /** |
|
20 | + * {@inheritdoc} |
|
21 | + */ |
|
22 | + protected static $version = '3.19.5'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * {@inheritdoc} |
|
26 | - */ |
|
27 | - public function install() { |
|
24 | + /** |
|
25 | + * {@inheritdoc} |
|
26 | + */ |
|
27 | + public function install() { |
|
28 | 28 | |
29 | - /* |
|
29 | + /* |
|
30 | 30 | * Flush all the caches, since we changed some JSON-LD publishing rules. |
31 | 31 | * |
32 | 32 | * @see https://github.com/insideout10/wordlift-plugin/issues/858 |
33 | 33 | */ |
34 | - Wordlift_File_Cache_Service::flush_all(); |
|
34 | + Wordlift_File_Cache_Service::flush_all(); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | $key = $configuration_service->get_key(); |
37 | 37 | |
38 | 38 | // Bail out if the `key` isn't set. |
39 | - if ( empty( $key ) ) { |
|
39 | + if (empty($key)) { |
|
40 | 40 | return; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Calling this function will get and set the remote dataset and package type. |
44 | - $configuration_service->get_remote_dataset_uri( $key ); |
|
44 | + $configuration_service->get_remote_dataset_uri($key); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | $package_type = $configuration_service->get_package_type(); |
61 | 61 | |
62 | 62 | // We need to determine the package type if the `key` is set, but the `package_type` isn't. |
63 | - return is_admin() && ! empty( $key ) && empty( $package_type ); |
|
63 | + return is_admin() && ! empty($key) && empty($package_type); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
@@ -16,51 +16,51 @@ |
||
16 | 16 | */ |
17 | 17 | class Wordlift_Install_Package_Type extends Wordlift_Install { |
18 | 18 | |
19 | - /** |
|
20 | - * The install version. |
|
21 | - * |
|
22 | - * @since 3.20.0 |
|
23 | - */ |
|
24 | - protected static $version = '3.20.0'; |
|
19 | + /** |
|
20 | + * The install version. |
|
21 | + * |
|
22 | + * @since 3.20.0 |
|
23 | + */ |
|
24 | + protected static $version = '3.20.0'; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Run the install procedure. |
|
28 | - * |
|
29 | - * @since 3.20.0 |
|
30 | - * |
|
31 | - * @return mixed The result. |
|
32 | - */ |
|
33 | - public function install() { |
|
26 | + /** |
|
27 | + * Run the install procedure. |
|
28 | + * |
|
29 | + * @since 3.20.0 |
|
30 | + * |
|
31 | + * @return mixed The result. |
|
32 | + */ |
|
33 | + public function install() { |
|
34 | 34 | |
35 | - $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
36 | - $key = $configuration_service->get_key(); |
|
35 | + $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
36 | + $key = $configuration_service->get_key(); |
|
37 | 37 | |
38 | - // Bail out if the `key` isn't set. |
|
39 | - if ( empty( $key ) ) { |
|
40 | - return; |
|
41 | - } |
|
38 | + // Bail out if the `key` isn't set. |
|
39 | + if ( empty( $key ) ) { |
|
40 | + return; |
|
41 | + } |
|
42 | 42 | |
43 | - // Calling this function will get and set the remote dataset and package type. |
|
44 | - $configuration_service->get_remote_dataset_uri( $key ); |
|
43 | + // Calling this function will get and set the remote dataset and package type. |
|
44 | + $configuration_service->get_remote_dataset_uri( $key ); |
|
45 | 45 | |
46 | - } |
|
46 | + } |
|
47 | 47 | |
48 | - /** |
|
49 | - * Must install when the package type isn't set. |
|
50 | - * |
|
51 | - * See https://github.com/insideout10/wordlift-plugin/issues/761 |
|
52 | - * |
|
53 | - * @since 3.20.0 |
|
54 | - * @return bool True if package type is set, otherwise false. |
|
55 | - */ |
|
56 | - public function must_install() { |
|
48 | + /** |
|
49 | + * Must install when the package type isn't set. |
|
50 | + * |
|
51 | + * See https://github.com/insideout10/wordlift-plugin/issues/761 |
|
52 | + * |
|
53 | + * @since 3.20.0 |
|
54 | + * @return bool True if package type is set, otherwise false. |
|
55 | + */ |
|
56 | + public function must_install() { |
|
57 | 57 | |
58 | - $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
59 | - $key = $configuration_service->get_key(); |
|
60 | - $package_type = $configuration_service->get_package_type(); |
|
58 | + $configuration_service = Wordlift_Configuration_Service::get_instance(); |
|
59 | + $key = $configuration_service->get_key(); |
|
60 | + $package_type = $configuration_service->get_package_type(); |
|
61 | 61 | |
62 | - // We need to determine the package type if the `key` is set, but the `package_type` isn't. |
|
63 | - return is_admin() && ! empty( $key ) && empty( $package_type ); |
|
64 | - } |
|
62 | + // We need to determine the package type if the `key` is set, but the `package_type` isn't. |
|
63 | + return is_admin() && ! empty( $key ) && empty( $package_type ); |
|
64 | + } |
|
65 | 65 | |
66 | 66 | } |
@@ -15,32 +15,32 @@ |
||
15 | 15 | */ |
16 | 16 | interface Wordlift_Batch_Operation_Interface { |
17 | 17 | |
18 | - /** |
|
19 | - * Process the batch operation starting from the specified offset. |
|
20 | - * |
|
21 | - * @since 3.20.0 |
|
22 | - * |
|
23 | - * @param int $offset Start from the specified offset (or 0 if not specified). |
|
24 | - * @param int $limit Process the specified amount of items per call (or 10 if not specified). |
|
25 | - * |
|
26 | - * @return array { |
|
27 | - * The operation result. |
|
28 | - * |
|
29 | - * @type int $next The next offset. |
|
30 | - * @type int $limit The amount of items to process per call. |
|
31 | - * @type int $remaining The remaining number of elements to process. |
|
32 | - * @type bool $complete Whether the operation completed. |
|
33 | - * } |
|
34 | - */ |
|
35 | - public function process( $offset = 0, $limit = 10 ); |
|
18 | + /** |
|
19 | + * Process the batch operation starting from the specified offset. |
|
20 | + * |
|
21 | + * @since 3.20.0 |
|
22 | + * |
|
23 | + * @param int $offset Start from the specified offset (or 0 if not specified). |
|
24 | + * @param int $limit Process the specified amount of items per call (or 10 if not specified). |
|
25 | + * |
|
26 | + * @return array { |
|
27 | + * The operation result. |
|
28 | + * |
|
29 | + * @type int $next The next offset. |
|
30 | + * @type int $limit The amount of items to process per call. |
|
31 | + * @type int $remaining The remaining number of elements to process. |
|
32 | + * @type bool $complete Whether the operation completed. |
|
33 | + * } |
|
34 | + */ |
|
35 | + public function process( $offset = 0, $limit = 10 ); |
|
36 | 36 | |
37 | - /** |
|
38 | - * Count the number of elements that would be affected by the operation. |
|
39 | - * |
|
40 | - * @since 3.20.0 |
|
41 | - * |
|
42 | - * @return int The number of elements that would be affected. |
|
43 | - */ |
|
44 | - public function count(); |
|
37 | + /** |
|
38 | + * Count the number of elements that would be affected by the operation. |
|
39 | + * |
|
40 | + * @since 3.20.0 |
|
41 | + * |
|
42 | + * @return int The number of elements that would be affected. |
|
43 | + */ |
|
44 | + public function count(); |
|
45 | 45 | |
46 | 46 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | * @type bool $complete Whether the operation completed. |
33 | 33 | * } |
34 | 34 | */ |
35 | - public function process( $offset = 0, $limit = 10 ); |
|
35 | + public function process($offset = 0, $limit = 10); |
|
36 | 36 | |
37 | 37 | /** |
38 | 38 | * Count the number of elements that would be affected by the operation. |
@@ -18,75 +18,75 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Post_Property_Storage extends Wordlift_Storage { |
20 | 20 | |
21 | - /** |
|
22 | - * The `post_title` property. |
|
23 | - */ |
|
24 | - const TITLE = 'title'; |
|
25 | - |
|
26 | - /** |
|
27 | - * The `post_content` property stripped of tags and shortcodes. |
|
28 | - */ |
|
29 | - const DESCRIPTION_NO_TAGS_NO_SHORTCODES = 'description_no_tags_no_shortcodes'; |
|
30 | - |
|
31 | - /** |
|
32 | - * The `post_author` property. |
|
33 | - */ |
|
34 | - const AUTHOR = 'author'; |
|
35 | - |
|
36 | - /** |
|
37 | - * The {@link WP_Post} property to retrieve. |
|
38 | - * |
|
39 | - * @since 3.15.0 |
|
40 | - * @access private |
|
41 | - * @var string $property The {@link WP_Post} property to retrieve. |
|
42 | - */ |
|
43 | - private $property; |
|
44 | - |
|
45 | - /** |
|
46 | - * Create a {@link Wordlift_Post_Property_Storage} instance. |
|
47 | - * |
|
48 | - * @since 3.15.0 |
|
49 | - * |
|
50 | - * @param string $property A post property. |
|
51 | - */ |
|
52 | - public function __construct( $property ) { |
|
53 | - |
|
54 | - $this->property = $property; |
|
55 | - |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Get the property value. |
|
60 | - * |
|
61 | - * @since 3.15.0 |
|
62 | - * |
|
63 | - * @param int $post_id The {@link WP_Post}'s id. |
|
64 | - * |
|
65 | - * @return array|string|null A single string, or an array of values or null |
|
66 | - * if the property isn't recognized. |
|
67 | - */ |
|
68 | - public function get( $post_id ) { |
|
69 | - |
|
70 | - // Get the post. |
|
71 | - $post = get_post( $post_id ); |
|
72 | - |
|
73 | - // Switch according to the selected property. |
|
74 | - switch ( $this->property ) { |
|
75 | - |
|
76 | - // Title. |
|
77 | - case self::TITLE: |
|
78 | - return $post->post_title; |
|
79 | - |
|
80 | - // Description. |
|
81 | - case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES: |
|
82 | - return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) ); |
|
83 | - |
|
84 | - // Author. |
|
85 | - case self::AUTHOR: |
|
86 | - return $post->post_author; |
|
87 | - } |
|
88 | - |
|
89 | - return null; |
|
90 | - } |
|
21 | + /** |
|
22 | + * The `post_title` property. |
|
23 | + */ |
|
24 | + const TITLE = 'title'; |
|
25 | + |
|
26 | + /** |
|
27 | + * The `post_content` property stripped of tags and shortcodes. |
|
28 | + */ |
|
29 | + const DESCRIPTION_NO_TAGS_NO_SHORTCODES = 'description_no_tags_no_shortcodes'; |
|
30 | + |
|
31 | + /** |
|
32 | + * The `post_author` property. |
|
33 | + */ |
|
34 | + const AUTHOR = 'author'; |
|
35 | + |
|
36 | + /** |
|
37 | + * The {@link WP_Post} property to retrieve. |
|
38 | + * |
|
39 | + * @since 3.15.0 |
|
40 | + * @access private |
|
41 | + * @var string $property The {@link WP_Post} property to retrieve. |
|
42 | + */ |
|
43 | + private $property; |
|
44 | + |
|
45 | + /** |
|
46 | + * Create a {@link Wordlift_Post_Property_Storage} instance. |
|
47 | + * |
|
48 | + * @since 3.15.0 |
|
49 | + * |
|
50 | + * @param string $property A post property. |
|
51 | + */ |
|
52 | + public function __construct( $property ) { |
|
53 | + |
|
54 | + $this->property = $property; |
|
55 | + |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Get the property value. |
|
60 | + * |
|
61 | + * @since 3.15.0 |
|
62 | + * |
|
63 | + * @param int $post_id The {@link WP_Post}'s id. |
|
64 | + * |
|
65 | + * @return array|string|null A single string, or an array of values or null |
|
66 | + * if the property isn't recognized. |
|
67 | + */ |
|
68 | + public function get( $post_id ) { |
|
69 | + |
|
70 | + // Get the post. |
|
71 | + $post = get_post( $post_id ); |
|
72 | + |
|
73 | + // Switch according to the selected property. |
|
74 | + switch ( $this->property ) { |
|
75 | + |
|
76 | + // Title. |
|
77 | + case self::TITLE: |
|
78 | + return $post->post_title; |
|
79 | + |
|
80 | + // Description. |
|
81 | + case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES: |
|
82 | + return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) ); |
|
83 | + |
|
84 | + // Author. |
|
85 | + case self::AUTHOR: |
|
86 | + return $post->post_author; |
|
87 | + } |
|
88 | + |
|
89 | + return null; |
|
90 | + } |
|
91 | 91 | |
92 | 92 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @param string $property A post property. |
51 | 51 | */ |
52 | - public function __construct( $property ) { |
|
52 | + public function __construct($property) { |
|
53 | 53 | |
54 | 54 | $this->property = $property; |
55 | 55 | |
@@ -65,13 +65,13 @@ discard block |
||
65 | 65 | * @return array|string|null A single string, or an array of values or null |
66 | 66 | * if the property isn't recognized. |
67 | 67 | */ |
68 | - public function get( $post_id ) { |
|
68 | + public function get($post_id) { |
|
69 | 69 | |
70 | 70 | // Get the post. |
71 | - $post = get_post( $post_id ); |
|
71 | + $post = get_post($post_id); |
|
72 | 72 | |
73 | 73 | // Switch according to the selected property. |
74 | - switch ( $this->property ) { |
|
74 | + switch ($this->property) { |
|
75 | 75 | |
76 | 76 | // Title. |
77 | 77 | case self::TITLE: |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | // Description. |
81 | 81 | case self::DESCRIPTION_NO_TAGS_NO_SHORTCODES: |
82 | - return wp_strip_all_tags( preg_replace( '/\[[^]]+\]/', '', do_shortcode( $post->post_content ) ) ); |
|
82 | + return wp_strip_all_tags(preg_replace('/\[[^]]+\]/', '', do_shortcode($post->post_content))); |
|
83 | 83 | |
84 | 84 | // Author. |
85 | 85 | case self::AUTHOR: |
@@ -12,15 +12,15 @@ |
||
12 | 12 | */ |
13 | 13 | class Wordlift_Install_3_27_1 extends Wordlift_Install { |
14 | 14 | |
15 | - /** |
|
16 | - * {@inheritdoc} |
|
17 | - */ |
|
18 | - protected static $version = '3.27.1'; |
|
15 | + /** |
|
16 | + * {@inheritdoc} |
|
17 | + */ |
|
18 | + protected static $version = '3.27.1'; |
|
19 | 19 | |
20 | - public function install() { |
|
21 | - $procedure = new Recipe_Maker_Entity_Type_Procedure(); |
|
22 | - $procedure->run_procedure(); |
|
23 | - } |
|
20 | + public function install() { |
|
21 | + $procedure = new Recipe_Maker_Entity_Type_Procedure(); |
|
22 | + $procedure->run_procedure(); |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | 26 | } |
@@ -12,170 +12,170 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class Wordlift_Plugin_WP_Async_Request { |
14 | 14 | |
15 | - /** |
|
16 | - * Prefix |
|
17 | - * |
|
18 | - * (default value: 'wp') |
|
19 | - * |
|
20 | - * @var string |
|
21 | - * @access protected |
|
22 | - */ |
|
23 | - protected $prefix = 'wp'; |
|
24 | - |
|
25 | - /** |
|
26 | - * Action |
|
27 | - * |
|
28 | - * (default value: 'async_request') |
|
29 | - * |
|
30 | - * @var string |
|
31 | - * @access protected |
|
32 | - */ |
|
33 | - protected $action = 'async_request'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Identifier |
|
37 | - * |
|
38 | - * @var mixed |
|
39 | - * @access protected |
|
40 | - */ |
|
41 | - protected $identifier; |
|
42 | - |
|
43 | - /** |
|
44 | - * Data |
|
45 | - * |
|
46 | - * (default value: array()) |
|
47 | - * |
|
48 | - * @var array |
|
49 | - * @access protected |
|
50 | - */ |
|
51 | - protected $data = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * Initiate new async request |
|
55 | - */ |
|
56 | - public function __construct() { |
|
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | - |
|
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Set data used during the request |
|
65 | - * |
|
66 | - * @param array $data Data. |
|
67 | - * |
|
68 | - * @return $this |
|
69 | - */ |
|
70 | - public function data( $data ) { |
|
71 | - $this->data = $data; |
|
72 | - |
|
73 | - return $this; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Dispatch the async request |
|
78 | - * |
|
79 | - * @return array|WP_Error |
|
80 | - */ |
|
81 | - public function dispatch() { |
|
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | - $args = $this->get_post_args(); |
|
84 | - |
|
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get query args |
|
90 | - * |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function get_query_args() { |
|
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
95 | - return $this->query_args; |
|
96 | - } |
|
97 | - |
|
98 | - $args = array( |
|
99 | - 'action' => $this->identifier, |
|
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | - ); |
|
102 | - |
|
103 | - /** |
|
104 | - * Filters the post arguments used during an async request. |
|
105 | - * |
|
106 | - * @param array $url |
|
107 | - */ |
|
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get query URL |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - protected function get_query_url() { |
|
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
118 | - return $this->query_url; |
|
119 | - } |
|
120 | - |
|
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
122 | - |
|
123 | - /** |
|
124 | - * Filters the post arguments used during an async request. |
|
125 | - * |
|
126 | - * @param string $url |
|
127 | - */ |
|
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Get post args |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - protected function get_post_args() { |
|
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
138 | - return $this->post_args; |
|
139 | - } |
|
140 | - |
|
141 | - $args = array( |
|
142 | - 'timeout' => 0.01, |
|
143 | - 'blocking' => false, |
|
144 | - 'body' => $this->data, |
|
145 | - 'cookies' => $_COOKIE, |
|
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | - ); |
|
148 | - |
|
149 | - /** |
|
150 | - * Filters the post arguments used during an async request. |
|
151 | - * |
|
152 | - * @param array $args |
|
153 | - */ |
|
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Maybe handle |
|
159 | - * |
|
160 | - * Check for correct nonce and pass to handler. |
|
161 | - */ |
|
162 | - public function maybe_handle() { |
|
163 | - // Don't lock up other requests while processing |
|
164 | - session_write_close(); |
|
165 | - |
|
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | - |
|
168 | - $this->handle(); |
|
169 | - |
|
170 | - wp_die(); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Handle |
|
175 | - * |
|
176 | - * Override this method to perform any actions required |
|
177 | - * during the async request. |
|
178 | - */ |
|
179 | - abstract protected function handle(); |
|
15 | + /** |
|
16 | + * Prefix |
|
17 | + * |
|
18 | + * (default value: 'wp') |
|
19 | + * |
|
20 | + * @var string |
|
21 | + * @access protected |
|
22 | + */ |
|
23 | + protected $prefix = 'wp'; |
|
24 | + |
|
25 | + /** |
|
26 | + * Action |
|
27 | + * |
|
28 | + * (default value: 'async_request') |
|
29 | + * |
|
30 | + * @var string |
|
31 | + * @access protected |
|
32 | + */ |
|
33 | + protected $action = 'async_request'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Identifier |
|
37 | + * |
|
38 | + * @var mixed |
|
39 | + * @access protected |
|
40 | + */ |
|
41 | + protected $identifier; |
|
42 | + |
|
43 | + /** |
|
44 | + * Data |
|
45 | + * |
|
46 | + * (default value: array()) |
|
47 | + * |
|
48 | + * @var array |
|
49 | + * @access protected |
|
50 | + */ |
|
51 | + protected $data = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * Initiate new async request |
|
55 | + */ |
|
56 | + public function __construct() { |
|
57 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | + |
|
59 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Set data used during the request |
|
65 | + * |
|
66 | + * @param array $data Data. |
|
67 | + * |
|
68 | + * @return $this |
|
69 | + */ |
|
70 | + public function data( $data ) { |
|
71 | + $this->data = $data; |
|
72 | + |
|
73 | + return $this; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Dispatch the async request |
|
78 | + * |
|
79 | + * @return array|WP_Error |
|
80 | + */ |
|
81 | + public function dispatch() { |
|
82 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | + $args = $this->get_post_args(); |
|
84 | + |
|
85 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get query args |
|
90 | + * |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function get_query_args() { |
|
94 | + if ( property_exists( $this, 'query_args' ) ) { |
|
95 | + return $this->query_args; |
|
96 | + } |
|
97 | + |
|
98 | + $args = array( |
|
99 | + 'action' => $this->identifier, |
|
100 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | + ); |
|
102 | + |
|
103 | + /** |
|
104 | + * Filters the post arguments used during an async request. |
|
105 | + * |
|
106 | + * @param array $url |
|
107 | + */ |
|
108 | + return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get query URL |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + protected function get_query_url() { |
|
117 | + if ( property_exists( $this, 'query_url' ) ) { |
|
118 | + return $this->query_url; |
|
119 | + } |
|
120 | + |
|
121 | + $url = admin_url( 'admin-ajax.php' ); |
|
122 | + |
|
123 | + /** |
|
124 | + * Filters the post arguments used during an async request. |
|
125 | + * |
|
126 | + * @param string $url |
|
127 | + */ |
|
128 | + return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Get post args |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + protected function get_post_args() { |
|
137 | + if ( property_exists( $this, 'post_args' ) ) { |
|
138 | + return $this->post_args; |
|
139 | + } |
|
140 | + |
|
141 | + $args = array( |
|
142 | + 'timeout' => 0.01, |
|
143 | + 'blocking' => false, |
|
144 | + 'body' => $this->data, |
|
145 | + 'cookies' => $_COOKIE, |
|
146 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | + ); |
|
148 | + |
|
149 | + /** |
|
150 | + * Filters the post arguments used during an async request. |
|
151 | + * |
|
152 | + * @param array $args |
|
153 | + */ |
|
154 | + return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Maybe handle |
|
159 | + * |
|
160 | + * Check for correct nonce and pass to handler. |
|
161 | + */ |
|
162 | + public function maybe_handle() { |
|
163 | + // Don't lock up other requests while processing |
|
164 | + session_write_close(); |
|
165 | + |
|
166 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | + |
|
168 | + $this->handle(); |
|
169 | + |
|
170 | + wp_die(); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Handle |
|
175 | + * |
|
176 | + * Override this method to perform any actions required |
|
177 | + * during the async request. |
|
178 | + */ |
|
179 | + abstract protected function handle(); |
|
180 | 180 | |
181 | 181 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * Initiate new async request |
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
57 | + $this->identifier = $this->prefix.'_'.$this->action; |
|
58 | 58 | |
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
59 | + add_action('wp_ajax_'.$this->identifier, array($this, 'maybe_handle')); |
|
60 | + add_action('wp_ajax_nopriv_'.$this->identifier, array($this, 'maybe_handle')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function data( $data ) { |
|
70 | + public function data($data) { |
|
71 | 71 | $this->data = $data; |
72 | 72 | |
73 | 73 | return $this; |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @return array|WP_Error |
80 | 80 | */ |
81 | 81 | public function dispatch() { |
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
82 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
83 | 83 | $args = $this->get_post_args(); |
84 | 84 | |
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
85 | + return wp_remote_post(esc_url_raw($url), $args); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | protected function get_query_args() { |
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
94 | + if (property_exists($this, 'query_args')) { |
|
95 | 95 | return $this->query_args; |
96 | 96 | } |
97 | 97 | |
98 | 98 | $args = array( |
99 | 99 | 'action' => $this->identifier, |
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
100 | + 'nonce' => wp_create_nonce($this->identifier), |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param array $url |
107 | 107 | */ |
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
108 | + return apply_filters($this->identifier.'_query_args', $args); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * @return string |
115 | 115 | */ |
116 | 116 | protected function get_query_url() { |
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
117 | + if (property_exists($this, 'query_url')) { |
|
118 | 118 | return $this->query_url; |
119 | 119 | } |
120 | 120 | |
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
121 | + $url = admin_url('admin-ajax.php'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Filters the post arguments used during an async request. |
125 | 125 | * |
126 | 126 | * @param string $url |
127 | 127 | */ |
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
128 | + return apply_filters($this->identifier.'_query_url', $url); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return array |
135 | 135 | */ |
136 | 136 | protected function get_post_args() { |
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
137 | + if (property_exists($this, 'post_args')) { |
|
138 | 138 | return $this->post_args; |
139 | 139 | } |
140 | 140 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'blocking' => false, |
144 | 144 | 'body' => $this->data, |
145 | 145 | 'cookies' => $_COOKIE, |
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
146 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param array $args |
153 | 153 | */ |
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
154 | + return apply_filters($this->identifier.'_post_args', $args); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // Don't lock up other requests while processing |
164 | 164 | session_write_close(); |
165 | 165 | |
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
166 | + check_ajax_referer($this->identifier, 'nonce'); |
|
167 | 167 | |
168 | 168 | $this->handle(); |
169 | 169 |
@@ -12,170 +12,170 @@ |
||
12 | 12 | */ |
13 | 13 | abstract class WP_Async_Request { |
14 | 14 | |
15 | - /** |
|
16 | - * Prefix |
|
17 | - * |
|
18 | - * (default value: 'wp') |
|
19 | - * |
|
20 | - * @var string |
|
21 | - * @access protected |
|
22 | - */ |
|
23 | - protected $prefix = 'wp'; |
|
24 | - |
|
25 | - /** |
|
26 | - * Action |
|
27 | - * |
|
28 | - * (default value: 'async_request') |
|
29 | - * |
|
30 | - * @var string |
|
31 | - * @access protected |
|
32 | - */ |
|
33 | - protected $action = 'async_request'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Identifier |
|
37 | - * |
|
38 | - * @var mixed |
|
39 | - * @access protected |
|
40 | - */ |
|
41 | - protected $identifier; |
|
42 | - |
|
43 | - /** |
|
44 | - * Data |
|
45 | - * |
|
46 | - * (default value: array()) |
|
47 | - * |
|
48 | - * @var array |
|
49 | - * @access protected |
|
50 | - */ |
|
51 | - protected $data = array(); |
|
52 | - |
|
53 | - /** |
|
54 | - * Initiate new async request |
|
55 | - */ |
|
56 | - public function __construct() { |
|
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | - |
|
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Set data used during the request |
|
65 | - * |
|
66 | - * @param array $data Data. |
|
67 | - * |
|
68 | - * @return $this |
|
69 | - */ |
|
70 | - public function data( $data ) { |
|
71 | - $this->data = $data; |
|
72 | - |
|
73 | - return $this; |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Dispatch the async request |
|
78 | - * |
|
79 | - * @return array|WP_Error |
|
80 | - */ |
|
81 | - public function dispatch() { |
|
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | - $args = $this->get_post_args(); |
|
84 | - |
|
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | - } |
|
87 | - |
|
88 | - /** |
|
89 | - * Get query args |
|
90 | - * |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - protected function get_query_args() { |
|
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
95 | - return $this->query_args; |
|
96 | - } |
|
97 | - |
|
98 | - $args = array( |
|
99 | - 'action' => $this->identifier, |
|
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | - ); |
|
102 | - |
|
103 | - /** |
|
104 | - * Filters the post arguments used during an async request. |
|
105 | - * |
|
106 | - * @param array $url |
|
107 | - */ |
|
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Get query URL |
|
113 | - * |
|
114 | - * @return string |
|
115 | - */ |
|
116 | - protected function get_query_url() { |
|
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
118 | - return $this->query_url; |
|
119 | - } |
|
120 | - |
|
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
122 | - |
|
123 | - /** |
|
124 | - * Filters the post arguments used during an async request. |
|
125 | - * |
|
126 | - * @param string $url |
|
127 | - */ |
|
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Get post args |
|
133 | - * |
|
134 | - * @return array |
|
135 | - */ |
|
136 | - protected function get_post_args() { |
|
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
138 | - return $this->post_args; |
|
139 | - } |
|
140 | - |
|
141 | - $args = array( |
|
142 | - 'timeout' => 0.01, |
|
143 | - 'blocking' => false, |
|
144 | - 'body' => $this->data, |
|
145 | - 'cookies' => $_COOKIE, |
|
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | - ); |
|
148 | - |
|
149 | - /** |
|
150 | - * Filters the post arguments used during an async request. |
|
151 | - * |
|
152 | - * @param array $args |
|
153 | - */ |
|
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | - } |
|
156 | - |
|
157 | - /** |
|
158 | - * Maybe handle |
|
159 | - * |
|
160 | - * Check for correct nonce and pass to handler. |
|
161 | - */ |
|
162 | - public function maybe_handle() { |
|
163 | - // Don't lock up other requests while processing |
|
164 | - session_write_close(); |
|
165 | - |
|
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | - |
|
168 | - $this->handle(); |
|
169 | - |
|
170 | - wp_die(); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Handle |
|
175 | - * |
|
176 | - * Override this method to perform any actions required |
|
177 | - * during the async request. |
|
178 | - */ |
|
179 | - abstract protected function handle(); |
|
15 | + /** |
|
16 | + * Prefix |
|
17 | + * |
|
18 | + * (default value: 'wp') |
|
19 | + * |
|
20 | + * @var string |
|
21 | + * @access protected |
|
22 | + */ |
|
23 | + protected $prefix = 'wp'; |
|
24 | + |
|
25 | + /** |
|
26 | + * Action |
|
27 | + * |
|
28 | + * (default value: 'async_request') |
|
29 | + * |
|
30 | + * @var string |
|
31 | + * @access protected |
|
32 | + */ |
|
33 | + protected $action = 'async_request'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Identifier |
|
37 | + * |
|
38 | + * @var mixed |
|
39 | + * @access protected |
|
40 | + */ |
|
41 | + protected $identifier; |
|
42 | + |
|
43 | + /** |
|
44 | + * Data |
|
45 | + * |
|
46 | + * (default value: array()) |
|
47 | + * |
|
48 | + * @var array |
|
49 | + * @access protected |
|
50 | + */ |
|
51 | + protected $data = array(); |
|
52 | + |
|
53 | + /** |
|
54 | + * Initiate new async request |
|
55 | + */ |
|
56 | + public function __construct() { |
|
57 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
58 | + |
|
59 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Set data used during the request |
|
65 | + * |
|
66 | + * @param array $data Data. |
|
67 | + * |
|
68 | + * @return $this |
|
69 | + */ |
|
70 | + public function data( $data ) { |
|
71 | + $this->data = $data; |
|
72 | + |
|
73 | + return $this; |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Dispatch the async request |
|
78 | + * |
|
79 | + * @return array|WP_Error |
|
80 | + */ |
|
81 | + public function dispatch() { |
|
82 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
83 | + $args = $this->get_post_args(); |
|
84 | + |
|
85 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
86 | + } |
|
87 | + |
|
88 | + /** |
|
89 | + * Get query args |
|
90 | + * |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + protected function get_query_args() { |
|
94 | + if ( property_exists( $this, 'query_args' ) ) { |
|
95 | + return $this->query_args; |
|
96 | + } |
|
97 | + |
|
98 | + $args = array( |
|
99 | + 'action' => $this->identifier, |
|
100 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
101 | + ); |
|
102 | + |
|
103 | + /** |
|
104 | + * Filters the post arguments used during an async request. |
|
105 | + * |
|
106 | + * @param array $url |
|
107 | + */ |
|
108 | + return apply_filters( $this->identifier . '_query_args', $args ); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Get query URL |
|
113 | + * |
|
114 | + * @return string |
|
115 | + */ |
|
116 | + protected function get_query_url() { |
|
117 | + if ( property_exists( $this, 'query_url' ) ) { |
|
118 | + return $this->query_url; |
|
119 | + } |
|
120 | + |
|
121 | + $url = admin_url( 'admin-ajax.php' ); |
|
122 | + |
|
123 | + /** |
|
124 | + * Filters the post arguments used during an async request. |
|
125 | + * |
|
126 | + * @param string $url |
|
127 | + */ |
|
128 | + return apply_filters( $this->identifier . '_query_url', $url ); |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Get post args |
|
133 | + * |
|
134 | + * @return array |
|
135 | + */ |
|
136 | + protected function get_post_args() { |
|
137 | + if ( property_exists( $this, 'post_args' ) ) { |
|
138 | + return $this->post_args; |
|
139 | + } |
|
140 | + |
|
141 | + $args = array( |
|
142 | + 'timeout' => 0.01, |
|
143 | + 'blocking' => false, |
|
144 | + 'body' => $this->data, |
|
145 | + 'cookies' => $_COOKIE, |
|
146 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
147 | + ); |
|
148 | + |
|
149 | + /** |
|
150 | + * Filters the post arguments used during an async request. |
|
151 | + * |
|
152 | + * @param array $args |
|
153 | + */ |
|
154 | + return apply_filters( $this->identifier . '_post_args', $args ); |
|
155 | + } |
|
156 | + |
|
157 | + /** |
|
158 | + * Maybe handle |
|
159 | + * |
|
160 | + * Check for correct nonce and pass to handler. |
|
161 | + */ |
|
162 | + public function maybe_handle() { |
|
163 | + // Don't lock up other requests while processing |
|
164 | + session_write_close(); |
|
165 | + |
|
166 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
167 | + |
|
168 | + $this->handle(); |
|
169 | + |
|
170 | + wp_die(); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Handle |
|
175 | + * |
|
176 | + * Override this method to perform any actions required |
|
177 | + * during the async request. |
|
178 | + */ |
|
179 | + abstract protected function handle(); |
|
180 | 180 | |
181 | 181 | } |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | * Initiate new async request |
55 | 55 | */ |
56 | 56 | public function __construct() { |
57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
57 | + $this->identifier = $this->prefix.'_'.$this->action; |
|
58 | 58 | |
59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
59 | + add_action('wp_ajax_'.$this->identifier, array($this, 'maybe_handle')); |
|
60 | + add_action('wp_ajax_nopriv_'.$this->identifier, array($this, 'maybe_handle')); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return $this |
69 | 69 | */ |
70 | - public function data( $data ) { |
|
70 | + public function data($data) { |
|
71 | 71 | $this->data = $data; |
72 | 72 | |
73 | 73 | return $this; |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | * @return array|WP_Error |
80 | 80 | */ |
81 | 81 | public function dispatch() { |
82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
82 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
83 | 83 | $args = $this->get_post_args(); |
84 | 84 | |
85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
85 | + return wp_remote_post(esc_url_raw($url), $args); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |
@@ -91,13 +91,13 @@ discard block |
||
91 | 91 | * @return array |
92 | 92 | */ |
93 | 93 | protected function get_query_args() { |
94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
94 | + if (property_exists($this, 'query_args')) { |
|
95 | 95 | return $this->query_args; |
96 | 96 | } |
97 | 97 | |
98 | 98 | $args = array( |
99 | 99 | 'action' => $this->identifier, |
100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
100 | + 'nonce' => wp_create_nonce($this->identifier), |
|
101 | 101 | ); |
102 | 102 | |
103 | 103 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * |
106 | 106 | * @param array $url |
107 | 107 | */ |
108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
108 | + return apply_filters($this->identifier.'_query_args', $args); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | /** |
@@ -114,18 +114,18 @@ discard block |
||
114 | 114 | * @return string |
115 | 115 | */ |
116 | 116 | protected function get_query_url() { |
117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
117 | + if (property_exists($this, 'query_url')) { |
|
118 | 118 | return $this->query_url; |
119 | 119 | } |
120 | 120 | |
121 | - $url = admin_url( 'admin-ajax.php' ); |
|
121 | + $url = admin_url('admin-ajax.php'); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Filters the post arguments used during an async request. |
125 | 125 | * |
126 | 126 | * @param string $url |
127 | 127 | */ |
128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
128 | + return apply_filters($this->identifier.'_query_url', $url); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @return array |
135 | 135 | */ |
136 | 136 | protected function get_post_args() { |
137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
137 | + if (property_exists($this, 'post_args')) { |
|
138 | 138 | return $this->post_args; |
139 | 139 | } |
140 | 140 | |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'blocking' => false, |
144 | 144 | 'body' => $this->data, |
145 | 145 | 'cookies' => $_COOKIE, |
146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
146 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
147 | 147 | ); |
148 | 148 | |
149 | 149 | /** |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param array $args |
153 | 153 | */ |
154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
154 | + return apply_filters($this->identifier.'_post_args', $args); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | // Don't lock up other requests while processing |
164 | 164 | session_write_close(); |
165 | 165 | |
166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
166 | + check_ajax_referer($this->identifier, 'nonce'); |
|
167 | 167 | |
168 | 168 | $this->handle(); |
169 | 169 |