Passed
Branch master (50908e)
by Stiofan
07:01
created
includes/class-wpinv-api.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
10
+if (!defined('WPINC')) {
11 11
     exit;
12 12
 }
13 13
 
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
     /**
20 20
      * @param string A prefix for our REST routes
21 21
      */
22
-    public $api_namespace    = '';
22
+    public $api_namespace = '';
23 23
 
24 24
     /**
25 25
      * @param WPInv_REST_Invoice_Controller Invoices controller
@@ -37,18 +37,18 @@  discard block
 block discarded – undo
37 37
      * @since 1.0.13
38 38
      * Sets the API namespace and inits hooks
39 39
      */
40
-    public function __construct( $api_namespace = 'invoicing/v1' ) {
40
+    public function __construct($api_namespace = 'invoicing/v1') {
41 41
 
42 42
         // Include controllers and related files
43 43
         $this->includes();
44 44
 
45 45
         // Set up class variables
46
-        $this->api_namespace       = apply_filters( 'wpinv_rest_api_namespace', $api_namespace );
47
-        $this->invoices_controller = new WPInv_REST_Invoice_Controller( $this->api_namespace );
48
-        $this->items_controller    = new WPInv_REST_Items_Controller( $this->api_namespace );
46
+        $this->api_namespace       = apply_filters('wpinv_rest_api_namespace', $api_namespace);
47
+        $this->invoices_controller = new WPInv_REST_Invoice_Controller($this->api_namespace);
48
+        $this->items_controller    = new WPInv_REST_Items_Controller($this->api_namespace);
49 49
 
50 50
         //Register REST routes
51
-        add_action( 'rest_api_init', array( $this, 'register_rest_routes' ) );
51
+        add_action('rest_api_init', array($this, 'register_rest_routes'));
52 52
     }
53 53
 
54 54
 
@@ -76,10 +76,10 @@  discard block
 block discarded – undo
76 76
     protected function includes() {
77 77
         
78 78
         // Invoices
79
-        require_once( WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-invoice-controller.php' );
79
+        require_once(WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-invoice-controller.php');
80 80
 
81 81
         // Items
82
-        require_once( WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-items-controller.php' );
82
+        require_once(WPINV_PLUGIN_DIR . 'includes/api/class-wpinv-rest-items-controller.php');
83 83
 
84 84
     }
85 85
     
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 1 patch
Spacing   +422 added lines, -422 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8 8
 
9 9
 	/**
@@ -54,27 +54,27 @@  discard block
 block discarded – undo
54 54
 		/**
55 55
 		 * Take the array options and use them to build.
56 56
 		 */
57
-		public function __construct( $options ) {
57
+		public function __construct($options) {
58 58
 			global $sd_widgets;
59 59
 
60
-			$sd_widgets[ $options['base_id'] ] = array(
60
+			$sd_widgets[$options['base_id']] = array(
61 61
 				'name'       => $options['name'],
62 62
 				'class_name' => $options['class_name']
63 63
 			);
64
-			$this->base_id                     = $options['base_id'];
64
+			$this->base_id = $options['base_id'];
65 65
 			// lets filter the options before we do anything
66
-			$options       = apply_filters( "wp_super_duper_options", $options );
67
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
68
-			$options       = $this->add_name_from_key( $options );
66
+			$options       = apply_filters("wp_super_duper_options", $options);
67
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
68
+			$options       = $this->add_name_from_key($options);
69 69
 			$this->options = $options;
70 70
 
71 71
 			$this->base_id   = $options['base_id'];
72
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
72
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
73 73
 
74 74
 			// init parent
75
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
75
+			parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
76 76
 
77
-			if ( isset( $options['class_name'] ) ) {
77
+			if (isset($options['class_name'])) {
78 78
 				// register widget
79 79
 				$this->class_name = $options['class_name'];
80 80
 
@@ -82,54 +82,54 @@  discard block
 block discarded – undo
82 82
 				$this->register_shortcode();
83 83
 
84 84
 				// Fusion Builder (avada) support
85
-				if( function_exists('fusion_builder_map') ){ $this->register_fusion_element(); }
85
+				if (function_exists('fusion_builder_map')) { $this->register_fusion_element(); }
86 86
 
87 87
 				// register block
88
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
88
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
89 89
 			}
90 90
 
91 91
 			// add the CSS and JS we need ONCE
92 92
 			global $sd_widget_scripts;
93 93
 
94
-			if ( ! $sd_widget_scripts ) {
95
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
96
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
97
-				wp_add_inline_style( 'widgets', $this->widget_css() );
94
+			if (!$sd_widget_scripts) {
95
+				wp_add_inline_script('admin-widgets', $this->widget_js());
96
+				wp_add_inline_script('customize-controls', $this->widget_js());
97
+				wp_add_inline_style('widgets', $this->widget_css());
98 98
 
99 99
 				$sd_widget_scripts = true;
100 100
 
101 101
 				// add shortcode insert button once
102
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
102
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
103 103
 				// generatepress theme sections compatibility
104
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
105
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
104
+				if (function_exists('generate_sections_sections_metabox')) {
105
+					add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script'));
106 106
 				}
107
-				if ( $this->is_preview() ) {
108
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
107
+				if ($this->is_preview()) {
108
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
109 109
 					// this makes the insert button work for elementor
110
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
110
+					add_action('elementor/editor/after_enqueue_scripts', array(
111 111
 						$this,
112 112
 						'shortcode_insert_button_script'
113
-					) ); // for elementor
113
+					)); // for elementor
114 114
 				}
115 115
 				// this makes the insert button work for cornerstone
116
-				add_action('wp_print_footer_scripts',array( __CLASS__, 'maybe_cornerstone_builder' ));
116
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
117 117
 
118
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
119
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
118
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
119
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
120 120
 
121 121
 				// add generator text to admin head
122
-				add_action( 'admin_head', array( $this, 'generator' ) );
122
+				add_action('admin_head', array($this, 'generator'));
123 123
 			}
124 124
 
125
-			do_action( 'wp_super_duper_widget_init', $options, $this );
125
+			do_action('wp_super_duper_widget_init', $options, $this);
126 126
 		}
127 127
 
128
-		public function register_fusion_element(){
128
+		public function register_fusion_element() {
129 129
 
130 130
 			$options = $this->options;
131 131
 
132
-			if($this->base_id){
132
+			if ($this->base_id) {
133 133
 
134 134
 				$params = $this->get_fusion_params();
135 135
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 					'allow_generator' => true,
141 141
 				);
142 142
 
143
-				if(!empty($params)){
143
+				if (!empty($params)) {
144 144
 					$args['params'] = $params;
145 145
 				}
146 146
 
@@ -149,12 +149,12 @@  discard block
 block discarded – undo
149 149
 
150 150
 		}
151 151
 
152
-		public function get_fusion_params(){
152
+		public function get_fusion_params() {
153 153
 			$params = array();
154 154
 			$arguments = $this->get_arguments();
155 155
 
156
-			if(!empty($arguments)){
157
-				foreach($arguments as $key => $val){
156
+			if (!empty($arguments)) {
157
+				foreach ($arguments as $key => $val) {
158 158
 					$param = array();
159 159
 					// type
160 160
 					$param['type'] = str_replace(
@@ -188,19 +188,19 @@  discard block
 block discarded – undo
188 188
 					$param['default'] = isset($val['default']) ? $val['default'] : '';
189 189
 
190 190
 					// Group
191
-					if(isset($val['group'])){
191
+					if (isset($val['group'])) {
192 192
 						$param['group'] = $val['group'];
193 193
 					}
194 194
 
195 195
 					// value
196
-					if($val['type'] == 'checkbox'){
197
-						if(isset($val['default']) && $val['default'] == '0'){
196
+					if ($val['type'] == 'checkbox') {
197
+						if (isset($val['default']) && $val['default'] == '0') {
198 198
 							unset($param['default']);
199 199
 						}
200
-						$param['value'] = array(''=>__("No"),'1'=>__("Yes"));
201
-					}elseif($param['type'] == 'select'){
200
+						$param['value'] = array(''=>__("No"), '1'=>__("Yes"));
201
+					}elseif ($param['type'] == 'select') {
202 202
 						$param['value'] = isset($val['options']) ? $val['options'] : array();
203
-					}else{
203
+					} else {
204 204
 						$param['value'] = isset($val['default']) ? $val['default'] : '';
205 205
 					}
206 206
 
@@ -217,8 +217,8 @@  discard block
 block discarded – undo
217 217
 		/**
218 218
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
219 219
 		 */
220
-		public static function maybe_cornerstone_builder(){
221
-			if(did_action('cornerstone_before_boot_app')){
220
+		public static function maybe_cornerstone_builder() {
221
+			if (did_action('cornerstone_before_boot_app')) {
222 222
 				self::shortcode_insert_button_script();
223 223
 			}
224 224
 		}
@@ -230,12 +230,12 @@  discard block
 block discarded – undo
230 230
 		 *
231 231
 		 * @return string
232 232
 		 */
233
-		public static function get_picker( $editor_id = '' ) {
233
+		public static function get_picker($editor_id = '') {
234 234
 
235 235
 			ob_start();
236
-			if ( isset( $_POST['editor_id'] ) ) {
237
-				$editor_id = esc_attr( $_POST['editor_id'] );
238
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
236
+			if (isset($_POST['editor_id'])) {
237
+				$editor_id = esc_attr($_POST['editor_id']);
238
+			} elseif (isset($_REQUEST['et_fb'])) {
239 239
 				$editor_id = 'main_content_content_vb_tiny_mce';
240 240
 			}
241 241
 
@@ -244,13 +244,13 @@  discard block
 block discarded – undo
244 244
 
245 245
 			<div class="sd-shortcode-left-wrap">
246 246
 				<?php
247
-				ksort( $sd_widgets );
247
+				ksort($sd_widgets);
248 248
 //				print_r($sd_widgets);exit;
249
-				if ( ! empty( $sd_widgets ) ) {
249
+				if (!empty($sd_widgets)) {
250 250
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
251
-					echo "<option>" . __( 'Select shortcode' ) . "</option>";
252
-					foreach ( $sd_widgets as $shortcode => $class ) {
253
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
251
+					echo "<option>" . __('Select shortcode') . "</option>";
252
+					foreach ($sd_widgets as $shortcode => $class) {
253
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
254 254
 					}
255 255
 					echo "</select>";
256 256
 
@@ -263,37 +263,37 @@  discard block
 block discarded – undo
263 263
 			<div class="sd-shortcode-right-wrap">
264 264
 				<textarea id='sd-shortcode-output' disabled></textarea>
265 265
 				<div id='sd-shortcode-output-actions'>
266
-					<?php if ( $editor_id != '' ) { ?>
266
+					<?php if ($editor_id != '') { ?>
267 267
 						<button class="button sd-insert-shortcode-button"
268
-						        onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
268
+						        onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
269 269
 							        echo "'" . $editor_id . "'";
270
-						        } ?>)"><?php _e( 'Insert shortcode' ); ?></button>
270
+						        } ?>)"><?php _e('Insert shortcode'); ?></button>
271 271
 					<?php } ?>
272 272
 					<button class="button"
273
-					        onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
273
+					        onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
274 274
 				</div>
275 275
 			</div>
276 276
 			<?php
277 277
 
278 278
 			$html = ob_get_clean();
279 279
 
280
-			if ( wp_doing_ajax() ) {
280
+			if (wp_doing_ajax()) {
281 281
 				echo $html;
282 282
 				$should_die = true;
283 283
 
284 284
 				// some builder get the editor via ajax so we should not die on those ocasions
285 285
 				$dont_die = array(
286
-					'parent_tag',// WP Bakery
286
+					'parent_tag', // WP Bakery
287 287
 					'avia_request' // enfold
288 288
 				);
289 289
 
290
-				foreach ( $dont_die as $request ) {
291
-					if ( isset( $_REQUEST[ $request ] ) ) {
290
+				foreach ($dont_die as $request) {
291
+					if (isset($_REQUEST[$request])) {
292 292
 						$should_die = false;
293 293
 					}
294 294
 				}
295 295
 
296
-				if ( $should_die ) {
296
+				if ($should_die) {
297 297
 					wp_die();
298 298
 				}
299 299
 
@@ -320,16 +320,16 @@  discard block
 block discarded – undo
320 320
 		public static function get_widget_settings() {
321 321
 			global $sd_widgets;
322 322
 
323
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
324
-			if ( ! $shortcode ) {
323
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
324
+			if (!$shortcode) {
325 325
 				wp_die();
326 326
 			}
327
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
328
-			if ( ! $widget_args ) {
327
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
328
+			if (!$widget_args) {
329 329
 				wp_die();
330 330
 			}
331
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
332
-			if ( ! $class_name ) {
331
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
332
+			if (!$class_name) {
333 333
 				wp_die();
334 334
 			}
335 335
 
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 			$widget = new $class_name;
338 338
 
339 339
 			ob_start();
340
-			$widget->form( array() );
340
+			$widget->form(array());
341 341
 			$form = ob_get_clean();
342 342
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
343 343
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
356 356
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
357 357
 		 */
358
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
358
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
359 359
 			global $sd_widgets, $shortcode_insert_button_once;
360
-			if ( $shortcode_insert_button_once ) {
360
+			if ($shortcode_insert_button_once) {
361 361
 				return;
362 362
 			}
363 363
 			add_thickbox();
@@ -367,21 +367,21 @@  discard block
 block discarded – undo
367 367
 			 * Cornerstone makes us play dirty tricks :/
368 368
 			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
369 369
 			 */
370
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
370
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
371 371
 				echo '<span id="insert-media-button">';
372 372
 			}
373 373
 
374
-			echo self::shortcode_button( 'this', 'true' );
374
+			echo self::shortcode_button('this', 'true');
375 375
 
376 376
 			// see opening note
377
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
377
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
378 378
 				echo '</span>'; // end #insert-media-button
379 379
 			}
380 380
 
381 381
 			// Add separate script for generatepress theme sections
382
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
382
+			if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) {
383 383
 			} else {
384
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
384
+				self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
385 385
 			}
386 386
 
387 387
 			$shortcode_insert_button_once = true;
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
 		 *
396 396
 		 * @return mixed
397 397
 		 */
398
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
398
+		public static function shortcode_button($id = '', $search_for_id = '') {
399 399
 			ob_start();
400 400
 			?>
401 401
 			<span class="sd-lable-shortcode-inserter">
402 402
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
403
-				if ( $search_for_id ) {
403
+				if ($search_for_id) {
404 404
 					echo "," . $search_for_id;
405 405
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
406 406
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -416,7 +416,7 @@  discard block
 block discarded – undo
416 416
 			$html = ob_get_clean();
417 417
 
418 418
 			// remove line breaks so we can use it in js
419
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
419
+			return preg_replace("/\r|\n/", "", trim($html));
420 420
 		}
421 421
 
422 422
 		/**
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 						jQuery($this).data('sd-widget-enabled', true);
475 475
 					}
476 476
 
477
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
477
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
478 478
 					var form = jQuery($this).parents('' + $selector + '');
479 479
 
480 480
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -511,10 +511,10 @@  discard block
 block discarded – undo
511 511
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
512 512
 			 */
513 513
 
514
-			return str_replace( array(
514
+			return str_replace(array(
515 515
 				'<script>',
516 516
 				'</script>'
517
-			), '', $output );
517
+			), '', $output);
518 518
 		}
519 519
 
520 520
 		/**
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
 		 * @param string $editor_id
526 526
 		 * @param string $insert_shortcode_function
527 527
 		 */
528
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
528
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
529 529
 			?>
530 530
 			<style>
531 531
 				.sd-shortcode-left-wrap {
@@ -643,22 +643,22 @@  discard block
 block discarded – undo
643 643
 					height: 250px;
644 644
 					width: 100%;
645 645
 				}
646
-				<?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?>
646
+				<?php if (function_exists('generate_sections_sections_metabox')) { ?>
647 647
 				.generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter {
648 648
 					display: inline;
649 649
 				}
650 650
 				<?php } ?>
651 651
 			</style>
652 652
 			<?php
653
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
653
+			if (class_exists('SiteOrigin_Panels')) {
654 654
 				echo "<script>" . self::siteorigin_js() . "</script>";
655 655
 			}
656 656
 			?>
657 657
 			<script>
658 658
 				<?php
659
-				if(! empty( $insert_shortcode_function )){
659
+				if (!empty($insert_shortcode_function)) {
660 660
 					echo $insert_shortcode_function;
661
-				}else{
661
+				} else {
662 662
 
663 663
 				/**
664 664
 				 * Function for super duper insert shortcode.
@@ -671,9 +671,9 @@  discard block
 block discarded – undo
671 671
 					if ($shortcode) {
672 672
 						if (!$editor_id) {
673 673
 							<?php
674
-							if ( isset( $_REQUEST['et_fb'] ) ) {
674
+							if (isset($_REQUEST['et_fb'])) {
675 675
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
676
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
676
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
677 677
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
678 678
 							} else {
679 679
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -758,11 +758,11 @@  discard block
 block discarded – undo
758 758
 							'shortcode': $short_code,
759 759
 							'attributes': 123,
760 760
 							'post_id': 321,
761
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
761
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
762 762
 						};
763 763
 
764 764
 						if (typeof ajaxurl === 'undefined') {
765
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
765
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
766 766
 						}
767 767
 
768 768
 						jQuery.post(ajaxurl, data, function (response) {
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 					var data = {
961 961
 						'action': 'super_duper_get_picker',
962 962
 						'editor_id': $id,
963
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
963
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
964 964
 					};
965 965
 
966 966
 					if (!ajaxurl) {
967
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
967
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
968 968
 					}
969 969
 
970 970
 					jQuery.post(ajaxurl, data, function (response) {
@@ -985,9 +985,9 @@  discard block
 block discarded – undo
985 985
 				 */
986 986
 				function sd_shortcode_button($id) {
987 987
 					if ($id) {
988
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
988
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
989 989
 					} else {
990
-						return '<?php echo self::shortcode_button();?>';
990
+						return '<?php echo self::shortcode_button(); ?>';
991 991
 					}
992 992
 				}
993 993
 
@@ -1043,10 +1043,10 @@  discard block
 block discarded – undo
1043 1043
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1044 1044
 			 */
1045 1045
 
1046
-			return str_replace( array(
1046
+			return str_replace(array(
1047 1047
 				'<style>',
1048 1048
 				'</style>'
1049
-			), '', $output );
1049
+			), '', $output);
1050 1050
 		}
1051 1051
 
1052 1052
 		/**
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 						jQuery($this).data('sd-widget-enabled', true);
1117 1117
 					}
1118 1118
 
1119
-					var $button = '<button title="<?php _e( 'Advanced Settings' );?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1119
+					var $button = '<button title="<?php _e('Advanced Settings'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1120 1120
 					var form = jQuery($this).parents('' + $selector + '');
1121 1121
 
1122 1122
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1208,7 +1208,7 @@  discard block
 block discarded – undo
1208 1208
 					});
1209 1209
 
1210 1210
 				}
1211
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1211
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1212 1212
 			</script>
1213 1213
 			<?php
1214 1214
 			$output = ob_get_clean();
@@ -1217,10 +1217,10 @@  discard block
 block discarded – undo
1217 1217
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1218 1218
 			 */
1219 1219
 
1220
-			return str_replace( array(
1220
+			return str_replace(array(
1221 1221
 				'<script>',
1222 1222
 				'</script>'
1223
-			), '', $output );
1223
+			), '', $output);
1224 1224
 		}
1225 1225
 
1226 1226
 
@@ -1231,14 +1231,14 @@  discard block
 block discarded – undo
1231 1231
 		 *
1232 1232
 		 * @return mixed
1233 1233
 		 */
1234
-		private function add_name_from_key( $options, $arguments = false ) {
1235
-			if ( ! empty( $options['arguments'] ) ) {
1236
-				foreach ( $options['arguments'] as $key => $val ) {
1237
-					$options['arguments'][ $key ]['name'] = $key;
1234
+		private function add_name_from_key($options, $arguments = false) {
1235
+			if (!empty($options['arguments'])) {
1236
+				foreach ($options['arguments'] as $key => $val) {
1237
+					$options['arguments'][$key]['name'] = $key;
1238 1238
 				}
1239
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1240
-				foreach ( $options as $key => $val ) {
1241
-					$options[ $key ]['name'] = $key;
1239
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1240
+				foreach ($options as $key => $val) {
1241
+					$options[$key]['name'] = $key;
1242 1242
 				}
1243 1243
 			}
1244 1244
 
@@ -1251,8 +1251,8 @@  discard block
 block discarded – undo
1251 1251
 		 * @since 1.0.0
1252 1252
 		 */
1253 1253
 		public function register_shortcode() {
1254
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1255
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
1254
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1255
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
1256 1256
 		}
1257 1257
 
1258 1258
 		/**
@@ -1262,33 +1262,33 @@  discard block
 block discarded – undo
1262 1262
 		 */
1263 1263
 		public static function render_shortcode() {
1264 1264
 
1265
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1266
-			if ( ! current_user_can( 'manage_options' ) ) {
1265
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1266
+			if (!current_user_can('manage_options')) {
1267 1267
 				wp_die();
1268 1268
 			}
1269 1269
 
1270 1270
 			// we might need the $post value here so lets set it.
1271
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1272
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1273
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1271
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1272
+				$post_obj = get_post(absint($_POST['post_id']));
1273
+				if (!empty($post_obj) && empty($post)) {
1274 1274
 					global $post;
1275 1275
 					$post = $post_obj;
1276 1276
 				}
1277 1277
 			}
1278 1278
 
1279
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1280
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1281
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1279
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1280
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1281
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1282 1282
 				$attributes       = '';
1283
-				if ( ! empty( $attributes_array ) ) {
1284
-					foreach ( $attributes_array as $key => $value ) {
1285
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
1283
+				if (!empty($attributes_array)) {
1284
+					foreach ($attributes_array as $key => $value) {
1285
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
1286 1286
 					}
1287 1287
 				}
1288 1288
 
1289 1289
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
1290 1290
 
1291
-				echo do_shortcode( $shortcode );
1291
+				echo do_shortcode($shortcode);
1292 1292
 
1293 1293
 			}
1294 1294
 			wp_die();
@@ -1302,37 +1302,37 @@  discard block
 block discarded – undo
1302 1302
 		 *
1303 1303
 		 * @return string
1304 1304
 		 */
1305
-		public function shortcode_output( $args = array(), $content = '' ) {
1306
-			$args = self::argument_values( $args );
1305
+		public function shortcode_output($args = array(), $content = '') {
1306
+			$args = self::argument_values($args);
1307 1307
 
1308 1308
 			// add extra argument so we know its a output to gutenberg
1309 1309
 			//$args
1310
-			$args = $this->string_to_bool( $args );
1310
+			$args = $this->string_to_bool($args);
1311 1311
 
1312 1312
 
1313
-			$calss = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1313
+			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1314 1314
 
1315
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
1316
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
1315
+			$calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this);
1316
+			$calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this);
1317 1317
 
1318
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1319
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1318
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1319
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1320 1320
 
1321 1321
 			$shortcode_args = array();
1322 1322
 			$output         = '';
1323
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1324
-			$main_content   = $this->output( $args, $shortcode_args, $content );
1325
-			if ( $main_content && ! $no_wrap ) {
1323
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1324
+			$main_content   = $this->output($args, $shortcode_args, $content);
1325
+			if ($main_content && !$no_wrap) {
1326 1326
 				// wrap the shortcode in a dive with the same class as the widget
1327 1327
 				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
1328
-				if ( ! empty( $args['title'] ) ) {
1328
+				if (!empty($args['title'])) {
1329 1329
 					// if its a shortcode and there is a title try to grab the title wrappers
1330
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1331
-					if ( empty( $instance ) ) {
1330
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1331
+					if (empty($instance)) {
1332 1332
 						global $wp_registered_sidebars;
1333
-						if ( ! empty( $wp_registered_sidebars ) ) {
1334
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1335
-								if ( ! empty( $sidebar['before_title'] ) ) {
1333
+						if (!empty($wp_registered_sidebars)) {
1334
+							foreach ($wp_registered_sidebars as $sidebar) {
1335
+								if (!empty($sidebar['before_title'])) {
1336 1336
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1337 1337
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1338 1338
 									break;
@@ -1340,20 +1340,20 @@  discard block
 block discarded – undo
1340 1340
 							}
1341 1341
 						}
1342 1342
 					}
1343
-					$output .= $this->output_title( $shortcode_args, $args );
1343
+					$output .= $this->output_title($shortcode_args, $args);
1344 1344
 				}
1345 1345
 				$output .= $main_content;
1346 1346
 				$output .= '</div>';
1347
-			} elseif ( $main_content && $no_wrap ) {
1347
+			} elseif ($main_content && $no_wrap) {
1348 1348
 				$output .= $main_content;
1349 1349
 			}
1350 1350
 
1351 1351
 			// if preview show a placeholder if empty
1352
-			if ( $this->is_preview() && $output == '' ) {
1353
-				$output = $this->preview_placeholder_text( "[{" . $this->base_id . "}]" );
1352
+			if ($this->is_preview() && $output == '') {
1353
+				$output = $this->preview_placeholder_text("[{" . $this->base_id . "}]");
1354 1354
 			}
1355 1355
 
1356
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1356
+			return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this);
1357 1357
 		}
1358 1358
 
1359 1359
 		/**
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 		 *
1364 1364
 		 * @return string
1365 1365
 		 */
1366
-		public function preview_placeholder_text( $name = '' ) {
1367
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf( __( 'Placeholder for: %s' ), $name ) . "</div>";
1366
+		public function preview_placeholder_text($name = '') {
1367
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . sprintf(__('Placeholder for: %s'), $name) . "</div>";
1368 1368
 		}
1369 1369
 
1370 1370
 		/**
@@ -1374,13 +1374,13 @@  discard block
 block discarded – undo
1374 1374
 		 *
1375 1375
 		 * @return mixed
1376 1376
 		 */
1377
-		public function string_to_bool( $options ) {
1377
+		public function string_to_bool($options) {
1378 1378
 			// convert bool strings to booleans
1379
-			foreach ( $options as $key => $val ) {
1380
-				if ( $val == 'false' ) {
1381
-					$options[ $key ] = false;
1382
-				} elseif ( $val == 'true' ) {
1383
-					$options[ $key ] = true;
1379
+			foreach ($options as $key => $val) {
1380
+				if ($val == 'false') {
1381
+					$options[$key] = false;
1382
+				} elseif ($val == 'true') {
1383
+					$options[$key] = true;
1384 1384
 				}
1385 1385
 			}
1386 1386
 
@@ -1396,27 +1396,27 @@  discard block
 block discarded – undo
1396 1396
 		 *
1397 1397
 		 * @return array
1398 1398
 		 */
1399
-		public function argument_values( $instance ) {
1399
+		public function argument_values($instance) {
1400 1400
 			$argument_values = array();
1401 1401
 
1402 1402
 			// set widget instance
1403 1403
 			$this->instance = $instance;
1404 1404
 
1405
-			if ( empty( $this->arguments ) ) {
1405
+			if (empty($this->arguments)) {
1406 1406
 				$this->arguments = $this->get_arguments();
1407 1407
 			}
1408 1408
 
1409
-			if ( ! empty( $this->arguments ) ) {
1410
-				foreach ( $this->arguments as $key => $args ) {
1409
+			if (!empty($this->arguments)) {
1410
+				foreach ($this->arguments as $key => $args) {
1411 1411
 					// set the input name from the key
1412 1412
 					$args['name'] = $key;
1413 1413
 					//
1414
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1415
-					if($args['type']=='checkbox' && $argument_values[ $key ] == ''){
1414
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1415
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1416 1416
 						// don't set default for an empty checkbox
1417 1417
 					}
1418
-					elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1419
-						$argument_values[ $key ] = $args['default'];
1418
+					elseif ($argument_values[$key] == '' && isset($args['default'])) {
1419
+						$argument_values[$key] = $args['default'];
1420 1420
 					}
1421 1421
 				}
1422 1422
 			}
@@ -1443,12 +1443,12 @@  discard block
 block discarded – undo
1443 1443
 		 * @return array Get arguments.
1444 1444
 		 */
1445 1445
 		public function get_arguments() {
1446
-			if ( empty( $this->arguments ) ) {
1446
+			if (empty($this->arguments)) {
1447 1447
 				$this->arguments = $this->set_arguments();
1448 1448
 			}
1449 1449
 
1450
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1451
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1450
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1451
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1452 1452
 
1453 1453
 			return $this->arguments;
1454 1454
 		}
@@ -1460,7 +1460,7 @@  discard block
 block discarded – undo
1460 1460
 		 * @param array $widget_args
1461 1461
 		 * @param string $content
1462 1462
 		 */
1463
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1463
+		public function output($args = array(), $widget_args = array(), $content = '') {
1464 1464
 
1465 1465
 		}
1466 1466
 
@@ -1468,10 +1468,10 @@  discard block
 block discarded – undo
1468 1468
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1469 1469
 		 */
1470 1470
 		public function register_block() {
1471
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1472
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1471
+			wp_add_inline_script('wp-blocks', $this->block());
1472
+			if (class_exists('SiteOrigin_Panels')) {
1473 1473
 
1474
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1474
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1475 1475
 
1476 1476
 			}
1477 1477
 		}
@@ -1486,13 +1486,13 @@  discard block
 block discarded – undo
1486 1486
 			$show      = false;
1487 1487
 			$arguments = $this->arguments;
1488 1488
 
1489
-			if ( empty( $arguments ) ) {
1489
+			if (empty($arguments)) {
1490 1490
 				$arguments = $this->get_arguments();
1491 1491
 			}
1492 1492
 
1493
-			if ( ! empty( $arguments ) ) {
1494
-				foreach ( $arguments as $argument ) {
1495
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1493
+			if (!empty($arguments)) {
1494
+				foreach ($arguments as $argument) {
1495
+					if (isset($argument['advanced']) && $argument['advanced']) {
1496 1496
 						$show = true;
1497 1497
 						break; // no need to continue if we know we have it
1498 1498
 					}
@@ -1511,15 +1511,15 @@  discard block
 block discarded – undo
1511 1511
 
1512 1512
 			$url = $this->url;
1513 1513
 
1514
-			if(!$url){
1514
+			if (!$url) {
1515 1515
 				// check if we are inside a plugin
1516
-				$file_dir = str_replace("/includes","", dirname( __FILE__ ));
1516
+				$file_dir = str_replace("/includes", "", dirname(__FILE__));
1517 1517
 
1518
-				$dir_parts = explode("/wp-content/",$file_dir);
1519
-				$url_parts = explode("/wp-content/",plugins_url());
1518
+				$dir_parts = explode("/wp-content/", $file_dir);
1519
+				$url_parts = explode("/wp-content/", plugins_url());
1520 1520
 
1521
-				if(!empty($url_parts[0]) && !empty($dir_parts[1])){
1522
-					$url = trailingslashit( $url_parts[0]."/wp-content/".$dir_parts[1] );
1521
+				if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1522
+					$url = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]);
1523 1523
 					$this->url = $url;
1524 1524
 				}
1525 1525
 			}
@@ -1538,46 +1538,46 @@  discard block
 block discarded – undo
1538 1538
 		 * @since 1.1.0
1539 1539
 		 * @return string
1540 1540
 		 */
1541
-		public function get_block_icon($icon){
1541
+		public function get_block_icon($icon) {
1542 1542
 
1543 1543
 			// check if we have a Font Awesome icon
1544 1544
 			$fa_type = '';
1545
-			if(substr( $icon, 0, 7 ) === "fas fa-"){
1545
+			if (substr($icon, 0, 7) === "fas fa-") {
1546 1546
 				$fa_type = 'solid';
1547
-			}elseif(substr( $icon, 0, 7 ) === "far fa-"){
1547
+			}elseif (substr($icon, 0, 7) === "far fa-") {
1548 1548
 				$fa_type = 'regular';
1549
-			}elseif(substr( $icon, 0, 7 ) === "fab fa-"){
1549
+			}elseif (substr($icon, 0, 7) === "fab fa-") {
1550 1550
 				$fa_type = 'brands';
1551
-			}else{
1552
-				$icon = "'".$icon."'";
1551
+			} else {
1552
+				$icon = "'" . $icon . "'";
1553 1553
 			}
1554 1554
 
1555 1555
 			// set the icon if we found one
1556
-			if($fa_type){
1557
-				$fa_icon = str_replace(array("fas fa-","far fa-","fab fa-"),"",$icon);
1558
-				$icon  = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '".$this->get_url()."icons/".$fa_type.".svg#".$fa_icon."','href': '".$this->get_url()."icons/".$fa_type.".svg#".$fa_icon."'}))";
1556
+			if ($fa_type) {
1557
+				$fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon);
1558
+				$icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1559 1559
 			}
1560 1560
 
1561 1561
 			return $icon;
1562 1562
 		}
1563 1563
 
1564
-		public function group_arguments($arguments){
1564
+		public function group_arguments($arguments) {
1565 1565
 //			echo '###';print_r($arguments);
1566
-			if(!empty($arguments)){
1566
+			if (!empty($arguments)) {
1567 1567
 				$temp_arguments = array();
1568 1568
 				$general = __("General");
1569 1569
 				$add_sections = false;
1570
-				foreach($arguments as $key => $args){
1571
-					if(isset($args['group'])){
1570
+				foreach ($arguments as $key => $args) {
1571
+					if (isset($args['group'])) {
1572 1572
 						$temp_arguments[$args['group']][$key] = $args;
1573 1573
 						$add_sections = true;
1574
-					}else{
1574
+					} else {
1575 1575
 						$temp_arguments[$general][$key] = $args;
1576 1576
 					}
1577 1577
 				}
1578 1578
 
1579 1579
 				// only add sections if more than one
1580
-				if($add_sections){
1580
+				if ($add_sections) {
1581 1581
 					$arguments = $temp_arguments;
1582 1582
 				}
1583 1583
 			}
@@ -1629,19 +1629,19 @@  discard block
 block discarded – undo
1629 1629
 					 * @return {?WPBlock}          The block, if it has been successfully
1630 1630
 					 *                             registered; otherwise `undefined`.
1631 1631
 					 */
1632
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1633
-						title: '<?php echo $this->options['name'];?>', // Block title.
1634
-						description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title.
1635
-						icon: <?php echo $this->get_block_icon($this->options['block-icon']);?>,//'<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
1632
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
1633
+						title: '<?php echo $this->options['name']; ?>', // Block title.
1634
+						description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title.
1635
+						icon: <?php echo $this->get_block_icon($this->options['block-icon']); ?>,//'<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
1636 1636
 						supports: {
1637 1637
 							<?php
1638
-							if(isset($this->options['block-supports'])){
1639
-								echo $this->array_to_attributes( $this->options['block-supports'] );
1638
+							if (isset($this->options['block-supports'])) {
1639
+								echo $this->array_to_attributes($this->options['block-supports']);
1640 1640
 							}
1641 1641
 							?>
1642 1642
 						},
1643
-						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
1644
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
1643
+						category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
1644
+						<?php if (isset($this->options['block-keywords'])) {
1645 1645
 						echo "keywords : " . $this->options['block-keywords'] . ",";
1646 1646
 					}?>
1647 1647
 
@@ -1656,10 +1656,10 @@  discard block
 block discarded – undo
1656 1656
 						echo "  html: false";
1657 1657
 						echo "},";*/
1658 1658
 
1659
-						if ( ! empty( $this->arguments ) ) {
1659
+						if (!empty($this->arguments)) {
1660 1660
 							echo "attributes : {";
1661 1661
 
1662
-							if ( $show_advanced ) {
1662
+							if ($show_advanced) {
1663 1663
 								echo "show_advanced: {";
1664 1664
 								echo "	type: 'boolean',";
1665 1665
 								echo "  default: false,";
@@ -1667,41 +1667,41 @@  discard block
 block discarded – undo
1667 1667
 							}
1668 1668
 
1669 1669
 							// block wrap element
1670
-							if ( isset( $this->options['block-wrap'] ) ) { //@todo we should validate this?
1670
+							if (isset($this->options['block-wrap'])) { //@todo we should validate this?
1671 1671
 								echo "block_wrap: {";
1672 1672
 								echo "	type: 'string',";
1673
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
1673
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
1674 1674
 								echo "},";
1675 1675
 							}
1676 1676
 
1677
-							foreach ( $this->arguments as $key => $args ) {
1677
+							foreach ($this->arguments as $key => $args) {
1678 1678
 
1679 1679
 								// set if we should show alignment
1680
-								if ( $key == 'alignment' ) {
1680
+								if ($key == 'alignment') {
1681 1681
 									$show_alignment = true;
1682 1682
 								}
1683 1683
 
1684 1684
 								$extra = '';
1685 1685
 
1686
-								if ( $args['type'] == 'checkbox' ) {
1686
+								if ($args['type'] == 'checkbox') {
1687 1687
 									$type    = 'boolean';
1688
-									$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
1689
-								} elseif ( $args['type'] == 'number' ) {
1688
+									$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
1689
+								} elseif ($args['type'] == 'number') {
1690 1690
 									$type    = 'number';
1691
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1692
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
1691
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1692
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
1693 1693
 									$type = 'array';
1694
-									if ( is_array( $args['default'] ) ) {
1695
-										$default = isset( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
1694
+									if (is_array($args['default'])) {
1695
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
1696 1696
 									} else {
1697
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1697
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1698 1698
 									}
1699
-								} elseif ( $args['type'] == 'multiselect' ) {
1699
+								} elseif ($args['type'] == 'multiselect') {
1700 1700
 									$type    = 'array';
1701
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1701
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1702 1702
 								} else {
1703 1703
 									$type    = 'string';
1704
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
1704
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
1705 1705
 								}
1706 1706
 								echo $key . " : {";
1707 1707
 								echo "type : '$type',";
@@ -1732,12 +1732,12 @@  discard block
 block discarded – undo
1732 1732
 									is_fetching = true;
1733 1733
 									var data = {
1734 1734
 										'action': 'super_duper_output_shortcode',
1735
-										'shortcode': '<?php echo $this->options['base_id'];?>',
1735
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
1736 1736
 										'attributes': props.attributes,
1737
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
1737
+										'post_id': <?php global $post; if (isset($post->ID)) {
1738 1738
 										echo $post->ID;
1739 1739
 									}?>,
1740
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
1740
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
1741 1741
 									};
1742 1742
 
1743 1743
 									jQuery.post(ajaxurl, data, function (response) {
@@ -1746,7 +1746,7 @@  discard block
 block discarded – undo
1746 1746
 
1747 1747
 										// if the content is empty then we place some placeholder text
1748 1748
 										if (env == '') {
1749
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for: ' );?>" + props.name + "</div>";
1749
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for: '); ?>" + props.name + "</div>";
1750 1750
 										}
1751 1751
 
1752 1752
 										props.setAttributes({content: env});
@@ -1765,7 +1765,7 @@  discard block
 block discarded – undo
1765 1765
 
1766 1766
 								el(wp.editor.BlockControls, {key: 'controls'},
1767 1767
 
1768
-									<?php if($show_alignment){?>
1768
+									<?php if ($show_alignment) {?>
1769 1769
 									el(
1770 1770
 										wp.editor.AlignmentToolbar,
1771 1771
 										{
@@ -1783,9 +1783,9 @@  discard block
 block discarded – undo
1783 1783
 
1784 1784
 									<?php
1785 1785
 
1786
-									if(! empty( $this->arguments )){
1786
+									if (!empty($this->arguments)) {
1787 1787
 
1788
-										if ( $show_advanced ) {
1788
+										if ($show_advanced) {
1789 1789
 										?>
1790 1790
 										el(
1791 1791
 											wp.components.ToggleControl,
@@ -1807,17 +1807,17 @@  discard block
 block discarded – undo
1807 1807
 										$has_sections = $arguments == $this->arguments ? false : true;
1808 1808
 
1809 1809
 										
1810
-									if($has_sections){
1810
+									if ($has_sections) {
1811 1811
 										$panel_count = 0;
1812
-										foreach($arguments as $key => $args){
1812
+										foreach ($arguments as $key => $args) {
1813 1813
 											?>
1814 1814
 											el(wp.components.PanelBody, {
1815 1815
 													title: '<?php esc_attr_e($key); ?>',
1816
-													initialOpen: <?php if($panel_count){echo "false";}else{echo "true";}?>
1816
+													initialOpen: <?php if ($panel_count) {echo "false"; } else {echo "true"; }?>
1817 1817
 												},
1818 1818
 											<?php
1819 1819
 
1820
-											foreach($args as $k => $a){
1820
+											foreach ($args as $k => $a) {
1821 1821
 												$this->build_block_arguments($k, $a);
1822 1822
 											}
1823 1823
 											?>
@@ -1826,8 +1826,8 @@  discard block
 block discarded – undo
1826 1826
 									$panel_count++;
1827 1827
 
1828 1828
 										}
1829
-									}else{
1830
-										foreach($this->arguments as $key => $args){
1829
+									} else {
1830
+										foreach ($this->arguments as $key => $args) {
1831 1831
 											$this->build_block_arguments($key, $args);
1832 1832
 										}
1833 1833
 									}
@@ -1841,9 +1841,9 @@  discard block
 block discarded – undo
1841 1841
 
1842 1842
 								<?php
1843 1843
 								// If the user sets block-output array then build it
1844
-								if ( ! empty( $this->options['block-output'] ) ) {
1845
-								$this->block_element( $this->options['block-output'] );
1846
-							}else{
1844
+								if (!empty($this->options['block-output'])) {
1845
+								$this->block_element($this->options['block-output']);
1846
+							} else {
1847 1847
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1848 1848
 								?>
1849 1849
 								el('div', {
@@ -1867,14 +1867,14 @@  discard block
 block discarded – undo
1867 1867
 							var align = '';
1868 1868
 
1869 1869
 							// build the shortcode.
1870
-							var content = "[<?php echo $this->options['base_id'];?>";
1870
+							var content = "[<?php echo $this->options['base_id']; ?>";
1871 1871
 							<?php
1872 1872
 
1873
-							if(! empty( $this->arguments )){
1874
-							foreach($this->arguments as $key => $args){
1873
+							if (!empty($this->arguments)) {
1874
+							foreach ($this->arguments as $key => $args) {
1875 1875
 							?>
1876
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1877
-								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1876
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1877
+								content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1878 1878
 							}
1879 1879
 							<?php
1880 1880
 							}
@@ -1915,82 +1915,82 @@  discard block
 block discarded – undo
1915 1915
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1916 1916
 			 */
1917 1917
 
1918
-			return str_replace( array(
1918
+			return str_replace(array(
1919 1919
 				'<script>',
1920 1920
 				'</script>'
1921
-			), '', $output );
1921
+			), '', $output);
1922 1922
 		}
1923 1923
 
1924
-		public function build_block_arguments($key,$args){
1925
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
1924
+		public function build_block_arguments($key, $args) {
1925
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
1926 1926
 			$options = '';
1927 1927
 			$extra = '';
1928 1928
 			$require = '';
1929 1929
 			$onchange = "props.setAttributes({ $key: $key } )";
1930 1930
 			$value = "props.attributes.$key";
1931
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1932
-			if ( in_array( $args['type'], $text_type ) ) {
1931
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color');
1932
+			if (in_array($args['type'], $text_type)) {
1933 1933
 				$type = 'TextControl';
1934 1934
 				// Save numbers as numbers and not strings
1935
-				if ( $args['type'] == 'number' ) {
1935
+				if ($args['type'] == 'number') {
1936 1936
 					$onchange = "props.setAttributes({ $key: Number($key) } )";
1937 1937
 				}
1938 1938
 			}
1939 1939
 			//									elseif ( $args['type'] == 'color' ) { //@todo ColorPicker labels are not shown yet, we use html5 color input for now https://github.com/WordPress/gutenberg/issues/14378
1940 1940
 			//										$type = 'ColorPicker';
1941 1941
 			//									}
1942
-			elseif ( $args['type'] == 'checkbox' ) {
1942
+			elseif ($args['type'] == 'checkbox') {
1943 1943
 				$type = 'CheckboxControl';
1944 1944
 				$extra .= "checked: props.attributes.$key,";
1945 1945
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1946
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1946
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
1947 1947
 				$type = 'SelectControl';
1948
-				if ( ! empty( $args['options'] ) ) {
1948
+				if (!empty($args['options'])) {
1949 1949
 					$options .= "options  : [";
1950
-					foreach ( $args['options'] as $option_val => $option_label ) {
1951
-						$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1950
+					foreach ($args['options'] as $option_val => $option_label) {
1951
+						$options .= "{ value : '" . esc_attr($option_val) . "',     label : '" . esc_attr($option_label) . "'     },";
1952 1952
 					}
1953 1953
 					$options .= "],";
1954 1954
 				}
1955
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1955
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1956 1956
 					$extra .= ' multiple: true, ';
1957 1957
 					//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1958 1958
 					//$value = "['edit', 'delete']";
1959 1959
 				}
1960
-			} elseif ( $args['type'] == 'alignment' ) {
1960
+			} elseif ($args['type'] == 'alignment') {
1961 1961
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1962 1962
 			} else {
1963
-				return;// if we have not implemented the control then don't break the JS.
1963
+				return; // if we have not implemented the control then don't break the JS.
1964 1964
 			}
1965 1965
 
1966 1966
 			// add show only if advanced
1967
-			if ( ! empty( $args['advanced'] ) ) {
1967
+			if (!empty($args['advanced'])) {
1968 1968
 				echo "props.attributes.show_advanced && ";
1969 1969
 			}
1970 1970
 			// add setting require if defined
1971
-			if ( ! empty( $args['element_require'] ) ) {
1972
-				echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1971
+			if (!empty($args['element_require'])) {
1972
+				echo $this->block_props_replace($args['element_require'], true) . " && ";
1973 1973
 			}
1974 1974
 			?>
1975 1975
 			el(
1976
-			wp.components.<?php echo esc_attr( $type );?>,
1976
+			wp.components.<?php echo esc_attr($type); ?>,
1977 1977
 			{
1978
-			label: '<?php echo esc_attr( $args['title'] );?>',
1979
-			help: '<?php if ( isset( $args['desc'] ) ) {
1980
-				echo esc_attr( $args['desc'] );
1978
+			label: '<?php echo esc_attr($args['title']); ?>',
1979
+			help: '<?php if (isset($args['desc'])) {
1980
+				echo esc_attr($args['desc']);
1981 1981
 			}?>',
1982
-			value: <?php echo $value;?>,
1983
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1984
-				echo "type: '" . esc_attr( $args['type'] ) . "',";
1982
+			value: <?php echo $value; ?>,
1983
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
1984
+				echo "type: '" . esc_attr($args['type']) . "',";
1985 1985
 			}?>
1986
-			<?php if ( ! empty( $args['placeholder'] ) ) {
1987
-				echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1986
+			<?php if (!empty($args['placeholder'])) {
1987
+				echo "placeholder: '" . esc_attr($args['placeholder']) . "',";
1988 1988
 			}?>
1989
-			<?php echo $options;?>
1990
-			<?php echo $extra;?>
1991
-			<?php echo $custom_attributes;?>
1992
-			onChange: function ( <?php echo $key;?> ) {
1993
-			<?php echo $onchange;?>
1989
+			<?php echo $options; ?>
1990
+			<?php echo $extra; ?>
1991
+			<?php echo $custom_attributes; ?>
1992
+			onChange: function ( <?php echo $key; ?> ) {
1993
+			<?php echo $onchange; ?>
1994 1994
 			}
1995 1995
 			}
1996 1996
 			),
@@ -2006,16 +2006,16 @@  discard block
 block discarded – undo
2006 2006
 		 *
2007 2007
 		 * @return string
2008 2008
 		 */
2009
-		public function array_to_attributes( $custom_attributes, $html = false ) {
2009
+		public function array_to_attributes($custom_attributes, $html = false) {
2010 2010
 			$attributes = '';
2011
-			if ( ! empty( $custom_attributes ) ) {
2011
+			if (!empty($custom_attributes)) {
2012 2012
 
2013
-				if ( $html ) {
2014
-					foreach ( $custom_attributes as $key => $val ) {
2013
+				if ($html) {
2014
+					foreach ($custom_attributes as $key => $val) {
2015 2015
 						$attributes .= " $key='$val' ";
2016 2016
 					}
2017 2017
 				} else {
2018
-					foreach ( $custom_attributes as $key => $val ) {
2018
+					foreach ($custom_attributes as $key => $val) {
2019 2019
 						$attributes .= "'$key': '$val',";
2020 2020
 					}
2021 2021
 				}
@@ -2031,86 +2031,86 @@  discard block
 block discarded – undo
2031 2031
 		 *
2032 2032
 		 * @param $args
2033 2033
 		 */
2034
-		public function block_element( $args ) {
2034
+		public function block_element($args) {
2035 2035
 
2036 2036
 
2037
-			if ( ! empty( $args ) ) {
2038
-				foreach ( $args as $element => $new_args ) {
2037
+			if (!empty($args)) {
2038
+				foreach ($args as $element => $new_args) {
2039 2039
 
2040
-					if ( is_array( $new_args ) ) { // its an element
2040
+					if (is_array($new_args)) { // its an element
2041 2041
 
2042 2042
 
2043
-						if ( isset( $new_args['element'] ) ) {
2043
+						if (isset($new_args['element'])) {
2044 2044
 
2045
-							if ( isset( $new_args['element_require'] ) ) {
2046
-								echo str_replace( array(
2045
+							if (isset($new_args['element_require'])) {
2046
+								echo str_replace(array(
2047 2047
 										"'+",
2048 2048
 										"+'"
2049
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
2050
-								unset( $new_args['element_require'] );
2049
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
2050
+								unset($new_args['element_require']);
2051 2051
 							}
2052 2052
 
2053 2053
 							echo "\n el( '" . $new_args['element'] . "', {";
2054 2054
 
2055 2055
 							// get the attributes
2056
-							foreach ( $new_args as $new_key => $new_value ) {
2056
+							foreach ($new_args as $new_key => $new_value) {
2057 2057
 
2058 2058
 
2059
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
2059
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
2060 2060
 									// do nothing
2061 2061
 								} else {
2062
-									echo $this->block_element( array( $new_key => $new_value ) );
2062
+									echo $this->block_element(array($new_key => $new_value));
2063 2063
 								}
2064 2064
 							}
2065 2065
 
2066
-							echo "},";// end attributes
2066
+							echo "},"; // end attributes
2067 2067
 
2068 2068
 							// get the content
2069 2069
 							$first_item = 0;
2070
-							foreach ( $new_args as $new_key => $new_value ) {
2071
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
2070
+							foreach ($new_args as $new_key => $new_value) {
2071
+								if ($new_key === 'content' || is_array($new_value)) {
2072 2072
 
2073
-									if ( $new_key === 'content' ) {
2074
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
2073
+									if ($new_key === 'content') {
2074
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
2075 2075
 									}
2076 2076
 
2077
-									if ( is_array( $new_value ) ) {
2077
+									if (is_array($new_value)) {
2078 2078
 
2079
-										if ( isset( $new_value['element_require'] ) ) {
2080
-											echo str_replace( array(
2079
+										if (isset($new_value['element_require'])) {
2080
+											echo str_replace(array(
2081 2081
 													"'+",
2082 2082
 													"+'"
2083
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
2084
-											unset( $new_value['element_require'] );
2083
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
2084
+											unset($new_value['element_require']);
2085 2085
 										}
2086 2086
 
2087
-										if ( isset( $new_value['element_repeat'] ) ) {
2087
+										if (isset($new_value['element_repeat'])) {
2088 2088
 											$x = 1;
2089
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
2090
-												$this->block_element( array( '' => $new_value ) );
2091
-												$x ++;
2089
+											while ($x <= absint($new_value['element_repeat'])) {
2090
+												$this->block_element(array('' => $new_value));
2091
+												$x++;
2092 2092
 											}
2093 2093
 										} else {
2094
-											$this->block_element( array( '' => $new_value ) );
2094
+											$this->block_element(array('' => $new_value));
2095 2095
 										}
2096 2096
 									}
2097
-									$first_item ++;
2097
+									$first_item++;
2098 2098
 								}
2099 2099
 							}
2100 2100
 
2101
-							echo ")";// end content
2101
+							echo ")"; // end content
2102 2102
 
2103 2103
 							echo ", \n";
2104 2104
 
2105 2105
 						}
2106 2106
 					} else {
2107 2107
 
2108
-						if ( substr( $element, 0, 3 ) === "if_" ) {
2109
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
2110
-						} elseif ( $element == 'style' ) {
2111
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
2108
+						if (substr($element, 0, 3) === "if_") {
2109
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
2110
+						} elseif ($element == 'style') {
2111
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
2112 2112
 						} else {
2113
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
2113
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
2114 2114
 						}
2115 2115
 
2116 2116
 					}
@@ -2125,12 +2125,12 @@  discard block
 block discarded – undo
2125 2125
 		 *
2126 2126
 		 * @return mixed
2127 2127
 		 */
2128
-		public function block_props_replace( $string, $no_wrap = false ) {
2128
+		public function block_props_replace($string, $no_wrap = false) {
2129 2129
 
2130
-			if ( $no_wrap ) {
2131
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
2130
+			if ($no_wrap) {
2131
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
2132 2132
 			} else {
2133
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
2133
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
2134 2134
 			}
2135 2135
 
2136 2136
 			return $string;
@@ -2142,43 +2142,43 @@  discard block
 block discarded – undo
2142 2142
 		 * @param array $args
2143 2143
 		 * @param array $instance
2144 2144
 		 */
2145
-		public function widget( $args, $instance ) {
2145
+		public function widget($args, $instance) {
2146 2146
 
2147 2147
 			// get the filtered values
2148
-			$argument_values = $this->argument_values( $instance );
2149
-			$argument_values = $this->string_to_bool( $argument_values );
2150
-			$output          = $this->output( $argument_values, $args );
2148
+			$argument_values = $this->argument_values($instance);
2149
+			$argument_values = $this->string_to_bool($argument_values);
2150
+			$output          = $this->output($argument_values, $args);
2151 2151
 
2152 2152
 			ob_start();
2153
-			if ( $output ) {
2153
+			if ($output) {
2154 2154
 				// Before widget
2155 2155
 				$before_widget = $args['before_widget'];
2156
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
2157
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
2156
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
2157
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
2158 2158
 
2159 2159
 				// After widget
2160 2160
 				$after_widget = $args['after_widget'];
2161
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
2162
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
2161
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
2162
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
2163 2163
 
2164 2164
 				echo $before_widget;
2165 2165
 				// elementor strips the widget wrapping div so we check for and add it back if needed
2166
-				if ( $this->is_elementor_widget_output() ) {
2167
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "<span class='" . esc_attr( $this->options['widget_ops']['classname'] ) . "'>" : '';
2166
+				if ($this->is_elementor_widget_output()) {
2167
+					echo !empty($this->options['widget_ops']['classname']) ? "<span class='" . esc_attr($this->options['widget_ops']['classname']) . "'>" : '';
2168 2168
 				}
2169
-				echo $this->output_title( $args, $instance );
2169
+				echo $this->output_title($args, $instance);
2170 2170
 				echo $output;
2171
-				if ( $this->is_elementor_widget_output() ) {
2172
-					echo ! empty( $this->options['widget_ops']['classname'] ) ? "</span>" : '';
2171
+				if ($this->is_elementor_widget_output()) {
2172
+					echo !empty($this->options['widget_ops']['classname']) ? "</span>" : '';
2173 2173
 				}
2174 2174
 				echo $after_widget;
2175
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
2176
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
2175
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
2176
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
2177 2177
 				echo $output;
2178 2178
 			}
2179 2179
 			$output = ob_get_clean();
2180 2180
 
2181
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
2181
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
2182 2182
 
2183 2183
 			echo $output;
2184 2184
 		}
@@ -2191,7 +2191,7 @@  discard block
 block discarded – undo
2191 2191
 		 */
2192 2192
 		public function is_elementor_widget_output() {
2193 2193
 			$result = false;
2194
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
2194
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
2195 2195
 				$result = true;
2196 2196
 			}
2197 2197
 
@@ -2206,7 +2206,7 @@  discard block
 block discarded – undo
2206 2206
 		 */
2207 2207
 		public function is_elementor_preview() {
2208 2208
 			$result = false;
2209
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
2209
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
2210 2210
 				$result = true;
2211 2211
 			}
2212 2212
 
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
 		 */
2222 2222
 		public function is_divi_preview() {
2223 2223
 			$result = false;
2224
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
2224
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
2225 2225
 				$result = true;
2226 2226
 			}
2227 2227
 
@@ -2236,7 +2236,7 @@  discard block
 block discarded – undo
2236 2236
 		 */
2237 2237
 		public function is_beaver_preview() {
2238 2238
 			$result = false;
2239
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
2239
+			if (isset($_REQUEST['fl_builder'])) {
2240 2240
 				$result = true;
2241 2241
 			}
2242 2242
 
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
 		 */
2252 2252
 		public function is_siteorigin_preview() {
2253 2253
 			$result = false;
2254
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
2254
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
2255 2255
 				$result = true;
2256 2256
 			}
2257 2257
 
@@ -2266,7 +2266,7 @@  discard block
 block discarded – undo
2266 2266
 		 */
2267 2267
 		public function is_cornerstone_preview() {
2268 2268
 			$result = false;
2269
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
2269
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
2270 2270
 				$result = true;
2271 2271
 			}
2272 2272
 
@@ -2281,7 +2281,7 @@  discard block
 block discarded – undo
2281 2281
 		 */
2282 2282
 		public function is_fusion_preview() {
2283 2283
 			$result = false;
2284
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
2284
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
2285 2285
 				$result = true;
2286 2286
 			}
2287 2287
 
@@ -2296,17 +2296,17 @@  discard block
 block discarded – undo
2296 2296
 		 */
2297 2297
 		public function is_preview() {
2298 2298
 			$preview = false;
2299
-			if ( $this->is_divi_preview() ) {
2299
+			if ($this->is_divi_preview()) {
2300 2300
 				$preview = true;
2301
-			} elseif ( $this->is_elementor_preview() ) {
2301
+			} elseif ($this->is_elementor_preview()) {
2302 2302
 				$preview = true;
2303
-			} elseif ( $this->is_beaver_preview() ) {
2303
+			} elseif ($this->is_beaver_preview()) {
2304 2304
 				$preview = true;
2305
-			} elseif ( $this->is_siteorigin_preview() ) {
2305
+			} elseif ($this->is_siteorigin_preview()) {
2306 2306
 				$preview = true;
2307
-			} elseif ( $this->is_cornerstone_preview() ) {
2307
+			} elseif ($this->is_cornerstone_preview()) {
2308 2308
 				$preview = true;
2309
-			} elseif ( $this->is_fusion_preview() ) {
2309
+			} elseif ($this->is_fusion_preview()) {
2310 2310
 				$preview = true;
2311 2311
 			}
2312 2312
 
@@ -2321,11 +2321,11 @@  discard block
 block discarded – undo
2321 2321
 		 *
2322 2322
 		 * @return string
2323 2323
 		 */
2324
-		public function output_title( $args, $instance = array() ) {
2324
+		public function output_title($args, $instance = array()) {
2325 2325
 			$output = '';
2326
-			if ( ! empty( $instance['title'] ) ) {
2326
+			if (!empty($instance['title'])) {
2327 2327
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
2328
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
2328
+				$title  = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
2329 2329
 				$output = $args['before_title'] . $title . $args['after_title'];
2330 2330
 			}
2331 2331
 
@@ -2337,7 +2337,7 @@  discard block
 block discarded – undo
2337 2337
 		 *
2338 2338
 		 * @param array $instance The widget options.
2339 2339
 		 */
2340
-		public function form( $instance ) {
2340
+		public function form($instance) {
2341 2341
 
2342 2342
 			// set widget instance
2343 2343
 			$this->instance = $instance;
@@ -2345,10 +2345,10 @@  discard block
 block discarded – undo
2345 2345
 			// set it as a SD widget
2346 2346
 			echo $this->widget_advanced_toggle();
2347 2347
 
2348
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
2348
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
2349 2349
 			$arguments_raw = $this->get_arguments();
2350 2350
 
2351
-			if ( is_array( $arguments_raw ) ) {
2351
+			if (is_array($arguments_raw)) {
2352 2352
 
2353 2353
 				$arguments = $this->group_arguments($arguments_raw);
2354 2354
 
@@ -2356,9 +2356,9 @@  discard block
 block discarded – undo
2356 2356
 				$has_sections = $arguments == $arguments_raw ? false : true;
2357 2357
 
2358 2358
 
2359
-				if($has_sections){
2359
+				if ($has_sections) {
2360 2360
 					$panel_count = 0;
2361
-					foreach($arguments as $key => $args){
2361
+					foreach ($arguments as $key => $args) {
2362 2362
 
2363 2363
 						?>
2364 2364
 						<script>
@@ -2368,10 +2368,10 @@  discard block
 block discarded – undo
2368 2368
 
2369 2369
 						$hide = $panel_count ? ' style="display:none;" ' : '';
2370 2370
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
2371
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle".sanitize_title_with_dashes($key)."'>".esc_attr($key)." <i style='float:right;' class='".$icon_class."'></i></button>";
2372
-						echo "<div class='sd-toggle-group sd-input-group-".sanitize_title_with_dashes($key)."' $hide>";
2371
+						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
2372
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
2373 2373
 
2374
-						foreach($args as $k => $a){
2374
+						foreach ($args as $k => $a) {
2375 2375
 							$this->widget_inputs($a, $instance);
2376 2376
 						}
2377 2377
 
@@ -2380,9 +2380,9 @@  discard block
 block discarded – undo
2380 2380
 						$panel_count++;
2381 2381
 
2382 2382
 					}
2383
-				}else{
2384
-					foreach ( $arguments as $key => $args ) {
2385
-						$this->widget_inputs( $args, $instance );
2383
+				} else {
2384
+					foreach ($arguments as $key => $args) {
2385
+						$this->widget_inputs($args, $instance);
2386 2386
 					}
2387 2387
 				}
2388 2388
 
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
 		public function widget_advanced_toggle() {
2398 2398
 
2399 2399
 			$output = '';
2400
-			if ( $this->block_show_advanced() ) {
2400
+			if ($this->block_show_advanced()) {
2401 2401
 				$val = 1;
2402 2402
 			} else {
2403 2403
 				$val = 0;
@@ -2417,14 +2417,14 @@  discard block
 block discarded – undo
2417 2417
 		 *
2418 2418
 		 * @return string $output
2419 2419
 		 */
2420
-		public function convert_element_require( $input ) {
2420
+		public function convert_element_require($input) {
2421 2421
 
2422
-			$input = str_replace( "'", '"', $input );// we only want double quotes
2422
+			$input = str_replace("'", '"', $input); // we only want double quotes
2423 2423
 
2424
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
2424
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
2425 2425
 				"jQuery(form).find('[data-argument=\"",
2426 2426
 				"\"]').find('input,select').val()"
2427
-			), $input ) );
2427
+			), $input));
2428 2428
 
2429 2429
 			return $output;
2430 2430
 		}
@@ -2435,54 +2435,54 @@  discard block
 block discarded – undo
2435 2435
 		 * @param $args
2436 2436
 		 * @param $instance
2437 2437
 		 */
2438
-		public function widget_inputs( $args, $instance ) {
2438
+		public function widget_inputs($args, $instance) {
2439 2439
 
2440 2440
 			$class             = "";
2441 2441
 			$element_require   = "";
2442 2442
 			$custom_attributes = "";
2443 2443
 
2444 2444
 			// get value
2445
-			if ( isset( $instance[ $args['name'] ] ) ) {
2446
-				$value = $instance[ $args['name'] ];
2447
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
2448
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
2445
+			if (isset($instance[$args['name']])) {
2446
+				$value = $instance[$args['name']];
2447
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
2448
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
2449 2449
 			} else {
2450 2450
 				$value = '';
2451 2451
 			}
2452 2452
 
2453 2453
 			// get placeholder
2454
-			if ( ! empty( $args['placeholder'] ) ) {
2455
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
2454
+			if (!empty($args['placeholder'])) {
2455
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
2456 2456
 			} else {
2457 2457
 				$placeholder = '';
2458 2458
 			}
2459 2459
 
2460 2460
 			// get if advanced
2461
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
2461
+			if (isset($args['advanced']) && $args['advanced']) {
2462 2462
 				$class .= " sd-advanced-setting ";
2463 2463
 			}
2464 2464
 
2465 2465
 			// element_require
2466
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
2466
+			if (isset($args['element_require']) && $args['element_require']) {
2467 2467
 				$element_require = $args['element_require'];
2468 2468
 			}
2469 2469
 
2470 2470
 			// custom_attributes
2471
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
2472
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
2471
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
2472
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
2473 2473
 			}
2474 2474
 
2475 2475
 			// before wrapper
2476 2476
 			?>
2477
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
2478
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
2479
-			   data-element_require='<?php if ( $element_require ) {
2480
-				   echo $this->convert_element_require( $element_require );
2477
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
2478
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
2479
+			   data-element_require='<?php if ($element_require) {
2480
+				   echo $this->convert_element_require($element_require);
2481 2481
 			   } ?>'
2482 2482
 			>
2483 2483
 				<?php
2484 2484
 
2485
-				switch ( $args['type'] ) {
2485
+				switch ($args['type']) {
2486 2486
 					//array('text','password','number','email','tel','url','color')
2487 2487
 					case "text":
2488 2488
 					case "password":
@@ -2493,46 +2493,46 @@  discard block
 block discarded – undo
2493 2493
 					case "color":
2494 2494
 						?>
2495 2495
 						<label
2496
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2496
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2497 2497
 						<input <?php echo $placeholder; ?> class="widefat"
2498 2498
 							<?php echo $custom_attributes; ?>
2499
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2500
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
2501
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
2502
-							                               value="<?php echo esc_attr( $value ); ?>">
2499
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2500
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
2501
+							                               type="<?php echo esc_attr($args['type']); ?>"
2502
+							                               value="<?php echo esc_attr($value); ?>">
2503 2503
 						<?php
2504 2504
 
2505 2505
 						break;
2506 2506
 					case "select":
2507
-						$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
2508
-						if ( $multiple ) {
2509
-							if ( empty( $value ) ) {
2507
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
2508
+						if ($multiple) {
2509
+							if (empty($value)) {
2510 2510
 								$value = array();
2511 2511
 							}
2512 2512
 						}
2513 2513
 						?>
2514 2514
 						<label
2515
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2515
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2516 2516
 						<select <?php echo $placeholder; ?> class="widefat"
2517 2517
 							<?php echo $custom_attributes; ?>
2518
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2519
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) );
2520
-							                                if ( $multiple ) {
2518
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2519
+							                                name="<?php echo esc_attr($this->get_field_name($args['name']));
2520
+							                                if ($multiple) {
2521 2521
 								                                echo "[]";
2522 2522
 							                                } ?>"
2523
-							<?php if ( $multiple ) {
2523
+							<?php if ($multiple) {
2524 2524
 								echo "multiple";
2525 2525
 							} //@todo not implemented yet due to gutenberg not supporting it
2526 2526
 							?>
2527 2527
 						>
2528 2528
 							<?php
2529 2529
 
2530
-							if ( ! empty( $args['options'] ) ) {
2531
-								foreach ( $args['options'] as $val => $label ) {
2532
-									if ( $multiple ) {
2533
-										$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
2530
+							if (!empty($args['options'])) {
2531
+								foreach ($args['options'] as $val => $label) {
2532
+									if ($multiple) {
2533
+										$selected = in_array($val, $value) ? 'selected="selected"' : '';
2534 2534
 									} else {
2535
-										$selected = selected( $value, $val, false );
2535
+										$selected = selected($value, $val, false);
2536 2536
 									}
2537 2537
 									echo "<option value='$val' " . $selected . ">$label</option>";
2538 2538
 								}
@@ -2544,20 +2544,20 @@  discard block
 block discarded – undo
2544 2544
 					case "checkbox":
2545 2545
 						?>
2546 2546
 						<input <?php echo $placeholder; ?>
2547
-							<?php checked( 1, $value, true ) ?>
2547
+							<?php checked(1, $value, true) ?>
2548 2548
 							<?php echo $custom_attributes; ?>
2549
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2550
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
2549
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2550
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
2551 2551
 							value="1">
2552 2552
 						<label
2553
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
2553
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
2554 2554
 						<?php
2555 2555
 						break;
2556 2556
 					case "hidden":
2557 2557
 						?>
2558
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
2559
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
2560
-						       value="<?php echo esc_attr( $value ); ?>">
2558
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
2559
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
2560
+						       value="<?php echo esc_attr($value); ?>">
2561 2561
 						<?php
2562 2562
 						break;
2563 2563
 					default:
@@ -2579,14 +2579,14 @@  discard block
 block discarded – undo
2579 2579
 		 * @return string
2580 2580
 		 * @todo, need to make its own tooltip script
2581 2581
 		 */
2582
-		public function widget_field_desc( $args ) {
2582
+		public function widget_field_desc($args) {
2583 2583
 
2584 2584
 			$description = '';
2585
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
2586
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
2587
-					$description = $this->desc_tip( $args['desc'] );
2585
+			if (isset($args['desc']) && $args['desc']) {
2586
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
2587
+					$description = $this->desc_tip($args['desc']);
2588 2588
 				} else {
2589
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
2589
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
2590 2590
 				}
2591 2591
 			}
2592 2592
 
@@ -2601,11 +2601,11 @@  discard block
 block discarded – undo
2601 2601
 		 *
2602 2602
 		 * @return string
2603 2603
 		 */
2604
-		function desc_tip( $tip, $allow_html = false ) {
2605
-			if ( $allow_html ) {
2606
-				$tip = $this->sanitize_tooltip( $tip );
2604
+		function desc_tip($tip, $allow_html = false) {
2605
+			if ($allow_html) {
2606
+				$tip = $this->sanitize_tooltip($tip);
2607 2607
 			} else {
2608
-				$tip = esc_attr( $tip );
2608
+				$tip = esc_attr($tip);
2609 2609
 			}
2610 2610
 
2611 2611
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -2618,8 +2618,8 @@  discard block
 block discarded – undo
2618 2618
 		 *
2619 2619
 		 * @return string
2620 2620
 		 */
2621
-		public function sanitize_tooltip( $var ) {
2622
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
2621
+		public function sanitize_tooltip($var) {
2622
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
2623 2623
 				'br'     => array(),
2624 2624
 				'em'     => array(),
2625 2625
 				'strong' => array(),
@@ -2629,7 +2629,7 @@  discard block
 block discarded – undo
2629 2629
 				'li'     => array(),
2630 2630
 				'ol'     => array(),
2631 2631
 				'p'      => array(),
2632
-			) ) );
2632
+			)));
2633 2633
 		}
2634 2634
 
2635 2635
 		/**
@@ -2641,23 +2641,23 @@  discard block
 block discarded – undo
2641 2641
 		 * @return array
2642 2642
 		 * @todo we should add some sanitation here.
2643 2643
 		 */
2644
-		public function update( $new_instance, $old_instance ) {
2644
+		public function update($new_instance, $old_instance) {
2645 2645
 
2646 2646
 			//save the widget
2647
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
2647
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
2648 2648
 
2649 2649
 			// set widget instance
2650 2650
 			$this->instance = $instance;
2651 2651
 
2652
-			if ( empty( $this->arguments ) ) {
2652
+			if (empty($this->arguments)) {
2653 2653
 				$this->get_arguments();
2654 2654
 			}
2655 2655
 
2656 2656
 			// check for checkboxes
2657
-			if ( ! empty( $this->arguments ) ) {
2658
-				foreach ( $this->arguments as $argument ) {
2659
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
2660
-						$instance[ $argument['name'] ] = '0';
2657
+			if (!empty($this->arguments)) {
2658
+				foreach ($this->arguments as $argument) {
2659
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
2660
+						$instance[$argument['name']] = '0';
2661 2661
 					}
2662 2662
 				}
2663 2663
 			}
@@ -2675,7 +2675,7 @@  discard block
 block discarded – undo
2675 2675
 		 */
2676 2676
 		public function is_block_content_call() {
2677 2677
 			$result = false;
2678
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
2678
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
2679 2679
 				$result = true;
2680 2680
 			}
2681 2681
 
Please login to merge, or discard this patch.
vendor/composer/ClassLoader.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
widgets/buy-item.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
     exit;
4 4
 }
5 5
 
@@ -23,40 +23,40 @@  discard block
 block discarded – undo
23 23
             'block-keywords'=> "['invoicing','buy', 'buy item']",
24 24
             'class_name'     => __CLASS__,
25 25
             'base_id'       => 'wpinv_buy',
26
-            'name'          => __('Invoicing > Buy Item Button','invoicing'),
26
+            'name'          => __('Invoicing > Buy Item Button', 'invoicing'),
27 27
             'widget_ops'    => array(
28 28
                 'classname'   => 'wpinv-buy-item-class',
29
-                'description' => esc_html__('Displays buy invoicing item button.','invoicing'),
29
+                'description' => esc_html__('Displays buy invoicing item button.', 'invoicing'),
30 30
             ),
31 31
             'arguments'     => array(
32 32
                 'title'  => array(
33
-                    'title'       => __( 'Widget title', 'invoicing' ),
34
-                    'desc'        => __( 'Enter widget title.', 'invoicing' ),
33
+                    'title'       => __('Widget title', 'invoicing'),
34
+                    'desc'        => __('Enter widget title.', 'invoicing'),
35 35
                     'type'        => 'text',
36 36
                     'desc_tip'    => true,
37 37
                     'default'     => '',
38 38
                     'advanced'    => false
39 39
                 ),
40 40
                 'buy_items'  => array(
41
-	                'title'       => __( 'Items to buy', 'invoicing' ),
42
-	                'desc'        => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing' ),
41
+	                'title'       => __('Items to buy', 'invoicing'),
42
+	                'desc'        => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2 ', 'invoicing'),
43 43
 	                'type'        => 'text',
44 44
 	                'desc_tip'    => true,
45 45
 	                'default'     => '',
46
-	                'placeholder' => __('Items to buy','invoicing'),
46
+	                'placeholder' => __('Items to buy', 'invoicing'),
47 47
 	                'advanced'    => false
48 48
                 ),
49 49
                 'button_label'  => array(
50
-	                'title'       => __( 'Button Label', 'invoicing' ),
51
-	                'desc'        => __( 'Enter button label. Default "Buy Now".', 'invoicing' ),
50
+	                'title'       => __('Button Label', 'invoicing'),
51
+	                'desc'        => __('Enter button label. Default "Buy Now".', 'invoicing'),
52 52
 	                'type'        => 'text',
53 53
 	                'desc_tip'    => true,
54 54
 	                'default'     => '',
55 55
 	                'advanced'    => true
56 56
                 ),
57 57
                 'post_id'  => array(
58
-	                'title'       => __( 'Post ID', 'invoicing' ),
59
-	                'desc'        => __( 'Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing' ),
58
+	                'title'       => __('Post ID', 'invoicing'),
59
+	                'desc'        => __('Enter related post ID. This is for 3rd party add ons and not mandatory field.', 'invoicing'),
60 60
 	                'type'        => 'number',
61 61
 	                'desc_tip'    => true,
62 62
 	                'default'     => '',
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         );
68 68
 
69 69
 
70
-        parent::__construct( $options );
70
+        parent::__construct($options);
71 71
     }
72 72
 
73 73
 	/**
@@ -79,24 +79,24 @@  discard block
 block discarded – undo
79 79
 	 *
80 80
 	 * @return string
81 81
 	 */
82
-    public function output( $args = array(), $widget_args = array(), $content = '' ) {
82
+    public function output($args = array(), $widget_args = array(), $content = '') {
83 83
 
84 84
 	    $defaults = array(
85 85
 		    'buy_items'     => '', // should be used like: item_id|quantity,item_id|quantity,item_id|quantity
86
-		    'button_label'  => __( 'Buy Now', 'invoicing' ), // the button title
86
+		    'button_label'  => __('Buy Now', 'invoicing'), // the button title
87 87
 		    'post_id'   => '', // any related post_id
88 88
 	    );
89 89
 
90 90
 	    /**
91 91
 	     * Parse incoming $args into an array and merge it with $defaults
92 92
 	     */
93
-	    $args = wp_parse_args( $args, $defaults );
93
+	    $args = wp_parse_args($args, $defaults);
94 94
 
95
-	    $post_id = isset( $args['post_id'] ) ? (int)$args['post_id'] : 0;
95
+	    $post_id = isset($args['post_id']) ? (int) $args['post_id'] : 0;
96 96
 
97 97
 	    $html = '<div class="wpi-buy-button-wrapper wpi-g">';
98 98
 	    $html .= '<button class="button button-primary wpi-buy-button" type="button" onclick="wpi_buy(this,\'' . $args['buy_items'] . '\',' . $post_id . ');">' . $args['button_label'] . '</button>';
99
-	    $html .= wp_nonce_field( 'wpinv_buy_items', 'wpinv_buy_nonce', true, false );
99
+	    $html .= wp_nonce_field('wpinv_buy_items', 'wpinv_buy_nonce', true, false);
100 100
 	    $html .= '</div>';
101 101
 
102 102
 	    return $html;
Please login to merge, or discard this patch.
includes/gateways/paypal.php 1 patch
Spacing   +284 added lines, -284 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8
-function wpinv_process_paypal_payment( $purchase_data ) {
9
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
10
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
8
+function wpinv_process_paypal_payment($purchase_data) {
9
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
10
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
11 11
     }
12 12
 
13 13
     // Collect payment data
@@ -25,30 +25,30 @@  discard block
 block discarded – undo
25 25
     );
26 26
 
27 27
     // Record the pending payment
28
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
28
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
29 29
 
30 30
     // Check payment
31
-    if ( ! $invoice ) {
31
+    if (!$invoice) {
32 32
         // Record the error
33
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
33
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
34 34
         // Problems? send back
35
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
35
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
36 36
     } else {
37 37
         // Only send to PayPal if the pending payment is created successfully
38
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
38
+        $listener_url = wpinv_get_ipn_url('paypal');
39 39
 
40 40
         // Get the success url
41
-        $return_url = add_query_arg( array(
41
+        $return_url = add_query_arg(array(
42 42
                 'payment-confirm' => 'paypal',
43 43
                 'invoice-id' => $invoice->ID
44
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
44
+            ), get_permalink(wpinv_get_option('success_page', false)));
45 45
 
46 46
         // Get the PayPal redirect uri
47
-        $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?';
47
+        $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?';
48 48
 
49 49
         // Setup PayPal arguments
50 50
         $paypal_args = array(
51
-            'business'      => wpinv_get_option( 'paypal_email', false ),
51
+            'business'      => wpinv_get_option('paypal_email', false),
52 52
             'email'         => $invoice->get_email(),
53 53
             'first_name'    => $invoice->get_first_name(),
54 54
             'last_name'     => $invoice->get_last_name(),
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
             'shipping'      => '0',
58 58
             'no_note'       => '1',
59 59
             'currency_code' => wpinv_get_currency(),
60
-            'charset'       => get_bloginfo( 'charset' ),
60
+            'charset'       => get_bloginfo('charset'),
61 61
             'custom'        => $invoice->ID,
62 62
             'rm'            => '2',
63 63
             'return'        => $return_url,
64
-            'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ),
64
+            'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID),
65 65
             'notify_url'    => $listener_url,
66
-            'cbt'           => get_bloginfo( 'name' ),
66
+            'cbt'           => get_bloginfo('name'),
67 67
             'bn'            => 'WPInvoicing_SP',
68 68
             'lc'            => 'US', // this will force paypal site to english
69
-            'landing_page'  => apply_filters( 'wpinv_paypal_standard_landing_page', 'billing', $invoice ), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
69
+            'landing_page'  => apply_filters('wpinv_paypal_standard_landing_page', 'billing', $invoice), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
70 70
         );
71 71
 
72 72
         $paypal_args['address1'] = $invoice->get_address();
@@ -80,83 +80,83 @@  discard block
 block discarded – undo
80 80
             'upload' => '1'
81 81
         );
82 82
 
83
-        $paypal_args = array_merge( $paypal_extra_args, $paypal_args );
83
+        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
84 84
 
85 85
         // Add cart items
86 86
         $i = 1;
87
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
88
-            foreach ( $purchase_data['cart_details'] as $item ) {
87
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
88
+            foreach ($purchase_data['cart_details'] as $item) {
89 89
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
90
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
90
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
91 91
 
92
-                if ( $item_amount <= 0 ) {
92
+                if ($item_amount <= 0) {
93 93
                     $item_amount = 0;
94 94
                 }
95 95
 
96
-                $paypal_args['item_number_' . $i ]      = $item['id'];
97
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
98
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
99
-                $paypal_args['amount_' . $i ]           = $item_amount;
100
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
96
+                $paypal_args['item_number_' . $i]      = $item['id'];
97
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
98
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
99
+                $paypal_args['amount_' . $i]           = $item_amount;
100
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
101 101
 
102 102
                 $i++;
103 103
             }
104 104
         }
105 105
 
106 106
         // Add taxes to the cart
107
-        if ( wpinv_use_taxes() ) {
108
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax(), 2 );
107
+        if (wpinv_use_taxes()) {
108
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_tax(), 2);
109 109
         }
110 110
 
111
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
111
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
112 112
 
113 113
         // Build query
114
-        $paypal_redirect .= http_build_query( $paypal_args );
114
+        $paypal_redirect .= http_build_query($paypal_args);
115 115
 
116 116
         // Fix for some sites that encode the entities
117
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
117
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
118 118
 
119 119
         // Get rid of cart contents
120 120
         wpinv_empty_cart();
121 121
         
122 122
         // Redirect to PayPal
123
-        wp_redirect( $paypal_redirect );
123
+        wp_redirect($paypal_redirect);
124 124
         exit;
125 125
     }
126 126
 }
127
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
127
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
128 128
 
129
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
130
-    if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) {
131
-        $item   = new WPInv_Item( $item_id );
129
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
130
+    if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) {
131
+        $item = new WPInv_Item($item_id);
132 132
         
133
-        if ( empty( $item ) ) {
133
+        if (empty($item)) {
134 134
             return $paypal_args;
135 135
         }
136 136
 
137 137
         $period             = $item->get_recurring_period();
138 138
         $interval           = $item->get_recurring_interval();
139
-        $bill_times         = (int)$item->get_recurring_limit();
139
+        $bill_times         = (int) $item->get_recurring_limit();
140 140
         
141
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
142
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
141
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
142
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
143 143
         
144 144
         $paypal_args['cmd'] = '_xclick-subscriptions';
145 145
         $paypal_args['sra'] = '1';
146 146
         $paypal_args['src'] = '1';
147 147
         
148 148
         // Set item description
149
-        $item_name                  = sprintf( '[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name( array( 'id' => $item->ID ) ) );
150
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( $item_name, ENT_COMPAT, 'UTF-8' ) );
149
+        $item_name                  = sprintf('[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name(array('id' => $item->ID)));
150
+        $paypal_args['item_name']   = stripslashes_deep(html_entity_decode($item_name, ENT_COMPAT, 'UTF-8'));
151 151
         
152
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
152
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
153 153
             $paypal_args['a1']  = $initial_amount;
154 154
             $paypal_args['p1']  = $item->get_trial_interval();
155 155
             $paypal_args['t1']  = $item->get_trial_period();
156 156
             
157 157
             // Set the recurring amount
158 158
             $paypal_args['a3']  = $recurring_amount;
159
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
159
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
160 160
             $paypal_args['a1']  = $initial_amount;
161 161
             $paypal_args['p1']  = $interval;
162 162
             $paypal_args['t1']  = $period;
@@ -164,63 +164,63 @@  discard block
 block discarded – undo
164 164
             // Set the recurring amount
165 165
             $paypal_args['a3']  = $recurring_amount;
166 166
             
167
-            if ( $bill_times > 1 ) {
167
+            if ($bill_times > 1) {
168 168
                 $bill_times--;
169 169
             }
170 170
         } else {
171
-            $paypal_args['a3']  = $initial_amount;
171
+            $paypal_args['a3'] = $initial_amount;
172 172
         }
173 173
         
174 174
         $paypal_args['p3']  = $interval;
175 175
         $paypal_args['t3']  = $period;
176 176
         
177
-        if ( $bill_times > 1 ) {
177
+        if ($bill_times > 1) {
178 178
             // Make sure it's not over the max of 52
179
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
179
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
180 180
         }
181 181
                 
182 182
         // Remove cart items
183 183
         $i = 1;
184
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
185
-            foreach ( $purchase_data['cart_details'] as $item ) {                
186
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
187
-                    unset( $paypal_args['item_number_' . $i] );
184
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
185
+            foreach ($purchase_data['cart_details'] as $item) {                
186
+                if (isset($paypal_args['item_number_' . $i])) {
187
+                    unset($paypal_args['item_number_' . $i]);
188 188
                 }
189
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
190
-                    unset( $paypal_args['item_name_' . $i] );
189
+                if (isset($paypal_args['item_name_' . $i])) {
190
+                    unset($paypal_args['item_name_' . $i]);
191 191
                 }
192
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
193
-                    unset( $paypal_args['quantity_' . $i] );
192
+                if (isset($paypal_args['quantity_' . $i])) {
193
+                    unset($paypal_args['quantity_' . $i]);
194 194
                 }
195
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
196
-                    unset( $paypal_args['amount_' . $i] );
195
+                if (isset($paypal_args['amount_' . $i])) {
196
+                    unset($paypal_args['amount_' . $i]);
197 197
                 }
198
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
199
-                    unset( $paypal_args['discount_amount_' . $i] );
198
+                if (isset($paypal_args['discount_amount_' . $i])) {
199
+                    unset($paypal_args['discount_amount_' . $i]);
200 200
                 }
201 201
 
202 202
                 $i++;
203 203
             }
204 204
         }
205 205
         
206
-        if ( isset( $paypal_args['tax_cart'] ) ) {
207
-            unset( $paypal_args['tax_cart'] );
206
+        if (isset($paypal_args['tax_cart'])) {
207
+            unset($paypal_args['tax_cart']);
208 208
         }
209 209
                 
210
-        if ( isset( $paypal_args['upload'] ) ) {
211
-            unset( $paypal_args['upload'] );
210
+        if (isset($paypal_args['upload'])) {
211
+            unset($paypal_args['upload']);
212 212
         }
213 213
         
214
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
214
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
215 215
     }
216 216
     
217 217
     return $paypal_args;
218 218
 }
219
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
219
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
220 220
 
221 221
 function wpinv_process_paypal_ipn() {
222 222
 	// Check the request method is POST
223
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
224 224
 		return;
225 225
 	}
226 226
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	$post_data = '';
229 229
 
230 230
 	// Fallback just in case post_max_size is lower than needed
231
-	if ( ini_get( 'allow_url_fopen' ) ) {
232
-		$post_data = file_get_contents( 'php://input' );
231
+	if (ini_get('allow_url_fopen')) {
232
+		$post_data = file_get_contents('php://input');
233 233
 	} else {
234 234
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
235
-		ini_set( 'post_max_size', '12M' );
235
+		ini_set('post_max_size', '12M');
236 236
 	}
237 237
 	// Start the encoded data collection with notification command
238 238
 	$encoded_data = 'cmd=_notify-validate';
@@ -241,43 +241,43 @@  discard block
 block discarded – undo
241 241
 	$arg_separator = wpinv_get_php_arg_separator_output();
242 242
 
243 243
 	// Verify there is a post_data
244
-	if ( $post_data || strlen( $post_data ) > 0 ) {
244
+	if ($post_data || strlen($post_data) > 0) {
245 245
 		// Append the data
246
-		$encoded_data .= $arg_separator.$post_data;
246
+		$encoded_data .= $arg_separator . $post_data;
247 247
 	} else {
248 248
 		// Check if POST is empty
249
-		if ( empty( $_POST ) ) {
249
+		if (empty($_POST)) {
250 250
 			// Nothing to do
251 251
 			return;
252 252
 		} else {
253 253
 			// Loop through each POST
254
-			foreach ( $_POST as $key => $value ) {
254
+			foreach ($_POST as $key => $value) {
255 255
 				// Encode the value and append the data
256
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
257 257
 			}
258 258
 		}
259 259
 	}
260 260
 
261 261
 	// Convert collected post data to an array
262
-	parse_str( $encoded_data, $encoded_data_array );
262
+	parse_str($encoded_data, $encoded_data_array);
263 263
 
264
-	foreach ( $encoded_data_array as $key => $value ) {
265
-		if ( false !== strpos( $key, 'amp;' ) ) {
266
-			$new_key = str_replace( '&amp;', '&', $key );
267
-			$new_key = str_replace( 'amp;', '&' , $new_key );
264
+	foreach ($encoded_data_array as $key => $value) {
265
+		if (false !== strpos($key, 'amp;')) {
266
+			$new_key = str_replace('&amp;', '&', $key);
267
+			$new_key = str_replace('amp;', '&', $new_key);
268 268
 
269
-			unset( $encoded_data_array[ $key ] );
270
-			$encoded_data_array[ $new_key ] = $value;
269
+			unset($encoded_data_array[$key]);
270
+			$encoded_data_array[$new_key] = $value;
271 271
 		}
272 272
 	}
273 273
 
274 274
 	// Get the PayPal redirect uri
275
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
275
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
276 276
 
277
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
278 278
 		// Validate the IPN
279 279
 
280
-		$remote_post_vars      = array(
280
+		$remote_post_vars = array(
281 281
 			'method'           => 'POST',
282 282
 			'timeout'          => 45,
283 283
 			'redirection'      => 5,
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
 		);
296 296
 
297 297
 		// Get response
298
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
299 299
 
300
-		if ( is_wp_error( $api_response ) ) {
301
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
300
+		if (is_wp_error($api_response)) {
301
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
302 302
 			return; // Something went wrong
303 303
 		}
304 304
 
305
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
306
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
305
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
306
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
307 307
 			return; // Response not okay
308 308
 		}
309 309
 	}
310 310
 
311 311
 	// Check if $post_data_array has been populated
312
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
313 313
 		return;
314 314
 
315 315
 	$defaults = array(
@@ -317,265 +317,265 @@  discard block
 block discarded – undo
317 317
 		'payment_status' => ''
318 318
 	);
319 319
 
320
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
321 321
 
322
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
322
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
323 323
     
324
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
325
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
324
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
325
+	wpinv_error_log($encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__);
326 326
 
327
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
328 328
 		// Allow PayPal IPN types to be processed separately
329
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
330 330
 	} else {
331 331
 		// Fallback to web accept just in case the txn_type isn't present
332
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
333 333
 	}
334 334
 	exit;
335 335
 }
336
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
336
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
337 337
 
338
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
339
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
338
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
339
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
340 340
 		return;
341 341
 	}
342 342
 
343
-	if( empty( $invoice_id ) ) {
343
+	if (empty($invoice_id)) {
344 344
 		return;
345 345
 	}
346 346
 
347 347
 	// Collect payment details
348
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
349 349
 	$paypal_amount  = $data['mc_gross'];
350
-	$payment_status = strtolower( $data['payment_status'] );
351
-	$currency_code  = strtolower( $data['mc_currency'] );
352
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
353
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
350
+	$payment_status = strtolower($data['payment_status']);
351
+	$currency_code  = strtolower($data['mc_currency']);
352
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
353
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
354 354
 
355
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
356 356
 		return; // this isn't a PayPal standard IPN
357 357
 	}
358 358
 
359 359
 	// Verify payment recipient
360
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
361
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
362
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
363
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
360
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
361
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
362
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
363
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'), '', '', true);
364 364
 		return;
365 365
 	}
366 366
 
367 367
 	// Verify payment currency
368
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
369
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
370
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
371
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
368
+	if ($currency_code != strtolower($payment_meta['currency'])) {
369
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
370
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
371
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'), '', '', true);
372 372
 		return;
373 373
 	}
374 374
 
375
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
+	if (!wpinv_get_payment_user_email($invoice_id)) {
376 376
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
377 377
 		// No email associated with purchase, so store from PayPal
378
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
379 379
 
380 380
 		// Setup and store the customer's details
381 381
 		$user_info = array(
382 382
 			'user_id'    => '-1',
383
-			'email'      => sanitize_text_field( $data['payer_email'] ),
384
-			'first_name' => sanitize_text_field( $data['first_name'] ),
385
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
383
+			'email'      => sanitize_text_field($data['payer_email']),
384
+			'first_name' => sanitize_text_field($data['first_name']),
385
+			'last_name'  => sanitize_text_field($data['last_name']),
386 386
 			'discount'   => '',
387 387
 		);
388
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
389
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
390
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
391
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
392
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
388
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
389
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
390
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
391
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
392
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
393 393
 
394 394
 		$payment_meta['user_info'] = $user_info;
395
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
396 396
 	}
397 397
 
398
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
399 399
 		// Process a refund
400
-		wpinv_process_paypal_refund( $data, $invoice_id );
400
+		wpinv_process_paypal_refund($data, $invoice_id);
401 401
 	} else {
402
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
402
+		if (get_post_status($invoice_id) == 'publish') {
403 403
 			return; // Only paid payments once
404 404
 		}
405 405
 
406 406
 		// Retrieve the total purchase amount (before PayPal)
407
-		$payment_amount = wpinv_payment_total( $invoice_id );
407
+		$payment_amount = wpinv_payment_total($invoice_id);
408 408
 
409
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
+		if (number_format((float) $paypal_amount, 2) < number_format((float) $payment_amount, 2)) {
410 410
 			// The prices don't match
411
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
412
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
413
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
411
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
412
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
413
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'), '', '', true);
414 414
 			return;
415 415
 		}
416
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
417 417
 			// Purchase keys don't match
418
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
419
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
420
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
418
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
419
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
420
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'), '', '', true);
421 421
 			return;
422 422
 		}
423 423
 
424
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
425
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
426
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
427
-			wpinv_update_payment_status( $invoice_id, 'publish' );
428
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
424
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
425
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
426
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
427
+			wpinv_update_payment_status($invoice_id, 'publish');
428
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
429 429
 			// Look for possible pending reasons, such as an echeck
430 430
 			$note = '';
431 431
 
432
-			switch( strtolower( $data['pending_reason'] ) ) {
432
+			switch (strtolower($data['pending_reason'])) {
433 433
 				case 'echeck' :
434
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
435 435
 					break;
436 436
 				
437 437
                 case 'address' :
438
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
439 439
 					break;
440 440
 				
441 441
                 case 'intl' :
442
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
443 443
 					break;
444 444
 				
445 445
                 case 'multi-currency' :
446
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
447 447
 					break;
448 448
 				
449 449
                 case 'paymentreview' :
450 450
                 case 'regulatory_review' :
451
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
452 452
 					break;
453 453
 				
454 454
                 case 'unilateral' :
455
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
456 456
 					break;
457 457
 				
458 458
                 case 'upgrade' :
459
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
460 460
 					break;
461 461
 				
462 462
                 case 'verify' :
463
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
464 464
 					break;
465 465
 
466 466
 				case 'other' :
467
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
468 468
 					break;
469 469
 			}
470 470
 
471
-			if ( ! empty( $note ) ) {
472
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
471
+			if (!empty($note)) {
472
+				wpinv_insert_payment_note($invoice_id, $note, '', '', true);
473 473
 			}
474 474
 		} else {
475
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status), '', '', true);
476 476
 		}
477 477
 	}
478 478
 }
479
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
479
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
480 480
 
481 481
 // Process PayPal subscription sign ups
482
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
482
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
483 483
 
484 484
 // Process PayPal subscription payments
485
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
485
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
486 486
 
487 487
 // Process PayPal subscription cancellations
488
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
488
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
489 489
 
490 490
 // Process PayPal subscription end of term notices
491
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
491
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
492 492
 
493 493
 // Process PayPal payment failed
494
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
494
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
495 495
 
496 496
 
497 497
 /**
498 498
  * Process the subscription started IPN.
499 499
  */
500
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
501
-    $parent_invoice_id = absint( $ipn_data['custom'] );
502
-    if( empty( $parent_invoice_id ) ) {
500
+function wpinv_process_paypal_subscr_signup($ipn_data) {
501
+    $parent_invoice_id = absint($ipn_data['custom']);
502
+    if (empty($parent_invoice_id)) {
503 503
         return;
504 504
     }
505 505
 
506
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
507
-    if ( empty( $invoice ) ) {
506
+    $invoice = wpinv_get_invoice($parent_invoice_id);
507
+    if (empty($invoice)) {
508 508
         return;
509 509
     }
510 510
 
511
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
512
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ), '', '', true);
513
-        if ( !empty( $ipn_data['txn_id'] ) ) {
514
-            wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
511
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
512
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']), '', '', true);
513
+        if (!empty($ipn_data['txn_id'])) {
514
+            wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
515 515
         }
516 516
     }
517 517
 
518
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
519
-    if ( false === $subscription ) {
518
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
519
+    if (false === $subscription) {
520 520
         return;
521 521
     }
522 522
     
523
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
523
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
524 524
     sleep(1);
525
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
526
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
525
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
526
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
527 527
 
528 528
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
529
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
530
-    $created    = date_i18n( 'Y-m-d H:i:s' );
531
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
529
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
530
+    $created    = date_i18n('Y-m-d H:i:s');
531
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
532 532
 
533 533
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
534
-    $subscription->update( array( 'profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
534
+    $subscription->update(array('profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration));
535 535
 }
536 536
 
537 537
 /**
538 538
  * Process the subscription payment received IPN.
539 539
  */
540
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
541
-    $parent_invoice_id = absint( $ipn_data['custom'] );
540
+function wpinv_process_paypal_subscr_payment($ipn_data) {
541
+    $parent_invoice_id = absint($ipn_data['custom']);
542 542
 
543
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
544
-    if ( empty( $parent_invoice ) ) {
543
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
544
+    if (empty($parent_invoice)) {
545 545
         return;
546 546
     }
547 547
 
548
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
549
-    if ( false === $subscription ) {
548
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
549
+    if (false === $subscription) {
550 550
         return;
551 551
     }
552 552
 
553
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
553
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
554 554
     $times_billed   = $subscription->get_times_billed();
555
-    $signup_date    = strtotime( $subscription->created );
556
-    $today          = date( 'Ynd', $signup_date ) == date( 'Ynd', strtotime( $ipn_data['payment_date'] ) );
555
+    $signup_date    = strtotime($subscription->created);
556
+    $today          = date('Ynd', $signup_date) == date('Ynd', strtotime($ipn_data['payment_date']));
557 557
 
558 558
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
559
-    if ( (empty($times_billed) || $today) && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
560
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
559
+    if ((empty($times_billed) || $today) && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
560
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
561 561
         sleep(1);
562 562
         
563 563
         // This is the very first payment
564
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
565
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
564
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
565
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
566 566
         return;
567 567
     }
568 568
 
569
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
569
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
570 570
         return; // Payment already recorded
571 571
     }
572 572
 
573
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
573
+    $currency_code = strtolower($ipn_data['mc_currency']);
574 574
 
575 575
     // verify details
576
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
576
+    if ($currency_code != strtolower(wpinv_get_currency())) {
577 577
         // the currency code is invalid
578
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
578
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
579 579
         return;
580 580
     }
581 581
 
@@ -585,11 +585,11 @@  discard block
 block discarded – undo
585 585
         'gateway'        => 'paypal'
586 586
     );
587 587
     
588
-    $invoice_id = $subscription->add_payment( $args );
588
+    $invoice_id = $subscription->add_payment($args);
589 589
 
590
-    if ( $invoice_id > 0 ) {
591
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
592
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
590
+    if ($invoice_id > 0) {
591
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
592
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
593 593
 
594 594
         $subscription->renew();
595 595
     }
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 /**
599 599
  * Process the subscription canceled IPN.
600 600
  */
601
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
602
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
601
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
602
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
603 603
 
604
-    if( false === $subscription ) {
604
+    if (false === $subscription) {
605 605
         return;
606 606
     }
607 607
 
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 /**
612 612
  * Process the subscription expired IPN.
613 613
  */
614
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
615
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
614
+function wpinv_process_paypal_subscr_eot($ipn_data) {
615
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
616 616
 
617
-    if( false === $subscription ) {
617
+    if (false === $subscription) {
618 618
         return;
619 619
     }
620 620
 
@@ -624,40 +624,40 @@  discard block
 block discarded – undo
624 624
 /**
625 625
  * Process the subscription payment failed IPN.
626 626
  */
627
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
628
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
627
+function wpinv_process_paypal_subscr_failed($ipn_data) {
628
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
629 629
 
630
-    if( false === $subscription ) {
630
+    if (false === $subscription) {
631 631
         return;
632 632
     }
633 633
 
634 634
     $subscription->failing();
635 635
 
636
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
636
+    do_action('wpinv_recurring_payment_failed', $subscription);
637 637
 }
638 638
 
639 639
 /**
640 640
  * Retrieve the subscription this IPN notice is for.
641 641
  */
642
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
643
-    $parent_invoice_id = absint( $ipn_data['custom'] );
642
+function wpinv_get_paypal_subscription($ipn_data = array()) {
643
+    $parent_invoice_id = absint($ipn_data['custom']);
644 644
 
645
-    if( empty( $parent_invoice_id ) ) {
645
+    if (empty($parent_invoice_id)) {
646 646
         return false;
647 647
     }
648 648
 
649
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
650
-    if ( empty( $invoice ) ) {
649
+    $invoice = wpinv_get_invoice($parent_invoice_id);
650
+    if (empty($invoice)) {
651 651
         return false;
652 652
     }
653 653
 
654
-    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
654
+    $subscription = new WPInv_Subscription($ipn_data['subscr_id'], true);
655 655
 
656
-    if ( ! ( ! empty( $subscription ) && $subscription->id > 0 ) ) {
657
-        $subscription = wpinv_get_subscription( $parent_invoice_id );
656
+    if (!(!empty($subscription) && $subscription->id > 0)) {
657
+        $subscription = wpinv_get_subscription($parent_invoice_id);
658 658
 
659
-        if ( ! empty( $subscription ) && $subscription->id > 0 ) {
660
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
659
+        if (!empty($subscription) && $subscription->id > 0) {
660
+            $subscription->update(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
661 661
         } else {
662 662
             return false;
663 663
         }
@@ -667,46 +667,46 @@  discard block
 block discarded – undo
667 667
 
668 668
 }
669 669
 
670
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
670
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
671 671
 	// Collect payment details
672 672
 
673
-	if( empty( $invoice_id ) ) {
673
+	if (empty($invoice_id)) {
674 674
 		return;
675 675
 	}
676 676
 
677
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
677
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
678 678
 		return; // Only refund payments once
679 679
 	}
680 680
 
681
-	$payment_amount = wpinv_payment_total( $invoice_id );
681
+	$payment_amount = wpinv_payment_total($invoice_id);
682 682
 	$refund_amount  = $data['mc_gross'] * -1;
683 683
 
684
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
684
+	do_action('wpinv_paypal_refund_request', $data, $invoice_id);
685 685
 
686
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
687
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
686
+	if (number_format((float) $refund_amount, 2) < number_format((float) $payment_amount, 2)) {
687
+		wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing'), (float) $refund_amount . ' ' . $data['mc_currency'], $data['parent_txn_id'], $data['reason_code']), '', '', true);
688 688
 
689
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
689
+		do_action('wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount);
690 690
 
691 691
 		return; // This is a partial refund
692 692
 	}
693 693
 
694
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
695
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
696
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
694
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']), '', '', true);
695
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
696
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
697 697
 
698
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
698
+	do_action('wpinv_paypal_invoice_fully_refunded', $data, $invoice_id);
699 699
 }
700 700
 
701
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
702
-    if ( is_ssl() || ! $ssl_check ) {
701
+function wpinv_get_paypal_redirect($ssl_check = false) {
702
+    if (is_ssl() || !$ssl_check) {
703 703
         $protocol = 'https://';
704 704
     } else {
705 705
         $protocol = 'http://';
706 706
     }
707 707
 
708 708
     // Check the current payment mode
709
-    if ( wpinv_is_test_mode( 'paypal' ) ) {
709
+    if (wpinv_is_test_mode('paypal')) {
710 710
         // Test mode
711 711
         $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
712 712
     } else {
@@ -714,120 +714,120 @@  discard block
 block discarded – undo
714 714
         $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
715 715
     }
716 716
 
717
-    return apply_filters( 'wpinv_paypal_uri', $paypal_uri );
717
+    return apply_filters('wpinv_paypal_uri', $paypal_uri);
718 718
 }
719 719
 
720
-function wpinv_paypal_success_page_content( $content ) {
720
+function wpinv_paypal_success_page_content($content) {
721 721
     global $wpi_invoice;
722 722
     
723 723
     $session = wpinv_get_checkout_session();
724 724
 
725
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
725
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
726 726
         return $content;
727 727
     }
728 728
 
729
-    $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
729
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
730 730
 
731
-    if ( empty(  $invoice_id ) ) {
731
+    if (empty($invoice_id)) {
732 732
         return $content;
733 733
     }
734 734
 
735
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
735
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
736 736
     
737
-    if ( !empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
737
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
738 738
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
739 739
         ob_start();
740
-        wpinv_get_template_part( 'wpinv-payment-processing' );
740
+        wpinv_get_template_part('wpinv-payment-processing');
741 741
         $content = ob_get_clean();
742 742
     }
743 743
 
744 744
     return $content;
745 745
 }
746
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
746
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
747 747
 
748
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
748
+function wpinv_paypal_get_transaction_id($invoice_id) {
749 749
     $transaction_id = '';
750
-    $notes = wpinv_get_invoice_notes( $invoice_id );
750
+    $notes = wpinv_get_invoice_notes($invoice_id);
751 751
 
752
-    foreach ( $notes as $note ) {
753
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
752
+    foreach ($notes as $note) {
753
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
754 754
             $transaction_id = $match[1];
755 755
             continue;
756 756
         }
757 757
     }
758 758
 
759
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
759
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
760 760
 }
761
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
761
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
762 762
 
763
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
764
-    if ( $transaction_id == $invoice_id ) {
763
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
764
+    if ($transaction_id == $invoice_id) {
765 765
         $transaction_link = $transaction_id;
766 766
     } else {
767
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
767
+        if (!empty($invoice) && !empty($invoice->mode)) {
768 768
             $mode = $invoice->mode;
769 769
         } else {
770
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
770
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
771 771
         }
772 772
 
773 773
         $sandbox = $mode == 'test' ? '.sandbox' : '';
774 774
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/webscr?cmd=_history-details-from-hub&id=' . $transaction_id;
775 775
 
776
-        $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
776
+        $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
777 777
     }
778 778
 
779
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice );
779
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice);
780 780
 }
781
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
781
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
782 782
 
783
-function wpinv_paypal_profile_id_link( $profile_id, $subscription ) {
783
+function wpinv_paypal_profile_id_link($profile_id, $subscription) {
784 784
     $link = $profile_id;
785 785
 
786
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
787
-        $invoice = wpinv_get_invoice( $invoice_id );
786
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
787
+        $invoice = wpinv_get_invoice($invoice_id);
788 788
 
789
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
789
+        if (!empty($invoice) && !empty($invoice->mode)) {
790 790
             $mode = $invoice->mode;
791 791
         } else {
792
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
792
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
793 793
         }
794 794
 
795 795
         $sandbox = $mode == 'test' ? '.sandbox' : '';
796 796
         $url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=' . $profile_id;
797 797
 
798
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
798
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
799 799
     }
800 800
     
801
-    return apply_filters( 'wpinv_paypal_profile_id_link', $link, $profile_id, $subscription );
801
+    return apply_filters('wpinv_paypal_profile_id_link', $link, $profile_id, $subscription);
802 802
 }
803
-add_filter( 'wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2 );
803
+add_filter('wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2);
804 804
 
805
-function wpinv_paypal_transaction_id_link( $transaction_id, $subscription ) {
806
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
807
-        $invoice = wpinv_get_invoice( $invoice_id );
805
+function wpinv_paypal_transaction_id_link($transaction_id, $subscription) {
806
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
807
+        $invoice = wpinv_get_invoice($invoice_id);
808 808
 
809
-        if ( ! empty( $invoice ) ) {
810
-            return wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice );
809
+        if (!empty($invoice)) {
810
+            return wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice);
811 811
         }        
812 812
     }
813 813
     
814 814
     return $transaction_id;
815 815
 }
816
-add_filter( 'wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2 );
816
+add_filter('wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2);
817 817
 
818 818
 function wpinv_is_paypal_valid_for_use() {
819
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_paypal_supported_currencies', array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) ) );
819
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR')));
820 820
 }
821 821
 
822
-function wpinv_check_paypal_currency_support( $gateway_list ) {
823
-    if ( isset( $gateway_list['paypal'] ) && ! wpinv_is_paypal_valid_for_use() ) {
824
-        unset( $gateway_list['paypal'] );
822
+function wpinv_check_paypal_currency_support($gateway_list) {
823
+    if (isset($gateway_list['paypal']) && !wpinv_is_paypal_valid_for_use()) {
824
+        unset($gateway_list['paypal']);
825 825
     }
826 826
     return $gateway_list;
827 827
 }
828
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1 );
828
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1);
829 829
 
830
-function wpinv_gateway_paypal_button_label( $label ) {
831
-    return __( 'Proceed to PayPal', 'invoicing' );
830
+function wpinv_gateway_paypal_button_label($label) {
831
+    return __('Proceed to PayPal', 'invoicing');
832 832
 }
833
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
834 833
\ No newline at end of file
834
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
835 835
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/authorizenet.php 1 patch
Spacing   +271 added lines, -271 removed lines patch added patch discarded remove patch
@@ -1,60 +1,60 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetTD.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -64,8 +64,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/gateways/authorizenet/anet_php_sdk/lib/AuthorizeNetSIM.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -178,11 +178,11 @@
 block discarded – undo
178 178
      */
179 179
     public function getHiddenFieldString()
180 180
     {
181
-        $array = (array)$this;
181
+        $array = (array) $this;
182 182
         $string = "";
183 183
         foreach ($array as $key => $value) {
184 184
             if ($value) {
185
-                $string .= '<input type="hidden" name="'.$key.'" value="'.$value.'">';
185
+                $string .= '<input type="hidden" name="' . $key . '" value="' . $value . '">';
186 186
             }
187 187
         }
188 188
         return $string;
Please login to merge, or discard this patch.
gateways/authorizenet/anet_php_sdk/lib/shared/AuthorizeNetTypes.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -114,24 +114,24 @@
 block discarded – undo
114 114
     
115 115
     public function __construct()
116 116
     {
117
-        $this->tax = (object)array();
117
+        $this->tax = (object) array();
118 118
         $this->tax->amount = "";
119 119
         $this->tax->name = "";
120 120
         $this->tax->description = "";
121 121
         
122
-        $this->shipping = (object)array();
122
+        $this->shipping = (object) array();
123 123
         $this->shipping->amount = "";
124 124
         $this->shipping->name = "";
125 125
         $this->shipping->description = "";
126 126
         
127
-        $this->duty = (object)array();
127
+        $this->duty = (object) array();
128 128
         $this->duty->amount = "";
129 129
         $this->duty->name = "";
130 130
         $this->duty->description = "";
131 131
         
132 132
         // line items
133 133
         
134
-        $this->order = (object)array();
134
+        $this->order = (object) array();
135 135
         $this->order->invoiceNumber = "";
136 136
         $this->order->description = "";
137 137
         $this->order->purchaseOrderNumber = "";
Please login to merge, or discard this patch.