@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | /** |
13 | 13 | * Bail if we are not in WP. |
14 | 14 | */ |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if (!defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Only add if the class does not already exist. |
21 | 21 | */ |
22 | -if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) { |
|
22 | +if (!class_exists('WP_Font_Awesome_Settings')) { |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * A Class to be able to change settings for Font Awesome. |
@@ -87,17 +87,17 @@ discard block |
||
87 | 87 | * @return WP_Font_Awesome_Settings - Main instance. |
88 | 88 | */ |
89 | 89 | public static function instance() { |
90 | - if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) { |
|
90 | + if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) { |
|
91 | 91 | self::$instance = new WP_Font_Awesome_Settings; |
92 | 92 | |
93 | - add_action( 'init', array( self::$instance, 'init' ) ); // set settings |
|
93 | + add_action('init', array(self::$instance, 'init')); // set settings |
|
94 | 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' ) ); |
|
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 | 98 | } |
99 | 99 | |
100 | - do_action( 'wp_font_awesome_settings_loaded' ); |
|
100 | + do_action('wp_font_awesome_settings_loaded'); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | return self::$instance; |
@@ -111,30 +111,30 @@ discard block |
||
111 | 111 | public function init() { |
112 | 112 | $this->settings = $this->get_settings(); |
113 | 113 | |
114 | - if ( $this->settings['type'] == 'CSS' ) { |
|
114 | + if ($this->settings['type'] == 'CSS') { |
|
115 | 115 | |
116 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
117 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
116 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
117 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
118 | 118 | } |
119 | 119 | |
120 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
121 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 ); |
|
120 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
121 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | } else { |
125 | 125 | |
126 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend' ) { |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
126 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'frontend') { |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend' ) { |
|
131 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 ); |
|
130 | + if ($this->settings['enqueue'] == '' || $this->settings['enqueue'] == 'backend') { |
|
131 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); |
|
132 | 132 | } |
133 | 133 | } |
134 | 134 | |
135 | 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 ); |
|
136 | + if ($this->settings['dequeue'] == '1') { |
|
137 | + add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | } |
@@ -146,15 +146,15 @@ discard block |
||
146 | 146 | // build url |
147 | 147 | $url = $this->get_url(); |
148 | 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' ); |
|
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 | 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' ); |
|
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 | 158 | } |
159 | 159 | } |
160 | 160 | |
@@ -166,15 +166,15 @@ discard block |
||
166 | 166 | $url = $this->get_url(); |
167 | 167 | |
168 | 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' ); |
|
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 | 178 | } |
179 | 179 | } |
180 | 180 | |
@@ -185,16 +185,16 @@ discard block |
||
185 | 185 | * |
186 | 186 | * @return string The url to the file. |
187 | 187 | */ |
188 | - public function get_url( $shims = false ) { |
|
188 | + public function get_url($shims = false) { |
|
189 | 189 | $script = $shims ? 'v4-shims' : 'all'; |
190 | 190 | $sub = $this->settings['pro'] ? 'pro' : 'use'; |
191 | 191 | $type = $this->settings['type']; |
192 | 192 | $version = $this->settings['version']; |
193 | - $kit_url = $this->settings['kit-url'] ? esc_url( $this->settings['kit-url'] ) : ''; |
|
193 | + $kit_url = $this->settings['kit-url'] ? esc_url($this->settings['kit-url']) : ''; |
|
194 | 194 | $url = ''; |
195 | 195 | |
196 | - if ( $type == 'KIT' && $kit_url ) { |
|
197 | - if ( $shims ) { |
|
196 | + if ($type == 'KIT' && $kit_url) { |
|
197 | + if ($shims) { |
|
198 | 198 | // if its a kit then we don't add shims here |
199 | 199 | return ''; |
200 | 200 | } |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | $url .= "?wpfas=true"; // set our var so our version is not removed |
203 | 203 | } else { |
204 | 204 | $url .= "https://$sub.fontawesome.com/releases/"; // CDN |
205 | - $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
205 | + $url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version |
|
206 | 206 | $url .= $type == 'CSS' ? 'css/' : 'js/'; // type |
207 | 207 | $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type |
208 | 208 | $url .= "?wpfas=true"; // set our var so our version is not removed |
@@ -222,16 +222,16 @@ discard block |
||
222 | 222 | * |
223 | 223 | * @return string The filtered url. |
224 | 224 | */ |
225 | - public function remove_font_awesome( $url, $original_url, $_context ) { |
|
225 | + public function remove_font_awesome($url, $original_url, $_context) { |
|
226 | 226 | |
227 | - if ( $_context == 'display' |
|
228 | - && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false ) |
|
229 | - && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false ) |
|
227 | + if ($_context == 'display' |
|
228 | + && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false) |
|
229 | + && (strstr($url, ".js") !== false || strstr($url, ".css") !== false) |
|
230 | 230 | ) {// it's a font-awesome-url (probably) |
231 | 231 | |
232 | - if ( strstr( $url, "wpfas=true" ) !== false ) { |
|
233 | - if ( $this->settings['type'] == 'JS' ) { |
|
234 | - if ( $this->settings['js-pseudo'] ) { |
|
232 | + if (strstr($url, "wpfas=true") !== false) { |
|
233 | + if ($this->settings['type'] == 'JS') { |
|
234 | + if ($this->settings['js-pseudo']) { |
|
235 | 235 | $url .= "' data-search-pseudo-elements defer='defer"; |
236 | 236 | } else { |
237 | 237 | $url .= "' defer='defer"; |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * Register the database settings with WordPress. |
251 | 251 | */ |
252 | 252 | public function register_settings() { |
253 | - register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' ); |
|
253 | + register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -259,10 +259,10 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public function menu_item() { |
261 | 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( |
|
262 | + call_user_func($menu_function, $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array( |
|
263 | 263 | $this, |
264 | 264 | 'settings_page' |
265 | - ) ); |
|
265 | + )); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function get_settings() { |
274 | 274 | |
275 | - $db_settings = get_option( 'wp-font-awesome-settings' ); |
|
275 | + $db_settings = get_option('wp-font-awesome-settings'); |
|
276 | 276 | |
277 | 277 | $defaults = array( |
278 | 278 | 'type' => 'CSS', // type to use, CSS or JS or KIT |
@@ -285,14 +285,14 @@ discard block |
||
285 | 285 | 'kit-url' => '', // the kit url |
286 | 286 | ); |
287 | 287 | |
288 | - $settings = wp_parse_args( $db_settings, $defaults ); |
|
288 | + $settings = wp_parse_args($db_settings, $defaults); |
|
289 | 289 | |
290 | 290 | /** |
291 | 291 | * Filter the Font Awesome settings. |
292 | 292 | * |
293 | 293 | * @todo if we add this filer people might use it and then it defeates the purpose of this class :/ |
294 | 294 | */ |
295 | - return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults ); |
|
295 | + return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | |
@@ -300,13 +300,13 @@ discard block |
||
300 | 300 | * The settings page html output. |
301 | 301 | */ |
302 | 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' ) ); |
|
303 | + if (!current_user_can('manage_options')) { |
|
304 | + wp_die(__('You do not have sufficient permissions to access this page.', 'font-awesome-settings')); |
|
305 | 305 | } |
306 | 306 | |
307 | 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 ); |
|
308 | + if (isset($_REQUEST['force-version-check'])) { |
|
309 | + $this->get_latest_version($force_api = true); |
|
310 | 310 | } |
311 | 311 | ?> |
312 | 312 | <style> |
@@ -326,37 +326,37 @@ 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' ); |
|
329 | + settings_fields('wp-font-awesome-settings'); |
|
330 | + do_settings_sections('wp-font-awesome-settings'); |
|
331 | 331 | $kit_set = $this->settings['type'] == 'KIT' ? 'wpfas-kit-set' : ''; |
332 | 332 | ?> |
333 | - <table class="form-table wpfas-table-settings <?php echo esc_attr( $kit_set ); ?>"> |
|
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 |
336 | - for="wpfas-type"><?php _e( 'Type', 'font-awesome-settings' ); ?></label></th> |
|
336 | + for="wpfas-type"><?php _e('Type', 'font-awesome-settings'); ?></label></th> |
|
337 | 337 | <td> |
338 | 338 | <select name="wp-font-awesome-settings[type]" id="wpfas-type" |
339 | 339 | onchange="if(this.value=='KIT'){jQuery('.wpfas-table-settings').addClass('wpfas-kit-set');}else{jQuery('.wpfas-table-settings').removeClass('wpfas-kit-set');}"> |
340 | 340 | <option |
341 | - value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)', 'font-awesome-settings' ); ?></option> |
|
342 | - <option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option> |
|
341 | + value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)', 'font-awesome-settings'); ?></option> |
|
342 | + <option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option> |
|
343 | 343 | <option |
344 | - value="KIT" <?php selected( $this->settings['type'], 'KIT' ); ?>><?php _e( 'Kits (settings managed on fontawesome.com)', 'font-awesome-settings' ); ?></option> |
|
344 | + value="KIT" <?php selected($this->settings['type'], 'KIT'); ?>><?php _e('Kits (settings managed on fontawesome.com)', 'font-awesome-settings'); ?></option> |
|
345 | 345 | </select> |
346 | 346 | </td> |
347 | 347 | </tr> |
348 | 348 | |
349 | 349 | <tr valign="top" class="wpfas-kit-show"> |
350 | 350 | <th scope="row"><label |
351 | - for="wpfas-kit-url"><?php _e( 'Kit URL', 'font-awesome-settings' ); ?></label></th> |
|
351 | + for="wpfas-kit-url"><?php _e('Kit URL', 'font-awesome-settings'); ?></label></th> |
|
352 | 352 | <td> |
353 | 353 | <input class="regular-text" id="wpfas-kit-url" type="url" |
354 | 354 | name="wp-font-awesome-settings[kit-url]" |
355 | - value="<?php echo esc_attr( $this->settings['kit-url'] ); ?>" |
|
355 | + value="<?php echo esc_attr($this->settings['kit-url']); ?>" |
|
356 | 356 | placeholder="https://kit.fontawesome.com/123abc.js"/> |
357 | 357 | <span><?php |
358 | 358 | echo sprintf( |
359 | - __( 'Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings' ), |
|
359 | + __('Requires a free account with Font Awesome. %sGet kit url%s', 'font-awesome-settings'), |
|
360 | 360 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/kits"><i class="fas fa-external-link-alt"></i>', |
361 | 361 | '</a>' |
362 | 362 | ); |
@@ -366,31 +366,31 @@ discard block |
||
366 | 366 | |
367 | 367 | <tr valign="top" class="wpfas-kit-hide"> |
368 | 368 | <th scope="row"><label |
369 | - for="wpfas-version"><?php _e( 'Version', 'font-awesome-settings' ); ?></label></th> |
|
369 | + for="wpfas-version"><?php _e('Version', 'font-awesome-settings'); ?></label></th> |
|
370 | 370 | <td> |
371 | 371 | <select name="wp-font-awesome-settings[version]" id="wpfas-version"> |
372 | 372 | <option |
373 | - value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)', 'font-awesome-settings' ), $this->get_latest_version() ); ?> |
|
373 | + value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)', 'font-awesome-settings'), $this->get_latest_version()); ?> |
|
374 | 374 | </option> |
375 | - <option value="5.6.0" <?php selected( $this->settings['version'], '5.6.0' ); ?>> |
|
375 | + <option value="5.6.0" <?php selected($this->settings['version'], '5.6.0'); ?>> |
|
376 | 376 | 5.6.0 |
377 | 377 | </option> |
378 | - <option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>> |
|
378 | + <option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>> |
|
379 | 379 | 5.5.0 |
380 | 380 | </option> |
381 | - <option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>> |
|
381 | + <option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>> |
|
382 | 382 | 5.4.0 |
383 | 383 | </option> |
384 | - <option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>> |
|
384 | + <option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>> |
|
385 | 385 | 5.3.0 |
386 | 386 | </option> |
387 | - <option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>> |
|
387 | + <option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>> |
|
388 | 388 | 5.2.0 |
389 | 389 | </option> |
390 | - <option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>> |
|
390 | + <option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>> |
|
391 | 391 | 5.1.0 |
392 | 392 | </option> |
393 | - <option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>> |
|
393 | + <option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>> |
|
394 | 394 | 4.7.1 (CSS only) |
395 | 395 | </option> |
396 | 396 | </select> |
@@ -399,29 +399,29 @@ discard block |
||
399 | 399 | |
400 | 400 | <tr valign="top"> |
401 | 401 | <th scope="row"><label |
402 | - for="wpfas-enqueue"><?php _e( 'Enqueue', 'font-awesome-settings' ); ?></label></th> |
|
402 | + for="wpfas-enqueue"><?php _e('Enqueue', 'font-awesome-settings'); ?></label></th> |
|
403 | 403 | <td> |
404 | 404 | <select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue"> |
405 | 405 | <option |
406 | - value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)', 'font-awesome-settings' ); ?></option> |
|
406 | + value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)', 'font-awesome-settings'); ?></option> |
|
407 | 407 | <option |
408 | - value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend', 'font-awesome-settings' ); ?></option> |
|
408 | + value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend', 'font-awesome-settings'); ?></option> |
|
409 | 409 | <option |
410 | - value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend', 'font-awesome-settings' ); ?></option> |
|
410 | + value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend', 'font-awesome-settings'); ?></option> |
|
411 | 411 | </select> |
412 | 412 | </td> |
413 | 413 | </tr> |
414 | 414 | |
415 | 415 | <tr valign="top" class="wpfas-kit-hide"> |
416 | 416 | <th scope="row"><label |
417 | - for="wpfas-pro"><?php _e( 'Enable pro', 'font-awesome-settings' ); ?></label></th> |
|
417 | + for="wpfas-pro"><?php _e('Enable pro', 'font-awesome-settings'); ?></label></th> |
|
418 | 418 | <td> |
419 | 419 | <input type="hidden" name="wp-font-awesome-settings[pro]" value="0"/> |
420 | 420 | <input type="checkbox" name="wp-font-awesome-settings[pro]" |
421 | - value="1" <?php checked( $this->settings['pro'], '1' ); ?> id="wpfas-pro"/> |
|
421 | + value="1" <?php checked($this->settings['pro'], '1'); ?> id="wpfas-pro"/> |
|
422 | 422 | <span><?php |
423 | 423 | echo sprintf( |
424 | - __( 'Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings' ), |
|
424 | + __('Requires a subscription. %sLearn more%s %sManage my allowed domains%s', 'font-awesome-settings'), |
|
425 | 425 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/pro"><i class="fas fa-external-link-alt"></i>', |
426 | 426 | '</a>', |
427 | 427 | '<a rel="noopener noreferrer" target="_blank" href="https://fontawesome.com/account/cdn"><i class="fas fa-external-link-alt"></i>', |
@@ -433,38 +433,38 @@ discard block |
||
433 | 433 | |
434 | 434 | <tr valign="top" class="wpfas-kit-hide"> |
435 | 435 | <th scope="row"><label |
436 | - for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility', 'font-awesome-settings' ); ?></label> |
|
436 | + for="wpfas-shims"><?php _e('Enable v4 shims compatibility', 'font-awesome-settings'); ?></label> |
|
437 | 437 | </th> |
438 | 438 | <td> |
439 | 439 | <input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/> |
440 | 440 | <input type="checkbox" name="wp-font-awesome-settings[shims]" |
441 | - value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/> |
|
442 | - <span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings' ); ?></span> |
|
441 | + value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/> |
|
442 | + <span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.', 'font-awesome-settings'); ?></span> |
|
443 | 443 | </td> |
444 | 444 | </tr> |
445 | 445 | |
446 | 446 | <tr valign="top" class="wpfas-kit-hide"> |
447 | 447 | <th scope="row"><label |
448 | - for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)', 'font-awesome-settings' ); ?></label> |
|
448 | + for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)', 'font-awesome-settings'); ?></label> |
|
449 | 449 | </th> |
450 | 450 | <td> |
451 | 451 | <input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/> |
452 | 452 | <input type="checkbox" name="wp-font-awesome-settings[js-pseudo]" |
453 | - value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?> |
|
453 | + value="1" <?php checked($this->settings['js-pseudo'], '1'); ?> |
|
454 | 454 | id="wpfas-js-pseudo"/> |
455 | - <span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings' ); ?></span> |
|
455 | + <span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.', 'font-awesome-settings'); ?></span> |
|
456 | 456 | </td> |
457 | 457 | </tr> |
458 | 458 | |
459 | 459 | <tr valign="top"> |
460 | 460 | <th scope="row"><label |
461 | - for="wpfas-dequeue"><?php _e( 'Dequeue', 'font-awesome-settings' ); ?></label></th> |
|
461 | + for="wpfas-dequeue"><?php _e('Dequeue', 'font-awesome-settings'); ?></label></th> |
|
462 | 462 | <td> |
463 | 463 | <input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/> |
464 | 464 | <input type="checkbox" name="wp-font-awesome-settings[dequeue]" |
465 | - value="1" <?php checked( $this->settings['dequeue'], '1' ); ?> |
|
465 | + value="1" <?php checked($this->settings['dequeue'], '1'); ?> |
|
466 | 466 | id="wpfas-dequeue"/> |
467 | - <span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings' ); ?></span> |
|
467 | + <span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.', 'font-awesome-settings'); ?></span> |
|
468 | 468 | </td> |
469 | 469 | </tr> |
470 | 470 | |
@@ -489,12 +489,12 @@ discard block |
||
489 | 489 | * |
490 | 490 | * @return string Either a valid version number or an empty string. |
491 | 491 | */ |
492 | - public function validate_version_number( $version ) { |
|
492 | + public function validate_version_number($version) { |
|
493 | 493 | |
494 | - if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) { |
|
494 | + if (version_compare($version, '0.0.1', '>=') >= 0) { |
|
495 | 495 | // valid |
496 | 496 | } else { |
497 | - $version = '';// not validated |
|
497 | + $version = ''; // not validated |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | return $version; |
@@ -509,19 +509,19 @@ discard block |
||
509 | 509 | * @since 1.0.7 |
510 | 510 | * @return mixed|string The latest version number found. |
511 | 511 | */ |
512 | - public function get_latest_version( $force_api = false ) { |
|
512 | + public function get_latest_version($force_api = false) { |
|
513 | 513 | $latest_version = $this->latest; |
514 | 514 | |
515 | - $cache = get_transient( 'wp-font-awesome-settings-version' ); |
|
515 | + $cache = get_transient('wp-font-awesome-settings-version'); |
|
516 | 516 | |
517 | - if ( $cache === false || $force_api ) { // its not set |
|
517 | + if ($cache === false || $force_api) { // its not set |
|
518 | 518 | $api_ver = $this->get_latest_version_from_api(); |
519 | - if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) { |
|
519 | + if (version_compare($api_ver, $this->latest, '>=') >= 0) { |
|
520 | 520 | $latest_version = $api_ver; |
521 | - set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS ); |
|
521 | + set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS); |
|
522 | 522 | } |
523 | - } elseif ( $this->validate_version_number( $cache ) ) { |
|
524 | - if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) { |
|
523 | + } elseif ($this->validate_version_number($cache)) { |
|
524 | + if (version_compare($cache, $this->latest, '>=') >= 0) { |
|
525 | 525 | $latest_version = $cache; |
526 | 526 | } |
527 | 527 | } |
@@ -537,10 +537,10 @@ discard block |
||
537 | 537 | */ |
538 | 538 | public function get_latest_version_from_api() { |
539 | 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'] ) ) { |
|
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 | 544 | $version = $api_response['tag_name']; |
545 | 545 | } |
546 | 546 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Abstract privacy class. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Abstract class that is intended to be extended by |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $name Plugin identifier. |
40 | 40 | */ |
41 | - public function __construct( $name = '' ) { |
|
41 | + public function __construct($name = '') { |
|
42 | 42 | $this->name = $name; |
43 | 43 | $this->init(); |
44 | 44 | } |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | * Hook in events. |
48 | 48 | */ |
49 | 49 | protected function init() { |
50 | - add_action( 'admin_init', array( $this, 'add_privacy_message' ) ); |
|
50 | + add_action('admin_init', array($this, 'add_privacy_message')); |
|
51 | 51 | // Register data exporters |
52 | - add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 ); |
|
52 | + add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10); |
|
53 | 53 | // Register data erasers |
54 | - add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) ); |
|
54 | + add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Adds the privacy message on invoicing privacy page. |
59 | 59 | */ |
60 | 60 | public function add_privacy_message() { |
61 | - if ( function_exists( 'wp_add_privacy_policy_content' ) ) { |
|
61 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
62 | 62 | $content = $this->get_privacy_message(); |
63 | 63 | |
64 | - if ( $content ) { |
|
65 | - wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() ); |
|
64 | + if ($content) { |
|
65 | + wp_add_privacy_policy_content($this->name, $this->get_privacy_message()); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param array $exporters List of exporter callbacks. |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public function register_exporters( $exporters = array() ) { |
|
87 | - foreach ( $this->exporters as $id => $exporter ) { |
|
88 | - $exporters[ $id ] = $exporter; |
|
86 | + public function register_exporters($exporters = array()) { |
|
87 | + foreach ($this->exporters as $id => $exporter) { |
|
88 | + $exporters[$id] = $exporter; |
|
89 | 89 | } |
90 | 90 | return $exporters; |
91 | 91 | } |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * @param array $erasers List of eraser callbacks. |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function register_erasers( $erasers = array() ) { |
|
100 | - foreach ( $this->erasers as $id => $eraser ) { |
|
101 | - $erasers[ $id ] = $eraser; |
|
99 | + public function register_erasers($erasers = array()) { |
|
100 | + foreach ($this->erasers as $id => $eraser) { |
|
101 | + $erasers[$id] = $eraser; |
|
102 | 102 | } |
103 | 103 | return $erasers; |
104 | 104 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function add_exporter( $id, $name, $callback ) { |
|
116 | - $this->exporters[ $id ] = array( |
|
115 | + public function add_exporter($id, $name, $callback) { |
|
116 | + $this->exporters[$id] = array( |
|
117 | 117 | 'exporter_friendly_name' => $name, |
118 | 118 | 'callback' => $callback, |
119 | 119 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function add_eraser( $id, $name, $callback ) { |
|
133 | - $this->erasers[ $id ] = array( |
|
132 | + public function add_eraser($id, $name, $callback) { |
|
133 | + $this->erasers[$id] = array( |
|
134 | 134 | 'eraser_friendly_name' => $name, |
135 | 135 | 'callback' => $callback, |
136 | 136 | ); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Handle data for the current customer session |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @param mixed $key Key to get. |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function __get( $key ) { |
|
55 | - return $this->get( $key ); |
|
54 | + public function __get($key) { |
|
55 | + return $this->get($key); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param mixed $key Key to set. |
62 | 62 | * @param mixed $value Value to set. |
63 | 63 | */ |
64 | - public function __set( $key, $value ) { |
|
65 | - $this->set( $key, $value ); |
|
64 | + public function __set($key, $value) { |
|
65 | + $this->set($key, $value); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param mixed $key Key to check. |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - public function __isset( $key ) { |
|
75 | - return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
74 | + public function __isset($key) { |
|
75 | + return isset($this->_data[sanitize_title($key)]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param mixed $key Key to unset. |
82 | 82 | */ |
83 | - public function __unset( $key ) { |
|
84 | - if ( isset( $this->_data[ $key ] ) ) { |
|
85 | - unset( $this->_data[ $key ] ); |
|
83 | + public function __unset($key) { |
|
84 | + if (isset($this->_data[$key])) { |
|
85 | + unset($this->_data[$key]); |
|
86 | 86 | $this->_dirty = true; |
87 | 87 | } |
88 | 88 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param mixed $default used if the session variable isn't set. |
95 | 95 | * @return array|string value of session variable |
96 | 96 | */ |
97 | - public function get( $key, $default = null ) { |
|
98 | - $key = sanitize_key( $key ); |
|
99 | - return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
97 | + public function get($key, $default = null) { |
|
98 | + $key = sanitize_key($key); |
|
99 | + return isset($this->_data[$key]) ? maybe_unserialize($this->_data[$key]) : $default; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string $key Key to set. |
106 | 106 | * @param mixed $value Value to set. |
107 | 107 | */ |
108 | - public function set( $key, $value ) { |
|
109 | - if ( $value !== $this->get( $key ) ) { |
|
110 | - $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
108 | + public function set($key, $value) { |
|
109 | + if ($value !== $this->get($key)) { |
|
110 | + $this->_data[sanitize_key($key)] = maybe_serialize($value); |
|
111 | 111 | $this->_dirty = true; |
112 | 112 | } |
113 | 113 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | 12 | <h1><?php echo get_admin_page_title(); ?></h1> |
13 | 13 | |
14 | - <?php if ( $tabs ){ ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if($current_tab == 'membership'){ |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if(defined('WP_EASY_UPDATES_ACTIVE')){?> |
|
36 | - <h2><?php _e("Have a membership key?","invoicing");?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?> |
|
36 | + <h2><?php _e("Have a membership key?", "invoicing"); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
40 | - echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351)); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php }?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php _e("Membership benefits Include:","invoicing");?></h2> |
|
47 | + <h2><?php _e("Membership benefits Include:", "invoicing"); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php _e("Membership Starts from","invoicing");?></h3> |
|
61 | + <h3><?php _e("Membership Starts from", "invoicing"); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php _e("Included Gateways:","invoicing");?></h3> |
|
65 | + <h3><?php _e("Included Gateways:", "invoicing"); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
84 | + echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
104 | + echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice","invoicing");?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice", "invoicing"); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -126,44 +126,44 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | ?> |
134 | - <ul class="wpi-products"><?php foreach ( $addons as $addon ) : |
|
135 | - if(965==$addon->info->id){continue;}// don't show quote add on |
|
134 | + <ul class="wpi-products"><?php foreach ($addons as $addon) : |
|
135 | + if (965 == $addon->info->id) {continue; }// don't show quote add on |
|
136 | 136 | ?><li class="wpi-product"> |
137 | 137 | <div class="wpi-product-title"> |
138 | 138 | <h3><?php |
139 | - if ( ! empty( $addon->info->excerpt) ){ |
|
140 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
139 | + if (!empty($addon->info->excerpt)) { |
|
140 | + echo wpi_help_tip($addon->info->excerpt); |
|
141 | 141 | } |
142 | - echo esc_html( $addon->info->title ); ?></h3> |
|
142 | + echo esc_html($addon->info->title); ?></h3> |
|
143 | 143 | </div> |
144 | 144 | |
145 | 145 | <span class="wpi-product-image"> |
146 | - <?php if ( ! empty( $addon->info->thumbnail) ) : ?> |
|
147 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
146 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
147 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
148 | 148 | <?php endif; |
149 | 149 | |
150 | - if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
151 | - echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
152 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
150 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") { |
|
151 | + echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
152 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
153 | 153 | echo '</a>'; |
154 | - }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){ |
|
155 | - if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
156 | - $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com&TB_iframe=true'); |
|
157 | - }else{ |
|
154 | + }elseif (isset($addon->info->link) && substr($addon->info->link, 0, 23) === "https://wpinvoicing.com") { |
|
155 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
156 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpinvoicing.com&TB_iframe=true'); |
|
157 | + } else { |
|
158 | 158 | // if installed show activation link |
159 | - if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
159 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
160 | 160 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
161 | - }else{ |
|
161 | + } else { |
|
162 | 162 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
163 | 163 | } |
164 | 164 | } |
165 | - echo '<a href="'.$url.'" class="thickbox">'; |
|
166 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
165 | + echo '<a href="' . $url . '" class="thickbox">'; |
|
166 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
167 | 167 | echo '</a>'; |
168 | 168 | } |
169 | 169 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | |
175 | 175 | <span class="wpi-product-button"> |
176 | 176 | <?php |
177 | - $addon_obj->output_button( $addon ); |
|
177 | + $addon_obj->output_button($addon); |
|
178 | 178 | ?> |
179 | 179 | </span> |
180 | 180 | |
@@ -188,21 +188,21 @@ discard block |
||
188 | 188 | |
189 | 189 | <div class="clearfix" ></div> |
190 | 190 | |
191 | - <?php if($current_tab =='addons'){ ?> |
|
192 | - <p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p> |
|
193 | - <?php } if($current_tab =='gateways'){ ?> |
|
194 | - <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p> |
|
191 | + <?php if ($current_tab == 'addons') { ?> |
|
192 | + <p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p> |
|
193 | + <?php } if ($current_tab == 'gateways') { ?> |
|
194 | + <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p> |
|
195 | 195 | <?php } ?> |
196 | 196 | |
197 | - <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div> |
|
198 | - <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div> |
|
197 | + <div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div> |
|
198 | + <div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div> |
|
199 | 199 | <div id="wpeu-licence-popup" style="display:none;"> |
200 | 200 | <span class="wpi-notification noti-white"> |
201 | - <h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3> |
|
202 | - <input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button> |
|
201 | + <h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3> |
|
202 | + <input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button> |
|
203 | 203 | <br> |
204 | 204 | <?php |
205 | - echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' ); |
|
205 | + echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>'); |
|
206 | 206 | ?> |
207 | 207 | </span> |
208 | 208 | </div> |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | * @param Array $assoc_args Key value arguments stored in associated array format. |
25 | 25 | * @since 1.0.13 |
26 | 26 | */ |
27 | - public function insert_invoice( $args, $assoc_args ) { |
|
27 | + public function insert_invoice($args, $assoc_args) { |
|
28 | 28 | |
29 | 29 | // Fetch invoice data from the args |
30 | - $invoice_data = wp_unslash( $assoc_args ); |
|
30 | + $invoice_data = wp_unslash($assoc_args); |
|
31 | 31 | |
32 | 32 | // Abort if no invoice data is provided |
33 | - if( empty( $invoice_data ) ) { |
|
34 | - return WP_CLI::error( __( 'Invoice data not provided', 'invoicing' ) ); |
|
33 | + if (empty($invoice_data)) { |
|
34 | + return WP_CLI::error(__('Invoice data not provided', 'invoicing')); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | //Cart details |
38 | - if( !empty( $invoice_data['cart_details'] ) ) { |
|
39 | - $invoice_data['cart_details'] = json_decode( $invoice_data['cart_details'], true ); |
|
38 | + if (!empty($invoice_data['cart_details'])) { |
|
39 | + $invoice_data['cart_details'] = json_decode($invoice_data['cart_details'], true); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //User details |
43 | - if( !empty( $invoice_data['user_info'] ) ) { |
|
44 | - $invoice_data['user_info'] = json_decode( $invoice_data['user_info'], true ); |
|
43 | + if (!empty($invoice_data['user_info'])) { |
|
44 | + $invoice_data['user_info'] = json_decode($invoice_data['user_info'], true); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | //Payment info |
48 | - if( !empty( $invoice_data['payment_details'] ) ) { |
|
49 | - $invoice_data['payment_details'] = json_decode( $invoice_data['payment_details'], true ); |
|
48 | + if (!empty($invoice_data['payment_details'])) { |
|
49 | + $invoice_data['payment_details'] = json_decode($invoice_data['payment_details'], true); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Try creating the invoice |
53 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
53 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
54 | 54 | |
55 | - if ( is_wp_error( $invoice ) ) { |
|
56 | - return WP_CLI::error( $invoice->get_error_message() ); |
|
55 | + if (is_wp_error($invoice)) { |
|
56 | + return WP_CLI::error($invoice->get_error_message()); |
|
57 | 57 | } |
58 | 58 | |
59 | - $message = sprintf( __( 'Invoice %s created', 'invoicing' ), $invoice->ID ); |
|
60 | - WP_CLI::success( $message ); |
|
59 | + $message = sprintf(__('Invoice %s created', 'invoicing'), $invoice->ID); |
|
60 | + WP_CLI::success($message); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 |
@@ -1,41 +1,41 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
6 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
7 | 7 | <div id="wpinv-email-billing"> |
8 | - <h3 class="wpinv-address-t"><?php echo apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ); ?></h3> |
|
8 | + <h3 class="wpinv-address-t"><?php echo apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing')); ?></h3> |
|
9 | 9 | |
10 | 10 | <table class="table table-bordered table-sm wpi-billing-details"> |
11 | 11 | <tbody> |
12 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
12 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
13 | 13 | <tr class="wpi-receipt-name"> |
14 | - <th class="text-left"><?php _e( 'Name', 'invoicing' ); ?></th> |
|
15 | - <td><?php if ( $sent_to_admin && $invoice->user_id ) { ?><a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ) ;?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a><?php } else { echo esc_html( $invoice->get_user_full_name() ); } ?></td> |
|
14 | + <th class="text-left"><?php _e('Name', 'invoicing'); ?></th> |
|
15 | + <td><?php if ($sent_to_admin && $invoice->user_id) { ?><a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a><?php } else { echo esc_html($invoice->get_user_full_name()); } ?></td> |
|
16 | 16 | </tr> |
17 | 17 | <tr class="wpi-receipt-email"> |
18 | - <th class="text-left"><?php _e( 'Email', 'invoicing' ); ?></th> |
|
19 | - <td><?php echo $invoice->get_email() ;?></td> |
|
18 | + <th class="text-left"><?php _e('Email', 'invoicing'); ?></th> |
|
19 | + <td><?php echo $invoice->get_email(); ?></td> |
|
20 | 20 | </tr> |
21 | - <?php if ( $invoice->company ) { ?> |
|
21 | + <?php if ($invoice->company) { ?> |
|
22 | 22 | <tr class="wpi-receipt-company"> |
23 | - <th class="text-left"><?php _e( 'Company', 'invoicing' ); ?></th> |
|
24 | - <td><?php echo esc_html( $invoice->company ) ;?></td> |
|
23 | + <th class="text-left"><?php _e('Company', 'invoicing'); ?></th> |
|
24 | + <td><?php echo esc_html($invoice->company); ?></td> |
|
25 | 25 | </tr> |
26 | 26 | <?php } ?> |
27 | 27 | <tr class="wpi-receipt-address"> |
28 | - <th class="text-left"><?php _e( 'Address', 'invoicing' ); ?></th> |
|
29 | - <td><?php echo wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ;?></td> |
|
28 | + <th class="text-left"><?php _e('Address', 'invoicing'); ?></th> |
|
29 | + <td><?php echo wpinv_get_invoice_address_markup($invoice->get_user_info()); ?></td> |
|
30 | 30 | </tr> |
31 | - <?php if ( $invoice->phone ) { ?> |
|
31 | + <?php if ($invoice->phone) { ?> |
|
32 | 32 | <tr class="wpi-receipt-phone"> |
33 | - <th class="text-left"><?php _e( 'Phone', 'invoicing' ); ?></th> |
|
34 | - <td><?php echo esc_html( $invoice->phone ) ;?></td> |
|
33 | + <th class="text-left"><?php _e('Phone', 'invoicing'); ?></th> |
|
34 | + <td><?php echo esc_html($invoice->phone); ?></td> |
|
35 | 35 | </tr> |
36 | 36 | <?php } ?> |
37 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
37 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
38 | 38 | </tbody> |
39 | 39 | </table> |
40 | 40 | </div> |
41 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
42 | 41 | \ No newline at end of file |
42 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
|
43 | 43 | \ No newline at end of file |
@@ -342,7 +342,7 @@ discard block |
||
342 | 342 | return false; |
343 | 343 | } |
344 | 344 | if (null !== $this->apcuPrefix) { |
345 | - $file = apcu_fetch($this->apcuPrefix.$class, $hit); |
|
345 | + $file = apcu_fetch($this->apcuPrefix . $class, $hit); |
|
346 | 346 | if ($hit) { |
347 | 347 | return $file; |
348 | 348 | } |
@@ -356,7 +356,7 @@ discard block |
||
356 | 356 | } |
357 | 357 | |
358 | 358 | if (null !== $this->apcuPrefix) { |
359 | - apcu_add($this->apcuPrefix.$class, $file); |
|
359 | + apcu_add($this->apcuPrefix . $class, $file); |
|
360 | 360 | } |
361 | 361 | |
362 | 362 | if (false === $file) { |
@@ -1,60 +1,60 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | -add_filter( 'wpinv_authorizenet_support_subscription', '__return_true' ); |
|
5 | +add_filter('wpinv_authorizenet_support_subscription', '__return_true'); |
|
6 | 6 | |
7 | -function wpinv_authorizenet_cc_form( $invoice_id ) { |
|
8 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
9 | - $cc_owner = !empty( $invoice ) ? esc_attr( $invoice->get_user_full_name() ) : ''; |
|
7 | +function wpinv_authorizenet_cc_form($invoice_id) { |
|
8 | + $invoice = wpinv_get_invoice($invoice_id); |
|
9 | + $cc_owner = !empty($invoice) ? esc_attr($invoice->get_user_full_name()) : ''; |
|
10 | 10 | ?> |
11 | 11 | <div id="authorizenet_cc_form" class="form-horizontal wpi-cc-form panel panel-default"> |
12 | - <div class="panel-heading"><h3 class="panel-title"><?php _e( 'Card Details', 'invoicing' ) ;?></h3></div> |
|
12 | + <div class="panel-heading"><h3 class="panel-title"><?php _e('Card Details', 'invoicing'); ?></h3></div> |
|
13 | 13 | <div class="panel-body"> |
14 | 14 | <div class="form-group required"> |
15 | - <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e( 'Card Owner', 'invoicing' ) ;?></label> |
|
15 | + <label for="auth-input-cc-owner" class="col-sm-3 control-label"><?php _e('Card Owner', 'invoicing'); ?></label> |
|
16 | 16 | <div class="col-sm-5"> |
17 | - <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e( 'Card Owner', 'invoicing' ) ;?>" value="<?php echo $cc_owner;?>" name="authorizenet[cc_owner]"> |
|
17 | + <input type="text" class="form-control" id="auth-input-cc-owner" placeholder="<?php esc_attr_e('Card Owner', 'invoicing'); ?>" value="<?php echo $cc_owner; ?>" name="authorizenet[cc_owner]"> |
|
18 | 18 | </div> |
19 | 19 | </div> |
20 | 20 | <div class="form-group required"> |
21 | - <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e( 'Card Number', 'invoicing' ) ;?></label> |
|
21 | + <label for="auth-input-cc-number" class="col-sm-3 control-label"><?php _e('Card Number', 'invoicing'); ?></label> |
|
22 | 22 | <div class="col-sm-5"> |
23 | - <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e( 'Card Number', 'invoicing' ) ;?>" value="" name="authorizenet[cc_number]"> |
|
23 | + <input type="text" class="form-control" id="auth-input-cc-number" placeholder="<?php esc_attr_e('Card Number', 'invoicing'); ?>" value="" name="authorizenet[cc_number]"> |
|
24 | 24 | </div> |
25 | 25 | </div> |
26 | 26 | <div class="form-group required"> |
27 | - <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e( 'Card Expiry Date', 'invoicing' ) ;?></label> |
|
27 | + <label for="auth-input-cc-expire-date" class="col-sm-3 control-label"><?php _e('Card Expiry Date', 'invoicing'); ?></label> |
|
28 | 28 | <div class="col-sm-2"> |
29 | 29 | <select class="form-control" id="auth-input-cc-expire-date" name="authorizenet[cc_expire_month]"> |
30 | - <?php for ( $i = 1; $i <= 12; $i++ ) { $value = str_pad( $i, 2, '0', STR_PAD_LEFT ); ?> |
|
31 | - <option value="<?php echo $value;?>"><?php echo $value;?></option> |
|
30 | + <?php for ($i = 1; $i <= 12; $i++) { $value = str_pad($i, 2, '0', STR_PAD_LEFT); ?> |
|
31 | + <option value="<?php echo $value; ?>"><?php echo $value; ?></option> |
|
32 | 32 | <?php } ?> |
33 | 33 | </select> |
34 | 34 | </div> |
35 | 35 | <div class="col-sm-3"> |
36 | 36 | <select class="form-control" name="authorizenet[cc_expire_year]"> |
37 | - <?php $year = date( 'Y' ); for ( $i = $year; $i <= ( $year + 10 ); $i++ ) { ?> |
|
38 | - <option value="<?php echo $i;?>"><?php echo $i;?></option> |
|
37 | + <?php $year = date('Y'); for ($i = $year; $i <= ($year + 10); $i++) { ?> |
|
38 | + <option value="<?php echo $i; ?>"><?php echo $i; ?></option> |
|
39 | 39 | <?php } ?> |
40 | 40 | </select> |
41 | 41 | </div> |
42 | 42 | </div> |
43 | 43 | <div class="form-group required"> |
44 | - <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e( 'Card Security Code (CVV2)', 'invoicing' ) ;?></label> |
|
44 | + <label for="auth-input-cc-cvv2" class="col-sm-3 control-label"><?php _e('Card Security Code (CVV2)', 'invoicing'); ?></label> |
|
45 | 45 | <div class="col-sm-5"> |
46 | - <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e( 'Card Security Code (CVV2)', 'invoicing' ) ;?>" value="" name="authorizenet[cc_cvv2]""> |
|
46 | + <input type="text" class="form-control" id="auth-input-cc-cvv2" placeholder="<?php esc_attr_e('Card Security Code (CVV2)', 'invoicing'); ?>" value="" name="authorizenet[cc_cvv2]""> |
|
47 | 47 | </div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | 50 | </div> |
51 | 51 | <?php |
52 | 52 | } |
53 | -add_action( 'wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1 ); |
|
53 | +add_action('wpinv_authorizenet_cc_form', 'wpinv_authorizenet_cc_form', 10, 1); |
|
54 | 54 | |
55 | -function wpinv_process_authorizenet_payment( $purchase_data ) { |
|
56 | - if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) { |
|
57 | - wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
55 | +function wpinv_process_authorizenet_payment($purchase_data) { |
|
56 | + if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) { |
|
57 | + wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Collect payment data |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | ); |
73 | 73 | |
74 | 74 | // Record the pending payment |
75 | - $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] ); |
|
75 | + $invoice = wpinv_get_invoice($purchase_data['invoice_id']); |
|
76 | 76 | |
77 | - if ( !empty( $invoice ) ) { |
|
78 | - $authorizenet_card = !empty( $_POST['authorizenet'] ) ? $_POST['authorizenet'] : array(); |
|
77 | + if (!empty($invoice)) { |
|
78 | + $authorizenet_card = !empty($_POST['authorizenet']) ? $_POST['authorizenet'] : array(); |
|
79 | 79 | $card_defaults = array( |
80 | 80 | 'cc_owner' => $invoice->get_user_full_name(), |
81 | 81 | 'cc_number' => false, |
@@ -83,192 +83,192 @@ discard block |
||
83 | 83 | 'cc_expire_year' => false, |
84 | 84 | 'cc_cvv2' => false, |
85 | 85 | ); |
86 | - $authorizenet_card = wp_parse_args( $authorizenet_card, $card_defaults ); |
|
86 | + $authorizenet_card = wp_parse_args($authorizenet_card, $card_defaults); |
|
87 | 87 | |
88 | - if ( empty( $authorizenet_card['cc_owner'] ) ) { |
|
89 | - wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing')); |
|
88 | + if (empty($authorizenet_card['cc_owner'])) { |
|
89 | + wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing')); |
|
90 | 90 | } |
91 | - if ( empty( $authorizenet_card['cc_number'] ) ) { |
|
92 | - wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing')); |
|
91 | + if (empty($authorizenet_card['cc_number'])) { |
|
92 | + wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing')); |
|
93 | 93 | } |
94 | - if ( empty( $authorizenet_card['cc_expire_month'] ) ) { |
|
95 | - wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing')); |
|
94 | + if (empty($authorizenet_card['cc_expire_month'])) { |
|
95 | + wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing')); |
|
96 | 96 | } |
97 | - if ( empty( $authorizenet_card['cc_expire_year'] ) ) { |
|
98 | - wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing')); |
|
97 | + if (empty($authorizenet_card['cc_expire_year'])) { |
|
98 | + wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing')); |
|
99 | 99 | } |
100 | - if ( empty( $authorizenet_card['cc_cvv2'] ) ) { |
|
101 | - wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) ); |
|
100 | + if (empty($authorizenet_card['cc_cvv2'])) { |
|
101 | + wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing')); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | $errors = wpinv_get_errors(); |
105 | 105 | |
106 | - if ( empty( $errors ) ) { |
|
106 | + if (empty($errors)) { |
|
107 | 107 | $invoice_id = $invoice->ID; |
108 | 108 | $quantities_enabled = wpinv_item_quantities_enabled(); |
109 | 109 | $use_taxes = wpinv_use_taxes(); |
110 | 110 | |
111 | 111 | $authorizeAIM = wpinv_authorizenet_AIM(); |
112 | - $authorizeAIM->first_name = wpinv_utf8_substr( $invoice->get_first_name(), 0, 50 ); |
|
113 | - $authorizeAIM->last_name = wpinv_utf8_substr( $invoice->get_last_name(), 0, 50 ); |
|
114 | - $authorizeAIM->company = wpinv_utf8_substr( $invoice->company, 0, 50 ); |
|
115 | - $authorizeAIM->address = wpinv_utf8_substr( wp_strip_all_tags( $invoice->get_address(), true ), 0, 60 ); |
|
116 | - $authorizeAIM->city = wpinv_utf8_substr( $invoice->city, 0, 40 ); |
|
117 | - $authorizeAIM->state = wpinv_utf8_substr( $invoice->state, 0, 40 ); |
|
118 | - $authorizeAIM->zip = wpinv_utf8_substr( $invoice->zip, 0, 40 ); |
|
119 | - $authorizeAIM->country = wpinv_utf8_substr( $invoice->country, 0, 60 ); |
|
120 | - $authorizeAIM->phone = wpinv_utf8_substr( $invoice->phone, 0, 25 ); |
|
121 | - $authorizeAIM->email = wpinv_utf8_substr( $invoice->get_email(), 0, 255 ); |
|
122 | - $authorizeAIM->amount = wpinv_sanitize_amount( $invoice->get_total() ); |
|
123 | - $authorizeAIM->card_num = str_replace( ' ', '', sanitize_text_field( $authorizenet_card['cc_number'] ) ); |
|
124 | - $authorizeAIM->exp_date = sanitize_text_field( $authorizenet_card['cc_expire_month'] ) . sanitize_text_field( $authorizenet_card['cc_expire_year'] ); |
|
125 | - $authorizeAIM->card_code = sanitize_text_field( $authorizenet_card['cc_cvv2'] ); |
|
112 | + $authorizeAIM->first_name = wpinv_utf8_substr($invoice->get_first_name(), 0, 50); |
|
113 | + $authorizeAIM->last_name = wpinv_utf8_substr($invoice->get_last_name(), 0, 50); |
|
114 | + $authorizeAIM->company = wpinv_utf8_substr($invoice->company, 0, 50); |
|
115 | + $authorizeAIM->address = wpinv_utf8_substr(wp_strip_all_tags($invoice->get_address(), true), 0, 60); |
|
116 | + $authorizeAIM->city = wpinv_utf8_substr($invoice->city, 0, 40); |
|
117 | + $authorizeAIM->state = wpinv_utf8_substr($invoice->state, 0, 40); |
|
118 | + $authorizeAIM->zip = wpinv_utf8_substr($invoice->zip, 0, 40); |
|
119 | + $authorizeAIM->country = wpinv_utf8_substr($invoice->country, 0, 60); |
|
120 | + $authorizeAIM->phone = wpinv_utf8_substr($invoice->phone, 0, 25); |
|
121 | + $authorizeAIM->email = wpinv_utf8_substr($invoice->get_email(), 0, 255); |
|
122 | + $authorizeAIM->amount = wpinv_sanitize_amount($invoice->get_total()); |
|
123 | + $authorizeAIM->card_num = str_replace(' ', '', sanitize_text_field($authorizenet_card['cc_number'])); |
|
124 | + $authorizeAIM->exp_date = sanitize_text_field($authorizenet_card['cc_expire_month']) . sanitize_text_field($authorizenet_card['cc_expire_year']); |
|
125 | + $authorizeAIM->card_code = sanitize_text_field($authorizenet_card['cc_cvv2']); |
|
126 | 126 | $authorizeAIM->invoice_num = $invoice->ID; |
127 | 127 | |
128 | 128 | $item_desc = array(); |
129 | - foreach ( $invoice->get_cart_details() as $item ) { |
|
130 | - $quantity = $quantities_enabled && !empty( $item['quantity'] ) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
131 | - $item_name = wpinv_utf8_substr( $item['name'], 0, 31 ); |
|
132 | - $item_desc[] = $item_name . ' (' . $quantity . 'x ' . wpinv_price( wpinv_format_amount( $item['item_price'] ) ) . ')'; |
|
129 | + foreach ($invoice->get_cart_details() as $item) { |
|
130 | + $quantity = $quantities_enabled && !empty($item['quantity']) && $item['quantity'] > 0 ? $item['quantity'] : 1; |
|
131 | + $item_name = wpinv_utf8_substr($item['name'], 0, 31); |
|
132 | + $item_desc[] = $item_name . ' (' . $quantity . 'x ' . wpinv_price(wpinv_format_amount($item['item_price'])) . ')'; |
|
133 | 133 | |
134 | - $authorizeAIM->addLineItem( $item['id'], $item_name, '', $quantity, $item['item_price'], ( $use_taxes && !empty( $item['tax'] ) && $item['tax'] > 0 ? 'Y' : 'N' ) ); |
|
134 | + $authorizeAIM->addLineItem($item['id'], $item_name, '', $quantity, $item['item_price'], ($use_taxes && !empty($item['tax']) && $item['tax'] > 0 ? 'Y' : 'N')); |
|
135 | 135 | } |
136 | 136 | |
137 | - $item_desc = '#' . $invoice->get_number() . ': ' . implode( ', ', $item_desc ); |
|
137 | + $item_desc = '#' . $invoice->get_number() . ': ' . implode(', ', $item_desc); |
|
138 | 138 | |
139 | - if ( $use_taxes && $invoice->get_tax() > 0 ) { |
|
140 | - $authorizeAIM->tax = $invoice->get_tax(); |
|
139 | + if ($use_taxes && $invoice->get_tax() > 0) { |
|
140 | + $authorizeAIM->tax = $invoice->get_tax(); |
|
141 | 141 | |
142 | - $item_desc .= ', ' . wp_sprintf( __( 'Tax: %s', 'invoicing' ), $invoice->get_tax( true ) ); |
|
142 | + $item_desc .= ', ' . wp_sprintf(__('Tax: %s', 'invoicing'), $invoice->get_tax(true)); |
|
143 | 143 | } |
144 | 144 | |
145 | - if ( $invoice->get_discount() > 0 ) { |
|
146 | - $item_desc .= ', ' . wp_sprintf( __( 'Discount: %s', 'invoicing' ), $invoice->get_discount( true ) ); |
|
145 | + if ($invoice->get_discount() > 0) { |
|
146 | + $item_desc .= ', ' . wp_sprintf(__('Discount: %s', 'invoicing'), $invoice->get_discount(true)); |
|
147 | 147 | } |
148 | 148 | |
149 | - $item_description = wpinv_utf8_substr( $item_desc, 0, 255 ); |
|
150 | - $item_description = html_entity_decode( $item_desc , ENT_QUOTES, 'UTF-8' ); |
|
149 | + $item_description = wpinv_utf8_substr($item_desc, 0, 255); |
|
150 | + $item_description = html_entity_decode($item_desc, ENT_QUOTES, 'UTF-8'); |
|
151 | 151 | |
152 | - $authorizeAIM->description = wpinv_utf8_substr( $item_description, 0, 255 ); |
|
152 | + $authorizeAIM->description = wpinv_utf8_substr($item_description, 0, 255); |
|
153 | 153 | |
154 | 154 | $is_recurring = $invoice->is_recurring(); // Recurring payment. |
155 | 155 | |
156 | - if ( $is_recurring ) { |
|
156 | + if ($is_recurring) { |
|
157 | 157 | $authorizeAIM->recurring_billing = true; |
158 | 158 | } |
159 | 159 | |
160 | 160 | try { |
161 | 161 | |
162 | - if ( $is_recurring ) { |
|
162 | + if ($is_recurring) { |
|
163 | 163 | $trx_type = wpinv_get_option('authorizenet_transaction_type_recurring', 'authorize_only'); |
164 | - if('authorize_capture' == $trx_type){ |
|
164 | + if ('authorize_capture' == $trx_type) { |
|
165 | 165 | $response = $authorizeAIM->authorizeAndCapture(); |
166 | 166 | } else { |
167 | 167 | $response = $authorizeAIM->authorizeOnly(); |
168 | 168 | } |
169 | 169 | } else { |
170 | 170 | $trx_type = wpinv_get_option('authorizenet_transaction_type', 'authorize_capture'); |
171 | - if('authorize_capture' == $trx_type){ |
|
171 | + if ('authorize_capture' == $trx_type) { |
|
172 | 172 | $response = $authorizeAIM->authorizeAndCapture(); |
173 | 173 | } else { |
174 | 174 | $response = $authorizeAIM->authorizeOnly(); |
175 | 175 | } |
176 | 176 | } |
177 | 177 | |
178 | - if ( $response->approved || $response->held ) { |
|
179 | - if ( $response->approved ) { |
|
180 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
178 | + if ($response->approved || $response->held) { |
|
179 | + if ($response->approved) { |
|
180 | + wpinv_update_payment_status($invoice_id, 'publish'); |
|
181 | 181 | } |
182 | - wpinv_set_payment_transaction_id( $invoice_id, $response->transaction_id ); |
|
182 | + wpinv_set_payment_transaction_id($invoice_id, $response->transaction_id); |
|
183 | 183 | |
184 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment response: %s', 'invoicing' ), $response->response_reason_text ), '', '', true ); |
|
185 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing' ), $response->transaction_id, strtoupper( $response->transaction_type ), $response->authorization_code ), '', '', true ); |
|
184 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment response: %s', 'invoicing'), $response->response_reason_text), '', '', true); |
|
185 | + wpinv_insert_payment_note($invoice_id, wp_sprintf(__('Authorize.Net payment: Transaction ID %s, Transaction Type %s, Authorization Code %s', 'invoicing'), $response->transaction_id, strtoupper($response->transaction_type), $response->authorization_code), '', '', true); |
|
186 | 186 | |
187 | - do_action( 'wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card ); |
|
187 | + do_action('wpinv_authorizenet_handle_response', $response, $invoice, $authorizenet_card); |
|
188 | 188 | |
189 | 189 | wpinv_clear_errors(); |
190 | 190 | wpinv_empty_cart(); |
191 | 191 | |
192 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
192 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
193 | 193 | } else { |
194 | - if ( !empty( $response->response_reason_text ) ) { |
|
195 | - $error = __( $response->response_reason_text, 'invoicing' ); |
|
196 | - } else if ( !empty( $response->error_message ) ) { |
|
197 | - $error = __( $response->error_message, 'invoicing' ); |
|
194 | + if (!empty($response->response_reason_text)) { |
|
195 | + $error = __($response->response_reason_text, 'invoicing'); |
|
196 | + } else if (!empty($response->error_message)) { |
|
197 | + $error = __($response->error_message, 'invoicing'); |
|
198 | 198 | } else { |
199 | - $error = wp_sprintf( __( 'Error data: %s', 'invoicing' ), print_r( $response, true ) ); |
|
199 | + $error = wp_sprintf(__('Error data: %s', 'invoicing'), print_r($response, true)); |
|
200 | 200 | } |
201 | 201 | |
202 | - $error = wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $error ); |
|
202 | + $error = wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $error); |
|
203 | 203 | |
204 | - wpinv_set_error( 'payment_error', $error ); |
|
205 | - wpinv_record_gateway_error( $error, $response ); |
|
206 | - wpinv_insert_payment_note( $invoice_id, $error, '', '', true ); |
|
204 | + wpinv_set_error('payment_error', $error); |
|
205 | + wpinv_record_gateway_error($error, $response); |
|
206 | + wpinv_insert_payment_note($invoice_id, $error, '', '', true); |
|
207 | 207 | |
208 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
208 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
209 | 209 | } |
210 | - } catch ( AuthorizeNetException $e ) { |
|
211 | - wpinv_set_error( 'request_error', $e->getMessage() ); |
|
212 | - wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. %s', 'invoicing' ), $e->getMessage() ) ); |
|
213 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
210 | + } catch (AuthorizeNetException $e) { |
|
211 | + wpinv_set_error('request_error', $e->getMessage()); |
|
212 | + wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. %s', 'invoicing'), $e->getMessage())); |
|
213 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
214 | 214 | } |
215 | 215 | } else { |
216 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
216 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
217 | 217 | } |
218 | 218 | } else { |
219 | - wpinv_record_gateway_error( wp_sprintf( __( 'Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.Net payment. Payment data: %s', 'invoicing' ), print_r( $payment_data, true ) ), $invoice ); |
|
220 | - wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] ); |
|
219 | + wpinv_record_gateway_error(wp_sprintf(__('Authorize.Net payment error occurred. Payment creation failed while processing a Authorize.Net payment. Payment data: %s', 'invoicing'), print_r($payment_data, true)), $invoice); |
|
220 | + wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']); |
|
221 | 221 | } |
222 | 222 | } |
223 | -add_action( 'wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment' ); |
|
223 | +add_action('wpinv_gateway_authorizenet', 'wpinv_process_authorizenet_payment'); |
|
224 | 224 | |
225 | -function wpinv_authorizenet_cancel_subscription( $subscription_id = '' ) { |
|
226 | - if ( empty( $subscription_id ) ) { |
|
225 | +function wpinv_authorizenet_cancel_subscription($subscription_id = '') { |
|
226 | + if (empty($subscription_id)) { |
|
227 | 227 | return false; |
228 | 228 | } |
229 | 229 | |
230 | 230 | try { |
231 | 231 | $authnetXML = wpinv_authorizenet_XML(); |
232 | - $authnetXML->ARBCancelSubscriptionRequest( array( 'subscriptionId' => $subscription_id ) ); |
|
232 | + $authnetXML->ARBCancelSubscriptionRequest(array('subscriptionId' => $subscription_id)); |
|
233 | 233 | return $authnetXML->isSuccessful(); |
234 | - } catch( Exception $e ) { |
|
235 | - wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) ); |
|
234 | + } catch (Exception $e) { |
|
235 | + wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing')); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | return false; |
239 | 239 | } |
240 | 240 | |
241 | -function wpinv_recurring_cancel_authorizenet_subscription( $subscription, $valid = false ) { |
|
242 | - if ( ! empty( $valid ) && ! empty( $subscription->profile_id ) ) { |
|
243 | - return wpinv_authorizenet_cancel_subscription( $subscription->profile_id ); |
|
241 | +function wpinv_recurring_cancel_authorizenet_subscription($subscription, $valid = false) { |
|
242 | + if (!empty($valid) && !empty($subscription->profile_id)) { |
|
243 | + return wpinv_authorizenet_cancel_subscription($subscription->profile_id); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return false; |
247 | 247 | } |
248 | -add_action( 'wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_recurring_cancel_authorizenet_subscription', 10, 2 ); |
|
248 | +add_action('wpinv_recurring_cancel_authorizenet_subscription', 'wpinv_recurring_cancel_authorizenet_subscription', 10, 2); |
|
249 | 249 | |
250 | -function wpinv_authorizenet_valid_ipn( $md5_hash, $transaction_id, $amount ) { |
|
251 | - $authorizenet_md5_hash = wpinv_get_option( 'authorizenet_md5_hash' ); |
|
252 | - if ( empty( $authorizenet_md5_hash ) ) { |
|
250 | +function wpinv_authorizenet_valid_ipn($md5_hash, $transaction_id, $amount) { |
|
251 | + $authorizenet_md5_hash = wpinv_get_option('authorizenet_md5_hash'); |
|
252 | + if (empty($authorizenet_md5_hash)) { |
|
253 | 253 | return true; |
254 | 254 | } |
255 | 255 | |
256 | - $compare_md5 = strtoupper( md5( $authorizenet_md5_hash . $transaction_id . $amount ) ); |
|
256 | + $compare_md5 = strtoupper(md5($authorizenet_md5_hash . $transaction_id . $amount)); |
|
257 | 257 | |
258 | - return hash_equals( $compare_md5, $md5_hash ); |
|
258 | + return hash_equals($compare_md5, $md5_hash); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | function wpinv_authorizenet_AIM() { |
262 | - if ( !class_exists( 'AuthorizeNetException' ) ) { |
|
263 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php'; |
|
262 | + if (!class_exists('AuthorizeNetException')) { |
|
263 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/anet_php_sdk/AuthorizeNet.php'; |
|
264 | 264 | } |
265 | 265 | |
266 | - $authorizeAIM = new AuthorizeNetAIM( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ) ); |
|
266 | + $authorizeAIM = new AuthorizeNetAIM(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key')); |
|
267 | 267 | |
268 | - if ( wpinv_is_test_mode( 'authorizenet' ) ) { |
|
269 | - $authorizeAIM->setSandbox( true ); |
|
268 | + if (wpinv_is_test_mode('authorizenet')) { |
|
269 | + $authorizeAIM->setSandbox(true); |
|
270 | 270 | } else { |
271 | - $authorizeAIM->setSandbox( false ); |
|
271 | + $authorizeAIM->setSandbox(false); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | $authorizeAIM->customer_ip = wpinv_get_ip(); |
@@ -277,250 +277,250 @@ discard block |
||
277 | 277 | } |
278 | 278 | |
279 | 279 | function wpinv_authorizenet_XML() { |
280 | - if ( !class_exists( 'AuthnetXML' ) ) { |
|
281 | - require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php'; |
|
280 | + if (!class_exists('AuthnetXML')) { |
|
281 | + require_once plugin_dir_path(WPINV_PLUGIN_FILE) . 'includes/gateways/authorizenet/Authorize.Net-XML/AuthnetXML.class.php'; |
|
282 | 282 | } |
283 | 283 | |
284 | - $authnetXML = new AuthnetXML( wpinv_get_option( 'authorizenet_login_id' ), wpinv_get_option( 'authorizenet_transaction_key' ), (bool)wpinv_is_test_mode( 'authorizenet' ) ); |
|
284 | + $authnetXML = new AuthnetXML(wpinv_get_option('authorizenet_login_id'), wpinv_get_option('authorizenet_transaction_key'), (bool) wpinv_is_test_mode('authorizenet')); |
|
285 | 285 | |
286 | 286 | return $authnetXML; |
287 | 287 | } |
288 | 288 | |
289 | -function wpinv_authorizenet_handle_response( $response, $invoice, $card_info = array() ) { |
|
290 | - if ( empty( $response ) || empty( $invoice ) ) { |
|
289 | +function wpinv_authorizenet_handle_response($response, $invoice, $card_info = array()) { |
|
290 | + if (empty($response) || empty($invoice)) { |
|
291 | 291 | return false; |
292 | 292 | } |
293 | 293 | |
294 | - if ( $invoice->is_recurring() && !empty( $response->approved ) ) { |
|
295 | - $subscription = wpinv_authorizenet_create_new_subscription( $invoice, $response, $card_info ); |
|
294 | + if ($invoice->is_recurring() && !empty($response->approved)) { |
|
295 | + $subscription = wpinv_authorizenet_create_new_subscription($invoice, $response, $card_info); |
|
296 | 296 | $success = false; |
297 | - if ( wpinv_is_test_mode( 'authorizenet' ) ) { |
|
297 | + if (wpinv_is_test_mode('authorizenet')) { |
|
298 | 298 | $success = true; |
299 | 299 | } else { |
300 | 300 | $success = $subscription->isSuccessful(); |
301 | 301 | } |
302 | 302 | |
303 | - if ( !empty( $subscription ) && $success ) { |
|
304 | - do_action( 'wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet' ); |
|
303 | + if (!empty($subscription) && $success) { |
|
304 | + do_action('wpinv_recurring_post_create_subscription', $subscription, $invoice, 'authorizenet'); |
|
305 | 305 | |
306 | - wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ); |
|
306 | + wpinv_authorizenet_subscription_record_signup($subscription, $invoice); |
|
307 | 307 | |
308 | - do_action( 'wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet' ); |
|
308 | + do_action('wpinv_recurring_post_record_signup', $subscription, $invoice, 'authorizenet'); |
|
309 | 309 | } else { |
310 | - if ( isset( $subscription->messages->message ) ) { |
|
310 | + if (isset($subscription->messages->message)) { |
|
311 | 311 | $error = $subscription->messages->message->code . ': ' . $subscription->messages->message->text; |
312 | - wpinv_set_error( 'wpinv_authorize_recurring_error', $error, 'invoicing' ); |
|
312 | + wpinv_set_error('wpinv_authorize_recurring_error', $error, 'invoicing'); |
|
313 | 313 | } else { |
314 | - $error = __( 'Your subscription cannot be created due to an error.', 'invoicing' ); |
|
315 | - wpinv_set_error( 'wpinv_authorize_recurring_error', $error ); |
|
314 | + $error = __('Your subscription cannot be created due to an error.', 'invoicing'); |
|
315 | + wpinv_set_error('wpinv_authorize_recurring_error', $error); |
|
316 | 316 | } |
317 | 317 | |
318 | - wpinv_record_gateway_error( $error, $subscription ); |
|
318 | + wpinv_record_gateway_error($error, $subscription); |
|
319 | 319 | |
320 | - wpinv_insert_payment_note( $invoice->ID, wp_sprintf( __( 'Authorize.Net subscription error occurred. %s', 'invoicing' ), $error ), '', '', true ); |
|
320 | + wpinv_insert_payment_note($invoice->ID, wp_sprintf(__('Authorize.Net subscription error occurred. %s', 'invoicing'), $error), '', '', true); |
|
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | -add_action( 'wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3 ); |
|
324 | +add_action('wpinv_authorizenet_handle_response', 'wpinv_authorizenet_handle_response', 10, 3); |
|
325 | 325 | |
326 | -function wpinv_authorizenet_create_new_subscription( $invoice, $response = array(), $card_info = array() ) { |
|
327 | - if ( empty( $invoice ) ) { |
|
326 | +function wpinv_authorizenet_create_new_subscription($invoice, $response = array(), $card_info = array()) { |
|
327 | + if (empty($invoice)) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | - $params = wpinv_authorizenet_generate_subscription_params( $invoice, $card_info, $response ); |
|
331 | + $params = wpinv_authorizenet_generate_subscription_params($invoice, $card_info, $response); |
|
332 | 332 | |
333 | 333 | try { |
334 | 334 | $authnetXML = wpinv_authorizenet_XML(); |
335 | - $authnetXML->ARBCreateSubscriptionRequest( $params ); |
|
336 | - } catch( Exception $e ) { |
|
335 | + $authnetXML->ARBCreateSubscriptionRequest($params); |
|
336 | + } catch (Exception $e) { |
|
337 | 337 | $authnetXML = array(); |
338 | - wpinv_error_log( $e->getMessage(), __( 'Authorize.Net cancel subscription', 'invoicing' ) ); |
|
338 | + wpinv_error_log($e->getMessage(), __('Authorize.Net cancel subscription', 'invoicing')); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $authnetXML; |
342 | 342 | } |
343 | 343 | |
344 | -function wpinv_authorizenet_generate_subscription_params( $invoice, $card_info = array(), $response = array() ) { |
|
345 | - if ( empty( $invoice ) ) { |
|
344 | +function wpinv_authorizenet_generate_subscription_params($invoice, $card_info = array(), $response = array()) { |
|
345 | + if (empty($invoice)) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | |
349 | - $subscription_item = $invoice->get_recurring( true ); |
|
350 | - if ( empty( $subscription_item->ID ) ) { |
|
349 | + $subscription_item = $invoice->get_recurring(true); |
|
350 | + if (empty($subscription_item->ID)) { |
|
351 | 351 | return false; |
352 | 352 | } |
353 | 353 | |
354 | - $item = $invoice->get_recurring( true ); |
|
354 | + $item = $invoice->get_recurring(true); |
|
355 | 355 | |
356 | - if ( empty( $item ) ) { |
|
356 | + if (empty($item)) { |
|
357 | 357 | $name = ''; |
358 | 358 | } |
359 | 359 | |
360 | - if ( !( $name = $item->get_name() ) ) { |
|
360 | + if (!($name = $item->get_name())) { |
|
361 | 361 | $name = $item->post_name; |
362 | 362 | } |
363 | 363 | |
364 | - $card_details = wpinv_authorizenet_generate_card_info( $card_info ); |
|
364 | + $card_details = wpinv_authorizenet_generate_card_info($card_info); |
|
365 | 365 | $subscription_name = $invoice->get_subscription_name(); |
366 | - $initial_amount = wpinv_round_amount( $invoice->get_total() ); |
|
367 | - $recurring_amount = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) ); |
|
366 | + $initial_amount = wpinv_round_amount($invoice->get_total()); |
|
367 | + $recurring_amount = wpinv_round_amount($invoice->get_recurring_details('total')); |
|
368 | 368 | $interval = $subscription_item->get_recurring_interval(); |
369 | 369 | $period = $subscription_item->get_recurring_period(); |
370 | - $bill_times = (int)$subscription_item->get_recurring_limit(); |
|
370 | + $bill_times = (int) $subscription_item->get_recurring_limit(); |
|
371 | 371 | $bill_times = $bill_times > 0 ? $bill_times : 9999; |
372 | 372 | |
373 | - $time_period = wpinv_authorizenet_get_time_period( $interval, $period ); |
|
373 | + $time_period = wpinv_authorizenet_get_time_period($interval, $period); |
|
374 | 374 | $interval = $time_period['interval']; |
375 | 375 | $period = $time_period['period']; |
376 | 376 | |
377 | 377 | $current_tz = date_default_timezone_get(); |
378 | - date_default_timezone_set( 'America/Denver' ); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts. |
|
379 | - $today = date( 'Y-m-d' ); |
|
380 | - date_default_timezone_set( $current_tz ); |
|
378 | + date_default_timezone_set('America/Denver'); // Set same timezone as Authorize's server (Mountain Time) to prevent conflicts. |
|
379 | + $today = date('Y-m-d'); |
|
380 | + date_default_timezone_set($current_tz); |
|
381 | 381 | |
382 | 382 | $free_trial = $invoice->is_free_trial(); |
383 | - if ( $free_trial && $subscription_item->has_free_trial() ) { |
|
383 | + if ($free_trial && $subscription_item->has_free_trial()) { |
|
384 | 384 | $trial_interval = $subscription_item->get_trial_interval(); |
385 | - $trial_period = $subscription_item->get_trial_period( true ); |
|
385 | + $trial_period = $subscription_item->get_trial_period(true); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | $subscription = array(); |
389 | 389 | $subscription['name'] = $subscription_name; |
390 | 390 | |
391 | 391 | $subscription['paymentSchedule'] = array( |
392 | - 'interval' => array( 'length' => $interval, 'unit' => $period ), |
|
392 | + 'interval' => array('length' => $interval, 'unit' => $period), |
|
393 | 393 | 'startDate' => $today, |
394 | 394 | 'totalOccurrences' => $bill_times, |
395 | - 'trialOccurrences' => $free_trial || ( $initial_amount != $recurring_amount ) ? 1 : 0, |
|
395 | + 'trialOccurrences' => $free_trial || ($initial_amount != $recurring_amount) ? 1 : 0, |
|
396 | 396 | ); |
397 | 397 | |
398 | 398 | $subscription['amount'] = $recurring_amount; |
399 | 399 | $subscription['trialAmount'] = $initial_amount; |
400 | - $subscription['payment'] = array( 'creditCard' => $card_details ); |
|
401 | - $subscription['order'] = array( 'invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number() ); |
|
402 | - $subscription['customer'] = array( 'id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone ); |
|
400 | + $subscription['payment'] = array('creditCard' => $card_details); |
|
401 | + $subscription['order'] = array('invoiceNumber' => $invoice->ID, 'description' => '#' . $invoice->get_number()); |
|
402 | + $subscription['customer'] = array('id' => $invoice->get_user_id(), 'email' => $invoice->get_email(), 'phoneNumber' => $invoice->phone); |
|
403 | 403 | |
404 | 404 | $subscription['billTo'] = array( |
405 | 405 | 'firstName' => $invoice->get_first_name(), |
406 | 406 | 'lastName' => $invoice->get_last_name(), |
407 | 407 | 'company' => $invoice->company, |
408 | - 'address' => wp_strip_all_tags( $invoice->get_address(), true ), |
|
408 | + 'address' => wp_strip_all_tags($invoice->get_address(), true), |
|
409 | 409 | 'city' => $invoice->city, |
410 | 410 | 'state' => $invoice->state, |
411 | 411 | 'zip' => $invoice->zip, |
412 | 412 | 'country' => $invoice->country, |
413 | 413 | ); |
414 | 414 | |
415 | - $params = array( 'subscription' => $subscription ); |
|
415 | + $params = array('subscription' => $subscription); |
|
416 | 416 | |
417 | - return apply_filters( 'wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response ); |
|
417 | + return apply_filters('wpinv_authorizenet_generate_subscription_params', $params, $invoice, $card_info, $response); |
|
418 | 418 | } |
419 | 419 | |
420 | -function wpinv_authorizenet_generate_card_info( $card_info = array() ) { |
|
421 | - $card_defaults = array( |
|
420 | +function wpinv_authorizenet_generate_card_info($card_info = array()) { |
|
421 | + $card_defaults = array( |
|
422 | 422 | 'cc_owner' => null, |
423 | 423 | 'cc_number' => null, |
424 | 424 | 'cc_expire_month' => null, |
425 | 425 | 'cc_expire_year' => null, |
426 | 426 | 'cc_cvv2' => null, |
427 | 427 | ); |
428 | - $card_info = wp_parse_args( $card_info, $card_defaults ); |
|
428 | + $card_info = wp_parse_args($card_info, $card_defaults); |
|
429 | 429 | |
430 | 430 | $card_details = array( |
431 | - 'cardNumber' => str_replace( ' ', '', sanitize_text_field( $card_info['cc_number'] ) ), |
|
432 | - 'expirationDate' => sanitize_text_field( $card_info['cc_expire_month'] ) . sanitize_text_field( $card_info['cc_expire_year'] ), |
|
433 | - 'cardCode' => sanitize_text_field( $card_info['cc_cvv2'] ), |
|
431 | + 'cardNumber' => str_replace(' ', '', sanitize_text_field($card_info['cc_number'])), |
|
432 | + 'expirationDate' => sanitize_text_field($card_info['cc_expire_month']) . sanitize_text_field($card_info['cc_expire_year']), |
|
433 | + 'cardCode' => sanitize_text_field($card_info['cc_cvv2']), |
|
434 | 434 | ); |
435 | 435 | |
436 | 436 | return $card_details; |
437 | 437 | } |
438 | 438 | |
439 | -function wpinv_authorizenet_subscription_record_signup( $subscription, $invoice ) { |
|
440 | - $parent_invoice_id = absint( $invoice->ID ); |
|
439 | +function wpinv_authorizenet_subscription_record_signup($subscription, $invoice) { |
|
440 | + $parent_invoice_id = absint($invoice->ID); |
|
441 | 441 | |
442 | - if( empty( $parent_invoice_id ) ) { |
|
442 | + if (empty($parent_invoice_id)) { |
|
443 | 443 | return; |
444 | 444 | } |
445 | 445 | |
446 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
447 | - if ( empty( $invoice ) ) { |
|
446 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
447 | + if (empty($invoice)) { |
|
448 | 448 | return; |
449 | 449 | } |
450 | 450 | |
451 | - $subscriptionId = (array)$subscription->subscriptionId; |
|
452 | - $subscription_id = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id; |
|
451 | + $subscriptionId = (array) $subscription->subscriptionId; |
|
452 | + $subscription_id = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id; |
|
453 | 453 | |
454 | - $subscription = wpinv_get_authorizenet_subscription( $subscription, $parent_invoice_id ); |
|
454 | + $subscription = wpinv_get_authorizenet_subscription($subscription, $parent_invoice_id); |
|
455 | 455 | |
456 | - if ( false === $subscription ) { |
|
456 | + if (false === $subscription) { |
|
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | 460 | // Set payment to complete |
461 | - wpinv_update_payment_status( $subscription->parent_payment_id, 'publish' ); |
|
461 | + wpinv_update_payment_status($subscription->parent_payment_id, 'publish'); |
|
462 | 462 | sleep(1); |
463 | - wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'Authorize.Net Subscription ID: %s', 'invoicing' ) , $subscription_id ), '', '', true ); |
|
464 | - update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $subscription_id); |
|
463 | + wpinv_insert_payment_note($parent_invoice_id, sprintf(__('Authorize.Net Subscription ID: %s', 'invoicing'), $subscription_id), '', '', true); |
|
464 | + update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $subscription_id); |
|
465 | 465 | |
466 | 466 | $status = 'trialling' == $subscription->status ? 'trialling' : 'active'; |
467 | - $diff_days = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) ); |
|
468 | - $created = date_i18n( 'Y-m-d H:i:s' ); |
|
469 | - $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) ); |
|
467 | + $diff_days = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS)); |
|
468 | + $created = date_i18n('Y-m-d H:i:s'); |
|
469 | + $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS))); |
|
470 | 470 | |
471 | 471 | // Retrieve pending subscription from database and update it's status to active and set proper profile ID |
472 | - $subscription->update( array( 'profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration ) ); |
|
472 | + $subscription->update(array('profile_id' => $subscription_id, 'status' => $status, 'created' => $created, 'expiration' => $expiration)); |
|
473 | 473 | } |
474 | 474 | |
475 | -function wpinv_authorizenet_validate_checkout( $valid_data, $post ) { |
|
476 | - if ( !empty( $post['wpi-gateway'] ) && $post['wpi-gateway'] == 'authorizenet' ) { |
|
475 | +function wpinv_authorizenet_validate_checkout($valid_data, $post) { |
|
476 | + if (!empty($post['wpi-gateway']) && $post['wpi-gateway'] == 'authorizenet') { |
|
477 | 477 | $error = false; |
478 | 478 | |
479 | - if ( empty( $post['authorizenet']['cc_owner'] ) ) { |
|
479 | + if (empty($post['authorizenet']['cc_owner'])) { |
|
480 | 480 | $error = true; |
481 | - wpinv_set_error( 'empty_card_name', __( 'You must enter the name on your card!', 'invoicing')); |
|
481 | + wpinv_set_error('empty_card_name', __('You must enter the name on your card!', 'invoicing')); |
|
482 | 482 | } |
483 | - if ( empty( $post['authorizenet']['cc_number'] ) ) { |
|
483 | + if (empty($post['authorizenet']['cc_number'])) { |
|
484 | 484 | $error = true; |
485 | - wpinv_set_error( 'empty_card', __( 'You must enter a card number!', 'invoicing')); |
|
485 | + wpinv_set_error('empty_card', __('You must enter a card number!', 'invoicing')); |
|
486 | 486 | } |
487 | - if ( empty( $post['authorizenet']['cc_expire_month'] ) ) { |
|
487 | + if (empty($post['authorizenet']['cc_expire_month'])) { |
|
488 | 488 | $error = true; |
489 | - wpinv_set_error( 'empty_month', __( 'You must enter an card expiration month!', 'invoicing')); |
|
489 | + wpinv_set_error('empty_month', __('You must enter an card expiration month!', 'invoicing')); |
|
490 | 490 | } |
491 | - if ( empty( $post['authorizenet']['cc_expire_year'] ) ) { |
|
491 | + if (empty($post['authorizenet']['cc_expire_year'])) { |
|
492 | 492 | $error = true; |
493 | - wpinv_set_error( 'empty_year', __( 'You must enter an card expiration year!', 'invoicing')); |
|
493 | + wpinv_set_error('empty_year', __('You must enter an card expiration year!', 'invoicing')); |
|
494 | 494 | } |
495 | - if ( empty( $post['authorizenet']['cc_cvv2'] ) ) { |
|
495 | + if (empty($post['authorizenet']['cc_cvv2'])) { |
|
496 | 496 | $error = true; |
497 | - wpinv_set_error( 'empty_cvv2', __( 'You must enter a valid CVV2!', 'invoicing' ) ); |
|
497 | + wpinv_set_error('empty_cvv2', __('You must enter a valid CVV2!', 'invoicing')); |
|
498 | 498 | } |
499 | 499 | |
500 | - if ( $error ) { |
|
500 | + if ($error) { |
|
501 | 501 | return; |
502 | 502 | } |
503 | 503 | |
504 | 504 | $invoice = wpinv_get_invoice_cart(); |
505 | 505 | |
506 | - if ( !empty( $invoice ) && $subscription_item = $invoice->get_recurring( true ) ) { |
|
507 | - $subscription_item = $invoice->get_recurring( true ); |
|
506 | + if (!empty($invoice) && $subscription_item = $invoice->get_recurring(true)) { |
|
507 | + $subscription_item = $invoice->get_recurring(true); |
|
508 | 508 | |
509 | 509 | $interval = $subscription_item->get_recurring_interval(); |
510 | 510 | $period = $subscription_item->get_recurring_period(); |
511 | 511 | |
512 | - if ( $period == 'D' && ( $interval < 7 || $interval > 365 ) ) { |
|
513 | - wpinv_set_error( 'authorizenet_subscription_error', __( 'Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing' ) ); |
|
512 | + if ($period == 'D' && ($interval < 7 || $interval > 365)) { |
|
513 | + wpinv_set_error('authorizenet_subscription_error', __('Interval Length must be a value from 7 through 365 for day based subscriptions.', 'invoicing')); |
|
514 | 514 | } |
515 | 515 | } |
516 | 516 | } |
517 | 517 | } |
518 | -add_action( 'wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2 ); |
|
518 | +add_action('wpinv_checkout_error_checks', 'wpinv_authorizenet_validate_checkout', 11, 2); |
|
519 | 519 | |
520 | -function wpinv_authorizenet_get_time_period( $subscription_interval, $subscription_period ) { |
|
521 | - $subscription_interval = absint( $subscription_interval ); |
|
520 | +function wpinv_authorizenet_get_time_period($subscription_interval, $subscription_period) { |
|
521 | + $subscription_interval = absint($subscription_interval); |
|
522 | 522 | |
523 | - switch( $subscription_period ) { |
|
523 | + switch ($subscription_period) { |
|
524 | 524 | case 'W': |
525 | 525 | case 'week': |
526 | 526 | case 'weeks': |
@@ -530,14 +530,14 @@ discard block |
||
530 | 530 | case 'M': |
531 | 531 | case 'month': |
532 | 532 | case 'months': |
533 | - if ( $subscription_interval > 12 ) { |
|
533 | + if ($subscription_interval > 12) { |
|
534 | 534 | $subscription_interval = 12; |
535 | 535 | } |
536 | 536 | |
537 | 537 | $interval = $subscription_interval; |
538 | 538 | $period = 'months'; |
539 | 539 | |
540 | - if ( !( $subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12 ) ) { |
|
540 | + if (!($subscription_interval === 1 || $subscription_interval === 2 || $subscription_interval === 3 || $subscription_interval === 6 || $subscription_interval === 12)) { |
|
541 | 541 | $interval = $subscription_interval * 30; |
542 | 542 | $period = 'days'; |
543 | 543 | } |
@@ -554,30 +554,30 @@ discard block |
||
554 | 554 | break; |
555 | 555 | } |
556 | 556 | |
557 | - return compact( 'interval', 'period' ); |
|
557 | + return compact('interval', 'period'); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | function wpinv_authorizenet_process_ipn() { |
561 | - if ( !( !empty( $_REQUEST['wpi-gateway'] ) && $_REQUEST['wpi-gateway'] == 'authorizenet' ) ) { |
|
561 | + if (!(!empty($_REQUEST['wpi-gateway']) && $_REQUEST['wpi-gateway'] == 'authorizenet')) { |
|
562 | 562 | return; |
563 | 563 | } |
564 | 564 | |
565 | - $subscription_id = !empty( $_POST['x_subscription_id'] ) ? intval( $_POST['x_subscription_id'] ) : false; |
|
565 | + $subscription_id = !empty($_POST['x_subscription_id']) ? intval($_POST['x_subscription_id']) : false; |
|
566 | 566 | |
567 | - if ( $subscription_id ) { |
|
568 | - $response_code = intval( $_POST['x_response_code'] ); |
|
569 | - $reason_code = intval( $_POST['x_response_reason_code'] ); |
|
567 | + if ($subscription_id) { |
|
568 | + $response_code = intval($_POST['x_response_code']); |
|
569 | + $reason_code = intval($_POST['x_response_reason_code']); |
|
570 | 570 | |
571 | - $subscription = new WPInv_Subscription( $subscription_id, true ); |
|
571 | + $subscription = new WPInv_Subscription($subscription_id, true); |
|
572 | 572 | |
573 | - if ( !$subscription->id ) { |
|
573 | + if (!$subscription->id) { |
|
574 | 574 | return; |
575 | 575 | } |
576 | 576 | |
577 | - if ( 1 == $response_code ) { |
|
577 | + if (1 == $response_code) { |
|
578 | 578 | // Approved |
579 | - $transaction_id = sanitize_text_field( $_POST['x_trans_id'] ); |
|
580 | - $renewal_amount = sanitize_text_field( $_POST['x_amount'] ); |
|
579 | + $transaction_id = sanitize_text_field($_POST['x_trans_id']); |
|
580 | + $renewal_amount = sanitize_text_field($_POST['x_amount']); |
|
581 | 581 | |
582 | 582 | $args = array( |
583 | 583 | 'amount' => $renewal_amount, |
@@ -585,63 +585,63 @@ discard block |
||
585 | 585 | 'gateway' => 'authorizenet' |
586 | 586 | ); |
587 | 587 | |
588 | - $subscription->add_payment( $args ); |
|
588 | + $subscription->add_payment($args); |
|
589 | 589 | $subscription->renew(); |
590 | 590 | |
591 | - do_action( 'wpinv_recurring_authorizenet_silent_post_payment', $subscription ); |
|
592 | - do_action( 'wpinv_authorizenet_renewal_payment', $subscription ); |
|
593 | - } else if ( 2 == $response_code ) { |
|
591 | + do_action('wpinv_recurring_authorizenet_silent_post_payment', $subscription); |
|
592 | + do_action('wpinv_authorizenet_renewal_payment', $subscription); |
|
593 | + } else if (2 == $response_code) { |
|
594 | 594 | // Declined |
595 | 595 | $subscription->failing(); |
596 | - do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription ); |
|
597 | - do_action( 'wpinv_authorizenet_renewal_error', $subscription ); |
|
598 | - } else if ( 3 == $response_code || 8 == $reason_code ) { |
|
596 | + do_action('wpinv_authorizenet_renewal_payment_failed', $subscription); |
|
597 | + do_action('wpinv_authorizenet_renewal_error', $subscription); |
|
598 | + } else if (3 == $response_code || 8 == $reason_code) { |
|
599 | 599 | // An expired card |
600 | 600 | $subscription->failing(); |
601 | - do_action( 'wpinv_authorizenet_renewal_payment_failed', $subscription ); |
|
602 | - do_action( 'wpinv_authorizenet_renewal_error', $subscription ); |
|
601 | + do_action('wpinv_authorizenet_renewal_payment_failed', $subscription); |
|
602 | + do_action('wpinv_authorizenet_renewal_error', $subscription); |
|
603 | 603 | } else { |
604 | 604 | // Other Error |
605 | - do_action( 'wpinv_authorizenet_renewal_payment_error', $subscription ); |
|
605 | + do_action('wpinv_authorizenet_renewal_payment_error', $subscription); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | exit; |
609 | 609 | } |
610 | 610 | } |
611 | -add_action( 'wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn' ); |
|
611 | +add_action('wpinv_verify_authorizenet_ipn', 'wpinv_authorizenet_process_ipn'); |
|
612 | 612 | |
613 | 613 | /** |
614 | 614 | * Retrieve the subscription |
615 | 615 | */ |
616 | -function wpinv_get_authorizenet_subscription( $subscription_data = array(), $invoice_id ) { |
|
617 | - $parent_invoice_id = absint( $invoice_id ); |
|
616 | +function wpinv_get_authorizenet_subscription($subscription_data = array(), $invoice_id) { |
|
617 | + $parent_invoice_id = absint($invoice_id); |
|
618 | 618 | |
619 | - if ( empty( $subscription_data ) ) { |
|
619 | + if (empty($subscription_data)) { |
|
620 | 620 | return false; |
621 | 621 | } |
622 | 622 | |
623 | - if ( empty( $parent_invoice_id ) ) { |
|
623 | + if (empty($parent_invoice_id)) { |
|
624 | 624 | return false; |
625 | 625 | } |
626 | 626 | |
627 | - $invoice = wpinv_get_invoice( $parent_invoice_id ); |
|
628 | - if ( empty( $invoice ) ) { |
|
627 | + $invoice = wpinv_get_invoice($parent_invoice_id); |
|
628 | + if (empty($invoice)) { |
|
629 | 629 | return false; |
630 | 630 | } |
631 | 631 | |
632 | - $subscriptionId = (array)$subscription_data->subscriptionId; |
|
633 | - $subscription_id = !empty( $subscriptionId[0] ) ? $subscriptionId[0] : $parent_invoice_id; |
|
632 | + $subscriptionId = (array) $subscription_data->subscriptionId; |
|
633 | + $subscription_id = !empty($subscriptionId[0]) ? $subscriptionId[0] : $parent_invoice_id; |
|
634 | 634 | |
635 | - $subscription = new WPInv_Subscription( $subscription_id, true ); |
|
635 | + $subscription = new WPInv_Subscription($subscription_id, true); |
|
636 | 636 | |
637 | - if ( ! $subscription || $subscription->id < 1 ) { |
|
637 | + if (!$subscription || $subscription->id < 1) { |
|
638 | 638 | $subs_db = new WPInv_Subscriptions_DB; |
639 | - $subs = $subs_db->get_subscriptions( array( 'parent_payment_id' => $parent_invoice_id, 'number' => 1 ) ); |
|
640 | - $subscription = reset( $subs ); |
|
639 | + $subs = $subs_db->get_subscriptions(array('parent_payment_id' => $parent_invoice_id, 'number' => 1)); |
|
640 | + $subscription = reset($subs); |
|
641 | 641 | |
642 | - if ( $subscription && $subscription->id > 0 ) { |
|
642 | + if ($subscription && $subscription->id > 0) { |
|
643 | 643 | // Update the profile ID so it is set for future renewals |
644 | - $subscription->update( array( 'profile_id' => sanitize_text_field( $subscription_id ) ) ); |
|
644 | + $subscription->update(array('profile_id' => sanitize_text_field($subscription_id))); |
|
645 | 645 | } else { |
646 | 646 | // No subscription found with a matching payment ID, bail |
647 | 647 | return false; |
@@ -652,67 +652,67 @@ discard block |
||
652 | 652 | } |
653 | 653 | |
654 | 654 | function wpinv_is_authorizenet_valid_for_use() { |
655 | - return in_array( wpinv_get_currency(), apply_filters( 'wpinv_authorizenet_supported_currencies', array( 'AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR' ) ) ); |
|
655 | + return in_array(wpinv_get_currency(), apply_filters('wpinv_authorizenet_supported_currencies', array('AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'PLN', 'SEK', 'USD', 'ZAR'))); |
|
656 | 656 | } |
657 | -function wpinv_check_authorizenet_currency_support( $gateway_list ) { |
|
658 | - if ( isset( $gateway_list['authorizenet'] ) && ! wpinv_is_authorizenet_valid_for_use() ) { |
|
659 | - unset( $gateway_list['authorizenet'] ); |
|
657 | +function wpinv_check_authorizenet_currency_support($gateway_list) { |
|
658 | + if (isset($gateway_list['authorizenet']) && !wpinv_is_authorizenet_valid_for_use()) { |
|
659 | + unset($gateway_list['authorizenet']); |
|
660 | 660 | } |
661 | 661 | return $gateway_list; |
662 | 662 | } |
663 | -add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1 ); |
|
663 | +add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_authorizenet_currency_support', 10, 1); |
|
664 | 664 | |
665 | -function wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ) { |
|
666 | - if ( $transaction_id == $invoice_id ) { |
|
665 | +function wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice) { |
|
666 | + if ($transaction_id == $invoice_id) { |
|
667 | 667 | $link = $transaction_id; |
668 | 668 | } else { |
669 | - if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) { |
|
669 | + if (!empty($invoice) && !empty($invoice->mode)) { |
|
670 | 670 | $mode = $invoice->mode; |
671 | 671 | } else { |
672 | - $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live'; |
|
672 | + $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live'; |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/'; |
676 | 676 | $url .= 'ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=' . $transaction_id; |
677 | 677 | |
678 | - $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $transaction_id . '</a>'; |
|
678 | + $link = '<a href="' . esc_url($url) . '" target="_blank">' . $transaction_id . '</a>'; |
|
679 | 679 | } |
680 | 680 | |
681 | - return apply_filters( 'wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice ); |
|
681 | + return apply_filters('wpinv_authorizenet_link_payment_details_transaction_id', $link, $transaction_id, $invoice); |
|
682 | 682 | } |
683 | -add_filter( 'wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3 ); |
|
683 | +add_filter('wpinv_payment_details_transaction_id-authorizenet', 'wpinv_authorizenet_link_transaction_id', 10, 3); |
|
684 | 684 | |
685 | -function wpinv_authorizenet_transaction_id_link( $transaction_id, $subscription ) { |
|
686 | - if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) { |
|
687 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
685 | +function wpinv_authorizenet_transaction_id_link($transaction_id, $subscription) { |
|
686 | + if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) { |
|
687 | + $invoice = wpinv_get_invoice($invoice_id); |
|
688 | 688 | |
689 | - if ( ! empty( $invoice ) ) { |
|
690 | - return wpinv_authorizenet_link_transaction_id( $transaction_id, $invoice_id, $invoice ); |
|
689 | + if (!empty($invoice)) { |
|
690 | + return wpinv_authorizenet_link_transaction_id($transaction_id, $invoice_id, $invoice); |
|
691 | 691 | } |
692 | 692 | } |
693 | 693 | |
694 | 694 | return $transaction_id; |
695 | 695 | } |
696 | -add_filter( 'wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2 ); |
|
696 | +add_filter('wpinv_subscription_transaction_link_authorizenet', 'wpinv_authorizenet_transaction_id_link', 10, 2); |
|
697 | 697 | |
698 | -function wpinv_authorizenet_profile_id_link( $profile_id, $subscription ) { |
|
698 | +function wpinv_authorizenet_profile_id_link($profile_id, $subscription) { |
|
699 | 699 | $link = $profile_id; |
700 | 700 | |
701 | - if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) { |
|
702 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
701 | + if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) { |
|
702 | + $invoice = wpinv_get_invoice($invoice_id); |
|
703 | 703 | |
704 | - if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) { |
|
704 | + if (!empty($invoice) && !empty($invoice->mode)) { |
|
705 | 705 | $mode = $invoice->mode; |
706 | 706 | } else { |
707 | - $mode = wpinv_is_test_mode( 'authorizenet' ) ? 'test' : 'live'; |
|
707 | + $mode = wpinv_is_test_mode('authorizenet') ? 'test' : 'live'; |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | $url = $mode == 'test' ? 'https://sandbox.authorize.net/' : 'https://authorize.net/'; |
711 | 711 | $url .= 'ui/themes/sandbox/ARB/SubscriptionDetail.aspx?SubscrID=' . $profile_id; |
712 | 712 | |
713 | - $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>'; |
|
713 | + $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>'; |
|
714 | 714 | } |
715 | 715 | |
716 | - return apply_filters( 'wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription ); |
|
716 | + return apply_filters('wpinv_authorizenet_profile_id_link', $link, $profile_id, $subscription); |
|
717 | 717 | } |
718 | -add_filter( 'wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2 ); |
|
719 | 718 | \ No newline at end of file |
719 | +add_filter('wpinv_subscription_profile_link_authorizenet', 'wpinv_authorizenet_profile_id_link', 10, 2); |
|
720 | 720 | \ No newline at end of file |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | { |
65 | 65 | $month = ($month ? $month : date('m')); |
66 | 66 | $year = ($year ? $year : date('Y')); |
67 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, $month, 1, $year)),0,-6); |
|
68 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, $month+1, 0, $year)),0,-6); |
|
67 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, $month, 1, $year)), 0, -6); |
|
68 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, $month + 1, 0, $year)), 0, -6); |
|
69 | 69 | return $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
70 | 70 | } |
71 | 71 | |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | $month = ($month ? $month : date('m')); |
99 | 99 | $day = ($day ? $day : date('d')); |
100 | 100 | $year = ($year ? $year : date('Y')); |
101 | - $firstSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
102 | - $lastSettlementDate = substr(date('c',mktime(0, 0, 0, (int)$month, (int)$day, (int)$year)),0,-6); |
|
101 | + $firstSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6); |
|
102 | + $lastSettlementDate = substr(date('c', mktime(0, 0, 0, (int) $month, (int) $day, (int) $year)), 0, -6); |
|
103 | 103 | $response = $this->getSettledBatchList(true, $firstSettlementDate, $lastSettlementDate); |
104 | 104 | $batches = $response->xpath("batchList/batch"); |
105 | 105 | foreach ($batches as $batch) { |
106 | - $batch_id = (string)$batch->batchId; |
|
106 | + $batch_id = (string) $batch->batchId; |
|
107 | 107 | $request = new AuthorizeNetTD; |
108 | 108 | $tran_list = $request->getTransactionList($batch_id); |
109 | 109 | $transactions = array_merge($transactions, $tran_list->xpath("transactions/transaction")); |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | */ |
188 | 188 | private function _constructXml($request_type) |
189 | 189 | { |
190 | - $string = '<?xml version="1.0" encoding="utf-8"?><'.$request_type.' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></'.$request_type.'>'; |
|
190 | + $string = '<?xml version="1.0" encoding="utf-8"?><' . $request_type . ' xmlns="AnetApi/xml/v1/schema/AnetApiSchema.xsd"></' . $request_type . '>'; |
|
191 | 191 | $this->_xml = @new SimpleXMLElement($string); |
192 | 192 | $merchant = $this->_xml->addChild('merchantAuthentication'); |
193 | - $merchant->addChild('name',$this->_api_login); |
|
194 | - $merchant->addChild('transactionKey',$this->_transaction_key); |
|
193 | + $merchant->addChild('name', $this->_api_login); |
|
194 | + $merchant->addChild('transactionKey', $this->_transaction_key); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |