@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
16 | - exit; |
|
16 | + exit; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -21,294 +21,294 @@ discard block |
||
21 | 21 | */ |
22 | 22 | if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
23 | 23 | |
24 | - /** |
|
25 | - * A Class to be able to change settings for Font Awesome. |
|
26 | - * |
|
27 | - * Class WP_Font_Awesome_Settings |
|
28 | - * @since 1.0.10 Now able to pass wp.org theme check. |
|
29 | - * @since 1.0.11 Font Awesome Pro now supported. |
|
30 | - * @since 1.0.11 Font Awesome Kits now supported. |
|
31 | - * @ver 1.0.11 |
|
32 | - * @todo decide how to implement textdomain |
|
33 | - */ |
|
34 | - class WP_Font_Awesome_Settings { |
|
35 | - |
|
36 | - /** |
|
37 | - * Class version version. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - */ |
|
41 | - public $version = '1.0.12'; |
|
42 | - |
|
43 | - /** |
|
44 | - * Class textdomain. |
|
45 | - * |
|
46 | - * @var string |
|
47 | - */ |
|
48 | - public $textdomain = 'font-awesome-settings'; |
|
49 | - |
|
50 | - /** |
|
51 | - * Latest version of Font Awesome at time of publish published. |
|
52 | - * |
|
53 | - * @var string |
|
54 | - */ |
|
55 | - public $latest = "5.8.2"; |
|
56 | - |
|
57 | - /** |
|
58 | - * The title. |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - public $name = 'Font Awesome'; |
|
63 | - |
|
64 | - /** |
|
65 | - * Holds the settings values. |
|
66 | - * |
|
67 | - * @var array |
|
68 | - */ |
|
69 | - private $settings; |
|
70 | - |
|
71 | - /** |
|
72 | - * WP_Font_Awesome_Settings instance. |
|
73 | - * |
|
74 | - * @access private |
|
75 | - * @since 1.0.0 |
|
76 | - * @var WP_Font_Awesome_Settings There can be only one! |
|
77 | - */ |
|
78 | - private static $instance = null; |
|
79 | - |
|
80 | - /** |
|
81 | - * Main WP_Font_Awesome_Settings Instance. |
|
82 | - * |
|
83 | - * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
84 | - * |
|
85 | - * @since 1.0.0 |
|
86 | - * @static |
|
87 | - * @return WP_Font_Awesome_Settings - Main instance. |
|
88 | - */ |
|
89 | - public static function instance() { |
|
90 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
91 | - self::$instance = new WP_Font_Awesome_Settings; |
|
92 | - |
|
93 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
94 | - |
|
95 | - if ( is_admin() ) { |
|
96 | - add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
97 | - add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
98 | - } |
|
99 | - |
|
100 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
101 | - } |
|
102 | - |
|
103 | - return self::$instance; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Initiate the settings and add the required action hooks. |
|
108 | - * |
|
109 | - * @since 1.0.8 Settings name wrong - FIXED |
|
110 | - */ |
|
111 | - public function init() { |
|
112 | - $this->settings = $this->get_settings(); |
|
113 | - |
|
114 | - if ( $this->settings['type'] == 'CSS' ) { |
|
115 | - |
|
116 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
117 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
118 | - } |
|
119 | - |
|
120 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
121 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
122 | - } |
|
123 | - |
|
124 | - } else { |
|
125 | - |
|
126 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
128 | - } |
|
129 | - |
|
130 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
131 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
132 | - } |
|
133 | - } |
|
134 | - |
|
135 | - // remove font awesome if set to do so |
|
136 | - if ( $this->settings['dequeue'] == '1' ) { |
|
137 | - add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
138 | - } |
|
139 | - |
|
140 | - } |
|
141 | - |
|
142 | - /** |
|
143 | - * Adds the Font Awesome styles. |
|
144 | - */ |
|
145 | - public function enqueue_style() { |
|
146 | - // build url |
|
147 | - $url = $this->get_url(); |
|
148 | - |
|
149 | - wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
150 | - wp_register_style( 'font-awesome', $url, array(), null ); |
|
151 | - wp_enqueue_style( 'font-awesome' ); |
|
152 | - |
|
153 | - if ( $this->settings['shims'] ) { |
|
154 | - $url = $this->get_url( true ); |
|
155 | - wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
156 | - wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
157 | - wp_enqueue_style( 'font-awesome-shims' ); |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - /** |
|
162 | - * Adds the Font Awesome JS. |
|
163 | - */ |
|
164 | - public function enqueue_scripts() { |
|
165 | - // build url |
|
166 | - $url = $this->get_url(); |
|
167 | - |
|
168 | - $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
169 | - call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
170 | - wp_register_script( 'font-awesome', $url, array(), null ); |
|
171 | - wp_enqueue_script( 'font-awesome' ); |
|
172 | - |
|
173 | - if ( $this->settings['shims'] ) { |
|
174 | - $url = $this->get_url( true ); |
|
175 | - call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
176 | - wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
177 | - wp_enqueue_script( 'font-awesome-shims' ); |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - /** |
|
182 | - * Get the url of the Font Awesome files. |
|
183 | - * |
|
184 | - * @param bool $shims If this is a shim file or not. |
|
185 | - * |
|
186 | - * @return string The url to the file. |
|
187 | - */ |
|
188 | - public function get_url( $shims = false ) { |
|
189 | - $script = $shims ? 'v4-shims' : 'all'; |
|
190 | - $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
191 | - $type = $this->settings['type']; |
|
192 | - $version = $this->settings['version']; |
|
193 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
194 | - $url = ''; |
|
195 | - |
|
196 | - if ( $type == 'KIT' && $kit_url ) { |
|
197 | - if ( $shims ) { |
|
198 | - // if its a kit then we don't add shims here |
|
199 | - return ''; |
|
200 | - } |
|
201 | - $url .= $kit_url; // CDN |
|
202 | - $url .= "?wpfas=true"; // set our var so our version is not removed |
|
203 | - } else { |
|
204 | - $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
205 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
206 | - $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
207 | - $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
208 | - $url .= "?wpfas=true"; // set our var so our version is not removed |
|
209 | - } |
|
210 | - |
|
211 | - return $url; |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
216 | - * |
|
217 | - * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
218 | - * |
|
219 | - * @param $url |
|
220 | - * @param $original_url |
|
221 | - * @param $_context |
|
222 | - * |
|
223 | - * @return string The filtered url. |
|
224 | - */ |
|
225 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
226 | - |
|
227 | - if ( $_context == 'display' |
|
228 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
229 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
230 | - ) {// it's a font-awesome-url (probably) |
|
231 | - |
|
232 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
233 | - if ( $this->settings['type'] == 'JS' ) { |
|
234 | - if ( $this->settings['js-pseudo'] ) { |
|
235 | - $url .= "' data-search-pseudo-elements defer='defer"; |
|
236 | - } else { |
|
237 | - $url .= "' defer='defer"; |
|
238 | - } |
|
239 | - } |
|
240 | - } else { |
|
241 | - $url = ''; // removing the url removes the file |
|
242 | - } |
|
243 | - |
|
244 | - } |
|
245 | - |
|
246 | - return $url; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Register the database settings with WordPress. |
|
251 | - */ |
|
252 | - public function register_settings() { |
|
253 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
254 | - } |
|
255 | - |
|
256 | - /** |
|
257 | - * Add the WordPress settings menu item. |
|
258 | - * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
259 | - */ |
|
260 | - public function menu_item() { |
|
261 | - $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
262 | - call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
263 | - $this, |
|
264 | - 'settings_page' |
|
265 | - ) ); |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Get the current Font Awesome output settings. |
|
270 | - * |
|
271 | - * @return array The array of settings. |
|
272 | - */ |
|
273 | - public function get_settings() { |
|
274 | - |
|
275 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
276 | - |
|
277 | - $defaults = array( |
|
278 | - 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
279 | - 'version' => '', // latest |
|
280 | - 'enqueue' => '', // front and backend |
|
281 | - 'shims' => '0', // default OFF now in 2020 |
|
282 | - 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
283 | - 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
284 | - 'pro' => '0', // if pro CDN url should be used |
|
285 | - 'kit-url' => '', // the kit url |
|
286 | - ); |
|
287 | - |
|
288 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
289 | - |
|
290 | - /** |
|
291 | - * Filter the Font Awesome settings. |
|
292 | - * |
|
293 | - * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
294 | - */ |
|
295 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
296 | - } |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * The settings page html output. |
|
301 | - */ |
|
302 | - public function settings_page() { |
|
303 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
304 | - wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
305 | - } |
|
306 | - |
|
307 | - // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours |
|
308 | - if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
309 | - $this->get_latest_version( $force_api = true ); |
|
310 | - } |
|
311 | - ?> |
|
24 | + /** |
|
25 | + * A Class to be able to change settings for Font Awesome. |
|
26 | + * |
|
27 | + * Class WP_Font_Awesome_Settings |
|
28 | + * @since 1.0.10 Now able to pass wp.org theme check. |
|
29 | + * @since 1.0.11 Font Awesome Pro now supported. |
|
30 | + * @since 1.0.11 Font Awesome Kits now supported. |
|
31 | + * @ver 1.0.11 |
|
32 | + * @todo decide how to implement textdomain |
|
33 | + */ |
|
34 | + class WP_Font_Awesome_Settings { |
|
35 | + |
|
36 | + /** |
|
37 | + * Class version version. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + */ |
|
41 | + public $version = '1.0.12'; |
|
42 | + |
|
43 | + /** |
|
44 | + * Class textdomain. |
|
45 | + * |
|
46 | + * @var string |
|
47 | + */ |
|
48 | + public $textdomain = 'font-awesome-settings'; |
|
49 | + |
|
50 | + /** |
|
51 | + * Latest version of Font Awesome at time of publish published. |
|
52 | + * |
|
53 | + * @var string |
|
54 | + */ |
|
55 | + public $latest = "5.8.2"; |
|
56 | + |
|
57 | + /** |
|
58 | + * The title. |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + public $name = 'Font Awesome'; |
|
63 | + |
|
64 | + /** |
|
65 | + * Holds the settings values. |
|
66 | + * |
|
67 | + * @var array |
|
68 | + */ |
|
69 | + private $settings; |
|
70 | + |
|
71 | + /** |
|
72 | + * WP_Font_Awesome_Settings instance. |
|
73 | + * |
|
74 | + * @access private |
|
75 | + * @since 1.0.0 |
|
76 | + * @var WP_Font_Awesome_Settings There can be only one! |
|
77 | + */ |
|
78 | + private static $instance = null; |
|
79 | + |
|
80 | + /** |
|
81 | + * Main WP_Font_Awesome_Settings Instance. |
|
82 | + * |
|
83 | + * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded. |
|
84 | + * |
|
85 | + * @since 1.0.0 |
|
86 | + * @static |
|
87 | + * @return WP_Font_Awesome_Settings - Main instance. |
|
88 | + */ |
|
89 | + public static function instance() { |
|
90 | + if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
91 | + self::$instance = new WP_Font_Awesome_Settings; |
|
92 | + |
|
93 | + add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
94 | + |
|
95 | + if ( is_admin() ) { |
|
96 | + add_action( 'admin_menu', array( self::$instance, 'menu_item' ) ); |
|
97 | + add_action( 'admin_init', array( self::$instance, 'register_settings' ) ); |
|
98 | + } |
|
99 | + |
|
100 | + do_action( 'wp_font_awesome_settings_loaded' ); |
|
101 | + } |
|
102 | + |
|
103 | + return self::$instance; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Initiate the settings and add the required action hooks. |
|
108 | + * |
|
109 | + * @since 1.0.8 Settings name wrong - FIXED |
|
110 | + */ |
|
111 | + public function init() { |
|
112 | + $this->settings = $this->get_settings(); |
|
113 | + |
|
114 | + if ( $this->settings['type'] == 'CSS' ) { |
|
115 | + |
|
116 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
117 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
118 | + } |
|
119 | + |
|
120 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
121 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
122 | + } |
|
123 | + |
|
124 | + } else { |
|
125 | + |
|
126 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
127 | + add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
128 | + } |
|
129 | + |
|
130 | + if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
131 | + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
132 | + } |
|
133 | + } |
|
134 | + |
|
135 | + // remove font awesome if set to do so |
|
136 | + if ( $this->settings['dequeue'] == '1' ) { |
|
137 | + add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 ); |
|
138 | + } |
|
139 | + |
|
140 | + } |
|
141 | + |
|
142 | + /** |
|
143 | + * Adds the Font Awesome styles. |
|
144 | + */ |
|
145 | + public function enqueue_style() { |
|
146 | + // build url |
|
147 | + $url = $this->get_url(); |
|
148 | + |
|
149 | + wp_deregister_style( 'font-awesome' ); // deregister in case its already there |
|
150 | + wp_register_style( 'font-awesome', $url, array(), null ); |
|
151 | + wp_enqueue_style( 'font-awesome' ); |
|
152 | + |
|
153 | + if ( $this->settings['shims'] ) { |
|
154 | + $url = $this->get_url( true ); |
|
155 | + wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there |
|
156 | + wp_register_style( 'font-awesome-shims', $url, array(), null ); |
|
157 | + wp_enqueue_style( 'font-awesome-shims' ); |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + /** |
|
162 | + * Adds the Font Awesome JS. |
|
163 | + */ |
|
164 | + public function enqueue_scripts() { |
|
165 | + // build url |
|
166 | + $url = $this->get_url(); |
|
167 | + |
|
168 | + $deregister_function = 'wp' . '_' . 'deregister' . '_' . 'script'; |
|
169 | + call_user_func( $deregister_function, 'font-awesome' ); // deregister in case its already there |
|
170 | + wp_register_script( 'font-awesome', $url, array(), null ); |
|
171 | + wp_enqueue_script( 'font-awesome' ); |
|
172 | + |
|
173 | + if ( $this->settings['shims'] ) { |
|
174 | + $url = $this->get_url( true ); |
|
175 | + call_user_func( $deregister_function, 'font-awesome-shims' ); // deregister in case its already there |
|
176 | + wp_register_script( 'font-awesome-shims', $url, array(), null ); |
|
177 | + wp_enqueue_script( 'font-awesome-shims' ); |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + /** |
|
182 | + * Get the url of the Font Awesome files. |
|
183 | + * |
|
184 | + * @param bool $shims If this is a shim file or not. |
|
185 | + * |
|
186 | + * @return string The url to the file. |
|
187 | + */ |
|
188 | + public function get_url( $shims = false ) { |
|
189 | + $script = $shims ? 'v4-shims' : 'all'; |
|
190 | + $sub = $this->settings['pro'] ? 'pro' : 'use'; |
|
191 | + $type = $this->settings['type']; |
|
192 | + $version = $this->settings['version']; |
|
193 | + $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
194 | + $url = ''; |
|
195 | + |
|
196 | + if ( $type == 'KIT' && $kit_url ) { |
|
197 | + if ( $shims ) { |
|
198 | + // if its a kit then we don't add shims here |
|
199 | + return ''; |
|
200 | + } |
|
201 | + $url .= $kit_url; // CDN |
|
202 | + $url .= "?wpfas=true"; // set our var so our version is not removed |
|
203 | + } else { |
|
204 | + $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
|
205 | + $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
206 | + $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
|
207 | + $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
|
208 | + $url .= "?wpfas=true"; // set our var so our version is not removed |
|
209 | + } |
|
210 | + |
|
211 | + return $url; |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Try and remove any other versions of Font Awesome added by other plugins/themes. |
|
216 | + * |
|
217 | + * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version. |
|
218 | + * |
|
219 | + * @param $url |
|
220 | + * @param $original_url |
|
221 | + * @param $_context |
|
222 | + * |
|
223 | + * @return string The filtered url. |
|
224 | + */ |
|
225 | + public function remove_font_awesome( $url, $original_url, $_context ) { |
|
226 | + |
|
227 | + if ( $_context == 'display' |
|
228 | + && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
229 | + && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
230 | + ) {// it's a font-awesome-url (probably) |
|
231 | + |
|
232 | + if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
233 | + if ( $this->settings['type'] == 'JS' ) { |
|
234 | + if ( $this->settings['js-pseudo'] ) { |
|
235 | + $url .= "' data-search-pseudo-elements defer='defer"; |
|
236 | + } else { |
|
237 | + $url .= "' defer='defer"; |
|
238 | + } |
|
239 | + } |
|
240 | + } else { |
|
241 | + $url = ''; // removing the url removes the file |
|
242 | + } |
|
243 | + |
|
244 | + } |
|
245 | + |
|
246 | + return $url; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Register the database settings with WordPress. |
|
251 | + */ |
|
252 | + public function register_settings() { |
|
253 | + register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
254 | + } |
|
255 | + |
|
256 | + /** |
|
257 | + * Add the WordPress settings menu item. |
|
258 | + * @since 1.0.10 Calling function name direct will fail theme check so we don't. |
|
259 | + */ |
|
260 | + public function menu_item() { |
|
261 | + $menu_function = 'add' . '_' . 'options' . '_' . 'page'; // won't pass theme check if function name present in theme |
|
262 | + call_user_func( $menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
263 | + $this, |
|
264 | + 'settings_page' |
|
265 | + ) ); |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Get the current Font Awesome output settings. |
|
270 | + * |
|
271 | + * @return array The array of settings. |
|
272 | + */ |
|
273 | + public function get_settings() { |
|
274 | + |
|
275 | + $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
276 | + |
|
277 | + $defaults = array( |
|
278 | + 'type' => 'CSS', // type to use, CSS or JS or KIT |
|
279 | + 'version' => '', // latest |
|
280 | + 'enqueue' => '', // front and backend |
|
281 | + 'shims' => '0', // default OFF now in 2020 |
|
282 | + 'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive) |
|
283 | + 'dequeue' => '0', // if we should try to remove other versions added by other plugins/themes |
|
284 | + 'pro' => '0', // if pro CDN url should be used |
|
285 | + 'kit-url' => '', // the kit url |
|
286 | + ); |
|
287 | + |
|
288 | + $settings = wp_parse_args( $db_settings, $defaults ); |
|
289 | + |
|
290 | + /** |
|
291 | + * Filter the Font Awesome settings. |
|
292 | + * |
|
293 | + * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
|
294 | + */ |
|
295 | + return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
296 | + } |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * The settings page html output. |
|
301 | + */ |
|
302 | + public function settings_page() { |
|
303 | + if ( ! current_user_can( 'manage_options' ) ) { |
|
304 | + wp_die( __( 'You do not have sufficient permissions to access this page.', 'font-awesome-settings' ) ); |
|
305 | + } |
|
306 | + |
|
307 | + // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours |
|
308 | + if ( isset( $_REQUEST['force-version-check'] ) ) { |
|
309 | + $this->get_latest_version( $force_api = true ); |
|
310 | + } |
|
311 | + ?> |
|
312 | 312 | <style> |
313 | 313 | .wpfas-kit-show { |
314 | 314 | display: none; |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | <h1><?php echo $this->name; ?></h1> |
327 | 327 | <form method="post" action="options.php"> |
328 | 328 | <?php |
329 | - settings_fields( 'wp-font-awesome-settings' ); |
|
330 | - do_settings_sections( 'wp-font-awesome-settings' ); |
|
331 | - $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
|
332 | - ?> |
|
329 | + settings_fields( 'wp-font-awesome-settings' ); |
|
330 | + do_settings_sections( 'wp-font-awesome-settings' ); |
|
331 | + $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
|
332 | + ?> |
|
333 | 333 | <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>"> |
334 | 334 | <tr valign="top"> |
335 | 335 | <th scope="row"><label |
@@ -355,12 +355,12 @@ discard block |
||
355 | 355 | value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" |
356 | 356 | placeholder="<?php echo 'https://kit.font';echo 'awesome.com/123abc.js'; // this won't pass theme check :(?>"/> |
357 | 357 | <span><?php |
358 | - echo sprintf( |
|
359 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
360 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
361 | - '</a>' |
|
362 | - ); |
|
363 | - ?></span> |
|
358 | + echo sprintf( |
|
359 | + __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
360 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
|
361 | + '</a>' |
|
362 | + ); |
|
363 | + ?></span> |
|
364 | 364 | </td> |
365 | 365 | </tr> |
366 | 366 | |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | <input type="checkbox" name="wp-font-awesome-settings[pro]" |
421 | 421 | value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/> |
422 | 422 | <span><?php |
423 | - echo sprintf( |
|
424 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
425 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
|
426 | - '</a>', |
|
427 | - '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
|
428 | - '</a>' |
|
429 | - ); |
|
430 | - ?></span> |
|
423 | + echo sprintf( |
|
424 | + __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
425 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
|
426 | + '</a>', |
|
427 | + '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
|
428 | + '</a>' |
|
429 | + ); |
|
430 | + ?></span> |
|
431 | 431 | </td> |
432 | 432 | </tr> |
433 | 433 | |
@@ -470,88 +470,88 @@ discard block |
||
470 | 470 | |
471 | 471 | </table> |
472 | 472 | <?php |
473 | - submit_button(); |
|
474 | - ?> |
|
473 | + submit_button(); |
|
474 | + ?> |
|
475 | 475 | </form> |
476 | 476 | |
477 | 477 | <div id="wpfas-version"><?php echo $this->version; ?></div> |
478 | 478 | </div> |
479 | 479 | |
480 | 480 | <?php |
481 | - } |
|
482 | - |
|
483 | - /** |
|
484 | - * Check a version number is valid and if so return it or else return an empty string. |
|
485 | - * |
|
486 | - * @param $version string The version number to check. |
|
487 | - * |
|
488 | - * @since 1.0.6 |
|
489 | - * |
|
490 | - * @return string Either a valid version number or an empty string. |
|
491 | - */ |
|
492 | - public function validate_version_number( $version ) { |
|
493 | - |
|
494 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
495 | - // valid |
|
496 | - } else { |
|
497 | - $version = '';// not validated |
|
498 | - } |
|
499 | - |
|
500 | - return $version; |
|
501 | - } |
|
502 | - |
|
503 | - |
|
504 | - /** |
|
505 | - * Get the latest version of Font Awesome. |
|
506 | - * |
|
507 | - * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours. |
|
508 | - * |
|
509 | - * @since 1.0.7 |
|
510 | - * @return mixed|string The latest version number found. |
|
511 | - */ |
|
512 | - public function get_latest_version( $force_api = false ) { |
|
513 | - $latest_version = $this->latest; |
|
514 | - |
|
515 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
516 | - |
|
517 | - if ( $cache === false || $force_api ) { // its not set |
|
518 | - $api_ver = $this->get_latest_version_from_api(); |
|
519 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
520 | - $latest_version = $api_ver; |
|
521 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
522 | - } |
|
523 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
524 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
525 | - $latest_version = $cache; |
|
526 | - } |
|
527 | - } |
|
528 | - |
|
529 | - return $latest_version; |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * Get the latest Font Awesome version from the github API. |
|
534 | - * |
|
535 | - * @since 1.0.7 |
|
536 | - * @return string The latest version number or `0` on API fail. |
|
537 | - */ |
|
538 | - public function get_latest_version_from_api() { |
|
539 | - $version = "0"; |
|
540 | - $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
541 | - if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
542 | - $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
543 | - if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
544 | - $version = $api_response['tag_name']; |
|
545 | - } |
|
546 | - } |
|
547 | - |
|
548 | - return $version; |
|
549 | - } |
|
550 | - |
|
551 | - } |
|
552 | - |
|
553 | - /** |
|
554 | - * Run the class if found. |
|
555 | - */ |
|
556 | - WP_Font_Awesome_Settings::instance(); |
|
481 | + } |
|
482 | + |
|
483 | + /** |
|
484 | + * Check a version number is valid and if so return it or else return an empty string. |
|
485 | + * |
|
486 | + * @param $version string The version number to check. |
|
487 | + * |
|
488 | + * @since 1.0.6 |
|
489 | + * |
|
490 | + * @return string Either a valid version number or an empty string. |
|
491 | + */ |
|
492 | + public function validate_version_number( $version ) { |
|
493 | + |
|
494 | + if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
495 | + // valid |
|
496 | + } else { |
|
497 | + $version = '';// not validated |
|
498 | + } |
|
499 | + |
|
500 | + return $version; |
|
501 | + } |
|
502 | + |
|
503 | + |
|
504 | + /** |
|
505 | + * Get the latest version of Font Awesome. |
|
506 | + * |
|
507 | + * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours. |
|
508 | + * |
|
509 | + * @since 1.0.7 |
|
510 | + * @return mixed|string The latest version number found. |
|
511 | + */ |
|
512 | + public function get_latest_version( $force_api = false ) { |
|
513 | + $latest_version = $this->latest; |
|
514 | + |
|
515 | + $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
516 | + |
|
517 | + if ( $cache === false || $force_api ) { // its not set |
|
518 | + $api_ver = $this->get_latest_version_from_api(); |
|
519 | + if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
520 | + $latest_version = $api_ver; |
|
521 | + set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
522 | + } |
|
523 | + } elseif ( $this->validate_version_number( $cache ) ) { |
|
524 | + if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
525 | + $latest_version = $cache; |
|
526 | + } |
|
527 | + } |
|
528 | + |
|
529 | + return $latest_version; |
|
530 | + } |
|
531 | + |
|
532 | + /** |
|
533 | + * Get the latest Font Awesome version from the github API. |
|
534 | + * |
|
535 | + * @since 1.0.7 |
|
536 | + * @return string The latest version number or `0` on API fail. |
|
537 | + */ |
|
538 | + public function get_latest_version_from_api() { |
|
539 | + $version = "0"; |
|
540 | + $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" ); |
|
541 | + if ( ! is_wp_error( $response ) && is_array( $response ) ) { |
|
542 | + $api_response = json_decode( wp_remote_retrieve_body( $response ), true ); |
|
543 | + if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) { |
|
544 | + $version = $api_response['tag_name']; |
|
545 | + } |
|
546 | + } |
|
547 | + |
|
548 | + return $version; |
|
549 | + } |
|
550 | + |
|
551 | + } |
|
552 | + |
|
553 | + /** |
|
554 | + * Run the class if found. |
|
555 | + */ |
|
556 | + WP_Font_Awesome_Settings::instance(); |
|
557 | 557 | } |
558 | 558 | \ No newline at end of file |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined( 'ABSPATH' ) ) { |
4 | - exit; // Exit if accessed directly |
|
4 | + exit; // Exit if accessed directly |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -11,77 +11,77 @@ discard block |
||
11 | 11 | */ |
12 | 12 | class AUI_Component_Pagination { |
13 | 13 | |
14 | - /** |
|
15 | - * Build the component. |
|
16 | - * |
|
17 | - * @param array $args |
|
18 | - * |
|
19 | - * @return string The rendered component. |
|
20 | - */ |
|
21 | - public static function get( $args = array() ) { |
|
22 | - global $wp_query; |
|
23 | - |
|
24 | - $defaults = array( |
|
25 | - 'class' => '', |
|
26 | - 'mid_size' => 2, |
|
27 | - 'prev_text' => '<i class="fas fa-chevron-left"></i>', |
|
28 | - 'next_text' => '<i class="fas fa-chevron-right"></i>', |
|
29 | - 'screen_reader_text' => __( 'Posts navigation','aui' ), |
|
30 | - 'before_paging' => '', |
|
31 | - 'after_paging' => '', |
|
32 | - 'type' => 'array', |
|
33 | - 'total' => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1, |
|
34 | - 'links' => array() // an array of links if using custom links, this includes the a tag. |
|
35 | - ); |
|
36 | - |
|
37 | - /** |
|
38 | - * Parse incoming $args into an array and merge it with $defaults |
|
39 | - */ |
|
40 | - $args = wp_parse_args( $args, $defaults ); |
|
41 | - |
|
42 | - $output = ''; |
|
43 | - |
|
44 | - // Don't print empty markup if there's only one page. |
|
45 | - if ( $args['total'] > 1 ) { |
|
46 | - |
|
47 | - // Set up paginated links. |
|
48 | - $links = !empty( $args['links'] ) ? $args['links'] : paginate_links( $args ); |
|
49 | - |
|
50 | - $class = !empty($args['class']) ? $args['class'] : ''; |
|
51 | - |
|
52 | - // make the output bootstrap ready |
|
53 | - $links_html = "<ul class='pagination m-0 p-0 $class'>"; |
|
54 | - if ( ! empty( $links ) ) { |
|
55 | - foreach ( $links as $link ) { |
|
56 | - $active = strpos( $link, 'current' ) !== false ? 'active' : ''; |
|
57 | - $links_html .= "<li class='page-item $active'>"; |
|
58 | - $links_html .= str_replace( "page-numbers", "page-link", $link ); |
|
59 | - $links_html .= "</li>"; |
|
60 | - } |
|
61 | - } |
|
62 | - $links_html .= "</ul>"; |
|
63 | - |
|
64 | - if ( $links ) { |
|
65 | - $output .= '<section class="px-0 py-2 w-100">'; |
|
66 | - $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] ); |
|
67 | - $output .= '</section>'; |
|
68 | - } |
|
69 | - |
|
70 | - $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output ); |
|
71 | - $output = str_replace( "nav-links", "aui-nav-links", $output ); |
|
72 | - } |
|
73 | - |
|
74 | - if ( $output ) { |
|
75 | - if ( ! empty( $args['before_paging'] ) ) { |
|
76 | - $output = $args['before_paging'] . $output; |
|
77 | - } |
|
78 | - |
|
79 | - if ( ! empty( $args['after_paging'] ) ) { |
|
80 | - $output = $output . $args['after_paging']; |
|
81 | - } |
|
82 | - } |
|
83 | - |
|
84 | - return $output; |
|
85 | - } |
|
14 | + /** |
|
15 | + * Build the component. |
|
16 | + * |
|
17 | + * @param array $args |
|
18 | + * |
|
19 | + * @return string The rendered component. |
|
20 | + */ |
|
21 | + public static function get( $args = array() ) { |
|
22 | + global $wp_query; |
|
23 | + |
|
24 | + $defaults = array( |
|
25 | + 'class' => '', |
|
26 | + 'mid_size' => 2, |
|
27 | + 'prev_text' => '<i class="fas fa-chevron-left"></i>', |
|
28 | + 'next_text' => '<i class="fas fa-chevron-right"></i>', |
|
29 | + 'screen_reader_text' => __( 'Posts navigation','aui' ), |
|
30 | + 'before_paging' => '', |
|
31 | + 'after_paging' => '', |
|
32 | + 'type' => 'array', |
|
33 | + 'total' => isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1, |
|
34 | + 'links' => array() // an array of links if using custom links, this includes the a tag. |
|
35 | + ); |
|
36 | + |
|
37 | + /** |
|
38 | + * Parse incoming $args into an array and merge it with $defaults |
|
39 | + */ |
|
40 | + $args = wp_parse_args( $args, $defaults ); |
|
41 | + |
|
42 | + $output = ''; |
|
43 | + |
|
44 | + // Don't print empty markup if there's only one page. |
|
45 | + if ( $args['total'] > 1 ) { |
|
46 | + |
|
47 | + // Set up paginated links. |
|
48 | + $links = !empty( $args['links'] ) ? $args['links'] : paginate_links( $args ); |
|
49 | + |
|
50 | + $class = !empty($args['class']) ? $args['class'] : ''; |
|
51 | + |
|
52 | + // make the output bootstrap ready |
|
53 | + $links_html = "<ul class='pagination m-0 p-0 $class'>"; |
|
54 | + if ( ! empty( $links ) ) { |
|
55 | + foreach ( $links as $link ) { |
|
56 | + $active = strpos( $link, 'current' ) !== false ? 'active' : ''; |
|
57 | + $links_html .= "<li class='page-item $active'>"; |
|
58 | + $links_html .= str_replace( "page-numbers", "page-link", $link ); |
|
59 | + $links_html .= "</li>"; |
|
60 | + } |
|
61 | + } |
|
62 | + $links_html .= "</ul>"; |
|
63 | + |
|
64 | + if ( $links ) { |
|
65 | + $output .= '<section class="px-0 py-2 w-100">'; |
|
66 | + $output .= _navigation_markup( $links_html, 'aui-pagination', $args['screen_reader_text'] ); |
|
67 | + $output .= '</section>'; |
|
68 | + } |
|
69 | + |
|
70 | + $output = str_replace( "screen-reader-text", "screen-reader-text sr-only", $output ); |
|
71 | + $output = str_replace( "nav-links", "aui-nav-links", $output ); |
|
72 | + } |
|
73 | + |
|
74 | + if ( $output ) { |
|
75 | + if ( ! empty( $args['before_paging'] ) ) { |
|
76 | + $output = $args['before_paging'] . $output; |
|
77 | + } |
|
78 | + |
|
79 | + if ( ! empty( $args['after_paging'] ) ) { |
|
80 | + $output = $output . $args['after_paging']; |
|
81 | + } |
|
82 | + } |
|
83 | + |
|
84 | + return $output; |
|
85 | + } |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | \ No newline at end of file |
@@ -31,16 +31,16 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | - $can_checkout = true; // Always true for now |
|
34 | + $can_checkout = true; // Always true for now |
|
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | + $page_id = absint( $page_id ); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | */ |
52 | 52 | function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
53 | 53 | $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
54 | + $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | + $page_id = absint( $page_id ); |
|
56 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | + $ret = $ret ? is_page( $ret ) : false; |
|
69 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | } |
90 | 90 | |
91 | 91 | function wpinv_send_to_failed_page( $args = null ) { |
92 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
92 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
93 | 93 | |
94 | 94 | if ( !empty( $args ) ) { |
95 | 95 | // Check for backward compatibility |
@@ -109,55 +109,55 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | function wpinv_get_checkout_uri( $args = array() ) { |
112 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
112 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
113 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | 114 | |
115 | - if ( !empty( $args ) ) { |
|
116 | - // Check for backward compatibility |
|
117 | - if ( is_string( $args ) ) |
|
118 | - $args = str_replace( '?', '', $args ); |
|
115 | + if ( !empty( $args ) ) { |
|
116 | + // Check for backward compatibility |
|
117 | + if ( is_string( $args ) ) |
|
118 | + $args = str_replace( '?', '', $args ); |
|
119 | 119 | |
120 | - $args = wp_parse_args( $args ); |
|
120 | + $args = wp_parse_args( $args ); |
|
121 | 121 | |
122 | - $uri = add_query_arg( $args, $uri ); |
|
123 | - } |
|
122 | + $uri = add_query_arg( $args, $uri ); |
|
123 | + } |
|
124 | 124 | |
125 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
125 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
126 | 126 | |
127 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
127 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
128 | 128 | |
129 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | - } |
|
129 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
130 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
131 | + } |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
133 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | function wpinv_get_success_page_url( $query_string = null ) { |
137 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
138 | - $success_page = get_permalink( $success_page ); |
|
137 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
138 | + $success_page = get_permalink( $success_page ); |
|
139 | 139 | |
140 | - if ( $query_string ) |
|
141 | - $success_page .= $query_string; |
|
140 | + if ( $query_string ) |
|
141 | + $success_page .= $query_string; |
|
142 | 142 | |
143 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
143 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
147 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
148 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
147 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
148 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
149 | 149 | |
150 | - if ( $extras ) |
|
151 | - $uri .= $extras; |
|
150 | + if ( $extras ) |
|
151 | + $uri .= $extras; |
|
152 | 152 | |
153 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
153 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | function wpinv_is_failed_transaction_page() { |
157 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
158 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
157 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
158 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
159 | 159 | |
160 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
160 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -232,36 +232,36 @@ discard block |
||
232 | 232 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
233 | 233 | |
234 | 234 | if ( $require_billing_details ) { |
235 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
236 | - $required_fields['first_name'] = array( |
|
237 | - 'error_id' => 'invalid_first_name', |
|
238 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
239 | - ); |
|
240 | - } |
|
241 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
242 | - $required_fields['address'] = array( |
|
243 | - 'error_id' => 'invalid_address', |
|
244 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
245 | - ); |
|
246 | - } |
|
247 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
248 | - $required_fields['city'] = array( |
|
249 | - 'error_id' => 'invalid_city', |
|
250 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
251 | - ); |
|
252 | - } |
|
253 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
254 | - $required_fields['state'] = array( |
|
255 | - 'error_id' => 'invalid_state', |
|
256 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
257 | - ); |
|
258 | - } |
|
259 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
260 | - $required_fields['country'] = array( |
|
261 | - 'error_id' => 'invalid_country', |
|
262 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
263 | - ); |
|
264 | - } |
|
235 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
236 | + $required_fields['first_name'] = array( |
|
237 | + 'error_id' => 'invalid_first_name', |
|
238 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
239 | + ); |
|
240 | + } |
|
241 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
242 | + $required_fields['address'] = array( |
|
243 | + 'error_id' => 'invalid_address', |
|
244 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
245 | + ); |
|
246 | + } |
|
247 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
248 | + $required_fields['city'] = array( |
|
249 | + 'error_id' => 'invalid_city', |
|
250 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
251 | + ); |
|
252 | + } |
|
253 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
254 | + $required_fields['state'] = array( |
|
255 | + 'error_id' => 'invalid_state', |
|
256 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
257 | + ); |
|
258 | + } |
|
259 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
260 | + $required_fields['country'] = array( |
|
261 | + 'error_id' => 'invalid_country', |
|
262 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
263 | + ); |
|
264 | + } |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -15,136 +15,136 @@ |
||
15 | 15 | class WPInv_REST_Invoice_Controller extends GetPaid_REST_Posts_Controller { |
16 | 16 | |
17 | 17 | /** |
18 | - * Post type. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $post_type = 'wpi_invoice'; |
|
23 | - |
|
24 | - /** |
|
25 | - * The base of this controller's route. |
|
26 | - * |
|
27 | - * @since 1.0.13 |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $rest_base = 'invoices'; |
|
31 | - |
|
32 | - /** Contains this controller's class name. |
|
33 | - * |
|
34 | - * @var string |
|
35 | - */ |
|
36 | - public $crud_class = 'WPInv_Invoice'; |
|
18 | + * Post type. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $post_type = 'wpi_invoice'; |
|
37 | 23 | |
38 | 24 | /** |
39 | - * Retrieves the query params for the invoices collection. |
|
40 | - * |
|
41 | - * @since 1.0.13 |
|
42 | - * |
|
43 | - * @return array Collection parameters. |
|
44 | - */ |
|
45 | - public function get_collection_params() { |
|
46 | - |
|
47 | - $params = array_merge( |
|
48 | - |
|
49 | - parent::get_collection_params(), |
|
50 | - |
|
51 | - array( |
|
52 | - |
|
53 | - |
|
54 | - 'customers' => array( |
|
55 | - 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
56 | - 'type' => 'array', |
|
57 | - 'items' => array( |
|
58 | - 'type' => 'integer', |
|
59 | - ), |
|
60 | - 'default' => array(), |
|
61 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
62 | - ), |
|
63 | - |
|
64 | - 'exclude_customers' => array( |
|
65 | - 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
66 | - 'type' => 'array', |
|
67 | - 'items' => array( |
|
68 | - 'type' => 'integer', |
|
69 | - ), |
|
70 | - 'default' => array(), |
|
71 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
72 | - ), |
|
73 | - |
|
74 | - 'parent' => array( |
|
75 | - 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
76 | - 'type' => 'array', |
|
77 | - 'items' => array( |
|
78 | - 'type' => 'integer', |
|
79 | - ), |
|
80 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
81 | - 'default' => array(), |
|
82 | - ), |
|
83 | - |
|
84 | - 'parent_exclude' => array( |
|
85 | - 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
86 | - 'type' => 'array', |
|
87 | - 'items' => array( |
|
88 | - 'type' => 'integer', |
|
89 | - ), |
|
90 | - 'sanitize_callback' => 'wp_parse_id_list', |
|
91 | - 'default' => array(), |
|
92 | - ), |
|
93 | - |
|
94 | - ) |
|
95 | - |
|
96 | - ); |
|
97 | - |
|
98 | - // Filter collection parameters for the invoices controller. |
|
99 | - return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Determine the allowed query_vars for a get_items() response and |
|
104 | - * prepare for WP_Query. |
|
105 | - * |
|
106 | - * @param array $prepared_args Prepared arguments. |
|
107 | - * @param WP_REST_Request $request Request object. |
|
108 | - * @return array $query_args |
|
109 | - */ |
|
110 | - protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
111 | - |
|
112 | - $query_args = parent::prepare_items_query( $prepared_args ); |
|
113 | - |
|
114 | - // Retrieve invoices for specific customers. |
|
115 | - if ( ! empty( $request['customers'] ) ) { |
|
116 | - $query_args['author__in'] = $request['customers']; |
|
117 | - } |
|
118 | - |
|
119 | - // Skip invoices for specific customers. |
|
120 | - if ( ! empty( $request['exclude_customers'] ) ) { |
|
121 | - $query_args['author__not_in'] = $request['exclude_customers']; |
|
122 | - } |
|
123 | - |
|
124 | - return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
125 | - |
|
126 | - } |
|
127 | - |
|
128 | - /** |
|
129 | - * Retrieves a valid list of post statuses. |
|
130 | - * |
|
131 | - * @since 1.0.15 |
|
132 | - * |
|
133 | - * @return array A list of registered item statuses. |
|
134 | - */ |
|
135 | - public function get_post_statuses() { |
|
136 | - return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Saves a single invoice. |
|
141 | - * |
|
142 | - * @param WPInv_Invoice $invoice Invoice to save. |
|
143 | - * @return WP_Error|WPInv_Invoice |
|
144 | - */ |
|
145 | - protected function save_object( $invoice ) { |
|
146 | - $invoice->recalculate_total(); |
|
147 | - return parent::save_object( $invoice ); |
|
148 | - } |
|
25 | + * The base of this controller's route. |
|
26 | + * |
|
27 | + * @since 1.0.13 |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $rest_base = 'invoices'; |
|
31 | + |
|
32 | + /** Contains this controller's class name. |
|
33 | + * |
|
34 | + * @var string |
|
35 | + */ |
|
36 | + public $crud_class = 'WPInv_Invoice'; |
|
37 | + |
|
38 | + /** |
|
39 | + * Retrieves the query params for the invoices collection. |
|
40 | + * |
|
41 | + * @since 1.0.13 |
|
42 | + * |
|
43 | + * @return array Collection parameters. |
|
44 | + */ |
|
45 | + public function get_collection_params() { |
|
46 | + |
|
47 | + $params = array_merge( |
|
48 | + |
|
49 | + parent::get_collection_params(), |
|
50 | + |
|
51 | + array( |
|
52 | + |
|
53 | + |
|
54 | + 'customers' => array( |
|
55 | + 'description' => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ), |
|
56 | + 'type' => 'array', |
|
57 | + 'items' => array( |
|
58 | + 'type' => 'integer', |
|
59 | + ), |
|
60 | + 'default' => array(), |
|
61 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
62 | + ), |
|
63 | + |
|
64 | + 'exclude_customers' => array( |
|
65 | + 'description' => __( 'Exclude invoices to specific users.', 'invoicing' ), |
|
66 | + 'type' => 'array', |
|
67 | + 'items' => array( |
|
68 | + 'type' => 'integer', |
|
69 | + ), |
|
70 | + 'default' => array(), |
|
71 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
72 | + ), |
|
73 | + |
|
74 | + 'parent' => array( |
|
75 | + 'description' => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ), |
|
76 | + 'type' => 'array', |
|
77 | + 'items' => array( |
|
78 | + 'type' => 'integer', |
|
79 | + ), |
|
80 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
81 | + 'default' => array(), |
|
82 | + ), |
|
83 | + |
|
84 | + 'parent_exclude' => array( |
|
85 | + 'description' => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ), |
|
86 | + 'type' => 'array', |
|
87 | + 'items' => array( |
|
88 | + 'type' => 'integer', |
|
89 | + ), |
|
90 | + 'sanitize_callback' => 'wp_parse_id_list', |
|
91 | + 'default' => array(), |
|
92 | + ), |
|
93 | + |
|
94 | + ) |
|
95 | + |
|
96 | + ); |
|
97 | + |
|
98 | + // Filter collection parameters for the invoices controller. |
|
99 | + return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this ); |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Determine the allowed query_vars for a get_items() response and |
|
104 | + * prepare for WP_Query. |
|
105 | + * |
|
106 | + * @param array $prepared_args Prepared arguments. |
|
107 | + * @param WP_REST_Request $request Request object. |
|
108 | + * @return array $query_args |
|
109 | + */ |
|
110 | + protected function prepare_items_query( $prepared_args = array(), $request = null ) { |
|
111 | + |
|
112 | + $query_args = parent::prepare_items_query( $prepared_args ); |
|
113 | + |
|
114 | + // Retrieve invoices for specific customers. |
|
115 | + if ( ! empty( $request['customers'] ) ) { |
|
116 | + $query_args['author__in'] = $request['customers']; |
|
117 | + } |
|
118 | + |
|
119 | + // Skip invoices for specific customers. |
|
120 | + if ( ! empty( $request['exclude_customers'] ) ) { |
|
121 | + $query_args['author__not_in'] = $request['exclude_customers']; |
|
122 | + } |
|
123 | + |
|
124 | + return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this ); |
|
125 | + |
|
126 | + } |
|
127 | + |
|
128 | + /** |
|
129 | + * Retrieves a valid list of post statuses. |
|
130 | + * |
|
131 | + * @since 1.0.15 |
|
132 | + * |
|
133 | + * @return array A list of registered item statuses. |
|
134 | + */ |
|
135 | + public function get_post_statuses() { |
|
136 | + return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Saves a single invoice. |
|
141 | + * |
|
142 | + * @param WPInv_Invoice $invoice Invoice to save. |
|
143 | + * @return WP_Error|WPInv_Invoice |
|
144 | + */ |
|
145 | + protected function save_object( $invoice ) { |
|
146 | + $invoice->recalculate_total(); |
|
147 | + return parent::save_object( $invoice ); |
|
148 | + } |
|
149 | 149 | |
150 | 150 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function wpinv_sanitize_country( $country ) { |
28 | 28 | |
29 | - // Enure the country is specified |
|
29 | + // Enure the country is specified |
|
30 | 30 | if ( empty( $country ) ) { |
31 | 31 | $country = wpinv_get_default_country(); |
32 | 32 | } |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_get_default_state() { |
59 | - $state = wpinv_get_option( 'default_state', '' ); |
|
59 | + $state = wpinv_get_option( 'default_state', '' ); |
|
60 | 60 | |
61 | - return apply_filters( 'wpinv_default_state', $state ); |
|
61 | + return apply_filters( 'wpinv_default_state', $state ); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | |
289 | 289 | $country = wpinv_sanitize_country( $country ); |
290 | 290 | |
291 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
292 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
293 | - return $continent_code; |
|
294 | - } |
|
295 | - } |
|
291 | + foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
292 | + if ( false !== array_search( $country, $countries, true ) ) { |
|
293 | + return $continent_code; |
|
294 | + } |
|
295 | + } |
|
296 | 296 | |
297 | 297 | return ''; |
298 | 298 | |
@@ -584,30 +584,30 @@ discard block |
||
584 | 584 | } |
585 | 585 | |
586 | 586 | function wpinv_get_states_field() { |
587 | - if( empty( $_POST['country'] ) ) { |
|
588 | - $_POST['country'] = wpinv_get_default_country(); |
|
589 | - } |
|
590 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
587 | + if( empty( $_POST['country'] ) ) { |
|
588 | + $_POST['country'] = wpinv_get_default_country(); |
|
589 | + } |
|
590 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
591 | 591 | |
592 | - if( !empty( $states ) ) { |
|
593 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
592 | + if( !empty( $states ) ) { |
|
593 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
594 | 594 | |
595 | 595 | $args = array( |
596 | - 'name' => $sanitized_field_name, |
|
597 | - 'id' => $sanitized_field_name, |
|
598 | - 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
|
599 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
600 | - 'show_option_all' => false, |
|
601 | - 'show_option_none' => false |
|
602 | - ); |
|
603 | - |
|
604 | - $response = wpinv_html_select( $args ); |
|
605 | - |
|
606 | - } else { |
|
607 | - $response = 'nostates'; |
|
608 | - } |
|
596 | + 'name' => $sanitized_field_name, |
|
597 | + 'id' => $sanitized_field_name, |
|
598 | + 'class' => $sanitized_field_name . 'custom-select wpinv-select wpi_select2', |
|
599 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
600 | + 'show_option_all' => false, |
|
601 | + 'show_option_none' => false |
|
602 | + ); |
|
603 | + |
|
604 | + $response = wpinv_html_select( $args ); |
|
605 | + |
|
606 | + } else { |
|
607 | + $response = 'nostates'; |
|
608 | + } |
|
609 | 609 | |
610 | - return $response; |
|
610 | + return $response; |
|
611 | 611 | } |
612 | 612 | |
613 | 613 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -625,46 +625,46 @@ discard block |
||
625 | 625 | */ |
626 | 626 | function wpinv_get_address_formats() { |
627 | 627 | |
628 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
629 | - array( |
|
630 | - 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
631 | - 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
632 | - 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
633 | - 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
634 | - 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
635 | - 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
636 | - 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
637 | - 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
638 | - 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
639 | - 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
640 | - 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
641 | - 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
642 | - 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
643 | - 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
644 | - 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
645 | - 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
646 | - 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
647 | - 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
648 | - 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
649 | - 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
650 | - 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
651 | - 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
652 | - 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
653 | - 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
654 | - 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
655 | - 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
656 | - 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | - 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
658 | - 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | - 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | - 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
661 | - 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
662 | - 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
663 | - 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
664 | - 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
665 | - 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
666 | - ) |
|
667 | - ); |
|
628 | + return apply_filters( 'wpinv_localisation_address_formats', |
|
629 | + array( |
|
630 | + 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
631 | + 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
632 | + 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
633 | + 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
634 | + 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
635 | + 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
636 | + 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
637 | + 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
638 | + 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
639 | + 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
640 | + 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
641 | + 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
642 | + 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
643 | + 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
644 | + 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
645 | + 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
646 | + 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
647 | + 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
648 | + 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
649 | + 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
650 | + 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
651 | + 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
652 | + 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
653 | + 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
654 | + 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
655 | + 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
656 | + 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | + 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
658 | + 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | + 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | + 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
661 | + 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
662 | + 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
663 | + 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
664 | + 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
665 | + 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
666 | + ) |
|
667 | + ); |
|
668 | 668 | } |
669 | 669 | |
670 | 670 | /** |
@@ -681,21 +681,21 @@ discard block |
||
681 | 681 | } |
682 | 682 | |
683 | 683 | // Get all formats. |
684 | - $formats = wpinv_get_address_formats(); |
|
684 | + $formats = wpinv_get_address_formats(); |
|
685 | 685 | |
686 | - // Get format for the specified country. |
|
687 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
686 | + // Get format for the specified country. |
|
687 | + $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
688 | 688 | |
689 | 689 | /** |
690 | - * Filters the address format to use on Invoices. |
|
690 | + * Filters the address format to use on Invoices. |
|
691 | 691 | * |
692 | 692 | * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed. |
693 | - * |
|
694 | - * @since 1.0.13 |
|
695 | - * |
|
696 | - * @param string $format The address format to use. |
|
693 | + * |
|
694 | + * @since 1.0.13 |
|
695 | + * |
|
696 | + * @param string $format The address format to use. |
|
697 | 697 | * @param string $country The country who's address format is being retrieved. |
698 | - */ |
|
698 | + */ |
|
699 | 699 | return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
700 | 700 | } |
701 | 701 | |
@@ -716,8 +716,8 @@ discard block |
||
716 | 716 | 'country' => '', |
717 | 717 | 'zip' => '', |
718 | 718 | 'first_name' => '', |
719 | - 'last_name' => '', |
|
720 | - 'company' => '', |
|
719 | + 'last_name' => '', |
|
720 | + 'company' => '', |
|
721 | 721 | ); |
722 | 722 | |
723 | 723 | $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
@@ -738,14 +738,14 @@ discard block |
||
738 | 738 | $args['country_code']= $country; |
739 | 739 | |
740 | 740 | /** |
741 | - * Filters the address format replacements to use on Invoices. |
|
741 | + * Filters the address format replacements to use on Invoices. |
|
742 | 742 | * |
743 | - * |
|
744 | - * @since 1.0.13 |
|
745 | - * |
|
746 | - * @param array $replacements The address replacements to use. |
|
743 | + * |
|
744 | + * @since 1.0.13 |
|
745 | + * |
|
746 | + * @param array $replacements The address replacements to use. |
|
747 | 747 | * @param array $billing_details The billing details to use. |
748 | - */ |
|
748 | + */ |
|
749 | 749 | $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
750 | 750 | |
751 | 751 | $return = array(); |
@@ -768,5 +768,5 @@ discard block |
||
768 | 768 | * @return string |
769 | 769 | */ |
770 | 770 | function wpinv_trim_formatted_address_line( $line ) { |
771 | - return trim( $line, ', ' ); |
|
771 | + return trim( $line, ', ' ); |
|
772 | 772 | } |
773 | 773 | \ No newline at end of file |
@@ -56,7 +56,7 @@ |
||
56 | 56 | } |
57 | 57 | |
58 | 58 | function wpinv_admin_messages() { |
59 | - settings_errors( 'wpinv-notices' ); |
|
59 | + settings_errors( 'wpinv-notices' ); |
|
60 | 60 | } |
61 | 61 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
62 | 62 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | if ( ! defined( 'ABSPATH' ) ) { |
10 | - exit; // Exit if accessed directly |
|
10 | + exit; // Exit if accessed directly |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -15,22 +15,22 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class GetPaid_Meta_Box_Invoice_Shipping_Address { |
17 | 17 | |
18 | - /** |
|
19 | - * Output the metabox. |
|
20 | - * |
|
21 | - * @param WP_Post $post |
|
22 | - */ |
|
23 | - public static function output( $post ) { |
|
18 | + /** |
|
19 | + * Output the metabox. |
|
20 | + * |
|
21 | + * @param WP_Post $post |
|
22 | + */ |
|
23 | + public static function output( $post ) { |
|
24 | 24 | |
25 | - // Retrieve shipping address. |
|
26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
25 | + // Retrieve shipping address. |
|
26 | + $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
27 | 27 | |
28 | - // Abort if it is invalid. |
|
29 | - if ( ! is_array( $shipping_address ) ) { |
|
30 | - return; |
|
31 | - } |
|
28 | + // Abort if it is invalid. |
|
29 | + if ( ! is_array( $shipping_address ) ) { |
|
30 | + return; |
|
31 | + } |
|
32 | 32 | |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | |
35 | 35 | <div class="bsui"> |
36 | 36 | |
@@ -55,31 +55,31 @@ discard block |
||
55 | 55 | |
56 | 56 | <?php |
57 | 57 | |
58 | - } |
|
58 | + } |
|
59 | 59 | |
60 | - /** |
|
61 | - * Prepares a value. |
|
62 | - * |
|
63 | - * @param array $address |
|
64 | - * @param string $key |
|
65 | - * @return string |
|
66 | - */ |
|
67 | - public static function prepare_for_display( $address, $key ) { |
|
60 | + /** |
|
61 | + * Prepares a value. |
|
62 | + * |
|
63 | + * @param array $address |
|
64 | + * @param string $key |
|
65 | + * @return string |
|
66 | + */ |
|
67 | + public static function prepare_for_display( $address, $key ) { |
|
68 | 68 | |
69 | - // Prepare the value. |
|
70 | - $value = $address[ $key ]; |
|
69 | + // Prepare the value. |
|
70 | + $value = $address[ $key ]; |
|
71 | 71 | |
72 | - if ( $key == 'country' ) { |
|
73 | - $value = wpinv_country_name( $value ); |
|
74 | - } |
|
72 | + if ( $key == 'country' ) { |
|
73 | + $value = wpinv_country_name( $value ); |
|
74 | + } |
|
75 | 75 | |
76 | - if ( $key == 'state' ) { |
|
77 | - $country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country(); |
|
78 | - $value = wpinv_state_name( $value, $country ); |
|
79 | - } |
|
76 | + if ( $key == 'state' ) { |
|
77 | + $country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country(); |
|
78 | + $value = wpinv_state_name( $value, $country ); |
|
79 | + } |
|
80 | 80 | |
81 | - return sanitize_text_field( $value ); |
|
81 | + return sanitize_text_field( $value ); |
|
82 | 82 | |
83 | - } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | } |
@@ -12,72 +12,72 @@ discard block |
||
12 | 12 | */ |
13 | 13 | abstract class GetPaid_Reports_Abstract_Report { |
14 | 14 | |
15 | - /** |
|
16 | - * @var array |
|
17 | - */ |
|
18 | - public $stats; |
|
19 | - |
|
20 | - /** |
|
21 | - * Class constructor. |
|
22 | - * |
|
23 | - */ |
|
24 | - public function __construct() { |
|
25 | - $this->prepare_stats(); |
|
26 | - } |
|
27 | - |
|
28 | - /** |
|
29 | - * Retrieves the current range. |
|
30 | - * |
|
31 | - */ |
|
32 | - public function get_range() { |
|
33 | - $valid_ranges = $this->get_periods(); |
|
34 | - |
|
35 | - if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | - return sanitize_key( $_GET['date_range'] ); |
|
37 | - } |
|
38 | - |
|
39 | - return '7_days'; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Returns an array of date ranges. |
|
44 | - * |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function get_periods() { |
|
48 | - |
|
49 | - $periods = array( |
|
15 | + /** |
|
16 | + * @var array |
|
17 | + */ |
|
18 | + public $stats; |
|
19 | + |
|
20 | + /** |
|
21 | + * Class constructor. |
|
22 | + * |
|
23 | + */ |
|
24 | + public function __construct() { |
|
25 | + $this->prepare_stats(); |
|
26 | + } |
|
27 | + |
|
28 | + /** |
|
29 | + * Retrieves the current range. |
|
30 | + * |
|
31 | + */ |
|
32 | + public function get_range() { |
|
33 | + $valid_ranges = $this->get_periods(); |
|
34 | + |
|
35 | + if ( isset( $_GET['date_range'] ) && array_key_exists( $_GET['date_range'], $valid_ranges ) ) { |
|
36 | + return sanitize_key( $_GET['date_range'] ); |
|
37 | + } |
|
38 | + |
|
39 | + return '7_days'; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Returns an array of date ranges. |
|
44 | + * |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function get_periods() { |
|
48 | + |
|
49 | + $periods = array( |
|
50 | 50 | 'today' => __( 'Today', 'invoicing' ), |
51 | 51 | 'yesterday' => __( 'Yesterday', 'invoicing' ), |
52 | 52 | '7_days' => __( 'Last 7 days', 'invoicing' ), |
53 | - '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | - '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | - '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | - '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | - '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
58 | - ); |
|
59 | - |
|
60 | - return apply_filters( 'getpaid_earning_periods', $periods ); |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Retrieves the current range's sql. |
|
65 | - * |
|
66 | - */ |
|
67 | - public function get_range_sql( $range ) { |
|
68 | - |
|
69 | - $date = 'CAST(meta.completed_date AS DATE)'; |
|
53 | + '30_days' => __( 'Last 30 days', 'invoicing' ), |
|
54 | + '60_days' => __( 'Last 60 days', 'invoicing' ), |
|
55 | + '90_days' => __( 'Last 90 days', 'invoicing' ), |
|
56 | + '180_days' => __( 'Last 180 days', 'invoicing' ), |
|
57 | + '360_days' => __( 'Last 360 days', 'invoicing' ), |
|
58 | + ); |
|
59 | + |
|
60 | + return apply_filters( 'getpaid_earning_periods', $periods ); |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Retrieves the current range's sql. |
|
65 | + * |
|
66 | + */ |
|
67 | + public function get_range_sql( $range ) { |
|
68 | + |
|
69 | + $date = 'CAST(meta.completed_date AS DATE)'; |
|
70 | 70 | $datetime = 'meta.completed_date'; |
71 | 71 | |
72 | 72 | // Prepare durations. |
73 | 73 | $today = current_time( 'Y-m-d' ); |
74 | - $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
75 | - $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
76 | - $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
77 | - $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
78 | - $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
79 | - $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
80 | - $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
74 | + $yesterday = date( 'Y-m-d', strtotime( '-1 day', current_time( 'timestamp' ) ) ); |
|
75 | + $seven_days_ago = date( 'Y-m-d', strtotime( '-7 days', current_time( 'timestamp' ) ) ); |
|
76 | + $thirty_days_ago = date( 'Y-m-d', strtotime( '-30 days', current_time( 'timestamp' ) ) ); |
|
77 | + $ninety_days_ago = date( 'Y-m-d', strtotime( '-90 days', current_time( 'timestamp' ) ) ); |
|
78 | + $sixty_days_ago = date( 'Y-m-d', strtotime( '-60 days', current_time( 'timestamp' ) ) ); |
|
79 | + $one_eighty_days_ago = date( 'Y-m-d', strtotime( '-180 days', current_time( 'timestamp' ) ) ); |
|
80 | + $three_sixty_days_ago = date( 'Y-m-d', strtotime( '-360 days', current_time( 'timestamp' ) ) ); |
|
81 | 81 | |
82 | 82 | $ranges = array( |
83 | 83 | |
@@ -94,130 +94,130 @@ discard block |
||
94 | 94 | '7_days' => array( |
95 | 95 | "DATE($datetime)", |
96 | 96 | "$date BETWEEN '$seven_days_ago' AND '$today'" |
97 | - ), |
|
97 | + ), |
|
98 | 98 | |
99 | - '30_days' => array( |
|
99 | + '30_days' => array( |
|
100 | 100 | "DATE($datetime)", |
101 | 101 | "$date BETWEEN '$thirty_days_ago' AND '$today'" |
102 | - ), |
|
102 | + ), |
|
103 | 103 | |
104 | - '60_days' => array( |
|
104 | + '60_days' => array( |
|
105 | 105 | "DATE($datetime)", |
106 | 106 | "$date BETWEEN '$sixty_days_ago' AND '$today'" |
107 | - ), |
|
107 | + ), |
|
108 | 108 | |
109 | - '90_days' => array( |
|
109 | + '90_days' => array( |
|
110 | 110 | "WEEK($datetime)", |
111 | 111 | "$date BETWEEN '$ninety_days_ago' AND '$today'" |
112 | - ), |
|
112 | + ), |
|
113 | 113 | |
114 | - '180_days' => array( |
|
114 | + '180_days' => array( |
|
115 | 115 | "WEEK($datetime)", |
116 | 116 | "$date BETWEEN '$one_eighty_days_ago' AND '$today'" |
117 | - ), |
|
117 | + ), |
|
118 | 118 | |
119 | - '360_days' => array( |
|
119 | + '360_days' => array( |
|
120 | 120 | "WEEK($datetime)", |
121 | 121 | "$date BETWEEN '$three_sixty_days_ago' AND '$today'" |
122 | 122 | ), |
123 | 123 | |
124 | 124 | ); |
125 | 125 | |
126 | - $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
127 | - return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
128 | - |
|
129 | - } |
|
130 | - |
|
131 | - /** |
|
132 | - * Retrieves the hours in a day |
|
133 | - * |
|
134 | - */ |
|
135 | - public function get_hours_in_a_day() { |
|
136 | - |
|
137 | - return array( |
|
138 | - '12AM' => __( '12 AM', 'invoicing'), |
|
139 | - '1AM' => __( '1 AM', 'invoicing'), |
|
140 | - '2AM' => __( '2 AM', 'invoicing'), |
|
141 | - '3AM' => __( '3 AM', 'invoicing'), |
|
142 | - '4AM' => __( '4 AM', 'invoicing'), |
|
143 | - '5AM' => __( '5 AM', 'invoicing'), |
|
144 | - '6AM' => __( '6 AM', 'invoicing'), |
|
145 | - '7AM' => __( '7 AM', 'invoicing'), |
|
146 | - '8AM' => __( '8 AM', 'invoicing'), |
|
147 | - '9AM' => __( '9 AM', 'invoicing'), |
|
148 | - '10AM' => __( '10 AM', 'invoicing'), |
|
149 | - '11AM' => __( '11 AM', 'invoicing'), |
|
150 | - '12pm' => __( '12 PM', 'invoicing'), |
|
151 | - '1PM' => __( '1 PM', 'invoicing'), |
|
152 | - '2PM' => __( '2 PM', 'invoicing'), |
|
153 | - '3PM' => __( '3 PM', 'invoicing'), |
|
154 | - '4PM' => __( '4 PM', 'invoicing'), |
|
155 | - '5PM' => __( '5 PM', 'invoicing'), |
|
156 | - '6PM' => __( '6 PM', 'invoicing'), |
|
157 | - '7PM' => __( '7 PM', 'invoicing'), |
|
158 | - '8PM' => __( '8 PM', 'invoicing'), |
|
159 | - '9PM' => __( '9 PM', 'invoicing'), |
|
160 | - '10PM' => __( '10 PM', 'invoicing'), |
|
161 | - '11PM' => __( '11 PM', 'invoicing'), |
|
162 | - ); |
|
163 | - |
|
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Retrieves the days in a period |
|
168 | - * |
|
169 | - */ |
|
170 | - public function get_days_in_period( $days ) { |
|
171 | - |
|
172 | - $return = array(); |
|
173 | - $format = 'Y-m-d'; |
|
174 | - |
|
175 | - if ( $days < 8 ) { |
|
176 | - $format = 'D'; |
|
177 | - } |
|
178 | - |
|
179 | - if ( $days < 32 ) { |
|
180 | - $format = 'M j'; |
|
181 | - } |
|
182 | - |
|
183 | - while ( $days > 0 ) { |
|
184 | - |
|
185 | - $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
186 | - $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
187 | - $return[ $key ] = $label; |
|
188 | - $days--; |
|
189 | - |
|
190 | - } |
|
191 | - |
|
192 | - return $return; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Retrieves the weeks in a period |
|
197 | - * |
|
198 | - */ |
|
199 | - public function get_weeks_in_period( $days ) { |
|
200 | - |
|
201 | - $return = array(); |
|
202 | - |
|
203 | - while ( $days > 0 ) { |
|
204 | - |
|
205 | - $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
206 | - $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
207 | - $return[ $key ] = $label; |
|
208 | - $days--; |
|
209 | - |
|
210 | - } |
|
211 | - |
|
212 | - return $return; |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Displays the report card. |
|
217 | - * |
|
218 | - */ |
|
219 | - public function display() { |
|
220 | - ?> |
|
126 | + $sql = isset( $ranges[ $range ] ) ? $ranges[ $range ] : $ranges[ '7_days' ]; |
|
127 | + return apply_filters( 'getpaid_earning_graphs_get_range_sql', $sql, $range ); |
|
128 | + |
|
129 | + } |
|
130 | + |
|
131 | + /** |
|
132 | + * Retrieves the hours in a day |
|
133 | + * |
|
134 | + */ |
|
135 | + public function get_hours_in_a_day() { |
|
136 | + |
|
137 | + return array( |
|
138 | + '12AM' => __( '12 AM', 'invoicing'), |
|
139 | + '1AM' => __( '1 AM', 'invoicing'), |
|
140 | + '2AM' => __( '2 AM', 'invoicing'), |
|
141 | + '3AM' => __( '3 AM', 'invoicing'), |
|
142 | + '4AM' => __( '4 AM', 'invoicing'), |
|
143 | + '5AM' => __( '5 AM', 'invoicing'), |
|
144 | + '6AM' => __( '6 AM', 'invoicing'), |
|
145 | + '7AM' => __( '7 AM', 'invoicing'), |
|
146 | + '8AM' => __( '8 AM', 'invoicing'), |
|
147 | + '9AM' => __( '9 AM', 'invoicing'), |
|
148 | + '10AM' => __( '10 AM', 'invoicing'), |
|
149 | + '11AM' => __( '11 AM', 'invoicing'), |
|
150 | + '12pm' => __( '12 PM', 'invoicing'), |
|
151 | + '1PM' => __( '1 PM', 'invoicing'), |
|
152 | + '2PM' => __( '2 PM', 'invoicing'), |
|
153 | + '3PM' => __( '3 PM', 'invoicing'), |
|
154 | + '4PM' => __( '4 PM', 'invoicing'), |
|
155 | + '5PM' => __( '5 PM', 'invoicing'), |
|
156 | + '6PM' => __( '6 PM', 'invoicing'), |
|
157 | + '7PM' => __( '7 PM', 'invoicing'), |
|
158 | + '8PM' => __( '8 PM', 'invoicing'), |
|
159 | + '9PM' => __( '9 PM', 'invoicing'), |
|
160 | + '10PM' => __( '10 PM', 'invoicing'), |
|
161 | + '11PM' => __( '11 PM', 'invoicing'), |
|
162 | + ); |
|
163 | + |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Retrieves the days in a period |
|
168 | + * |
|
169 | + */ |
|
170 | + public function get_days_in_period( $days ) { |
|
171 | + |
|
172 | + $return = array(); |
|
173 | + $format = 'Y-m-d'; |
|
174 | + |
|
175 | + if ( $days < 8 ) { |
|
176 | + $format = 'D'; |
|
177 | + } |
|
178 | + |
|
179 | + if ( $days < 32 ) { |
|
180 | + $format = 'M j'; |
|
181 | + } |
|
182 | + |
|
183 | + while ( $days > 0 ) { |
|
184 | + |
|
185 | + $key = date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
186 | + $label = date_i18n( $format, strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
187 | + $return[ $key ] = $label; |
|
188 | + $days--; |
|
189 | + |
|
190 | + } |
|
191 | + |
|
192 | + return $return; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Retrieves the weeks in a period |
|
197 | + * |
|
198 | + */ |
|
199 | + public function get_weeks_in_period( $days ) { |
|
200 | + |
|
201 | + $return = array(); |
|
202 | + |
|
203 | + while ( $days > 0 ) { |
|
204 | + |
|
205 | + $key = date( 'W', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
206 | + $label = date_i18n( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ); |
|
207 | + $return[ $key ] = $label; |
|
208 | + $days--; |
|
209 | + |
|
210 | + } |
|
211 | + |
|
212 | + return $return; |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Displays the report card. |
|
217 | + * |
|
218 | + */ |
|
219 | + public function display() { |
|
220 | + ?> |
|
221 | 221 | |
222 | 222 | <div class="row"> |
223 | 223 | <div class="col-12"> |
@@ -231,20 +231,20 @@ discard block |
||
231 | 231 | |
232 | 232 | <?php |
233 | 233 | |
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Prepares the report stats. |
|
238 | - * |
|
239 | - * Extend this in child classes. |
|
240 | - */ |
|
241 | - abstract public function prepare_stats(); |
|
242 | - |
|
243 | - /** |
|
244 | - * Displays the actual report. |
|
245 | - * |
|
246 | - * Extend this in child classes. |
|
247 | - */ |
|
248 | - abstract public function display_stats(); |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Prepares the report stats. |
|
238 | + * |
|
239 | + * Extend this in child classes. |
|
240 | + */ |
|
241 | + abstract public function prepare_stats(); |
|
242 | + |
|
243 | + /** |
|
244 | + * Displays the actual report. |
|
245 | + * |
|
246 | + * Extend this in child classes. |
|
247 | + */ |
|
248 | + abstract public function display_stats(); |
|
249 | 249 | |
250 | 250 | } |
@@ -13,154 +13,154 @@ |
||
13 | 13 | */ |
14 | 14 | class GetPaid_MaxMind_Database_Service { |
15 | 15 | |
16 | - /** |
|
17 | - * The name of the MaxMind database to utilize. |
|
18 | - */ |
|
19 | - const DATABASE = 'GeoLite2-Country'; |
|
20 | - |
|
21 | - /** |
|
22 | - * The extension for the MaxMind database. |
|
23 | - */ |
|
24 | - const DATABASE_EXTENSION = '.mmdb'; |
|
25 | - |
|
26 | - /** |
|
27 | - * A prefix for the MaxMind database filename. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - private $database_prefix; |
|
32 | - |
|
33 | - /** |
|
34 | - * Class constructor. |
|
35 | - * |
|
36 | - * @param string|null $database_prefix A prefix for the MaxMind database filename. |
|
37 | - */ |
|
38 | - public function __construct( $database_prefix ) { |
|
39 | - $this->database_prefix = $database_prefix; |
|
40 | - } |
|
41 | - |
|
42 | - /** |
|
43 | - * Fetches the path that the database should be stored. |
|
44 | - * |
|
45 | - * @return string The local database path. |
|
46 | - */ |
|
47 | - public function get_database_path() { |
|
48 | - $uploads_dir = wp_upload_dir(); |
|
49 | - |
|
50 | - $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/'; |
|
51 | - if ( ! empty( $this->database_prefix ) ) { |
|
52 | - $database_path .= $this->database_prefix . '-'; |
|
53 | - } |
|
54 | - $database_path .= self::DATABASE . self::DATABASE_EXTENSION; |
|
55 | - |
|
56 | - // Filter the geolocation database storage path. |
|
57 | - return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path ); |
|
58 | - } |
|
59 | - |
|
60 | - /** |
|
61 | - * Fetches the database from the MaxMind service. |
|
62 | - * |
|
63 | - * @param string $license_key The license key to be used when downloading the database. |
|
64 | - * @return string|WP_Error The path to the database file or an error if invalid. |
|
65 | - */ |
|
66 | - public function download_database( $license_key ) { |
|
67 | - |
|
68 | - $download_uri = add_query_arg( |
|
69 | - array( |
|
70 | - 'edition_id' => self::DATABASE, |
|
71 | - 'license_key' => urlencode( wpinv_clean( $license_key ) ), |
|
72 | - 'suffix' => 'tar.gz', |
|
73 | - ), |
|
74 | - 'https://download.maxmind.com/app/geoip_download' |
|
75 | - ); |
|
76 | - |
|
77 | - // Needed for the download_url call right below. |
|
78 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
79 | - |
|
80 | - $tmp_archive_path = download_url( esc_url_raw( $download_uri ) ); |
|
81 | - |
|
82 | - if ( is_wp_error( $tmp_archive_path ) ) { |
|
83 | - // Transform the error into something more informative. |
|
84 | - $error_data = $tmp_archive_path->get_error_data(); |
|
85 | - if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) { |
|
86 | - return new WP_Error( |
|
87 | - 'getpaid_maxmind_geolocation_database_license_key', |
|
88 | - __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
89 | - ); |
|
90 | - } |
|
91 | - |
|
92 | - return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
|
93 | - } |
|
94 | - |
|
95 | - // Extract the database from the archive. |
|
96 | - return $this->extract_downloaded_database( $tmp_archive_path ); |
|
97 | - |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Extracts the downloaded database. |
|
102 | - * |
|
103 | - * @param string $tmp_archive_path The database archive path. |
|
104 | - * @return string|WP_Error The path to the database file or an error if invalid. |
|
105 | - */ |
|
106 | - protected function extract_downloaded_database( $tmp_archive_path ) { |
|
107 | - |
|
108 | - // Extract the database from the archive. |
|
109 | - $tmp_database_path = ''; |
|
110 | - |
|
111 | - try { |
|
112 | - |
|
113 | - $file = new PharData( $tmp_archive_path ); |
|
114 | - $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION; |
|
115 | - |
|
116 | - $file->extractTo( |
|
117 | - dirname( $tmp_archive_path ), |
|
118 | - trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION, |
|
119 | - true |
|
120 | - ); |
|
121 | - |
|
122 | - } catch ( Exception $exception ) { |
|
123 | - return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
124 | - } finally { |
|
125 | - // Remove the archive since we only care about a single file in it. |
|
126 | - unlink( $tmp_archive_path ); |
|
127 | - } |
|
128 | - |
|
129 | - return $tmp_database_path; |
|
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Fetches the ISO country code associated with an IP address. |
|
134 | - * |
|
135 | - * @param string $ip_address The IP address to find the country code for. |
|
136 | - * @return string The country code for the IP address, or empty if not found. |
|
137 | - */ |
|
138 | - public function get_iso_country_code_for_ip( $ip_address ) { |
|
139 | - $country_code = ''; |
|
140 | - |
|
141 | - if ( ! class_exists( 'MaxMind\Db\Reader' ) ) { |
|
142 | - return $country_code; |
|
143 | - } |
|
144 | - |
|
145 | - $database_path = $this->get_database_path(); |
|
146 | - if ( ! file_exists( $database_path ) ) { |
|
147 | - return $country_code; |
|
148 | - } |
|
149 | - |
|
150 | - try { |
|
151 | - $reader = new MaxMind\Db\Reader( $database_path ); |
|
152 | - $data = $reader->get( $ip_address ); |
|
153 | - |
|
154 | - if ( isset( $data['country']['iso_code'] ) ) { |
|
155 | - $country_code = $data['country']['iso_code']; |
|
156 | - } |
|
157 | - |
|
158 | - $reader->close(); |
|
159 | - } catch ( Exception $e ) { |
|
160 | - wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' ); |
|
161 | - } |
|
162 | - |
|
163 | - return $country_code; |
|
164 | - } |
|
16 | + /** |
|
17 | + * The name of the MaxMind database to utilize. |
|
18 | + */ |
|
19 | + const DATABASE = 'GeoLite2-Country'; |
|
20 | + |
|
21 | + /** |
|
22 | + * The extension for the MaxMind database. |
|
23 | + */ |
|
24 | + const DATABASE_EXTENSION = '.mmdb'; |
|
25 | + |
|
26 | + /** |
|
27 | + * A prefix for the MaxMind database filename. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + private $database_prefix; |
|
32 | + |
|
33 | + /** |
|
34 | + * Class constructor. |
|
35 | + * |
|
36 | + * @param string|null $database_prefix A prefix for the MaxMind database filename. |
|
37 | + */ |
|
38 | + public function __construct( $database_prefix ) { |
|
39 | + $this->database_prefix = $database_prefix; |
|
40 | + } |
|
41 | + |
|
42 | + /** |
|
43 | + * Fetches the path that the database should be stored. |
|
44 | + * |
|
45 | + * @return string The local database path. |
|
46 | + */ |
|
47 | + public function get_database_path() { |
|
48 | + $uploads_dir = wp_upload_dir(); |
|
49 | + |
|
50 | + $database_path = trailingslashit( $uploads_dir['basedir'] ) . 'invoicing/'; |
|
51 | + if ( ! empty( $this->database_prefix ) ) { |
|
52 | + $database_path .= $this->database_prefix . '-'; |
|
53 | + } |
|
54 | + $database_path .= self::DATABASE . self::DATABASE_EXTENSION; |
|
55 | + |
|
56 | + // Filter the geolocation database storage path. |
|
57 | + return apply_filters( 'getpaid_maxmind_geolocation_database_path', $database_path ); |
|
58 | + } |
|
59 | + |
|
60 | + /** |
|
61 | + * Fetches the database from the MaxMind service. |
|
62 | + * |
|
63 | + * @param string $license_key The license key to be used when downloading the database. |
|
64 | + * @return string|WP_Error The path to the database file or an error if invalid. |
|
65 | + */ |
|
66 | + public function download_database( $license_key ) { |
|
67 | + |
|
68 | + $download_uri = add_query_arg( |
|
69 | + array( |
|
70 | + 'edition_id' => self::DATABASE, |
|
71 | + 'license_key' => urlencode( wpinv_clean( $license_key ) ), |
|
72 | + 'suffix' => 'tar.gz', |
|
73 | + ), |
|
74 | + 'https://download.maxmind.com/app/geoip_download' |
|
75 | + ); |
|
76 | + |
|
77 | + // Needed for the download_url call right below. |
|
78 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
79 | + |
|
80 | + $tmp_archive_path = download_url( esc_url_raw( $download_uri ) ); |
|
81 | + |
|
82 | + if ( is_wp_error( $tmp_archive_path ) ) { |
|
83 | + // Transform the error into something more informative. |
|
84 | + $error_data = $tmp_archive_path->get_error_data(); |
|
85 | + if ( isset( $error_data['code'] ) && $error_data['code'] == 401 ) { |
|
86 | + return new WP_Error( |
|
87 | + 'getpaid_maxmind_geolocation_database_license_key', |
|
88 | + __( 'The MaxMind license key is invalid. If you have recently created this key, you may need to wait for it to become active.', 'invoicing' ) |
|
89 | + ); |
|
90 | + } |
|
91 | + |
|
92 | + return new WP_Error( 'getpaid_maxmind_geolocation_database_download', __( 'Failed to download the MaxMind database.', 'invoicing' ) ); |
|
93 | + } |
|
94 | + |
|
95 | + // Extract the database from the archive. |
|
96 | + return $this->extract_downloaded_database( $tmp_archive_path ); |
|
97 | + |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Extracts the downloaded database. |
|
102 | + * |
|
103 | + * @param string $tmp_archive_path The database archive path. |
|
104 | + * @return string|WP_Error The path to the database file or an error if invalid. |
|
105 | + */ |
|
106 | + protected function extract_downloaded_database( $tmp_archive_path ) { |
|
107 | + |
|
108 | + // Extract the database from the archive. |
|
109 | + $tmp_database_path = ''; |
|
110 | + |
|
111 | + try { |
|
112 | + |
|
113 | + $file = new PharData( $tmp_archive_path ); |
|
114 | + $tmp_database_path = trailingslashit( dirname( $tmp_archive_path ) ) . trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION; |
|
115 | + |
|
116 | + $file->extractTo( |
|
117 | + dirname( $tmp_archive_path ), |
|
118 | + trailingslashit( $file->current()->getFilename() ) . self::DATABASE . self::DATABASE_EXTENSION, |
|
119 | + true |
|
120 | + ); |
|
121 | + |
|
122 | + } catch ( Exception $exception ) { |
|
123 | + return new WP_Error( 'invoicing_maxmind_geolocation_database_archive', $exception->getMessage() ); |
|
124 | + } finally { |
|
125 | + // Remove the archive since we only care about a single file in it. |
|
126 | + unlink( $tmp_archive_path ); |
|
127 | + } |
|
128 | + |
|
129 | + return $tmp_database_path; |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Fetches the ISO country code associated with an IP address. |
|
134 | + * |
|
135 | + * @param string $ip_address The IP address to find the country code for. |
|
136 | + * @return string The country code for the IP address, or empty if not found. |
|
137 | + */ |
|
138 | + public function get_iso_country_code_for_ip( $ip_address ) { |
|
139 | + $country_code = ''; |
|
140 | + |
|
141 | + if ( ! class_exists( 'MaxMind\Db\Reader' ) ) { |
|
142 | + return $country_code; |
|
143 | + } |
|
144 | + |
|
145 | + $database_path = $this->get_database_path(); |
|
146 | + if ( ! file_exists( $database_path ) ) { |
|
147 | + return $country_code; |
|
148 | + } |
|
149 | + |
|
150 | + try { |
|
151 | + $reader = new MaxMind\Db\Reader( $database_path ); |
|
152 | + $data = $reader->get( $ip_address ); |
|
153 | + |
|
154 | + if ( isset( $data['country']['iso_code'] ) ) { |
|
155 | + $country_code = $data['country']['iso_code']; |
|
156 | + } |
|
157 | + |
|
158 | + $reader->close(); |
|
159 | + } catch ( Exception $e ) { |
|
160 | + wpinv_error_log( $e->getMessage(), 'SOURCE: MaxMind GeoLocation' ); |
|
161 | + } |
|
162 | + |
|
163 | + return $country_code; |
|
164 | + } |
|
165 | 165 | |
166 | 166 | } |