@@ -5,95 +5,95 @@ |
||
5 | 5 | */ |
6 | 6 | class ActionScheduler_Compatibility { |
7 | 7 | |
8 | - /** |
|
9 | - * Converts a shorthand byte value to an integer byte value. |
|
10 | - * |
|
11 | - * Wrapper for wp_convert_hr_to_bytes(), moved to load.php in WordPress 4.6 from media.php |
|
12 | - * |
|
13 | - * @link https://secure.php.net/manual/en/function.ini-get.php |
|
14 | - * @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes |
|
15 | - * |
|
16 | - * @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
|
17 | - * @return int An integer byte value. |
|
18 | - */ |
|
19 | - public static function convert_hr_to_bytes( $value ) { |
|
20 | - if ( function_exists( 'wp_convert_hr_to_bytes' ) ) { |
|
21 | - return wp_convert_hr_to_bytes( $value ); |
|
22 | - } |
|
8 | + /** |
|
9 | + * Converts a shorthand byte value to an integer byte value. |
|
10 | + * |
|
11 | + * Wrapper for wp_convert_hr_to_bytes(), moved to load.php in WordPress 4.6 from media.php |
|
12 | + * |
|
13 | + * @link https://secure.php.net/manual/en/function.ini-get.php |
|
14 | + * @link https://secure.php.net/manual/en/faq.using.php#faq.using.shorthandbytes |
|
15 | + * |
|
16 | + * @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
|
17 | + * @return int An integer byte value. |
|
18 | + */ |
|
19 | + public static function convert_hr_to_bytes( $value ) { |
|
20 | + if ( function_exists( 'wp_convert_hr_to_bytes' ) ) { |
|
21 | + return wp_convert_hr_to_bytes( $value ); |
|
22 | + } |
|
23 | 23 | |
24 | - $value = strtolower( trim( $value ) ); |
|
25 | - $bytes = (int) $value; |
|
24 | + $value = strtolower( trim( $value ) ); |
|
25 | + $bytes = (int) $value; |
|
26 | 26 | |
27 | - if ( false !== strpos( $value, 'g' ) ) { |
|
28 | - $bytes *= GB_IN_BYTES; |
|
29 | - } elseif ( false !== strpos( $value, 'm' ) ) { |
|
30 | - $bytes *= MB_IN_BYTES; |
|
31 | - } elseif ( false !== strpos( $value, 'k' ) ) { |
|
32 | - $bytes *= KB_IN_BYTES; |
|
33 | - } |
|
27 | + if ( false !== strpos( $value, 'g' ) ) { |
|
28 | + $bytes *= GB_IN_BYTES; |
|
29 | + } elseif ( false !== strpos( $value, 'm' ) ) { |
|
30 | + $bytes *= MB_IN_BYTES; |
|
31 | + } elseif ( false !== strpos( $value, 'k' ) ) { |
|
32 | + $bytes *= KB_IN_BYTES; |
|
33 | + } |
|
34 | 34 | |
35 | - // Deal with large (float) values which run into the maximum integer size. |
|
36 | - return min( $bytes, PHP_INT_MAX ); |
|
37 | - } |
|
35 | + // Deal with large (float) values which run into the maximum integer size. |
|
36 | + return min( $bytes, PHP_INT_MAX ); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Attempts to raise the PHP memory limit for memory intensive processes. |
|
41 | - * |
|
42 | - * Only allows raising the existing limit and prevents lowering it. |
|
43 | - * |
|
44 | - * Wrapper for wp_raise_memory_limit(), added in WordPress v4.6.0 |
|
45 | - * |
|
46 | - * @return bool|int|string The limit that was set or false on failure. |
|
47 | - */ |
|
48 | - public static function raise_memory_limit() { |
|
49 | - if ( function_exists( 'wp_raise_memory_limit' ) ) { |
|
50 | - return wp_raise_memory_limit( 'admin' ); |
|
51 | - } |
|
39 | + /** |
|
40 | + * Attempts to raise the PHP memory limit for memory intensive processes. |
|
41 | + * |
|
42 | + * Only allows raising the existing limit and prevents lowering it. |
|
43 | + * |
|
44 | + * Wrapper for wp_raise_memory_limit(), added in WordPress v4.6.0 |
|
45 | + * |
|
46 | + * @return bool|int|string The limit that was set or false on failure. |
|
47 | + */ |
|
48 | + public static function raise_memory_limit() { |
|
49 | + if ( function_exists( 'wp_raise_memory_limit' ) ) { |
|
50 | + return wp_raise_memory_limit( 'admin' ); |
|
51 | + } |
|
52 | 52 | |
53 | - $current_limit = @ini_get( 'memory_limit' ); |
|
54 | - $current_limit_int = self::convert_hr_to_bytes( $current_limit ); |
|
53 | + $current_limit = @ini_get( 'memory_limit' ); |
|
54 | + $current_limit_int = self::convert_hr_to_bytes( $current_limit ); |
|
55 | 55 | |
56 | - if ( -1 === $current_limit_int ) { |
|
57 | - return false; |
|
58 | - } |
|
56 | + if ( -1 === $current_limit_int ) { |
|
57 | + return false; |
|
58 | + } |
|
59 | 59 | |
60 | - $wp_max_limit = WP_MAX_MEMORY_LIMIT; |
|
61 | - $wp_max_limit_int = self::convert_hr_to_bytes( $wp_max_limit ); |
|
62 | - $filtered_limit = apply_filters( 'admin_memory_limit', $wp_max_limit ); |
|
63 | - $filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit ); |
|
60 | + $wp_max_limit = WP_MAX_MEMORY_LIMIT; |
|
61 | + $wp_max_limit_int = self::convert_hr_to_bytes( $wp_max_limit ); |
|
62 | + $filtered_limit = apply_filters( 'admin_memory_limit', $wp_max_limit ); |
|
63 | + $filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit ); |
|
64 | 64 | |
65 | - if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { |
|
66 | - if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) { |
|
67 | - return $filtered_limit; |
|
68 | - } else { |
|
69 | - return false; |
|
70 | - } |
|
71 | - } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { |
|
72 | - if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) { |
|
73 | - return $wp_max_limit; |
|
74 | - } else { |
|
75 | - return false; |
|
76 | - } |
|
77 | - } |
|
78 | - return false; |
|
79 | - } |
|
65 | + if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { |
|
66 | + if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) { |
|
67 | + return $filtered_limit; |
|
68 | + } else { |
|
69 | + return false; |
|
70 | + } |
|
71 | + } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { |
|
72 | + if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) { |
|
73 | + return $wp_max_limit; |
|
74 | + } else { |
|
75 | + return false; |
|
76 | + } |
|
77 | + } |
|
78 | + return false; |
|
79 | + } |
|
80 | 80 | |
81 | - /** |
|
82 | - * Attempts to raise the PHP timeout for time intensive processes. |
|
83 | - * |
|
84 | - * Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available. |
|
85 | - * |
|
86 | - * @param int The time limit in seconds. |
|
87 | - */ |
|
88 | - public static function raise_time_limit( $limit = 0 ) { |
|
89 | - if ( $limit < ini_get( 'max_execution_time' ) ) { |
|
90 | - return; |
|
91 | - } |
|
81 | + /** |
|
82 | + * Attempts to raise the PHP timeout for time intensive processes. |
|
83 | + * |
|
84 | + * Only allows raising the existing limit and prevents lowering it. Wrapper for wc_set_time_limit(), when available. |
|
85 | + * |
|
86 | + * @param int The time limit in seconds. |
|
87 | + */ |
|
88 | + public static function raise_time_limit( $limit = 0 ) { |
|
89 | + if ( $limit < ini_get( 'max_execution_time' ) ) { |
|
90 | + return; |
|
91 | + } |
|
92 | 92 | |
93 | - if ( function_exists( 'wc_set_time_limit' ) ) { |
|
94 | - wc_set_time_limit( $limit ); |
|
95 | - } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
96 | - @set_time_limit( $limit ); |
|
97 | - } |
|
98 | - } |
|
93 | + if ( function_exists( 'wc_set_time_limit' ) ) { |
|
94 | + wc_set_time_limit( $limit ); |
|
95 | + } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
96 | + @set_time_limit( $limit ); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | } |
@@ -16,24 +16,24 @@ discard block |
||
16 | 16 | * @param string $value A (PHP ini) byte value, either shorthand or ordinary. |
17 | 17 | * @return int An integer byte value. |
18 | 18 | */ |
19 | - public static function convert_hr_to_bytes( $value ) { |
|
20 | - if ( function_exists( 'wp_convert_hr_to_bytes' ) ) { |
|
21 | - return wp_convert_hr_to_bytes( $value ); |
|
19 | + public static function convert_hr_to_bytes($value) { |
|
20 | + if (function_exists('wp_convert_hr_to_bytes')) { |
|
21 | + return wp_convert_hr_to_bytes($value); |
|
22 | 22 | } |
23 | 23 | |
24 | - $value = strtolower( trim( $value ) ); |
|
24 | + $value = strtolower(trim($value)); |
|
25 | 25 | $bytes = (int) $value; |
26 | 26 | |
27 | - if ( false !== strpos( $value, 'g' ) ) { |
|
27 | + if (false !== strpos($value, 'g')) { |
|
28 | 28 | $bytes *= GB_IN_BYTES; |
29 | - } elseif ( false !== strpos( $value, 'm' ) ) { |
|
29 | + } elseif (false !== strpos($value, 'm')) { |
|
30 | 30 | $bytes *= MB_IN_BYTES; |
31 | - } elseif ( false !== strpos( $value, 'k' ) ) { |
|
31 | + } elseif (false !== strpos($value, 'k')) { |
|
32 | 32 | $bytes *= KB_IN_BYTES; |
33 | 33 | } |
34 | 34 | |
35 | 35 | // Deal with large (float) values which run into the maximum integer size. |
36 | - return min( $bytes, PHP_INT_MAX ); |
|
36 | + return min($bytes, PHP_INT_MAX); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -46,30 +46,30 @@ discard block |
||
46 | 46 | * @return bool|int|string The limit that was set or false on failure. |
47 | 47 | */ |
48 | 48 | public static function raise_memory_limit() { |
49 | - if ( function_exists( 'wp_raise_memory_limit' ) ) { |
|
50 | - return wp_raise_memory_limit( 'admin' ); |
|
49 | + if (function_exists('wp_raise_memory_limit')) { |
|
50 | + return wp_raise_memory_limit('admin'); |
|
51 | 51 | } |
52 | 52 | |
53 | - $current_limit = @ini_get( 'memory_limit' ); |
|
54 | - $current_limit_int = self::convert_hr_to_bytes( $current_limit ); |
|
53 | + $current_limit = @ini_get('memory_limit'); |
|
54 | + $current_limit_int = self::convert_hr_to_bytes($current_limit); |
|
55 | 55 | |
56 | 56 | if ( -1 === $current_limit_int ) { |
57 | 57 | return false; |
58 | 58 | } |
59 | 59 | |
60 | 60 | $wp_max_limit = WP_MAX_MEMORY_LIMIT; |
61 | - $wp_max_limit_int = self::convert_hr_to_bytes( $wp_max_limit ); |
|
62 | - $filtered_limit = apply_filters( 'admin_memory_limit', $wp_max_limit ); |
|
63 | - $filtered_limit_int = self::convert_hr_to_bytes( $filtered_limit ); |
|
61 | + $wp_max_limit_int = self::convert_hr_to_bytes($wp_max_limit); |
|
62 | + $filtered_limit = apply_filters('admin_memory_limit', $wp_max_limit); |
|
63 | + $filtered_limit_int = self::convert_hr_to_bytes($filtered_limit); |
|
64 | 64 | |
65 | - if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { |
|
66 | - if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) { |
|
65 | + if ( -1 === $filtered_limit_int || ($filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int) ) { |
|
66 | + if (false !== @ini_set('memory_limit', $filtered_limit)) { |
|
67 | 67 | return $filtered_limit; |
68 | 68 | } else { |
69 | 69 | return false; |
70 | 70 | } |
71 | 71 | } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { |
72 | - if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) { |
|
72 | + if (false !== @ini_set('memory_limit', $wp_max_limit)) { |
|
73 | 73 | return $wp_max_limit; |
74 | 74 | } else { |
75 | 75 | return false; |
@@ -85,15 +85,15 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @param int The time limit in seconds. |
87 | 87 | */ |
88 | - public static function raise_time_limit( $limit = 0 ) { |
|
89 | - if ( $limit < ini_get( 'max_execution_time' ) ) { |
|
88 | + public static function raise_time_limit($limit = 0) { |
|
89 | + if ($limit < ini_get('max_execution_time')) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - if ( function_exists( 'wc_set_time_limit' ) ) { |
|
94 | - wc_set_time_limit( $limit ); |
|
95 | - } elseif ( function_exists( 'set_time_limit' ) && false === strpos( ini_get( 'disable_functions' ), 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
96 | - @set_time_limit( $limit ); |
|
93 | + if (function_exists('wc_set_time_limit')) { |
|
94 | + wc_set_time_limit($limit); |
|
95 | + } elseif (function_exists('set_time_limit') && false === strpos(ini_get('disable_functions'), 'set_time_limit') && !ini_get('safe_mode')) { |
|
96 | + @set_time_limit($limit); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 | } |
@@ -14,157 +14,157 @@ |
||
14 | 14 | |
15 | 15 | if ( ! class_exists( 'WP_Async_Request' ) ) { |
16 | 16 | |
17 | - /** |
|
18 | - * Abstract WP_Async_Request class. |
|
19 | - * |
|
20 | - * @abstract |
|
21 | - */ |
|
22 | - abstract class WP_Async_Request { |
|
23 | - |
|
24 | - /** |
|
25 | - * Prefix |
|
26 | - * |
|
27 | - * (default value: 'wp') |
|
28 | - * |
|
29 | - * @var string |
|
30 | - * @access protected |
|
31 | - */ |
|
32 | - protected $prefix = 'wp'; |
|
33 | - |
|
34 | - /** |
|
35 | - * Action |
|
36 | - * |
|
37 | - * (default value: 'async_request') |
|
38 | - * |
|
39 | - * @var string |
|
40 | - * @access protected |
|
41 | - */ |
|
42 | - protected $action = 'async_request'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Identifier |
|
46 | - * |
|
47 | - * @var mixed |
|
48 | - * @access protected |
|
49 | - */ |
|
50 | - protected $identifier; |
|
51 | - |
|
52 | - /** |
|
53 | - * Data |
|
54 | - * |
|
55 | - * (default value: array()) |
|
56 | - * |
|
57 | - * @var array |
|
58 | - * @access protected |
|
59 | - */ |
|
60 | - protected $data = array(); |
|
61 | - |
|
62 | - /** |
|
63 | - * Initiate new async request |
|
64 | - */ |
|
65 | - public function __construct() { |
|
66 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
67 | - |
|
68 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
69 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
70 | - } |
|
71 | - |
|
72 | - /** |
|
73 | - * Set data used during the request |
|
74 | - * |
|
75 | - * @param array $data Data. |
|
76 | - * |
|
77 | - * @return $this |
|
78 | - */ |
|
79 | - public function data( $data ) { |
|
80 | - $this->data = $data; |
|
81 | - |
|
82 | - return $this; |
|
83 | - } |
|
84 | - |
|
85 | - /** |
|
86 | - * Dispatch the async request |
|
87 | - * |
|
88 | - * @return array|WP_Error |
|
89 | - */ |
|
90 | - public function dispatch() { |
|
91 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
92 | - $args = $this->get_post_args(); |
|
93 | - |
|
94 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Get query args |
|
99 | - * |
|
100 | - * @return array |
|
101 | - */ |
|
102 | - protected function get_query_args() { |
|
103 | - if ( property_exists( $this, 'query_args' ) ) { |
|
104 | - return $this->query_args; |
|
105 | - } |
|
106 | - |
|
107 | - return array( |
|
108 | - 'action' => $this->identifier, |
|
109 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
110 | - ); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Get query URL |
|
115 | - * |
|
116 | - * @return string |
|
117 | - */ |
|
118 | - protected function get_query_url() { |
|
119 | - if ( property_exists( $this, 'query_url' ) ) { |
|
120 | - return $this->query_url; |
|
121 | - } |
|
122 | - |
|
123 | - return admin_url( 'admin-ajax.php' ); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Get post args |
|
128 | - * |
|
129 | - * @return array |
|
130 | - */ |
|
131 | - protected function get_post_args() { |
|
132 | - if ( property_exists( $this, 'post_args' ) ) { |
|
133 | - return $this->post_args; |
|
134 | - } |
|
135 | - |
|
136 | - return array( |
|
137 | - 'timeout' => 0.01, |
|
138 | - 'blocking' => false, |
|
139 | - 'body' => $this->data, |
|
140 | - 'cookies' => $_COOKIE, |
|
141 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Maybe handle |
|
147 | - * |
|
148 | - * Check for correct nonce and pass to handler. |
|
149 | - */ |
|
150 | - public function maybe_handle() { |
|
151 | - // Don't lock up other requests while processing |
|
152 | - session_write_close(); |
|
153 | - |
|
154 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
155 | - |
|
156 | - $this->handle(); |
|
157 | - |
|
158 | - wp_die(); |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Handle |
|
163 | - * |
|
164 | - * Override this method to perform any actions required |
|
165 | - * during the async request. |
|
166 | - */ |
|
167 | - abstract protected function handle(); |
|
168 | - |
|
169 | - } |
|
17 | + /** |
|
18 | + * Abstract WP_Async_Request class. |
|
19 | + * |
|
20 | + * @abstract |
|
21 | + */ |
|
22 | + abstract class WP_Async_Request { |
|
23 | + |
|
24 | + /** |
|
25 | + * Prefix |
|
26 | + * |
|
27 | + * (default value: 'wp') |
|
28 | + * |
|
29 | + * @var string |
|
30 | + * @access protected |
|
31 | + */ |
|
32 | + protected $prefix = 'wp'; |
|
33 | + |
|
34 | + /** |
|
35 | + * Action |
|
36 | + * |
|
37 | + * (default value: 'async_request') |
|
38 | + * |
|
39 | + * @var string |
|
40 | + * @access protected |
|
41 | + */ |
|
42 | + protected $action = 'async_request'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Identifier |
|
46 | + * |
|
47 | + * @var mixed |
|
48 | + * @access protected |
|
49 | + */ |
|
50 | + protected $identifier; |
|
51 | + |
|
52 | + /** |
|
53 | + * Data |
|
54 | + * |
|
55 | + * (default value: array()) |
|
56 | + * |
|
57 | + * @var array |
|
58 | + * @access protected |
|
59 | + */ |
|
60 | + protected $data = array(); |
|
61 | + |
|
62 | + /** |
|
63 | + * Initiate new async request |
|
64 | + */ |
|
65 | + public function __construct() { |
|
66 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
67 | + |
|
68 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
69 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
70 | + } |
|
71 | + |
|
72 | + /** |
|
73 | + * Set data used during the request |
|
74 | + * |
|
75 | + * @param array $data Data. |
|
76 | + * |
|
77 | + * @return $this |
|
78 | + */ |
|
79 | + public function data( $data ) { |
|
80 | + $this->data = $data; |
|
81 | + |
|
82 | + return $this; |
|
83 | + } |
|
84 | + |
|
85 | + /** |
|
86 | + * Dispatch the async request |
|
87 | + * |
|
88 | + * @return array|WP_Error |
|
89 | + */ |
|
90 | + public function dispatch() { |
|
91 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
92 | + $args = $this->get_post_args(); |
|
93 | + |
|
94 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Get query args |
|
99 | + * |
|
100 | + * @return array |
|
101 | + */ |
|
102 | + protected function get_query_args() { |
|
103 | + if ( property_exists( $this, 'query_args' ) ) { |
|
104 | + return $this->query_args; |
|
105 | + } |
|
106 | + |
|
107 | + return array( |
|
108 | + 'action' => $this->identifier, |
|
109 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
110 | + ); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Get query URL |
|
115 | + * |
|
116 | + * @return string |
|
117 | + */ |
|
118 | + protected function get_query_url() { |
|
119 | + if ( property_exists( $this, 'query_url' ) ) { |
|
120 | + return $this->query_url; |
|
121 | + } |
|
122 | + |
|
123 | + return admin_url( 'admin-ajax.php' ); |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Get post args |
|
128 | + * |
|
129 | + * @return array |
|
130 | + */ |
|
131 | + protected function get_post_args() { |
|
132 | + if ( property_exists( $this, 'post_args' ) ) { |
|
133 | + return $this->post_args; |
|
134 | + } |
|
135 | + |
|
136 | + return array( |
|
137 | + 'timeout' => 0.01, |
|
138 | + 'blocking' => false, |
|
139 | + 'body' => $this->data, |
|
140 | + 'cookies' => $_COOKIE, |
|
141 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Maybe handle |
|
147 | + * |
|
148 | + * Check for correct nonce and pass to handler. |
|
149 | + */ |
|
150 | + public function maybe_handle() { |
|
151 | + // Don't lock up other requests while processing |
|
152 | + session_write_close(); |
|
153 | + |
|
154 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
155 | + |
|
156 | + $this->handle(); |
|
157 | + |
|
158 | + wp_die(); |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Handle |
|
163 | + * |
|
164 | + * Override this method to perform any actions required |
|
165 | + * during the async request. |
|
166 | + */ |
|
167 | + abstract protected function handle(); |
|
168 | + |
|
169 | + } |
|
170 | 170 | } |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | License URI: https://github.com/deliciousbrains/wp-background-processing/commit/126d7945dd3d39f39cb6488ca08fe1fb66cb351a |
13 | 13 | */ |
14 | 14 | |
15 | -if ( ! class_exists( 'WP_Async_Request' ) ) { |
|
15 | +if (!class_exists('WP_Async_Request')) { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Abstract WP_Async_Request class. |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | public function __construct() { |
66 | 66 | $this->identifier = $this->prefix . '_' . $this->action; |
67 | 67 | |
68 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
69 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
68 | + add_action('wp_ajax_' . $this->identifier, array($this, 'maybe_handle')); |
|
69 | + add_action('wp_ajax_nopriv_' . $this->identifier, array($this, 'maybe_handle')); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return $this |
78 | 78 | */ |
79 | - public function data( $data ) { |
|
79 | + public function data($data) { |
|
80 | 80 | $this->data = $data; |
81 | 81 | |
82 | 82 | return $this; |
@@ -88,10 +88,10 @@ discard block |
||
88 | 88 | * @return array|WP_Error |
89 | 89 | */ |
90 | 90 | public function dispatch() { |
91 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
91 | + $url = add_query_arg($this->get_query_args(), $this->get_query_url()); |
|
92 | 92 | $args = $this->get_post_args(); |
93 | 93 | |
94 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
94 | + return wp_remote_post(esc_url_raw($url), $args); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -100,13 +100,13 @@ discard block |
||
100 | 100 | * @return array |
101 | 101 | */ |
102 | 102 | protected function get_query_args() { |
103 | - if ( property_exists( $this, 'query_args' ) ) { |
|
103 | + if (property_exists($this, 'query_args')) { |
|
104 | 104 | return $this->query_args; |
105 | 105 | } |
106 | 106 | |
107 | 107 | return array( |
108 | 108 | 'action' => $this->identifier, |
109 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
109 | + 'nonce' => wp_create_nonce($this->identifier), |
|
110 | 110 | ); |
111 | 111 | } |
112 | 112 | |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | * @return string |
117 | 117 | */ |
118 | 118 | protected function get_query_url() { |
119 | - if ( property_exists( $this, 'query_url' ) ) { |
|
119 | + if (property_exists($this, 'query_url')) { |
|
120 | 120 | return $this->query_url; |
121 | 121 | } |
122 | 122 | |
123 | - return admin_url( 'admin-ajax.php' ); |
|
123 | + return admin_url('admin-ajax.php'); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | * @return array |
130 | 130 | */ |
131 | 131 | protected function get_post_args() { |
132 | - if ( property_exists( $this, 'post_args' ) ) { |
|
132 | + if (property_exists($this, 'post_args')) { |
|
133 | 133 | return $this->post_args; |
134 | 134 | } |
135 | 135 | |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | 'blocking' => false, |
139 | 139 | 'body' => $this->data, |
140 | 140 | 'cookies' => $_COOKIE, |
141 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
141 | + 'sslverify' => apply_filters('https_local_ssl_verify', false), |
|
142 | 142 | ); |
143 | 143 | } |
144 | 144 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | // Don't lock up other requests while processing |
152 | 152 | session_write_close(); |
153 | 153 | |
154 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
154 | + check_ajax_referer($this->identifier, 'nonce'); |
|
155 | 155 | |
156 | 156 | $this->handle(); |
157 | 157 |
@@ -89,7 +89,7 @@ |
||
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
92 | - for ($i = $offset; $i <= $to; $i+= $stepSize) { |
|
92 | + for ($i = $offset; $i <= $to; $i += $stepSize) { |
|
93 | 93 | if ($i == $dateValue) { |
94 | 94 | return true; |
95 | 95 | } |
@@ -240,7 +240,7 @@ |
||
240 | 240 | $currentTime = new DateTime($currentTime); |
241 | 241 | $currentTime->setTime($currentTime->format('H'), $currentTime->format('i'), 0); |
242 | 242 | $currentDate = $currentTime->format('Y-m-d H:i'); |
243 | - $currentTime = (int)($currentTime->getTimestamp()); |
|
243 | + $currentTime = (int) ($currentTime->getTimestamp()); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return $this->getNextRunDate($currentDate, 0, true)->getTimestamp() == $currentTime; |
@@ -12,19 +12,19 @@ |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // MUST have WordPress. |
15 | -if ( !defined( 'WPINC' ) ) { |
|
16 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
15 | +if (!defined('WPINC')) { |
|
16 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
17 | 17 | } |
18 | 18 | |
19 | -if ( !defined( 'WPINV_VERSION' ) ) { |
|
20 | - define( 'WPINV_VERSION', '1.0.18' ); |
|
19 | +if (!defined('WPINV_VERSION')) { |
|
20 | + define('WPINV_VERSION', '1.0.18'); |
|
21 | 21 | } |
22 | 22 | |
23 | -if ( !defined( 'WPINV_PLUGIN_FILE' ) ) { |
|
24 | - define( 'WPINV_PLUGIN_FILE', __FILE__ ); |
|
23 | +if (!defined('WPINV_PLUGIN_FILE')) { |
|
24 | + define('WPINV_PLUGIN_FILE', __FILE__); |
|
25 | 25 | } |
26 | 26 | |
27 | -require plugin_dir_path( __FILE__ ) . 'includes/class-wpinv.php'; |
|
27 | +require plugin_dir_path(__FILE__) . 'includes/class-wpinv.php'; |
|
28 | 28 | |
29 | 29 | function wpinv_run() { |
30 | 30 | global $invoicing; |
@@ -6,33 +6,33 @@ |
||
6 | 6 | |
7 | 7 | class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5 |
8 | 8 | { |
9 | - public static $files = array ( |
|
9 | + public static $files = array( |
|
10 | 10 | 'e8d544c98e79f913e13eae1306ab635e' => __DIR__ . '/..' . '/ayecode/wp-ayecode-ui/ayecode-ui-loader.php', |
11 | 11 | '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php', |
12 | 12 | ); |
13 | 13 | |
14 | - public static $prefixLengthsPsr4 = array ( |
|
14 | + public static $prefixLengthsPsr4 = array( |
|
15 | 15 | 'C' => |
16 | - array ( |
|
16 | + array( |
|
17 | 17 | 'Composer\\Installers\\' => 20, |
18 | 18 | ), |
19 | 19 | ); |
20 | 20 | |
21 | - public static $prefixDirsPsr4 = array ( |
|
21 | + public static $prefixDirsPsr4 = array( |
|
22 | 22 | 'Composer\\Installers\\' => |
23 | - array ( |
|
23 | + array( |
|
24 | 24 | 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', |
25 | 25 | ), |
26 | 26 | ); |
27 | 27 | |
28 | - public static $classMap = array ( |
|
28 | + public static $classMap = array( |
|
29 | 29 | 'AyeCode_Connect_Helper' => __DIR__ . '/..' . '/ayecode/ayecode-connect-helper/ayecode-connect-helper.php', |
30 | 30 | 'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php', |
31 | 31 | ); |
32 | 32 | |
33 | 33 | public static function getInitializer(ClassLoader $loader) |
34 | 34 | { |
35 | - return \Closure::bind(function () use ($loader) { |
|
35 | + return \Closure::bind(function() use ($loader) { |
|
36 | 36 | $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4; |
37 | 37 | $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4; |
38 | 38 | $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap; |
@@ -8,13 +8,13 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | return array( |
14 | 14 | |
15 | 15 | array( |
16 | 16 | |
17 | - 'title' => __( 'My Cool Item', 'invoicing' ), |
|
17 | + 'title' => __('My Cool Item', 'invoicing'), |
|
18 | 18 | 'id' => 'fxhnagzi', |
19 | 19 | 'price' => '999.00', |
20 | 20 | 'recurring' => false, |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | array( |
26 | 26 | |
27 | - 'title' => __( 'Shipping Fee', 'invoicing' ), |
|
27 | + 'title' => __('Shipping Fee', 'invoicing'), |
|
28 | 28 | 'id' => 'rxnymibri', |
29 | 29 | 'price' => '19.99', |
30 | 30 | 'recurring' => false, |
@@ -8,14 +8,14 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | return array( |
14 | 14 | |
15 | 15 | array( |
16 | 16 | |
17 | 17 | 'level' => 'h2', |
18 | - 'text' => __( 'Payment Form', 'invoicing' ), |
|
18 | + 'text' => __('Payment Form', 'invoicing'), |
|
19 | 19 | 'id' => 'uiylyczw', |
20 | 20 | 'name' => 'uiylyczw', |
21 | 21 | 'type' => 'heading' |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | array( |
25 | 25 | |
26 | - 'text' => __( 'Fill the form below to place an order for my cool item', 'invoicing' ), |
|
26 | + 'text' => __('Fill the form below to place an order for my cool item', 'invoicing'), |
|
27 | 27 | 'id' => 'pcvqjj', |
28 | 28 | 'name' => 'pcvqjj', |
29 | 29 | 'type' => 'paragraph' |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | 'placeholder' => 'Jon', |
36 | 36 | 'value' => '', |
37 | - 'label' => __( 'First Name', 'invoicing' ), |
|
37 | + 'label' => __('First Name', 'invoicing'), |
|
38 | 38 | 'description' => '', |
39 | 39 | 'required' => false, |
40 | 40 | 'id' => 'ynkzkjyc', |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | |
48 | 48 | 'placeholder' => 'Snow', |
49 | 49 | 'value' => '', |
50 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
50 | + 'label' => __('Last Name', 'invoicing'), |
|
51 | 51 | 'description' => '', |
52 | 52 | 'required' => false, |
53 | 53 | 'id' => 'wfjcdmzox', |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | 'placeholder' => '[email protected]', |
62 | 62 | 'value' => '', |
63 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
63 | + 'label' => __('Billing Email', 'invoicing'), |
|
64 | 64 | 'description' => '', |
65 | 65 | 'required' => true, |
66 | 66 | 'id' => 'mmdwqzpox', |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | |
86 | 86 | 'value' =>'', |
87 | 87 | 'class' => 'btn-primary', |
88 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
89 | - 'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
88 | + 'label' => __('Pay Now »', 'invoicing'), |
|
89 | + 'description' => __('By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
90 | 90 | 'id' => 'rtqljyy', |
91 | 91 | 'name' => 'rtqljyy', |
92 | 92 | 'type' => 'pay_button', |
@@ -16,23 +16,23 @@ discard block |
||
16 | 16 | */ |
17 | 17 | public function __construct() { |
18 | 18 | |
19 | - $forms = get_posts( |
|
20 | - array( |
|
21 | - 'post_type' => 'wpi_payment_form', |
|
22 | - 'orderby' => 'title', |
|
23 | - 'order' => 'ASC', |
|
24 | - 'posts_per_page' => -1, |
|
25 | - 'post_status' => array( 'publish' ), |
|
26 | - ) |
|
27 | - ); |
|
28 | - |
|
29 | - $options = array( |
|
30 | - '' => __('Select a Form','invoicing') |
|
31 | - ); |
|
32 | - |
|
33 | - foreach( $forms as $form ) { |
|
34 | - $options[ $form->ID ] = $form->post_title; |
|
35 | - } |
|
19 | + $forms = get_posts( |
|
20 | + array( |
|
21 | + 'post_type' => 'wpi_payment_form', |
|
22 | + 'orderby' => 'title', |
|
23 | + 'order' => 'ASC', |
|
24 | + 'posts_per_page' => -1, |
|
25 | + 'post_status' => array( 'publish' ), |
|
26 | + ) |
|
27 | + ); |
|
28 | + |
|
29 | + $options = array( |
|
30 | + '' => __('Select a Form','invoicing') |
|
31 | + ); |
|
32 | + |
|
33 | + foreach( $forms as $form ) { |
|
34 | + $options[ $form->ID ] = $form->post_title; |
|
35 | + } |
|
36 | 36 | |
37 | 37 | $options = array( |
38 | 38 | 'textdomain' => 'invoicing', |
@@ -50,8 +50,8 @@ discard block |
||
50 | 50 | 'form' => array( |
51 | 51 | 'title' => __( 'Payment Form', 'invoicing' ), |
52 | 52 | 'desc' => __( 'Select your payment form.', 'invoicing' ), |
53 | - 'type' => 'select', |
|
54 | - 'options' => $options, |
|
53 | + 'type' => 'select', |
|
54 | + 'options' => $options, |
|
55 | 55 | 'desc_tip' => true, |
56 | 56 | 'default' => '', |
57 | 57 | 'advanced' => false |
@@ -64,59 +64,59 @@ discard block |
||
64 | 64 | parent::__construct( $options ); |
65 | 65 | } |
66 | 66 | |
67 | - /** |
|
68 | - * The Super block output function. |
|
69 | - * |
|
70 | - * @param array $args |
|
71 | - * @param array $widget_args |
|
72 | - * @param string $content |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
67 | + /** |
|
68 | + * The Super block output function. |
|
69 | + * |
|
70 | + * @param array $args |
|
71 | + * @param array $widget_args |
|
72 | + * @param string $content |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | 76 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
77 | - global $invoicing; |
|
78 | - |
|
79 | - // Do we have a payment form? |
|
80 | - if ( empty( $args['form'] ) ) { |
|
81 | - return aui()->alert( |
|
82 | - array( |
|
83 | - 'type' => 'warning', |
|
84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
85 | - ) |
|
86 | - ); |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - // If yes, ensure that it is published. |
|
91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
92 | - return aui()->alert( |
|
93 | - array( |
|
94 | - 'type' => 'warning', |
|
95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
96 | - ) |
|
97 | - ); |
|
98 | - } |
|
99 | - |
|
100 | - // Get the form elements and items. |
|
101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
103 | - |
|
104 | - ob_start(); |
|
105 | - echo "<form class='wpinv_payment_form'>"; |
|
106 | - echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
108 | - |
|
109 | - foreach ( $elements as $element ) { |
|
110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
112 | - } |
|
113 | - |
|
114 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
115 | - echo '</form>'; |
|
116 | - |
|
117 | - $content = ob_get_clean(); |
|
77 | + global $invoicing; |
|
78 | + |
|
79 | + // Do we have a payment form? |
|
80 | + if ( empty( $args['form'] ) ) { |
|
81 | + return aui()->alert( |
|
82 | + array( |
|
83 | + 'type' => 'warning', |
|
84 | + 'content' => __( 'No payment form selected', 'invoicing' ), |
|
85 | + ) |
|
86 | + ); |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + // If yes, ensure that it is published. |
|
91 | + if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
92 | + return aui()->alert( |
|
93 | + array( |
|
94 | + 'type' => 'warning', |
|
95 | + 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
96 | + ) |
|
97 | + ); |
|
98 | + } |
|
99 | + |
|
100 | + // Get the form elements and items. |
|
101 | + $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
102 | + $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
103 | + |
|
104 | + ob_start(); |
|
105 | + echo "<form class='wpinv_payment_form'>"; |
|
106 | + echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
|
107 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
108 | + |
|
109 | + foreach ( $elements as $element ) { |
|
110 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
111 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
112 | + } |
|
113 | + |
|
114 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
115 | + echo '</form>'; |
|
116 | + |
|
117 | + $content = ob_get_clean(); |
|
118 | 118 | |
119 | - return str_replace( 'sr-only', '', $content ); |
|
119 | + return str_replace( 'sr-only', '', $content ); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | 4 | exit; // Exit if accessed directly |
5 | 5 | } |
6 | 6 | |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | 'orderby' => 'title', |
23 | 23 | 'order' => 'ASC', |
24 | 24 | 'posts_per_page' => -1, |
25 | - 'post_status' => array( 'publish' ), |
|
25 | + 'post_status' => array('publish'), |
|
26 | 26 | ) |
27 | 27 | ); |
28 | 28 | |
29 | 29 | $options = array( |
30 | - '' => __('Select a Form','invoicing') |
|
30 | + '' => __('Select a Form', 'invoicing') |
|
31 | 31 | ); |
32 | 32 | |
33 | - foreach( $forms as $form ) { |
|
34 | - $options[ $form->ID ] = $form->post_title; |
|
33 | + foreach ($forms as $form) { |
|
34 | + $options[$form->ID] = $form->post_title; |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | $options = array( |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'pay', 'payment form']", |
42 | 42 | 'class_name' => __CLASS__, |
43 | 43 | 'base_id' => 'wpinv_payment_form', |
44 | - 'name' => __('Invoicing > Payment Form','invoicing'), |
|
44 | + 'name' => __('Invoicing > Payment Form', 'invoicing'), |
|
45 | 45 | 'widget_ops' => array( |
46 | 46 | 'classname' => 'wpinv-payment-form-class bsui', |
47 | - 'description' => esc_html__('Displays a payment form.','invoicing'), |
|
47 | + 'description' => esc_html__('Displays a payment form.', 'invoicing'), |
|
48 | 48 | ), |
49 | 49 | 'arguments' => array( |
50 | 50 | 'form' => array( |
51 | - 'title' => __( 'Payment Form', 'invoicing' ), |
|
52 | - 'desc' => __( 'Select your payment form.', 'invoicing' ), |
|
51 | + 'title' => __('Payment Form', 'invoicing'), |
|
52 | + 'desc' => __('Select your payment form.', 'invoicing'), |
|
53 | 53 | 'type' => 'select', |
54 | 54 | 'options' => $options, |
55 | 55 | 'desc_tip' => true, |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | ); |
62 | 62 | |
63 | 63 | |
64 | - parent::__construct( $options ); |
|
64 | + parent::__construct($options); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -73,42 +73,42 @@ discard block |
||
73 | 73 | * |
74 | 74 | * @return string |
75 | 75 | */ |
76 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
76 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
77 | 77 | global $invoicing; |
78 | 78 | |
79 | 79 | // Do we have a payment form? |
80 | - if ( empty( $args['form'] ) ) { |
|
80 | + if (empty($args['form'])) { |
|
81 | 81 | return aui()->alert( |
82 | 82 | array( |
83 | 83 | 'type' => 'warning', |
84 | - 'content' => __( 'No payment form selected', 'invoicing' ), |
|
84 | + 'content' => __('No payment form selected', 'invoicing'), |
|
85 | 85 | ) |
86 | 86 | ); |
87 | 87 | |
88 | 88 | } |
89 | 89 | |
90 | 90 | // If yes, ensure that it is published. |
91 | - if ( 'publish' != get_post_status( $args['form'] ) ) { |
|
91 | + if ('publish' != get_post_status($args['form'])) { |
|
92 | 92 | return aui()->alert( |
93 | 93 | array( |
94 | 94 | 'type' => 'warning', |
95 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
95 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | } |
99 | 99 | |
100 | 100 | // Get the form elements and items. |
101 | - $elements = $invoicing->form_elements->get_form_elements( $args['form'] ); |
|
102 | - $items = $invoicing->form_elements->get_form_items( $args['form'] ); |
|
101 | + $elements = $invoicing->form_elements->get_form_elements($args['form']); |
|
102 | + $items = $invoicing->form_elements->get_form_items($args['form']); |
|
103 | 103 | |
104 | 104 | ob_start(); |
105 | 105 | echo "<form class='wpinv_payment_form'>"; |
106 | 106 | echo "<input type='hidden' name='form_id' value='{$args['form']}'/>"; |
107 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
107 | + wp_nonce_field('wpinv_payment_form', 'wpinv_payment_form'); |
|
108 | 108 | |
109 | - foreach ( $elements as $element ) { |
|
110 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $args['form'] ); |
|
111 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form'] ); |
|
109 | + foreach ($elements as $element) { |
|
110 | + do_action('wpinv_frontend_render_payment_form_element', $element, $items, $args['form']); |
|
111 | + do_action("wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $args['form']); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | |
117 | 117 | $content = ob_get_clean(); |
118 | 118 | |
119 | - return str_replace( 'sr-only', '', $content ); |
|
119 | + return str_replace('sr-only', '', $content); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 |