Passed
Pull Request — master (#217)
by Patrik
03:30
created
includes/admin/html-admin-page-addons.php 3 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2>Have a membership key?</h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -89,8 +89,8 @@  discard block
 block discarded – undo
89 89
 						<div class="testimonial-content">
90 90
 							<div class="t-image">
91 91
 								<?php
92
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
93
-								?>
92
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
93
+                                ?>
94 94
 							</div>
95 95
 							<div class="t-content">
96 96
 								<p>
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 						<div class="testimonial-content">
110 110
 							<div class="t-image">
111 111
 								<?php
112
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
113
-								?>
112
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
113
+                                ?>
114 114
 							</div>
115 115
 							<div class="t-content">
116 116
 								<p>
@@ -134,20 +134,20 @@  discard block
 block discarded – undo
134 134
 			</div>
135 135
 		</div>
136 136
 			<?php
137
-		}else{
138
-			$installed_plugins = get_plugins();
137
+        }else{
138
+            $installed_plugins = get_plugins();
139 139
             $addon_obj = new WPInv_Admin_Addons();
140
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
141
-				?>
140
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
141
+                ?>
142 142
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
143 143
                         if(965==$addon->info->id){continue;}// don't show quote add on
144
-						?><li class="wpi-product">
144
+                        ?><li class="wpi-product">
145 145
 								<div class="wpi-product-title">
146 146
 									<h3><?php
147
-										if ( ! empty( $addon->info->excerpt) ){
148
-											echo wpi_help_tip( $addon->info->excerpt );
149
-										}
150
-										echo esc_html( $addon->info->title ); ?></h3>
147
+                                        if ( ! empty( $addon->info->excerpt) ){
148
+                                            echo wpi_help_tip( $addon->info->excerpt );
149
+                                        }
150
+                                        echo esc_html( $addon->info->title ); ?></h3>
151 151
 								</div>
152 152
 
153 153
 								<span class="wpi-product-image">
@@ -155,27 +155,27 @@  discard block
 block discarded – undo
155 155
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
156 156
 									<?php endif;
157 157
 
158
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
159
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
161
-										echo '</a>';
162
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
163
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
164
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com');
165
-										}else{
166
-											// if installed show activation link
167
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
168
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
169
-											}else{
170
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
171
-											}
172
-										}
173
-										echo '<a href="'.$url.'" class="thickbox">';
174
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
175
-										echo '</a>';
176
-									}
177
-
178
-									?>
158
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
159
+                                        echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
161
+                                        echo '</a>';
162
+                                    }elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
163
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
164
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com');
165
+                                        }else{
166
+                                            // if installed show activation link
167
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
168
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
169
+                                            }else{
170
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
171
+                                            }
172
+                                        }
173
+                                        echo '<a href="'.$url.'" class="thickbox">';
174
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
175
+                                        echo '</a>';
176
+                                    }
177
+
178
+                                    ?>
179 179
 
180 180
 								</span>
181 181
 
@@ -183,15 +183,15 @@  discard block
 block discarded – undo
183 183
 								<span class="wpi-product-button">
184 184
 									<?php
185 185
                                     $addon_obj->output_button( $addon );
186
-									?>
186
+                                    ?>
187 187
 								</span>
188 188
 
189 189
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
190 190
 			<?php endif;
191
-		}
191
+        }
192 192
 
193
-	}
194
-	?>
193
+    }
194
+    ?>
195 195
 
196 196
 
197 197
 	<div class="clearfix" ></div>
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
211 211
 			<br>
212 212
 			<?php
213
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
214
-			?>
213
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
214
+            ?>
215 215
 		</span>
216 216
 	</div>
217 217
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Admin View: Page - Addons
4 4
  *
5 5
  */
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 add_ThickBox();
@@ -11,19 +11,19 @@  discard block
 block discarded – undo
11 11
 <div class="wrap wpi_addons_wrap">
12 12
 	<h1><?php echo get_admin_page_title(); ?></h1>
13 13
 
14
-	<?php if ( $tabs ){ ?>
14
+	<?php if ($tabs) { ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
17
+			foreach ($tabs as $name => $label) {
18
+				echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>';
19 19
 			}
20
-			do_action( 'wpi_addons_tabs' );
20
+			do_action('wpi_addons_tabs');
21 21
 			?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+		if ($current_tab == 'membership') {
27 27
 
28 28
 			?>
29 29
 
@@ -32,12 +32,12 @@  discard block
 block discarded – undo
32 32
 <!--
33 33
 				<h2>With our WPInvoicing Membership you get access to all our products!</h2>
34 34
 				<p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>-->
35
-				<?php if(defined('WP_EASY_UPDATES_ACTIVE')){?>
35
+				<?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?>
36 36
 					<h2>Have a membership key?</h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108));
39
+						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1');
40
+						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108));
41 41
 						?>
42 42
 					</p>
43 43
 				<?php }?>
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 						<div class="testimonial-content">
90 90
 							<div class="t-image">
91 91
 								<?php
92
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
92
+									echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > ';
93 93
 								?>
94 94
 							</div>
95 95
 							<div class="t-content">
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 						<div class="testimonial-content">
110 110
 							<div class="t-image">
111 111
 								<?php
112
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
112
+									echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > ';
113 113
 								?>
114 114
 							</div>
115 115
 							<div class="t-content">
@@ -134,44 +134,44 @@  discard block
 block discarded – undo
134 134
 			</div>
135 135
 		</div>
136 136
 			<?php
137
-		}else{
137
+		} else {
138 138
 			$installed_plugins = get_plugins();
139 139
             $addon_obj = new WPInv_Admin_Addons();
140
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
140
+			if ($addons = $addon_obj->get_section_data($current_tab)) :
141 141
 				?>
142
-				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
143
-                        if(965==$addon->info->id){continue;}// don't show quote add on
142
+				<ul class="wpi-products"><?php foreach ($addons as $addon) :
143
+                        if (965 == $addon->info->id) {continue; }// don't show quote add on
144 144
 						?><li class="wpi-product">
145 145
 								<div class="wpi-product-title">
146 146
 									<h3><?php
147
-										if ( ! empty( $addon->info->excerpt) ){
148
-											echo wpi_help_tip( $addon->info->excerpt );
147
+										if (!empty($addon->info->excerpt)) {
148
+											echo wpi_help_tip($addon->info->excerpt);
149 149
 										}
150
-										echo esc_html( $addon->info->title ); ?></h3>
150
+										echo esc_html($addon->info->title); ?></h3>
151 151
 								</div>
152 152
 
153 153
 								<span class="wpi-product-image">
154
-									<?php if ( ! empty( $addon->info->thumbnail) ) : ?>
155
-										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
154
+									<?php if (!empty($addon->info->thumbnail)) : ?>
155
+										<img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/>
156 156
 									<?php endif;
157 157
 
158
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
159
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
158
+									if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") {
159
+										echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&TB_iframe=true&width=770&height=660" class="thickbox" >';
160
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
161 161
 										echo '</a>';
162
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
163
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
164
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com');
165
-										}else{
162
+									}elseif (isset($addon->info->link) && substr($addon->info->link, 0, 23) === "https://wpinvoicing.com") {
163
+										if (defined('WP_EASY_UPDATES_ACTIVE')) {
164
+											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&TB_iframe=true&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpinvoicing.com');
165
+										} else {
166 166
 											// if installed show activation link
167
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
167
+											if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) {
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
169
-											}else{
169
+											} else {
170 170
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
171 171
 											}
172 172
 										}
173
-										echo '<a href="'.$url.'" class="thickbox">';
174
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+										echo '<a href="' . $url . '" class="thickbox">';
174
+										echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>';
175 175
 										echo '</a>';
176 176
 									}
177 177
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 								<span class="wpi-product-button">
184 184
 									<?php
185
-                                    $addon_obj->output_button( $addon );
185
+                                    $addon_obj->output_button($addon);
186 186
 									?>
187 187
 								</span>
188 188
 
@@ -196,21 +196,21 @@  discard block
 block discarded – undo
196 196
 
197 197
 	<div class="clearfix" ></div>
198 198
 
199
-	<?php if($current_tab =='addons'){ ?>
200
-	<p><?php printf( __( 'All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/addons/' ); ?></p>
201
-	<?php } if($current_tab =='gateways'){  ?>
202
-    <p><?php printf( __( 'All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing' ), 'https://wpinvoicing.com/downloads/category/gateways/' ); ?></p>
199
+	<?php if ($current_tab == 'addons') { ?>
200
+	<p><?php printf(__('All of our Invoicing Addons can be found on WPInvoicing.com here: <a href="%s">Invoicing Addons</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/addons/'); ?></p>
201
+	<?php } if ($current_tab == 'gateways') {  ?>
202
+    <p><?php printf(__('All of our Invoicing Payment Gateways can be found on WPInvoicing.com here: <a href="%s">Invoicing Payment Gateways</a>', 'invoicing'), 'https://wpinvoicing.com/downloads/category/gateways/'); ?></p>
203 203
     <?php } ?>
204 204
 
205
-	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf( __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.",'invoicing'),wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php'));?></span></div>
206
-	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(  __("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.",'invoicing'),admin_url("plugin-install.php?tab=upload&wpeu-install=true"));?></span></div>
205
+	<div id="wpi-wpeu-required-activation" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s'>activate</a> it now.", 'invoicing'), wp_nonce_url(admin_url('plugins.php?action=activate&plugin=wp-easy-updates/external-updates.php'), 'activate-plugin_wp-easy-updates/external-updates.php')); ?></span></div>
206
+	<div id="wpi-wpeu-required-for-external" style="display:none;"><span class="wpi-notification "><?php printf(__("The plugin <a href='https://wpeasyupdates.com/' target='_blank'>WP Easy Updates</a> is required to check for and update some installed plugins/themes, please <a href='%s' onclick='window.open(\"https://wpeasyupdates.com/wp-easy-updates.zip\", \"_blank\");' >download</a> and install it now.", 'invoicing'), admin_url("plugin-install.php?tab=upload&wpeu-install=true")); ?></span></div>
207 207
 	<div id="wpeu-licence-popup" style="display:none;">
208 208
 		<span class="wpi-notification noti-white">
209
-			<h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3>
210
-			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209
+			<h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3>
210
+			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key", 'invoicing'); ?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install", 'invoicing'); ?></button>
211 211
 			<br>
212 212
 			<?php
213
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
213
+			echo sprintf(__('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">', '</a>', '<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">', '</a>');
214 214
 			?>
215 215
 		</span>
216 216
 	</div>
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 			</div>
135 135
 		</div>
136 136
 			<?php
137
-		}else{
137
+		} else{
138 138
 			$installed_plugins = get_plugins();
139 139
             $addon_obj = new WPInv_Admin_Addons();
140 140
 			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
@@ -159,14 +159,14 @@  discard block
 block discarded – undo
159 159
 										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&TB_iframe=true&width=770&height=660" class="thickbox" >';
160 160
 										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
161 161
 										echo '</a>';
162
-									}elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
162
+									} elseif(isset($addon->info->link) && substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com"){
163 163
 										if(defined('WP_EASY_UPDATES_ACTIVE')){
164 164
 											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&TB_iframe=true&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpinvoicing.com');
165
-										}else{
165
+										} else{
166 166
 											// if installed show activation link
167 167
 											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
168 168
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
169
-											}else{
169
+											} else{
170 170
 												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
171 171
 											}
172 172
 										}
Please login to merge, or discard this patch.
includes/class-wpinv-cardinal-commerce.php 4 patches
Doc Comments   +20 added lines patch added patch discarded remove patch
@@ -253,6 +253,9 @@  discard block
 block discarded – undo
253 253
 	        WPINV_VERSION, true);
254 254
     }
255 255
 
256
+    /**
257
+     * @param string $source
258
+     */
256 259
     private static function base64_encode_urlsafe($source) {
257 260
         $rv = base64_encode($source);
258 261
         $rv = str_replace('=', '', $rv);
@@ -286,6 +289,9 @@  discard block
 block discarded – undo
286 289
         return $header . '.' . $body . '.' . $signature;
287 290
     }
288 291
 
292
+    /**
293
+     * @param WPInv_Invoice $invoice
294
+     */
289 295
     private function generate_cruise_jwt($invoice = null) {
290 296
         $iat = time();
291 297
         $data = array(
@@ -317,6 +323,9 @@  discard block
 block discarded – undo
317 323
         return $payload;
318 324
     }
319 325
 
326
+    /**
327
+     * @param string $id
328
+     */
320 329
     public function hidden_input($id, $value = '') {
321 330
         echo "<input type='hidden' id='{$id}' value='{$value}' />";
322 331
     }
@@ -333,6 +342,10 @@  discard block
 block discarded – undo
333 342
         echo "<input type='hidden' autocomplete='off' id='{$id}' name='$id' /><div id='merchant-content-wrapper' style='display: none'><div id='actual-merchant-content'>{$merchant_content}</div></div>";
334 343
     }
335 344
 
345
+    /**
346
+     * @param string $type
347
+     * @param string $amount
348
+     */
336 349
     public function pm_message($type, $orderid, $amount, $currency, $fields=array()) {
337 350
         $timestamp = time() * 1000;
338 351
         $plaintext = $timestamp . '9b11d472-91c9-4c5d-aadf-c32e710db171';
@@ -427,6 +440,9 @@  discard block
 block discarded – undo
427 440
 	    wpinv_send_back_to_checkout( '?payment-mode=paypalpro' );
428 441
     }
429 442
 
443
+    /**
444
+     * @param WPInv_Invoice|null $invoice
445
+     */
430 446
     public function order_add($invoice, $key, $value) {
431 447
         update_post_meta($invoice->ID, "_{$this->id}_{$key}", $value);
432 448
     }
@@ -436,6 +452,10 @@  discard block
 block discarded – undo
436 452
         return isset($meta[0]) ? $meta[0] : null;
437 453
     }
438 454
 
455
+    /**
456
+     * @param WPInv_Invoice|null $invoice
457
+     * @param string $message
458
+     */
439 459
     public function status_message($invoice, $message, $amount = null,
440 460
                                    $error = null) {
441 461
         if (!$amount) {
Please login to merge, or discard this patch.
Indentation   +230 added lines, -230 removed lines patch added patch discarded remove patch
@@ -11,231 +11,231 @@  discard block
 block discarded – undo
11 11
         $this->method_title = '3-D Secure Payment Gateway by CardinalCommerce';
12 12
 
13 13
         $this->currencies = array(
14
-	        'ADP' => '020',
15
-	        'AED' => '784',
16
-	        'AFA' => '004',
17
-	        'AFN' => '971',
18
-	        'ALL' => '008',
19
-	        'AMD' => '051',
20
-	        'ANG' => '532',
21
-	        'AOA' => '973',
22
-	        'AON' => '024',
23
-	        'ARS' => '032',
24
-	        'ATS' => '040',
25
-	        'AUD' => '036',
26
-	        'AWG' => '533',
27
-	        'AZM' => '031',
28
-	        'AZN' => '944',
29
-	        'BAM' => '977',
30
-	        'BBD' => '052',
31
-	        'BDT' => '050',
32
-	        'BEF' => '056',
33
-	        'BGL' => '100',
34
-	        'BGN' => '975',
35
-	        'BHD' => '048',
36
-	        'BIF' => '108',
37
-	        'BMD' => '060',
38
-	        'BND' => '096',
39
-	        'BOB' => '068',
40
-	        'BOV' => '984',
41
-	        'BRL' => '986',
42
-	        'BSD' => '044',
43
-	        'BTN' => '064',
44
-	        'BWP' => '072',
45
-	        'BYR' => '974',
46
-	        'BZD' => '084',
47
-	        'CAD' => '124',
48
-	        'CDF' => '976',
49
-	        'CHE' => '947',
50
-	        'CHF' => '756',
51
-	        'CHW' => '948',
52
-	        'CLF' => '990',
53
-	        'CLP' => '152',
54
-	        'CNY' => '156',
55
-	        'COP' => '170',
56
-	        'COU' => '970',
57
-	        'CRC' => '188',
58
-	        'CSD' => '891',
59
-	        'CUC' => '931',
60
-	        'CUP' => '192',
61
-	        'CVE' => '132',
62
-	        'CYP' => '196',
63
-	        'CZK' => '203',
64
-	        'DEM' => '276',
65
-	        'DJF' => '262',
66
-	        'DKK' => '208',
67
-	        'DOP' => '214',
68
-	        'DZD' => '012',
69
-	        'EEK' => '233',
70
-	        'EGP' => '818',
71
-	        'ERN' => '232',
72
-	        'ESP' => '724',
73
-	        'ETB' => '230',
74
-	        'EUR' => '978',
75
-	        'FIM' => '246',
76
-	        'FJD' => '242',
77
-	        'FKP' => '238',
78
-	        'FRF' => '250',
79
-	        'GBP' => '826',
80
-	        'GEL' => '981',
81
-	        'GHC' => '288',
82
-	        'GHS' => '936',
83
-	        'GIP' => '292',
84
-	        'GMD' => '270',
85
-	        'GNF' => '324',
86
-	        'GTQ' => '320',
87
-	        'GWP' => '624',
88
-	        'GYD' => '328',
89
-	        'HKD' => '344',
90
-	        'HNL' => '340',
91
-	        'HRK' => '191',
92
-	        'HTG' => '332',
93
-	        'HUF' => '348',
94
-	        'IDR' => '360',
95
-	        'IEP' => '372',
96
-	        'ILS' => '376',
97
-	        'INR' => '356',
98
-	        'IQD' => '368',
99
-	        'IRR' => '364',
100
-	        'ISK' => '352',
101
-	        'ITL' => '380',
102
-	        'JMD' => '388',
103
-	        'JOD' => '400',
104
-	        'JPY' => '392',
105
-	        'KES' => '404',
106
-	        'KGS' => '417',
107
-	        'KHR' => '116',
108
-	        'KMF' => '174',
109
-	        'KPW' => '408',
110
-	        'KRW' => '410',
111
-	        'KWD' => '414',
112
-	        'KYD' => '136',
113
-	        'KZT' => '398',
114
-	        'LAK' => '418',
115
-	        'LBP' => '422',
116
-	        'LKR' => '144',
117
-	        'LRD' => '430',
118
-	        'LSL' => '426',
119
-	        'LTL' => '440',
120
-	        'LUF' => '442',
121
-	        'LVL' => '428',
122
-	        'LYD' => '434',
123
-	        'MAD' => '504',
124
-	        'MDL' => '498',
125
-	        'MGA' => '969',
126
-	        'MGF' => '450',
127
-	        'MKD' => '807',
128
-	        'MMK' => '104',
129
-	        'MNT' => '496',
130
-	        'MOP' => '446',
131
-	        'MRO' => '478',
132
-	        'MTL' => '470',
133
-	        'MUR' => '480',
134
-	        'MVR' => '462',
135
-	        'MWK' => '454',
136
-	        'MXN' => '484',
137
-	        'MXV' => '979',
138
-	        'MYR' => '458',
139
-	        'MZM' => '508',
140
-	        'MZN' => '943',
141
-	        'NAD' => '516',
142
-	        'NGN' => '566',
143
-	        'NIO' => '558',
144
-	        'NLG' => '528',
145
-	        'NOK' => '578',
146
-	        'NPR' => '524',
147
-	        'NZD' => '554',
148
-	        'OMR' => '512',
149
-	        'PAB' => '590',
150
-	        'PEN' => '604',
151
-	        'PGK' => '598',
152
-	        'PHP' => '608',
153
-	        'PKR' => '586',
154
-	        'PLN' => '985',
155
-	        'PTE' => '620',
156
-	        'PYG' => '600',
157
-	        'QAR' => '634',
158
-	        'ROL' => '642',
159
-	        'RON' => '946',
160
-	        'RSD' => '941',
161
-	        'RUB' => '643',
162
-	        'RUR' => '810',
163
-	        'RWF' => '646',
164
-	        'SAR' => '682',
165
-	        'SBD' => '090',
166
-	        'SCR' => '690',
167
-	        'SDD' => '736',
168
-	        'SDG' => '938',
169
-	        'SEK' => '752',
170
-	        'SGD' => '702',
171
-	        'SHP' => '654',
172
-	        'SIT' => '705',
173
-	        'SKK' => '703',
174
-	        'SLL' => '694',
175
-	        'SOS' => '706',
176
-	        'SRD' => '968',
177
-	        'SRG' => '740',
178
-	        'SSP' => '728',
179
-	        'STD' => '678',
180
-	        'SVC' => '222',
181
-	        'SYP' => '760',
182
-	        'SZL' => '748',
183
-	        'THB' => '764',
184
-	        'TJS' => '972',
185
-	        'TMM' => '795',
186
-	        'TMT' => '934',
187
-	        'TND' => '788',
188
-	        'TOP' => '776',
189
-	        'TPE' => '626',
190
-	        'TRL' => '792',
191
-	        'TRY' => '949',
192
-	        'TTD' => '780',
193
-	        'TWD' => '901',
194
-	        'TZS' => '834',
195
-	        'UAH' => '980',
196
-	        'UGX' => '800',
197
-	        'USD' => '840',
198
-	        'USN' => '997',
199
-	        'UYI' => '940',
200
-	        'UYU' => '858',
201
-	        'UZS' => '860',
202
-	        'VEB' => '862',
203
-	        'VEF' => '937',
204
-	        'VND' => '704',
205
-	        'VUV' => '548',
206
-	        'WST' => '882',
207
-	        'XAF' => '950',
208
-	        'XCD' => '951',
209
-	        'XOF' => '952',
210
-	        'XPF' => '953',
211
-	        'XXX' => '999',
212
-	        'YER' => '886',
213
-	        'YUM' => '891',
214
-	        'ZAR' => '710',
215
-	        'ZMK' => '894',
216
-	        'ZMW' => '967',
217
-	        'ZWD' => '716',
218
-	        'ZWL' => '932',
14
+            'ADP' => '020',
15
+            'AED' => '784',
16
+            'AFA' => '004',
17
+            'AFN' => '971',
18
+            'ALL' => '008',
19
+            'AMD' => '051',
20
+            'ANG' => '532',
21
+            'AOA' => '973',
22
+            'AON' => '024',
23
+            'ARS' => '032',
24
+            'ATS' => '040',
25
+            'AUD' => '036',
26
+            'AWG' => '533',
27
+            'AZM' => '031',
28
+            'AZN' => '944',
29
+            'BAM' => '977',
30
+            'BBD' => '052',
31
+            'BDT' => '050',
32
+            'BEF' => '056',
33
+            'BGL' => '100',
34
+            'BGN' => '975',
35
+            'BHD' => '048',
36
+            'BIF' => '108',
37
+            'BMD' => '060',
38
+            'BND' => '096',
39
+            'BOB' => '068',
40
+            'BOV' => '984',
41
+            'BRL' => '986',
42
+            'BSD' => '044',
43
+            'BTN' => '064',
44
+            'BWP' => '072',
45
+            'BYR' => '974',
46
+            'BZD' => '084',
47
+            'CAD' => '124',
48
+            'CDF' => '976',
49
+            'CHE' => '947',
50
+            'CHF' => '756',
51
+            'CHW' => '948',
52
+            'CLF' => '990',
53
+            'CLP' => '152',
54
+            'CNY' => '156',
55
+            'COP' => '170',
56
+            'COU' => '970',
57
+            'CRC' => '188',
58
+            'CSD' => '891',
59
+            'CUC' => '931',
60
+            'CUP' => '192',
61
+            'CVE' => '132',
62
+            'CYP' => '196',
63
+            'CZK' => '203',
64
+            'DEM' => '276',
65
+            'DJF' => '262',
66
+            'DKK' => '208',
67
+            'DOP' => '214',
68
+            'DZD' => '012',
69
+            'EEK' => '233',
70
+            'EGP' => '818',
71
+            'ERN' => '232',
72
+            'ESP' => '724',
73
+            'ETB' => '230',
74
+            'EUR' => '978',
75
+            'FIM' => '246',
76
+            'FJD' => '242',
77
+            'FKP' => '238',
78
+            'FRF' => '250',
79
+            'GBP' => '826',
80
+            'GEL' => '981',
81
+            'GHC' => '288',
82
+            'GHS' => '936',
83
+            'GIP' => '292',
84
+            'GMD' => '270',
85
+            'GNF' => '324',
86
+            'GTQ' => '320',
87
+            'GWP' => '624',
88
+            'GYD' => '328',
89
+            'HKD' => '344',
90
+            'HNL' => '340',
91
+            'HRK' => '191',
92
+            'HTG' => '332',
93
+            'HUF' => '348',
94
+            'IDR' => '360',
95
+            'IEP' => '372',
96
+            'ILS' => '376',
97
+            'INR' => '356',
98
+            'IQD' => '368',
99
+            'IRR' => '364',
100
+            'ISK' => '352',
101
+            'ITL' => '380',
102
+            'JMD' => '388',
103
+            'JOD' => '400',
104
+            'JPY' => '392',
105
+            'KES' => '404',
106
+            'KGS' => '417',
107
+            'KHR' => '116',
108
+            'KMF' => '174',
109
+            'KPW' => '408',
110
+            'KRW' => '410',
111
+            'KWD' => '414',
112
+            'KYD' => '136',
113
+            'KZT' => '398',
114
+            'LAK' => '418',
115
+            'LBP' => '422',
116
+            'LKR' => '144',
117
+            'LRD' => '430',
118
+            'LSL' => '426',
119
+            'LTL' => '440',
120
+            'LUF' => '442',
121
+            'LVL' => '428',
122
+            'LYD' => '434',
123
+            'MAD' => '504',
124
+            'MDL' => '498',
125
+            'MGA' => '969',
126
+            'MGF' => '450',
127
+            'MKD' => '807',
128
+            'MMK' => '104',
129
+            'MNT' => '496',
130
+            'MOP' => '446',
131
+            'MRO' => '478',
132
+            'MTL' => '470',
133
+            'MUR' => '480',
134
+            'MVR' => '462',
135
+            'MWK' => '454',
136
+            'MXN' => '484',
137
+            'MXV' => '979',
138
+            'MYR' => '458',
139
+            'MZM' => '508',
140
+            'MZN' => '943',
141
+            'NAD' => '516',
142
+            'NGN' => '566',
143
+            'NIO' => '558',
144
+            'NLG' => '528',
145
+            'NOK' => '578',
146
+            'NPR' => '524',
147
+            'NZD' => '554',
148
+            'OMR' => '512',
149
+            'PAB' => '590',
150
+            'PEN' => '604',
151
+            'PGK' => '598',
152
+            'PHP' => '608',
153
+            'PKR' => '586',
154
+            'PLN' => '985',
155
+            'PTE' => '620',
156
+            'PYG' => '600',
157
+            'QAR' => '634',
158
+            'ROL' => '642',
159
+            'RON' => '946',
160
+            'RSD' => '941',
161
+            'RUB' => '643',
162
+            'RUR' => '810',
163
+            'RWF' => '646',
164
+            'SAR' => '682',
165
+            'SBD' => '090',
166
+            'SCR' => '690',
167
+            'SDD' => '736',
168
+            'SDG' => '938',
169
+            'SEK' => '752',
170
+            'SGD' => '702',
171
+            'SHP' => '654',
172
+            'SIT' => '705',
173
+            'SKK' => '703',
174
+            'SLL' => '694',
175
+            'SOS' => '706',
176
+            'SRD' => '968',
177
+            'SRG' => '740',
178
+            'SSP' => '728',
179
+            'STD' => '678',
180
+            'SVC' => '222',
181
+            'SYP' => '760',
182
+            'SZL' => '748',
183
+            'THB' => '764',
184
+            'TJS' => '972',
185
+            'TMM' => '795',
186
+            'TMT' => '934',
187
+            'TND' => '788',
188
+            'TOP' => '776',
189
+            'TPE' => '626',
190
+            'TRL' => '792',
191
+            'TRY' => '949',
192
+            'TTD' => '780',
193
+            'TWD' => '901',
194
+            'TZS' => '834',
195
+            'UAH' => '980',
196
+            'UGX' => '800',
197
+            'USD' => '840',
198
+            'USN' => '997',
199
+            'UYI' => '940',
200
+            'UYU' => '858',
201
+            'UZS' => '860',
202
+            'VEB' => '862',
203
+            'VEF' => '937',
204
+            'VND' => '704',
205
+            'VUV' => '548',
206
+            'WST' => '882',
207
+            'XAF' => '950',
208
+            'XCD' => '951',
209
+            'XOF' => '952',
210
+            'XPF' => '953',
211
+            'XXX' => '999',
212
+            'YER' => '886',
213
+            'YUM' => '891',
214
+            'ZAR' => '710',
215
+            'ZMK' => '894',
216
+            'ZMW' => '967',
217
+            'ZWD' => '716',
218
+            'ZWL' => '932',
219 219
         );
220 220
 
221 221
         $this->instances = array(
222
-	        'STAG' => 'centineltest.cardinalcommerce.com',
223
-	        'CYBERSOURCE' => 'cybersource.cardinalcommerce.com',
224
-	        'FIRSTDATA' => 'production.altpayfirstdata.com',
225
-	        'FIRSTDATA_TEST' => 'test.altpayfirstdata.com',
226
-	        'PAYMENTECH' => 'paymentech.cardinalcommerce.com',
227
-	        'PAYPAL' => 'paypal.cardinalcommerce.com',
228
-	        '200' => 'centinel.cardinalcommerce.com',
229
-	        '300' => 'centinel300.cardinalcommerce.com',
230
-	        '400' => 'centinel400.cardinalcommerce.com',
231
-	        'PROD' => 'centinel600.cardinalcommerce.com',
232
-	        '800' => 'centinel800.cardinalcommerce.com',
233
-	        '1000' => 'centinel1000.cardinalcommerce.com',
234
-	        '1200' => 'centinel1200.cardinalcommerce.com',
222
+            'STAG' => 'centineltest.cardinalcommerce.com',
223
+            'CYBERSOURCE' => 'cybersource.cardinalcommerce.com',
224
+            'FIRSTDATA' => 'production.altpayfirstdata.com',
225
+            'FIRSTDATA_TEST' => 'test.altpayfirstdata.com',
226
+            'PAYMENTECH' => 'paymentech.cardinalcommerce.com',
227
+            'PAYPAL' => 'paypal.cardinalcommerce.com',
228
+            '200' => 'centinel.cardinalcommerce.com',
229
+            '300' => 'centinel300.cardinalcommerce.com',
230
+            '400' => 'centinel400.cardinalcommerce.com',
231
+            'PROD' => 'centinel600.cardinalcommerce.com',
232
+            '800' => 'centinel800.cardinalcommerce.com',
233
+            '1000' => 'centinel1000.cardinalcommerce.com',
234
+            '1200' => 'centinel1200.cardinalcommerce.com',
235 235
         );
236 236
 
237
-	    add_filter( 'wp_enqueue_scripts', array($this, 'register_scripts') );
238
-	    add_filter( 'wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit') );
237
+        add_filter( 'wp_enqueue_scripts', array($this, 'register_scripts') );
238
+        add_filter( 'wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit') );
239 239
 
240 240
     }
241 241
 
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         wp_register_script(
251 251
             'cardinalcommerce-oneconnect', WPINV_PLUGIN_URL.'assets/js/cardinalcommerce-oneconnect.js',
252 252
             array('jquery', 'cardinalcommerce-oneconnect-songbird'),
253
-	        WPINV_VERSION, true);
253
+            WPINV_VERSION, true);
254 254
     }
255 255
 
256 256
     private static function base64_encode_urlsafe($source) {
@@ -323,10 +323,10 @@  discard block
 block discarded – undo
323 323
 
324 324
     public function purchase_form_before_submit() {
325 325
         wp_enqueue_script('cardinalcommerce-oneconnect');
326
-	    $invoice = wpinv_get_invoice_cart();
327
-	    $jwt = $this->generate_cruise_jwt($invoice);
328
-	    $this->hidden_input('CardinalOneConnectJWT', $jwt);
329
-	    $this->hidden_input('CardinalOneConnectLoggingLevel','verbose');
326
+        $invoice = wpinv_get_invoice_cart();
327
+        $jwt = $this->generate_cruise_jwt($invoice);
328
+        $this->hidden_input('CardinalOneConnectJWT', $jwt);
329
+        $this->hidden_input('CardinalOneConnectLoggingLevel','verbose');
330 330
 
331 331
         $id = 'CardinalOneConnectResult';
332 332
         $merchant_content = 'Consumer Messaging';
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
     public function reject_with_error($message, $permanent = false) {
426 426
         wpinv_set_error('wpinv_error', "{$this->method_title}: {$message}");
427
-	    wpinv_send_back_to_checkout( '?payment-mode=paypalpro' );
427
+        wpinv_send_back_to_checkout( '?payment-mode=paypalpro' );
428 428
     }
429 429
 
430 430
     public function order_add($invoice, $key, $value) {
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
     }
438 438
 
439 439
     public function status_message($invoice, $message, $amount = null,
440
-                                   $error = null) {
440
+                                    $error = null) {
441 441
         if (!$amount) {
442 442
             $amount = $invoice->get_total();
443 443
         }
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
     }
451 451
 
452 452
     public function process_payment( $invoice_id ) {
453
-	    $invoice = wpinv_get_invoice( $invoice_id );
453
+        $invoice = wpinv_get_invoice( $invoice_id );
454 454
 
455 455
         $cruise_result_json = $_POST['CardinalOneConnectResult'];
456 456
         if ( ! $cruise_result_json ) {
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
             $this->reject_with_error('data and Payload ActionCode do not match');
501 501
         }
502 502
 
503
-	    $invoiceid = $payload->AuthorizationProcessor->ProcessorOrderId;
503
+        $invoiceid = $payload->AuthorizationProcessor->ProcessorOrderId;
504 504
         $cca = $payload->Payment->ExtendedData;
505 505
         $eci = isset($cca->ECIFlag) ? $cca->ECIFlag : '';
506 506
         $cavv = isset($cca->CAVV) ? $cca->CAVV : '';
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 
621 621
     public function create_request_order_object($invoice) {
622 622
         $currency = $invoice->get_currency();
623
-    	$currency_alpha = $this->currencies[$currency];
623
+        $currency_alpha = $this->currencies[$currency];
624 624
         $raw_amount = self::raw_amount($invoice->get_total(), $currency_alpha);
625 625
 
626 626
         $request_order_object = array(
Please login to merge, or discard this patch.
Switch Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -467,23 +467,23 @@
 block discarded – undo
467 467
         $this->order_add($invoice, "ActionCode", $data->ActionCode);
468 468
 
469 469
         switch ($data->ActionCode) {
470
-        case 'SUCCESS':
471
-        case 'NOACTION':
472
-            break;
473
-        case 'FAILURE':
474
-            $this->reject_with_error('Payment was unsuccessful. ' .
475
-                'Please try again or provide another form of payment.');
476
-            break;
477
-        case 'ERROR':
478
-            $message = $data->ErrorDescription;
479
-            if ( isset($data->ErrorNumber) ) {
480
-                $message .= " ({$data->ErrorNumber})";
481
-            }
482
-            $this->reject_with_error($message, isset($data->PermanentFatal));
483
-            break;
484
-        default:
485
-            $this->reject_with_error('Unknown ActionCode');
486
-            break;
470
+            case 'SUCCESS':
471
+            case 'NOACTION':
472
+                break;
473
+            case 'FAILURE':
474
+                $this->reject_with_error('Payment was unsuccessful. ' .
475
+                    'Please try again or provide another form of payment.');
476
+                break;
477
+            case 'ERROR':
478
+                $message = $data->ErrorDescription;
479
+                if ( isset($data->ErrorNumber) ) {
480
+                    $message .= " ({$data->ErrorNumber})";
481
+                }
482
+                $this->reject_with_error($message, isset($data->PermanentFatal));
483
+                break;
484
+            default:
485
+                $this->reject_with_error('Unknown ActionCode');
486
+                break;
487 487
         }
488 488
 
489 489
         if (!isset($cruise_result->jwt)) {
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
     exit;
5 5
 }
6 6
 
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
 	        '1200' => 'centinel1200.cardinalcommerce.com',
235 235
         );
236 236
 
237
-	    add_filter( 'wp_enqueue_scripts', array($this, 'register_scripts') );
238
-	    add_filter( 'wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit') );
237
+	    add_filter('wp_enqueue_scripts', array($this, 'register_scripts'));
238
+	    add_filter('wpinv_purchase_form_before_submit', array($this, 'purchase_form_before_submit'));
239 239
 
240 240
     }
241 241
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
             'cardinalcommerce-oneconnect-songbird',
249 249
             "https://{$songbird_domain}/edge/v1/songbird.js");
250 250
         wp_register_script(
251
-            'cardinalcommerce-oneconnect', WPINV_PLUGIN_URL.'assets/js/cardinalcommerce-oneconnect.js',
251
+            'cardinalcommerce-oneconnect', WPINV_PLUGIN_URL . 'assets/js/cardinalcommerce-oneconnect.js',
252 252
             array('jquery', 'cardinalcommerce-oneconnect-songbird'),
253 253
 	        WPINV_VERSION, true);
254 254
     }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             'iss' => '5d79e83d031e732958e19532',
296 296
             'OrgUnitId' => '5d79e83de0919f19584569b6',
297 297
         );
298
-        if ( $invoice ) {
298
+        if ($invoice) {
299 299
             $payload = $this->create_request_order_object($invoice);
300 300
             $data['Payload'] = $payload;
301 301
             $data['ObjectifyPayload'] = true;
@@ -326,14 +326,14 @@  discard block
 block discarded – undo
326 326
 	    $invoice = wpinv_get_invoice_cart();
327 327
 	    $jwt = $this->generate_cruise_jwt($invoice);
328 328
 	    $this->hidden_input('CardinalOneConnectJWT', $jwt);
329
-	    $this->hidden_input('CardinalOneConnectLoggingLevel','verbose');
329
+	    $this->hidden_input('CardinalOneConnectLoggingLevel', 'verbose');
330 330
 
331 331
         $id = 'CardinalOneConnectResult';
332 332
         $merchant_content = 'Consumer Messaging';
333 333
         echo "<input type='hidden' autocomplete='off' id='{$id}' name='$id' /><div id='merchant-content-wrapper' style='display: none'><div id='actual-merchant-content'>{$merchant_content}</div></div>";
334 334
     }
335 335
 
336
-    public function pm_message($type, $orderid, $amount, $currency, $fields=array()) {
336
+    public function pm_message($type, $orderid, $amount, $currency, $fields = array()) {
337 337
         $timestamp = time() * 1000;
338 338
         $plaintext = $timestamp . '9b11d472-91c9-4c5d-aadf-c32e710db171';
339 339
         $signature = base64_encode(hash('sha256', $plaintext, true));
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
 
425 425
     public function reject_with_error($message, $permanent = false) {
426 426
         wpinv_set_error('wpinv_error', "{$this->method_title}: {$message}");
427
-	    wpinv_send_back_to_checkout( '?payment-mode=paypalpro' );
427
+	    wpinv_send_back_to_checkout('?payment-mode=paypalpro');
428 428
     }
429 429
 
430 430
     public function order_add($invoice, $key, $value) {
@@ -449,11 +449,11 @@  discard block
 block discarded – undo
449 449
         return $rv;
450 450
     }
451 451
 
452
-    public function process_payment( $invoice_id ) {
453
-	    $invoice = wpinv_get_invoice( $invoice_id );
452
+    public function process_payment($invoice_id) {
453
+	    $invoice = wpinv_get_invoice($invoice_id);
454 454
 
455 455
         $cruise_result_json = $_POST['CardinalOneConnectResult'];
456
-        if ( ! $cruise_result_json ) {
456
+        if (!$cruise_result_json) {
457 457
             $jwt = $this->generate_cruise_jwt($invoice);
458 458
             wp_send_json(array(
459 459
                 'messages' =>
@@ -476,7 +476,7 @@  discard block
 block discarded – undo
476 476
             break;
477 477
         case 'ERROR':
478 478
             $message = $data->ErrorDescription;
479
-            if ( isset($data->ErrorNumber) ) {
479
+            if (isset($data->ErrorNumber)) {
480 480
                 $message .= " ({$data->ErrorNumber})";
481 481
             }
482 482
             $this->reject_with_error($message, isset($data->PermanentFatal));
@@ -585,7 +585,7 @@  discard block
 block discarded – undo
585 585
 
586 586
         return array(
587 587
             'result' => 'success',
588
-            'redirect' => $this->get_return_url( $invoice )
588
+            'redirect' => $this->get_return_url($invoice)
589 589
         );
590 590
     }
591 591
 
@@ -612,10 +612,10 @@  discard block
 block discarded – undo
612 612
     }
613 613
 
614 614
     public static function raw_amount($amount, $currency_alpha) {
615
-        $float_amount = (float) $amount;
615
+        $float_amount = (float)$amount;
616 616
         $exponent = self::currency_exponent($currency_alpha);
617
-        $int_amount = (int) round($float_amount * pow(10, $exponent));
618
-        return (string) $int_amount;
617
+        $int_amount = (int)round($float_amount * pow(10, $exponent));
618
+        return (string)$int_amount;
619 619
     }
620 620
 
621 621
     public function create_request_order_object($invoice) {
Please login to merge, or discard this patch.
includes/class-wpinv-session-handler.php 3 patches
Doc Comments   +5 added lines, -1 removed lines patch added patch discarded remove patch
@@ -130,6 +130,10 @@  discard block
 block discarded – undo
130 130
 		}
131 131
 	}
132 132
 
133
+	/**
134
+	 * @param string $name
135
+	 * @param string $value
136
+	 */
133 137
 	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134 138
         if ( ! headers_sent() ) {
135 139
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
@@ -274,7 +278,7 @@  discard block
 block discarded – undo
274 278
 	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
275 279
 	 *
276 280
 	 * @param int $uid User ID.
277
-	 * @return string
281
+	 * @return integer
278 282
 	 */
279 283
 	public function nonce_user_logged_out( $uid ) {
280 284
 		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
Please login to merge, or discard this patch.
Indentation   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -12,125 +12,125 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class WPInv_Session_Handler extends WPInv_Session {
14 14
 
15
-	/**
16
-	 * Cookie name used for the session.
17
-	 *
18
-	 * @var string cookie name
19
-	 */
20
-	protected $_cookie;
21
-
22
-	/**
23
-	 * Stores session expiry.
24
-	 *
25
-	 * @var string session due to expire timestamp
26
-	 */
27
-	protected $_session_expiring;
28
-
29
-	/**
30
-	 * Stores session due to expire timestamp.
31
-	 *
32
-	 * @var string session expiration timestamp
33
-	 */
34
-	protected $_session_expiration;
35
-
36
-	/**
37
-	 * True when the cookie exists.
38
-	 *
39
-	 * @var bool Based on whether a cookie exists.
40
-	 */
41
-	protected $_has_cookie = false;
42
-
43
-	/**
44
-	 * Table name for session data.
45
-	 *
46
-	 * @var string Custom session table name
47
-	 */
48
-	protected $_table;
49
-
50
-	/**
51
-	 * Constructor for the session class.
52
-	 */
53
-	public function __construct() {
54
-
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
15
+    /**
16
+     * Cookie name used for the session.
17
+     *
18
+     * @var string cookie name
19
+     */
20
+    protected $_cookie;
21
+
22
+    /**
23
+     * Stores session expiry.
24
+     *
25
+     * @var string session due to expire timestamp
26
+     */
27
+    protected $_session_expiring;
28
+
29
+    /**
30
+     * Stores session due to expire timestamp.
31
+     *
32
+     * @var string session expiration timestamp
33
+     */
34
+    protected $_session_expiration;
35
+
36
+    /**
37
+     * True when the cookie exists.
38
+     *
39
+     * @var bool Based on whether a cookie exists.
40
+     */
41
+    protected $_has_cookie = false;
42
+
43
+    /**
44
+     * Table name for session data.
45
+     *
46
+     * @var string Custom session table name
47
+     */
48
+    protected $_table;
49
+
50
+    /**
51
+     * Constructor for the session class.
52
+     */
53
+    public function __construct() {
54
+
55
+        $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56 56
         add_action( 'init', array( $this, 'init' ), -1 );
57
-	}
58
-
59
-	/**
60
-	 * Init hooks and session data.
61
-	 *
62
-	 * @since 3.3.0
63
-	 */
64
-	public function init() {
65
-		$this->init_session_cookie();
66
-
67
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
68
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
69
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
70
-
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
73
-		}
74
-	}
75
-
76
-	/**
77
-	 * Setup cookie and customer ID.
78
-	 *
79
-	 * @since 3.6.0
80
-	 */
81
-	public function init_session_cookie() {
82
-		$cookie = $this->get_session_cookie();
83
-
84
-		if ( $cookie ) {
85
-			$this->_customer_id        = $cookie[0];
86
-			$this->_session_expiration = $cookie[1];
87
-			$this->_session_expiring   = $cookie[2];
88
-			$this->_has_cookie         = true;
89
-			$this->_data               = $this->get_session_data();
90
-
91
-			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
-				$this->_customer_id = get_current_user_id();
94
-				$this->_dirty       = true;
95
-				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
97
-			}
98
-
99
-			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
101
-				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
-			}
104
-		} else {
105
-			$this->set_session_expiration();
106
-			$this->_customer_id = $this->generate_customer_id();
107
-			$this->_data        = $this->get_session_data();
108
-		}
109
-	}
110
-
111
-	/**
112
-	 * Sets the session cookie on-demand (usually after adding an item to the cart).
113
-	 *
114
-	 * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
-	 *
116
-	 * Warning: Cookies will only be set if this is called before the headers are sent.
117
-	 *
118
-	 * @param bool $set Should the session cookie be set.
119
-	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
122
-			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
-			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
-			$this->_has_cookie = true;
126
-
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
-			}
130
-		}
131
-	}
132
-
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
57
+    }
58
+
59
+    /**
60
+     * Init hooks and session data.
61
+     *
62
+     * @since 3.3.0
63
+     */
64
+    public function init() {
65
+        $this->init_session_cookie();
66
+
67
+        add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
68
+        add_action( 'shutdown', array( $this, 'save_data' ), 20 );
69
+        add_action( 'wp_logout', array( $this, 'destroy_session' ) );
70
+
71
+        if ( ! is_user_logged_in() ) {
72
+            add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
73
+        }
74
+    }
75
+
76
+    /**
77
+     * Setup cookie and customer ID.
78
+     *
79
+     * @since 3.6.0
80
+     */
81
+    public function init_session_cookie() {
82
+        $cookie = $this->get_session_cookie();
83
+
84
+        if ( $cookie ) {
85
+            $this->_customer_id        = $cookie[0];
86
+            $this->_session_expiration = $cookie[1];
87
+            $this->_session_expiring   = $cookie[2];
88
+            $this->_has_cookie         = true;
89
+            $this->_data               = $this->get_session_data();
90
+
91
+            // If the user logs in, update session.
92
+            if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
93
+                $this->_customer_id = get_current_user_id();
94
+                $this->_dirty       = true;
95
+                $this->save_data();
96
+                $this->set_customer_session_cookie( true );
97
+            }
98
+
99
+            // Update session if its close to expiring.
100
+            if ( time() > $this->_session_expiring ) {
101
+                $this->set_session_expiration();
102
+                $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
103
+            }
104
+        } else {
105
+            $this->set_session_expiration();
106
+            $this->_customer_id = $this->generate_customer_id();
107
+            $this->_data        = $this->get_session_data();
108
+        }
109
+    }
110
+
111
+    /**
112
+     * Sets the session cookie on-demand (usually after adding an item to the cart).
113
+     *
114
+     * Since the cookie name (as of 2.1) is prepended with wp, cache systems like batcache will not cache pages when set.
115
+     *
116
+     * Warning: Cookies will only be set if this is called before the headers are sent.
117
+     *
118
+     * @param bool $set Should the session cookie be set.
119
+     */
120
+    public function set_customer_session_cookie( $set ) {
121
+        if ( $set ) {
122
+            $to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
+            $cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
124
+            $cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125
+            $this->_has_cookie = true;
126
+
127
+            if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
+                $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
129
+            }
130
+        }
131
+    }
132
+
133
+    public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134 134
         if ( ! headers_sent() ) {
135 135
             setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136 136
         } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
@@ -139,96 +139,96 @@  discard block
 block discarded – undo
139 139
         }
140 140
     }
141 141
 
142
-	/**
143
-	 * Should the session cookie be secure?
144
-	 *
145
-	 * @since 3.6.0
146
-	 * @return bool
147
-	 */
148
-	protected function use_secure_cookie() {
142
+    /**
143
+     * Should the session cookie be secure?
144
+     *
145
+     * @since 3.6.0
146
+     * @return bool
147
+     */
148
+    protected function use_secure_cookie() {
149 149
         $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
-	}
152
-
153
-	/**
154
-	 * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
-	 *
156
-	 * @return bool
157
-	 */
158
-	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
-	}
161
-
162
-	/**
163
-	 * Set session expiration.
164
-	 */
165
-	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
-	}
169
-
170
-	/**
171
-	 * Generate a unique customer ID for guests, or return user ID if logged in.
172
-	 *
173
-	 * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.
174
-	 *
175
-	 * @return string
176
-	 */
177
-	public function generate_customer_id() {
178
-		$customer_id = '';
179
-
180
-		if ( is_user_logged_in() ) {
181
-			$customer_id = get_current_user_id();
182
-		}
183
-
184
-		if ( empty( $customer_id ) ) {
150
+        return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
151
+    }
152
+
153
+    /**
154
+     * Return true if the current user has an active session, i.e. a cookie to retrieve values.
155
+     *
156
+     * @return bool
157
+     */
158
+    public function has_session() {
159
+        return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160
+    }
161
+
162
+    /**
163
+     * Set session expiration.
164
+     */
165
+    public function set_session_expiration() {
166
+        $this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
+        $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
168
+    }
169
+
170
+    /**
171
+     * Generate a unique customer ID for guests, or return user ID if logged in.
172
+     *
173
+     * Uses Portable PHP password hashing framework to generate a unique cryptographically strong ID.
174
+     *
175
+     * @return string
176
+     */
177
+    public function generate_customer_id() {
178
+        $customer_id = '';
179
+
180
+        if ( is_user_logged_in() ) {
181
+            $customer_id = get_current_user_id();
182
+        }
183
+
184
+        if ( empty( $customer_id ) ) {
185 185
             $customer_id = wp_create_nonce('wpinv-session-customer-id');
186
-		}
187
-
188
-		return $customer_id;
189
-	}
190
-
191
-	/**
192
-	 * Get the session cookie, if set. Otherwise return false.
193
-	 *
194
-	 * Session cookies without a customer ID are invalid.
195
-	 *
196
-	 * @return bool|array
197
-	 */
198
-	public function get_session_cookie() {
199
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
200
-
201
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
202
-			return false;
203
-		}
204
-
205
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
206
-
207
-		if ( empty( $customer_id ) ) {
208
-			return false;
209
-		}
210
-
211
-		// Validate hash.
212
-		$to_hash = $customer_id . '|' . $session_expiration;
213
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
214
-
215
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
216
-			return false;
217
-		}
218
-
219
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
220
-	}
221
-
222
-	/**
223
-	 * Get session data.
224
-	 *
225
-	 * @return array
226
-	 */
227
-	public function get_session_data() {
228
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
229
-	}
230
-
231
-	public function generate_key($customer_id){
186
+        }
187
+
188
+        return $customer_id;
189
+    }
190
+
191
+    /**
192
+     * Get the session cookie, if set. Otherwise return false.
193
+     *
194
+     * Session cookies without a customer ID are invalid.
195
+     *
196
+     * @return bool|array
197
+     */
198
+    public function get_session_cookie() {
199
+        $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
200
+
201
+        if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
202
+            return false;
203
+        }
204
+
205
+        list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
206
+
207
+        if ( empty( $customer_id ) ) {
208
+            return false;
209
+        }
210
+
211
+        // Validate hash.
212
+        $to_hash = $customer_id . '|' . $session_expiration;
213
+        $hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
214
+
215
+        if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
216
+            return false;
217
+        }
218
+
219
+        return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
220
+    }
221
+
222
+    /**
223
+     * Get session data.
224
+     *
225
+     * @return array
226
+     */
227
+    public function get_session_data() {
228
+        return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
229
+    }
230
+
231
+    public function generate_key($customer_id){
232 232
         if(!$customer_id){
233 233
             return;
234 234
         }
@@ -236,62 +236,62 @@  discard block
 block discarded – undo
236 236
         return 'wpi_trans_'.$customer_id;
237 237
     }
238 238
 
239
-	/**
240
-	 * Save data.
241
-	 */
242
-	public function save_data() {
243
-		// Dirty if something changed - prevents saving nothing new.
244
-		if ( $this->_dirty && $this->has_session() ) {
239
+    /**
240
+     * Save data.
241
+     */
242
+    public function save_data() {
243
+        // Dirty if something changed - prevents saving nothing new.
244
+        if ( $this->_dirty && $this->has_session() ) {
245 245
 
246 246
             set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
247 247
 
248
-			$this->_dirty = false;
249
-		}
250
-	}
251
-
252
-	/**
253
-	 * Destroy all session data.
254
-	 */
255
-	public function destroy_session() {
256
-		$this->delete_session( $this->_customer_id );
257
-		$this->forget_session();
258
-	}
259
-
260
-	/**
261
-	 * Forget all session data without destroying it.
262
-	 */
263
-	public function forget_session() {
264
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
265
-
266
-		wpinv_empty_cart();
267
-
268
-		$this->_data        = array();
269
-		$this->_dirty       = false;
270
-		$this->_customer_id = $this->generate_customer_id();
271
-	}
272
-
273
-	/**
274
-	 * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
275
-	 *
276
-	 * @param int $uid User ID.
277
-	 * @return string
278
-	 */
279
-	public function nonce_user_logged_out( $uid ) {
280
-		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
281
-	}
282
-
283
-	/**
284
-	 * Returns the session.
285
-	 *
286
-	 * @param string $customer_id Customer ID.
287
-	 * @param mixed  $default Default session value.
288
-	 * @return string|array
289
-	 */
290
-	public function get_session( $customer_id, $default = false ) {
291
-
292
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
293
-			return false;
294
-		}
248
+            $this->_dirty = false;
249
+        }
250
+    }
251
+
252
+    /**
253
+     * Destroy all session data.
254
+     */
255
+    public function destroy_session() {
256
+        $this->delete_session( $this->_customer_id );
257
+        $this->forget_session();
258
+    }
259
+
260
+    /**
261
+     * Forget all session data without destroying it.
262
+     */
263
+    public function forget_session() {
264
+        $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
265
+
266
+        wpinv_empty_cart();
267
+
268
+        $this->_data        = array();
269
+        $this->_dirty       = false;
270
+        $this->_customer_id = $this->generate_customer_id();
271
+    }
272
+
273
+    /**
274
+     * When a user is logged out, ensure they have a unique nonce by using the customer/session ID.
275
+     *
276
+     * @param int $uid User ID.
277
+     * @return string
278
+     */
279
+    public function nonce_user_logged_out( $uid ) {
280
+        return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
281
+    }
282
+
283
+    /**
284
+     * Returns the session.
285
+     *
286
+     * @param string $customer_id Customer ID.
287
+     * @param mixed  $default Default session value.
288
+     * @return string|array
289
+     */
290
+    public function get_session( $customer_id, $default = false ) {
291
+
292
+        if ( defined( 'WP_SETUP_CONFIG' ) ) {
293
+            return false;
294
+        }
295 295
 
296 296
         if ( !is_user_logged_in() ) {
297 297
             if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){
@@ -306,32 +306,32 @@  discard block
 block discarded – undo
306 306
             $value = $default;
307 307
         }
308 308
 
309
-		return maybe_unserialize( $value );
310
-	}
309
+        return maybe_unserialize( $value );
310
+    }
311 311
 
312
-	/**
313
-	 * Delete the session from the cache and database.
314
-	 *
315
-	 * @param int $customer_id Customer ID.
316
-	 */
317
-	public function delete_session( $customer_id ) {
312
+    /**
313
+     * Delete the session from the cache and database.
314
+     *
315
+     * @param int $customer_id Customer ID.
316
+     */
317
+    public function delete_session( $customer_id ) {
318 318
 
319 319
         $key = $this->generate_key($customer_id);
320 320
 
321
-		delete_transient($key);
322
-	}
321
+        delete_transient($key);
322
+    }
323 323
 
324
-	/**
325
-	 * Update the session expiry timestamp.
326
-	 *
327
-	 * @param string $customer_id Customer ID.
328
-	 * @param int    $timestamp Timestamp to expire the cookie.
329
-	 */
330
-	public function update_session_timestamp( $customer_id, $timestamp ) {
324
+    /**
325
+     * Update the session expiry timestamp.
326
+     *
327
+     * @param string $customer_id Customer ID.
328
+     * @param int    $timestamp Timestamp to expire the cookie.
329
+     */
330
+    public function update_session_timestamp( $customer_id, $timestamp ) {
331 331
 
332 332
         set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
333 333
 
334
-	}
334
+    }
335 335
 }
336 336
 
337 337
 global $wpi_session;
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * Session handler class.
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 	 */
53 53
 	public function __construct() {
54 54
 
55
-	    $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH );
56
-        add_action( 'init', array( $this, 'init' ), -1 );
55
+	    $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH);
56
+        add_action('init', array($this, 'init'), -1);
57 57
 	}
58 58
 
59 59
 	/**
@@ -64,12 +64,12 @@  discard block
 block discarded – undo
64 64
 	public function init() {
65 65
 		$this->init_session_cookie();
66 66
 
67
-		add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 );
68
-		add_action( 'shutdown', array( $this, 'save_data' ), 20 );
69
-		add_action( 'wp_logout', array( $this, 'destroy_session' ) );
67
+		add_action('wp', array($this, 'set_customer_session_cookie'), 10);
68
+		add_action('shutdown', array($this, 'save_data'), 20);
69
+		add_action('wp_logout', array($this, 'destroy_session'));
70 70
 
71
-		if ( ! is_user_logged_in() ) {
72
-			add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ) );
71
+		if (!is_user_logged_in()) {
72
+			add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'));
73 73
 		}
74 74
 	}
75 75
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	public function init_session_cookie() {
82 82
 		$cookie = $this->get_session_cookie();
83 83
 
84
-		if ( $cookie ) {
84
+		if ($cookie) {
85 85
 			$this->_customer_id        = $cookie[0];
86 86
 			$this->_session_expiration = $cookie[1];
87 87
 			$this->_session_expiring   = $cookie[2];
@@ -89,17 +89,17 @@  discard block
 block discarded – undo
89 89
 			$this->_data               = $this->get_session_data();
90 90
 
91 91
 			// If the user logs in, update session.
92
-			if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) {
92
+			if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) {
93 93
 				$this->_customer_id = get_current_user_id();
94 94
 				$this->_dirty       = true;
95 95
 				$this->save_data();
96
-				$this->set_customer_session_cookie( true );
96
+				$this->set_customer_session_cookie(true);
97 97
 			}
98 98
 
99 99
 			// Update session if its close to expiring.
100
-			if ( time() > $this->_session_expiring ) {
100
+			if (time() > $this->_session_expiring) {
101 101
 				$this->set_session_expiration();
102
-				$this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );
102
+				$this->update_session_timestamp($this->_customer_id, $this->_session_expiration);
103 103
 			}
104 104
 		} else {
105 105
 			$this->set_session_expiration();
@@ -117,25 +117,25 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param bool $set Should the session cookie be set.
119 119
 	 */
120
-	public function set_customer_session_cookie( $set ) {
121
-		if ( $set ) {
120
+	public function set_customer_session_cookie($set) {
121
+		if ($set) {
122 122
 			$to_hash           = $this->_customer_id . '|' . $this->_session_expiration;
123
-			$cookie_hash       = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
123
+			$cookie_hash       = hash_hmac('md5', $to_hash, wp_hash($to_hash));
124 124
 			$cookie_value      = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash;
125 125
 			$this->_has_cookie = true;
126 126
 
127
-			if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) {
128
-				$this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true );
127
+			if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) {
128
+				$this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true);
129 129
 			}
130 130
 		}
131 131
 	}
132 132
 
133
-	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){
134
-        if ( ! headers_sent() ) {
135
-            setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) );
136
-        } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
137
-            headers_sent( $file, $line );
138
-            trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine
133
+	public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) {
134
+        if (!headers_sent()) {
135
+            setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure));
136
+        } elseif (defined('WP_DEBUG') && WP_DEBUG) {
137
+            headers_sent($file, $line);
138
+            trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine
139 139
         }
140 140
     }
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @return bool
147 147
 	 */
148 148
 	protected function use_secure_cookie() {
149
-        $is_https = false !== strstr( get_option( 'home' ), 'https:' );
150
-		return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() );
149
+        $is_https = false !== strstr(get_option('home'), 'https:');
150
+		return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl());
151 151
 	}
152 152
 
153 153
 	/**
@@ -156,15 +156,15 @@  discard block
 block discarded – undo
156 156
 	 * @return bool
157 157
 	 */
158 158
 	public function has_session() {
159
-		return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
159
+		return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine.
160 160
 	}
161 161
 
162 162
 	/**
163 163
 	 * Set session expiration.
164 164
 	 */
165 165
 	public function set_session_expiration() {
166
-		$this->_session_expiring   = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours.
167
-		$this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours.
166
+		$this->_session_expiring   = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours.
167
+		$this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours.
168 168
 	}
169 169
 
170 170
 	/**
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	public function generate_customer_id() {
178 178
 		$customer_id = '';
179 179
 
180
-		if ( is_user_logged_in() ) {
180
+		if (is_user_logged_in()) {
181 181
 			$customer_id = get_current_user_id();
182 182
 		}
183 183
 
184
-		if ( empty( $customer_id ) ) {
184
+		if (empty($customer_id)) {
185 185
             $customer_id = wp_create_nonce('wpinv-session-customer-id');
186 186
 		}
187 187
 
@@ -196,27 +196,27 @@  discard block
 block discarded – undo
196 196
 	 * @return bool|array
197 197
 	 */
198 198
 	public function get_session_cookie() {
199
-		$cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine.
199
+		$cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine.
200 200
 
201
-		if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) {
201
+		if (empty($cookie_value) || !is_string($cookie_value)) {
202 202
 			return false;
203 203
 		}
204 204
 
205
-		list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value );
205
+		list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value);
206 206
 
207
-		if ( empty( $customer_id ) ) {
207
+		if (empty($customer_id)) {
208 208
 			return false;
209 209
 		}
210 210
 
211 211
 		// Validate hash.
212 212
 		$to_hash = $customer_id . '|' . $session_expiration;
213
-		$hash    = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) );
213
+		$hash    = hash_hmac('md5', $to_hash, wp_hash($to_hash));
214 214
 
215
-		if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) {
215
+		if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) {
216 216
 			return false;
217 217
 		}
218 218
 
219
-		return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash );
219
+		return array($customer_id, $session_expiration, $session_expiring, $cookie_hash);
220 220
 	}
221 221
 
222 222
 	/**
@@ -225,15 +225,15 @@  discard block
 block discarded – undo
225 225
 	 * @return array
226 226
 	 */
227 227
 	public function get_session_data() {
228
-		return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array();
228
+		return $this->has_session() ? (array)$this->get_session($this->_customer_id) : array();
229 229
 	}
230 230
 
231
-	public function generate_key($customer_id){
232
-        if(!$customer_id){
231
+	public function generate_key($customer_id) {
232
+        if (!$customer_id) {
233 233
             return;
234 234
         }
235 235
 
236
-        return 'wpi_trans_'.$customer_id;
236
+        return 'wpi_trans_' . $customer_id;
237 237
     }
238 238
 
239 239
 	/**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
 	 */
242 242
 	public function save_data() {
243 243
 		// Dirty if something changed - prevents saving nothing new.
244
-		if ( $this->_dirty && $this->has_session() ) {
244
+		if ($this->_dirty && $this->has_session()) {
245 245
 
246
-            set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
246
+            set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration);
247 247
 
248 248
 			$this->_dirty = false;
249 249
 		}
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * Destroy all session data.
254 254
 	 */
255 255
 	public function destroy_session() {
256
-		$this->delete_session( $this->_customer_id );
256
+		$this->delete_session($this->_customer_id);
257 257
 		$this->forget_session();
258 258
 	}
259 259
 
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 	 * Forget all session data without destroying it.
262 262
 	 */
263 263
 	public function forget_session() {
264
-		$this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true );
264
+		$this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true);
265 265
 
266 266
 		wpinv_empty_cart();
267 267
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @param int $uid User ID.
277 277
 	 * @return string
278 278
 	 */
279
-	public function nonce_user_logged_out( $uid ) {
279
+	public function nonce_user_logged_out($uid) {
280 280
 		return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid;
281 281
 	}
282 282
 
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
 	 * @param mixed  $default Default session value.
288 288
 	 * @return string|array
289 289
 	 */
290
-	public function get_session( $customer_id, $default = false ) {
290
+	public function get_session($customer_id, $default = false) {
291 291
 
292
-		if ( defined( 'WP_SETUP_CONFIG' ) ) {
292
+		if (defined('WP_SETUP_CONFIG')) {
293 293
 			return false;
294 294
 		}
295 295
 
296
-        if ( !is_user_logged_in() ) {
297
-            if(!wp_verify_nonce( $customer_id, 'wpinv-session-customer-id' )){
296
+        if (!is_user_logged_in()) {
297
+            if (!wp_verify_nonce($customer_id, 'wpinv-session-customer-id')) {
298 298
                 return array();
299 299
             }
300 300
         }
@@ -302,11 +302,11 @@  discard block
 block discarded – undo
302 302
         $key = $this->generate_key($customer_id);
303 303
         $value = get_transient($key);
304 304
 
305
-        if ( !$value ) {
305
+        if (!$value) {
306 306
             $value = $default;
307 307
         }
308 308
 
309
-		return maybe_unserialize( $value );
309
+		return maybe_unserialize($value);
310 310
 	}
311 311
 
312 312
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 *
315 315
 	 * @param int $customer_id Customer ID.
316 316
 	 */
317
-	public function delete_session( $customer_id ) {
317
+	public function delete_session($customer_id) {
318 318
 
319 319
         $key = $this->generate_key($customer_id);
320 320
 
@@ -327,9 +327,9 @@  discard block
 block discarded – undo
327 327
 	 * @param string $customer_id Customer ID.
328 328
 	 * @param int    $timestamp Timestamp to expire the cookie.
329 329
 	 */
330
-	public function update_session_timestamp( $customer_id, $timestamp ) {
330
+	public function update_session_timestamp($customer_id, $timestamp) {
331 331
 
332
-        set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp);
332
+        set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp);
333 333
 
334 334
 	}
335 335
 }
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +186 added lines, -186 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -31,31 +31,31 @@  discard block
 block discarded – undo
31 31
     }
32 32
     
33 33
     public function define_constants() {
34
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
35
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
34
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
35
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
36 36
     }
37 37
     
38 38
     private function actions() {
39 39
         /* Internationalize the text strings used. */
40
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
40
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
41 41
         
42 42
         /* Perform actions on admin initialization. */
43
-        add_action( 'admin_init', array( &$this, 'admin_init') );
44
-        add_action( 'init', array( &$this, 'init' ), 3 );
45
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
46
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
43
+        add_action('admin_init', array(&$this, 'admin_init'));
44
+        add_action('init', array(&$this, 'init'), 3);
45
+        add_action('init', array('WPInv_Shortcodes', 'init'));
46
+        add_action('init', array(&$this, 'wpinv_actions'));
47 47
         
48
-        if ( class_exists( 'BuddyPress' ) ) {
49
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
48
+        if (class_exists('BuddyPress')) {
49
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
50 50
         }
51 51
 
52
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
52
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
53 53
         
54
-        if ( is_admin() ) {
55
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
56
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
54
+        if (is_admin()) {
55
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
56
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
57 57
         } else {
58
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
58
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
59 59
         }
60 60
         
61 61
         /**
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
          *
66 66
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
67 67
          */
68
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
68
+        do_action_ref_array('wpinv_actions', array(&$this));
69 69
 
70
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
70
+        add_action('admin_init', array(&$this, 'activation_redirect'));
71 71
     }
72 72
     
73 73
     public function plugins_loaded() {
74 74
         /* Internationalize the text strings used. */
75 75
         $this->load_textdomain();
76 76
 
77
-        do_action( 'wpinv_loaded' );
77
+        do_action('wpinv_loaded');
78 78
     }
79 79
     
80 80
     /**
@@ -82,221 +82,221 @@  discard block
 block discarded – undo
82 82
      *
83 83
      * @since 1.0
84 84
      */
85
-    public function load_textdomain( $locale = NULL ) {
86
-        if ( empty( $locale ) ) {
87
-            $locale = is_admin() && function_exists( 'get_user_locale' ) ? get_user_locale() : get_locale();
85
+    public function load_textdomain($locale = NULL) {
86
+        if (empty($locale)) {
87
+            $locale = is_admin() && function_exists('get_user_locale') ? get_user_locale() : get_locale();
88 88
         }
89 89
 
90
-        $locale = apply_filters( 'plugin_locale', $locale, 'invoicing' );
90
+        $locale = apply_filters('plugin_locale', $locale, 'invoicing');
91 91
         
92
-        unload_textdomain( 'invoicing' );
93
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
94
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
92
+        unload_textdomain('invoicing');
93
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
94
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
95 95
         
96 96
         /**
97 97
          * Define language constants.
98 98
          */
99
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
99
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
100 100
     }
101 101
         
102 102
     public function includes() {
103 103
         global $wpinv_options;
104 104
         
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
106 106
         $wpinv_options = wpinv_get_settings();
107 107
         
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
118
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
119
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
121
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
129
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
130
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
131
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php' );
132
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
133
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
134
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
135
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php' );
136
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php' );
137
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php' );
138
-        require_once( WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php' );
139
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php' );
140
-        require_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php' );
141
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php' );
142
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-cardinal-commerce.php' );
143
-        require_once( WPINV_PLUGIN_DIR . 'vendor/autoload.php' );
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
118
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
119
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
121
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session-handler.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
129
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
130
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
131
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cache-helper.php');
132
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php');
133
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php');
134
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php');
135
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions.php');
136
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-subscription.php');
137
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-subscriptions-list-table.php');
138
+        require_once(WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-privacy.php');
139
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-privacy.php');
140
+        require_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-ayecode-addons.php');
141
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-addons.php');
142
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-cardinal-commerce.php');
143
+        require_once(WPINV_PLUGIN_DIR . 'vendor/autoload.php');
144 144
 
145
-        if ( !class_exists( 'WPInv_EUVat' ) ) {
146
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
145
+        if (!class_exists('WPInv_EUVat')) {
146
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
147 147
         }
148 148
         
149
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
150
-        if ( !empty( $gateways ) ) {
151
-            foreach ( $gateways as $gateway ) {
152
-                if ( $gateway == 'manual' ) {
149
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
150
+        if (!empty($gateways)) {
151
+            foreach ($gateways as $gateway) {
152
+                if ($gateway == 'manual') {
153 153
                     continue;
154 154
                 }
155 155
                 
156 156
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
157 157
                 
158
-                if ( file_exists( $gateway_file ) ) {
159
-                    require_once( $gateway_file );
158
+                if (file_exists($gateway_file)) {
159
+                    require_once($gateway_file);
160 160
                 }
161 161
             }
162 162
         }
163
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
163
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
164 164
         
165
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
166
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
167
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
168
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
165
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
166
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
167
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
168
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
169 169
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
170
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
171
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
172
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
173
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
174
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
175
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' );
176
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' );
170
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
171
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
172
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
173
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
174
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
175
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php');
176
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php');
177 177
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
178 178
             // load the user class only on the users.php page
179 179
             global $pagenow;
180
-            if($pagenow=='users.php'){
180
+            if ($pagenow == 'users.php') {
181 181
                 new WPInv_Admin_Users();
182 182
             }
183 183
         }
184 184
         
185 185
         // include css inliner
186
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
187
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
186
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
187
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
188 188
         }
189 189
         
190
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
190
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
191 191
     }
192 192
     
193 193
     public function init() {
194 194
     }
195 195
     
196 196
     public function admin_init() {
197
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
197
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
198 198
         }
199 199
         
200
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
200
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
201 201
     }
202 202
 
203 203
     public function activation_redirect() {
204 204
         // Bail if no activation redirect
205
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
205
+        if (!get_transient('_wpinv_activation_redirect')) {
206 206
             return;
207 207
         }
208 208
 
209 209
         // Delete the redirect transient
210
-        delete_transient( '_wpinv_activation_redirect' );
210
+        delete_transient('_wpinv_activation_redirect');
211 211
 
212 212
         // Bail if activating from network, or bulk
213
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
213
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
214 214
             return;
215 215
         }
216 216
 
217
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
217
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
218 218
         exit;
219 219
     }
220 220
     
221 221
     public function enqueue_scripts() {
222
-        $suffix       = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
222
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
223 223
         
224
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
225
-        wp_enqueue_style( 'wpinv_front_style' );
224
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
225
+        wp_enqueue_style('wpinv_front_style');
226 226
                
227 227
         // Register scripts
228
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
229
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ),  WPINV_VERSION );
228
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
229
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION);
230 230
 
231 231
         $localize                         = array();
232
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
233
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
232
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
233
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
234 234
         $localize['currency_symbol']      = wpinv_currency_symbol();
235 235
         $localize['currency_pos']         = wpinv_currency_position();
236 236
         $localize['thousand_sep']         = wpinv_thousands_separator();
237 237
         $localize['decimal_sep']          = wpinv_decimal_separator();
238 238
         $localize['decimals']             = wpinv_decimals();
239
-        $localize['txtComplete']          = __( 'Complete', 'invoicing' );
239
+        $localize['txtComplete']          = __('Complete', 'invoicing');
240 240
         $localize['UseTaxes']             = wpinv_use_taxes();
241
-        $localize['checkoutNonce']        = wp_create_nonce( 'wpinv_checkout_nonce' );
241
+        $localize['checkoutNonce']        = wp_create_nonce('wpinv_checkout_nonce');
242 242
 
243
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
243
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
244 244
         
245
-        wp_enqueue_script( 'jquery-blockui' );
245
+        wp_enqueue_script('jquery-blockui');
246 246
         $autofill_api = wpinv_get_option('address_autofill_api');
247 247
         $autofill_active = wpinv_get_option('address_autofill_active');
248
-        if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) {
249
-            if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) {
250
-                wp_dequeue_script( 'google-maps-api' );
248
+        if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) {
249
+            if (wp_script_is('google-maps-api', 'enqueued')) {
250
+                wp_dequeue_script('google-maps-api');
251 251
             }
252
-            wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false );
253
-            wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true );
252
+            wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false);
253
+            wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true);
254 254
         }
255 255
 
256
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
257
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
256
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
257
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
258 258
 
259
-        wp_enqueue_script( 'wpinv-front-script' );
260
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
259
+        wp_enqueue_script('wpinv-front-script');
260
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
261 261
     }
262 262
 
263 263
     public function admin_enqueue_scripts() {
264 264
         global $post, $pagenow;
265 265
         
266 266
         $post_type  = wpinv_admin_post_type();
267
-        $suffix     = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
268
-        $page       = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : '';
267
+        $suffix     = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
268
+        $page       = isset($_GET['page']) ? strtolower($_GET['page']) : '';
269 269
 
270 270
         $jquery_ui_css = false;
271
-        if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
271
+        if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
272 272
             $jquery_ui_css = true;
273
-        } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) {
273
+        } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') {
274 274
             $jquery_ui_css = true;
275 275
         }
276
-        if ( $jquery_ui_css ) {
277
-            wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
278
-            wp_enqueue_style( 'jquery-ui-css' );
276
+        if ($jquery_ui_css) {
277
+            wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
278
+            wp_enqueue_style('jquery-ui-css');
279 279
         }
280 280
 
281
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
282
-        wp_enqueue_style( 'wpinv_meta_box_style' );
281
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
282
+        wp_enqueue_style('wpinv_meta_box_style');
283 283
         
284
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
285
-        wp_enqueue_style( 'wpinv_admin_style' );
284
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
285
+        wp_enqueue_style('wpinv_admin_style');
286 286
 
287
-        $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) );
288
-        if ( $page == 'wpinv-subscriptions' ) {
289
-            wp_enqueue_script( 'jquery-ui-datepicker' );
287
+        $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php'));
288
+        if ($page == 'wpinv-subscriptions') {
289
+            wp_enqueue_script('jquery-ui-datepicker');
290 290
         }
291 291
         
292
-        if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) {
293
-            wp_enqueue_script( 'jquery-ui-datepicker' );
292
+        if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) {
293
+            wp_enqueue_script('jquery-ui-datepicker');
294 294
         }
295 295
 
296
-        wp_enqueue_style( 'wp-color-picker' );
297
-        wp_enqueue_script( 'wp-color-picker' );
296
+        wp_enqueue_style('wp-color-picker');
297
+        wp_enqueue_script('wp-color-picker');
298 298
         
299
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
299
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
300 300
 
301 301
         if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
302 302
             $autofill_api = wpinv_get_option('address_autofill_api');
@@ -307,20 +307,20 @@  discard block
 block discarded – undo
307 307
             }
308 308
         }
309 309
 
310
-        wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' );
311
-        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION );
310
+        wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all');
311
+        wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION);
312 312
 
313
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ),  WPINV_VERSION );
314
-        wp_enqueue_script( 'wpinv-admin-script' );
313
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION);
314
+        wp_enqueue_script('wpinv-admin-script');
315 315
         
316 316
         $localize                               = array();
317
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
318
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
319
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
320
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
321
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
322
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
323
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
317
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
318
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
319
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
320
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
321
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
322
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
323
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
324 324
         $localize['tax']                        = wpinv_tax_amount();
325 325
         $localize['discount']                   = wpinv_discount_amount();
326 326
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -328,69 +328,69 @@  discard block
 block discarded – undo
328 328
         $localize['thousand_sep']               = wpinv_thousands_separator();
329 329
         $localize['decimal_sep']                = wpinv_decimal_separator();
330 330
         $localize['decimals']                   = wpinv_decimals();
331
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
332
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
333
-        $localize['status_pending']             = wpinv_status_nicename( 'wpi-pending' );
334
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
335
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
336
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
337
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
338
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
339
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
340
-        $localize['emptyInvoice']               = __( 'Add at least one item to save invoice!', 'invoicing' );
341
-        $localize['errDeleteItem']              = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
342
-        $localize['delete_subscription']        = __( 'Are you sure you want to delete this subscription?', 'invoicing' );
343
-        $localize['action_edit']                = __( 'Edit', 'invoicing' );
344
-        $localize['action_cancel']              = __( 'Cancel', 'invoicing' );
331
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
332
+        $localize['status_publish']             = wpinv_status_nicename('publish');
333
+        $localize['status_pending']             = wpinv_status_nicename('wpi-pending');
334
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
335
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
336
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
337
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
338
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
339
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
340
+        $localize['emptyInvoice']               = __('Add at least one item to save invoice!', 'invoicing');
341
+        $localize['errDeleteItem']              = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
342
+        $localize['delete_subscription']        = __('Are you sure you want to delete this subscription?', 'invoicing');
343
+        $localize['action_edit']                = __('Edit', 'invoicing');
344
+        $localize['action_cancel']              = __('Cancel', 'invoicing');
345 345
 
346
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
346
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
347 347
 
348
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
348
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
349 349
 
350
-        if ( $page == 'wpinv-subscriptions' ) {
351
-            wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ),  WPINV_VERSION );
352
-            wp_enqueue_script( 'wpinv-sub-admin-script' );
350
+        if ($page == 'wpinv-subscriptions') {
351
+            wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION);
352
+            wp_enqueue_script('wpinv-sub-admin-script');
353 353
         }
354 354
     }
355 355
     
356
-    public function admin_body_class( $classes ) {
356
+    public function admin_body_class($classes) {
357 357
         global $pagenow, $post, $current_screen;
358 358
         
359
-        if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) {
359
+        if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) {
360 360
             $classes .= ' wpinv-cpt';
361 361
         }
362 362
         
363
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
363
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
364 364
 
365
-        $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false;
366
-        if ( $add_class ) {
367
-            $classes .= ' wpi-' . wpinv_sanitize_key( $page );
365
+        $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false;
366
+        if ($add_class) {
367
+            $classes .= ' wpi-' . wpinv_sanitize_key($page);
368 368
         }
369 369
         
370 370
         $settings_class = array();
371
-        if ( $page == 'wpinv-settings' ) {
372
-            if ( !empty( $_REQUEST['tab'] ) ) {
373
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
371
+        if ($page == 'wpinv-settings') {
372
+            if (!empty($_REQUEST['tab'])) {
373
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
374 374
             }
375 375
             
376
-            if ( !empty( $_REQUEST['section'] ) ) {
377
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
376
+            if (!empty($_REQUEST['section'])) {
377
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
378 378
             }
379 379
             
380
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
380
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
381 381
         }
382 382
         
383
-        if ( !empty( $settings_class ) ) {
384
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
383
+        if (!empty($settings_class)) {
384
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
385 385
         }
386 386
         
387 387
         $post_type = wpinv_admin_post_type();
388 388
 
389
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
389
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
390 390
             return $classes .= ' wpinv';
391 391
         }
392 392
         
393
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
393
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
394 394
             $classes .= ' wpi-editable-n';
395 395
         }
396 396
 
@@ -402,20 +402,20 @@  discard block
 block discarded – undo
402 402
     }
403 403
     
404 404
     public function wpinv_actions() {
405
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
406
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
405
+        if (isset($_REQUEST['wpi_action'])) {
406
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
407 407
         }
408 408
     }
409 409
     
410
-    public function pre_get_posts( $wp_query ) {
411
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
412
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
410
+    public function pre_get_posts($wp_query) {
411
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
412
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
413 413
         }
414 414
         
415 415
         return $wp_query;
416 416
     }
417 417
     
418 418
     public function bp_invoicing_init() {
419
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
419
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
420 420
     }
421 421
 }
422 422
\ No newline at end of file
Please login to merge, or discard this patch.
includes/abstracts/abstract-wpinv-privacy.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Abstract privacy class.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Abstract class that is intended to be extended by
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      *
39 39
      * @param string $name Plugin identifier.
40 40
      */
41
-    public function __construct( $name = '' ) {
41
+    public function __construct($name = '') {
42 42
         $this->name = $name;
43 43
         $this->init();
44 44
     }
@@ -47,22 +47,22 @@  discard block
 block discarded – undo
47 47
      * Hook in events.
48 48
      */
49 49
     protected function init() {
50
-        add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
50
+        add_action('admin_init', array($this, 'add_privacy_message'));
51 51
         // Register data exporters
52
-        add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
52
+        add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10);
53 53
         // Register data erasers
54
-        add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) );
54
+        add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'));
55 55
     }
56 56
 
57 57
     /**
58 58
      * Adds the privacy message on invoicing privacy page.
59 59
      */
60 60
     public function add_privacy_message() {
61
-        if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
61
+        if (function_exists('wp_add_privacy_policy_content')) {
62 62
             $content = $this->get_privacy_message();
63 63
 
64
-            if ( $content ) {
65
-                wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() );
64
+            if ($content) {
65
+                wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
66 66
             }
67 67
         }
68 68
     }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param array $exporters List of exporter callbacks.
84 84
      * @return array
85 85
      */
86
-    public function register_exporters( $exporters = array() ) {
87
-        foreach ( $this->exporters as $id => $exporter ) {
88
-            $exporters[ $id ] = $exporter;
86
+    public function register_exporters($exporters = array()) {
87
+        foreach ($this->exporters as $id => $exporter) {
88
+            $exporters[$id] = $exporter;
89 89
         }
90 90
         return $exporters;
91 91
     }
@@ -96,9 +96,9 @@  discard block
 block discarded – undo
96 96
      * @param array $erasers List of eraser callbacks.
97 97
      * @return array
98 98
      */
99
-    public function register_erasers( $erasers = array() ) {
100
-        foreach ( $this->erasers as $id => $eraser ) {
101
-            $erasers[ $id ] = $eraser;
99
+    public function register_erasers($erasers = array()) {
100
+        foreach ($this->erasers as $id => $eraser) {
101
+            $erasers[$id] = $eraser;
102 102
         }
103 103
         return $erasers;
104 104
     }
@@ -112,8 +112,8 @@  discard block
 block discarded – undo
112 112
      *
113 113
      * @return array
114 114
      */
115
-    public function add_exporter( $id, $name, $callback ) {
116
-        $this->exporters[ $id ] = array(
115
+    public function add_exporter($id, $name, $callback) {
116
+        $this->exporters[$id] = array(
117 117
             'exporter_friendly_name' => $name,
118 118
             'callback'               => $callback,
119 119
         );
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
      *
130 130
      * @return array
131 131
      */
132
-    public function add_eraser( $id, $name, $callback ) {
133
-        $this->erasers[ $id ] = array(
132
+    public function add_eraser($id, $name, $callback) {
133
+        $this->erasers[$id] = array(
134 134
             'eraser_friendly_name' => $name,
135 135
             'callback'             => $callback,
136 136
         );
Please login to merge, or discard this patch.
includes/abstracts/abstract-wpinv-session.php 2 patches
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  */
5 5
 
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 
10 10
 /**
@@ -12,112 +12,112 @@  discard block
 block discarded – undo
12 12
  */
13 13
 abstract class WPInv_Session {
14 14
 
15
-	/**
16
-	 * Customer ID.
17
-	 *
18
-	 * @var int $_customer_id Customer ID.
19
-	 */
20
-	protected $_customer_id;
15
+    /**
16
+     * Customer ID.
17
+     *
18
+     * @var int $_customer_id Customer ID.
19
+     */
20
+    protected $_customer_id;
21 21
 
22
-	/**
23
-	 * Session Data.
24
-	 *
25
-	 * @var array $_data Data array.
26
-	 */
27
-	protected $_data = array();
22
+    /**
23
+     * Session Data.
24
+     *
25
+     * @var array $_data Data array.
26
+     */
27
+    protected $_data = array();
28 28
 
29
-	/**
30
-	 * Dirty when the session needs saving.
31
-	 *
32
-	 * @var bool $_dirty When something changes
33
-	 */
34
-	protected $_dirty = false;
29
+    /**
30
+     * Dirty when the session needs saving.
31
+     *
32
+     * @var bool $_dirty When something changes
33
+     */
34
+    protected $_dirty = false;
35 35
 
36
-	/**
37
-	 * Init hooks and session data. Extended by child classes.
38
-	 *
39
-	 * @since 3.3.0
40
-	 */
41
-	public function init() {}
36
+    /**
37
+     * Init hooks and session data. Extended by child classes.
38
+     *
39
+     * @since 3.3.0
40
+     */
41
+    public function init() {}
42 42
 
43
-	/**
44
-	 * Cleanup session data. Extended by child classes.
45
-	 */
46
-	public function cleanup_sessions() {}
43
+    /**
44
+     * Cleanup session data. Extended by child classes.
45
+     */
46
+    public function cleanup_sessions() {}
47 47
 
48
-	/**
49
-	 * Magic get method.
50
-	 *
51
-	 * @param mixed $key Key to get.
52
-	 * @return mixed
53
-	 */
54
-	public function __get( $key ) {
55
-		return $this->get( $key );
56
-	}
48
+    /**
49
+     * Magic get method.
50
+     *
51
+     * @param mixed $key Key to get.
52
+     * @return mixed
53
+     */
54
+    public function __get( $key ) {
55
+        return $this->get( $key );
56
+    }
57 57
 
58
-	/**
59
-	 * Magic set method.
60
-	 *
61
-	 * @param mixed $key Key to set.
62
-	 * @param mixed $value Value to set.
63
-	 */
64
-	public function __set( $key, $value ) {
65
-		$this->set( $key, $value );
66
-	}
58
+    /**
59
+     * Magic set method.
60
+     *
61
+     * @param mixed $key Key to set.
62
+     * @param mixed $value Value to set.
63
+     */
64
+    public function __set( $key, $value ) {
65
+        $this->set( $key, $value );
66
+    }
67 67
 
68
-	/**
69
-	 * Magic isset method.
70
-	 *
71
-	 * @param mixed $key Key to check.
72
-	 * @return bool
73
-	 */
74
-	public function __isset( $key ) {
75
-		return isset( $this->_data[ sanitize_title( $key ) ] );
76
-	}
68
+    /**
69
+     * Magic isset method.
70
+     *
71
+     * @param mixed $key Key to check.
72
+     * @return bool
73
+     */
74
+    public function __isset( $key ) {
75
+        return isset( $this->_data[ sanitize_title( $key ) ] );
76
+    }
77 77
 
78
-	/**
79
-	 * Magic unset method.
80
-	 *
81
-	 * @param mixed $key Key to unset.
82
-	 */
83
-	public function __unset( $key ) {
84
-		if ( isset( $this->_data[ $key ] ) ) {
85
-			unset( $this->_data[ $key ] );
86
-			$this->_dirty = true;
87
-		}
88
-	}
78
+    /**
79
+     * Magic unset method.
80
+     *
81
+     * @param mixed $key Key to unset.
82
+     */
83
+    public function __unset( $key ) {
84
+        if ( isset( $this->_data[ $key ] ) ) {
85
+            unset( $this->_data[ $key ] );
86
+            $this->_dirty = true;
87
+        }
88
+    }
89 89
 
90
-	/**
91
-	 * Get a session variable.
92
-	 *
93
-	 * @param string $key Key to get.
94
-	 * @param mixed  $default used if the session variable isn't set.
95
-	 * @return array|string value of session variable
96
-	 */
97
-	public function get( $key, $default = null ) {
98
-		$key = sanitize_key( $key );
99
-		return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
100
-	}
90
+    /**
91
+     * Get a session variable.
92
+     *
93
+     * @param string $key Key to get.
94
+     * @param mixed  $default used if the session variable isn't set.
95
+     * @return array|string value of session variable
96
+     */
97
+    public function get( $key, $default = null ) {
98
+        $key = sanitize_key( $key );
99
+        return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
100
+    }
101 101
 
102
-	/**
103
-	 * Set a session variable.
104
-	 *
105
-	 * @param string $key Key to set.
106
-	 * @param mixed  $value Value to set.
107
-	 */
108
-	public function set( $key, $value ) {
109
-		if ( $value !== $this->get( $key ) ) {
110
-			$this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
111
-			$this->_dirty                        = true;
112
-		}
113
-	}
102
+    /**
103
+     * Set a session variable.
104
+     *
105
+     * @param string $key Key to set.
106
+     * @param mixed  $value Value to set.
107
+     */
108
+    public function set( $key, $value ) {
109
+        if ( $value !== $this->get( $key ) ) {
110
+            $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
111
+            $this->_dirty                        = true;
112
+        }
113
+    }
114 114
 
115
-	/**
116
-	 * Get customer ID.
117
-	 *
118
-	 * @return int
119
-	 */
120
-	public function get_customer_id() {
121
-		return $this->_customer_id;
122
-	}
115
+    /**
116
+     * Get customer ID.
117
+     *
118
+     * @return int
119
+     */
120
+    public function get_customer_id() {
121
+        return $this->_customer_id;
122
+    }
123 123
 }
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Handle data for the current customer session
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 	exit;
8 8
 }
9 9
 
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
 	 * @param mixed $key Key to get.
52 52
 	 * @return mixed
53 53
 	 */
54
-	public function __get( $key ) {
55
-		return $this->get( $key );
54
+	public function __get($key) {
55
+		return $this->get($key);
56 56
 	}
57 57
 
58 58
 	/**
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 	 * @param mixed $key Key to set.
62 62
 	 * @param mixed $value Value to set.
63 63
 	 */
64
-	public function __set( $key, $value ) {
65
-		$this->set( $key, $value );
64
+	public function __set($key, $value) {
65
+		$this->set($key, $value);
66 66
 	}
67 67
 
68 68
 	/**
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 * @param mixed $key Key to check.
72 72
 	 * @return bool
73 73
 	 */
74
-	public function __isset( $key ) {
75
-		return isset( $this->_data[ sanitize_title( $key ) ] );
74
+	public function __isset($key) {
75
+		return isset($this->_data[sanitize_title($key)]);
76 76
 	}
77 77
 
78 78
 	/**
@@ -80,9 +80,9 @@  discard block
 block discarded – undo
80 80
 	 *
81 81
 	 * @param mixed $key Key to unset.
82 82
 	 */
83
-	public function __unset( $key ) {
84
-		if ( isset( $this->_data[ $key ] ) ) {
85
-			unset( $this->_data[ $key ] );
83
+	public function __unset($key) {
84
+		if (isset($this->_data[$key])) {
85
+			unset($this->_data[$key]);
86 86
 			$this->_dirty = true;
87 87
 		}
88 88
 	}
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 * @param mixed  $default used if the session variable isn't set.
95 95
 	 * @return array|string value of session variable
96 96
 	 */
97
-	public function get( $key, $default = null ) {
98
-		$key = sanitize_key( $key );
99
-		return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default;
97
+	public function get($key, $default = null) {
98
+		$key = sanitize_key($key);
99
+		return isset($this->_data[$key]) ? maybe_unserialize($this->_data[$key]) : $default;
100 100
 	}
101 101
 
102 102
 	/**
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 	 * @param string $key Key to set.
106 106
 	 * @param mixed  $value Value to set.
107 107
 	 */
108
-	public function set( $key, $value ) {
109
-		if ( $value !== $this->get( $key ) ) {
110
-			$this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value );
108
+	public function set($key, $value) {
109
+		if ($value !== $this->get($key)) {
110
+			$this->_data[sanitize_key($key)] = maybe_serialize($value);
111 111
 			$this->_dirty                        = true;
112 112
 		}
113 113
 	}
Please login to merge, or discard this patch.