@@ -4,7 +4,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | 12 | <h1><?php echo get_admin_page_title(); ?></h1> |
13 | 13 | |
14 | - <?php if ( $tabs ){ ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if($current_tab == 'membership'){ |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,12 +32,12 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if(defined('WP_EASY_UPDATES_ACTIVE')){?> |
|
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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> |
@@ -134,7 +134,7 @@ discard block |
||
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 |
||
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 | } |
@@ -130,6 +130,10 @@ discard block |
||
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 |
||
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; |
@@ -12,125 +12,125 @@ discard block |
||
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 int 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 int 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 |
||
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 |
||
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 array(); |
|
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 array(); |
|
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 |
||
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; |
@@ -5,7 +5,7 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 array(); |
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 |
||
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 |
||
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 |
||
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 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Abstract privacy class. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Abstract class that is intended to be extended by |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param string $name Plugin identifier. |
40 | 40 | */ |
41 | - public function __construct( $name = '' ) { |
|
41 | + public function __construct($name = '') { |
|
42 | 42 | $this->name = $name; |
43 | 43 | $this->init(); |
44 | 44 | } |
@@ -47,22 +47,22 @@ discard block |
||
47 | 47 | * Hook in events. |
48 | 48 | */ |
49 | 49 | protected function init() { |
50 | - add_action( 'admin_init', array( $this, 'add_privacy_message' ) ); |
|
50 | + add_action('admin_init', array($this, 'add_privacy_message')); |
|
51 | 51 | // Register data exporters |
52 | - add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 ); |
|
52 | + add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), 10); |
|
53 | 53 | // Register data erasers |
54 | - add_filter( 'wp_privacy_personal_data_erasers', array( $this, 'register_erasers' ) ); |
|
54 | + add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers')); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | /** |
58 | 58 | * Adds the privacy message on invoicing privacy page. |
59 | 59 | */ |
60 | 60 | public function add_privacy_message() { |
61 | - if ( function_exists( 'wp_add_privacy_policy_content' ) ) { |
|
61 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
62 | 62 | $content = $this->get_privacy_message(); |
63 | 63 | |
64 | - if ( $content ) { |
|
65 | - wp_add_privacy_policy_content( $this->name, $this->get_privacy_message() ); |
|
64 | + if ($content) { |
|
65 | + wp_add_privacy_policy_content($this->name, $this->get_privacy_message()); |
|
66 | 66 | } |
67 | 67 | } |
68 | 68 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param array $exporters List of exporter callbacks. |
84 | 84 | * @return array |
85 | 85 | */ |
86 | - public function register_exporters( $exporters = array() ) { |
|
87 | - foreach ( $this->exporters as $id => $exporter ) { |
|
88 | - $exporters[ $id ] = $exporter; |
|
86 | + public function register_exporters($exporters = array()) { |
|
87 | + foreach ($this->exporters as $id => $exporter) { |
|
88 | + $exporters[$id] = $exporter; |
|
89 | 89 | } |
90 | 90 | return $exporters; |
91 | 91 | } |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * @param array $erasers List of eraser callbacks. |
97 | 97 | * @return array |
98 | 98 | */ |
99 | - public function register_erasers( $erasers = array() ) { |
|
100 | - foreach ( $this->erasers as $id => $eraser ) { |
|
101 | - $erasers[ $id ] = $eraser; |
|
99 | + public function register_erasers($erasers = array()) { |
|
100 | + foreach ($this->erasers as $id => $eraser) { |
|
101 | + $erasers[$id] = $eraser; |
|
102 | 102 | } |
103 | 103 | return $erasers; |
104 | 104 | } |
@@ -112,8 +112,8 @@ discard block |
||
112 | 112 | * |
113 | 113 | * @return array |
114 | 114 | */ |
115 | - public function add_exporter( $id, $name, $callback ) { |
|
116 | - $this->exporters[ $id ] = array( |
|
115 | + public function add_exporter($id, $name, $callback) { |
|
116 | + $this->exporters[$id] = array( |
|
117 | 117 | 'exporter_friendly_name' => $name, |
118 | 118 | 'callback' => $callback, |
119 | 119 | ); |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function add_eraser( $id, $name, $callback ) { |
|
133 | - $this->erasers[ $id ] = array( |
|
132 | + public function add_eraser($id, $name, $callback) { |
|
133 | + $this->erasers[$id] = array( |
|
134 | 134 | 'eraser_friendly_name' => $name, |
135 | 135 | 'callback' => $callback, |
136 | 136 | ); |
@@ -4,7 +4,7 @@ discard block |
||
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 |
||
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 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Handle data for the current customer session |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * @param mixed $key Key to get. |
52 | 52 | * @return mixed |
53 | 53 | */ |
54 | - public function __get( $key ) { |
|
55 | - return $this->get( $key ); |
|
54 | + public function __get($key) { |
|
55 | + return $this->get($key); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param mixed $key Key to set. |
62 | 62 | * @param mixed $value Value to set. |
63 | 63 | */ |
64 | - public function __set( $key, $value ) { |
|
65 | - $this->set( $key, $value ); |
|
64 | + public function __set($key, $value) { |
|
65 | + $this->set($key, $value); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | * @param mixed $key Key to check. |
72 | 72 | * @return bool |
73 | 73 | */ |
74 | - public function __isset( $key ) { |
|
75 | - return isset( $this->_data[ sanitize_title( $key ) ] ); |
|
74 | + public function __isset($key) { |
|
75 | + return isset($this->_data[sanitize_title($key)]); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @param mixed $key Key to unset. |
82 | 82 | */ |
83 | - public function __unset( $key ) { |
|
84 | - if ( isset( $this->_data[ $key ] ) ) { |
|
85 | - unset( $this->_data[ $key ] ); |
|
83 | + public function __unset($key) { |
|
84 | + if (isset($this->_data[$key])) { |
|
85 | + unset($this->_data[$key]); |
|
86 | 86 | $this->_dirty = true; |
87 | 87 | } |
88 | 88 | } |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param mixed $default used if the session variable isn't set. |
95 | 95 | * @return array|string value of session variable |
96 | 96 | */ |
97 | - public function get( $key, $default = null ) { |
|
98 | - $key = sanitize_key( $key ); |
|
99 | - return isset( $this->_data[ $key ] ) ? maybe_unserialize( $this->_data[ $key ] ) : $default; |
|
97 | + public function get($key, $default = null) { |
|
98 | + $key = sanitize_key($key); |
|
99 | + return isset($this->_data[$key]) ? maybe_unserialize($this->_data[$key]) : $default; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param string $key Key to set. |
106 | 106 | * @param mixed $value Value to set. |
107 | 107 | */ |
108 | - public function set( $key, $value ) { |
|
109 | - if ( $value !== $this->get( $key ) ) { |
|
110 | - $this->_data[ sanitize_key( $key ) ] = maybe_serialize( $value ); |
|
108 | + public function set($key, $value) { |
|
109 | + if ($value !== $this->get($key)) { |
|
110 | + $this->_data[sanitize_key($key)] = maybe_serialize($value); |
|
111 | 111 | $this->_dirty = true; |
112 | 112 | } |
113 | 113 | } |
@@ -7,15 +7,15 @@ discard block |
||
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 |
||
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 |
||
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,220 +82,220 @@ discard block |
||
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 . '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 . 'vendor/autoload.php'); |
|
143 | 143 | |
144 | - if ( !class_exists( 'WPInv_EUVat' ) ) { |
|
145 | - require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' ); |
|
144 | + if (!class_exists('WPInv_EUVat')) { |
|
145 | + require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php'); |
|
146 | 146 | } |
147 | 147 | |
148 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
149 | - if ( !empty( $gateways ) ) { |
|
150 | - foreach ( $gateways as $gateway ) { |
|
151 | - if ( $gateway == 'manual' ) { |
|
148 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
149 | + if (!empty($gateways)) { |
|
150 | + foreach ($gateways as $gateway) { |
|
151 | + if ($gateway == 'manual') { |
|
152 | 152 | continue; |
153 | 153 | } |
154 | 154 | |
155 | 155 | $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php'; |
156 | 156 | |
157 | - if ( file_exists( $gateway_file ) ) { |
|
158 | - require_once( $gateway_file ); |
|
157 | + if (file_exists($gateway_file)) { |
|
158 | + require_once($gateway_file); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |
162 | - require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' ); |
|
162 | + require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php'); |
|
163 | 163 | |
164 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
165 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' ); |
|
166 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' ); |
|
167 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' ); |
|
164 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
165 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php'); |
|
166 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'); |
|
167 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php'); |
|
168 | 168 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' ); |
169 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' ); |
|
170 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' ); |
|
171 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' ); |
|
172 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' ); |
|
173 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' ); |
|
174 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php' ); |
|
175 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php' ); |
|
169 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php'); |
|
170 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php'); |
|
171 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php'); |
|
172 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php'); |
|
173 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'); |
|
174 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-admin-menus.php'); |
|
175 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-users.php'); |
|
176 | 176 | //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' ); |
177 | 177 | // load the user class only on the users.php page |
178 | 178 | global $pagenow; |
179 | - if($pagenow=='users.php'){ |
|
179 | + if ($pagenow == 'users.php') { |
|
180 | 180 | new WPInv_Admin_Users(); |
181 | 181 | } |
182 | 182 | } |
183 | 183 | |
184 | 184 | // include css inliner |
185 | - if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) { |
|
186 | - include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' ); |
|
185 | + if (!class_exists('Emogrifier') && class_exists('DOMDocument')) { |
|
186 | + include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php'); |
|
187 | 187 | } |
188 | 188 | |
189 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' ); |
|
189 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php'); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | public function init() { |
193 | 193 | } |
194 | 194 | |
195 | 195 | public function admin_init() { |
196 | - if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) { |
|
196 | + if (!(defined('DOING_AJAX') && DOING_AJAX)) { |
|
197 | 197 | } |
198 | 198 | |
199 | - add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) ); |
|
199 | + add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php')); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | public function activation_redirect() { |
203 | 203 | // Bail if no activation redirect |
204 | - if ( !get_transient( '_wpinv_activation_redirect' ) ) { |
|
204 | + if (!get_transient('_wpinv_activation_redirect')) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
208 | 208 | // Delete the redirect transient |
209 | - delete_transient( '_wpinv_activation_redirect' ); |
|
209 | + delete_transient('_wpinv_activation_redirect'); |
|
210 | 210 | |
211 | 211 | // Bail if activating from network, or bulk |
212 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
212 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
213 | 213 | return; |
214 | 214 | } |
215 | 215 | |
216 | - wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) ); |
|
216 | + wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general')); |
|
217 | 217 | exit; |
218 | 218 | } |
219 | 219 | |
220 | 220 | public function enqueue_scripts() { |
221 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
221 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
222 | 222 | |
223 | - wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION ); |
|
224 | - wp_enqueue_style( 'wpinv_front_style' ); |
|
223 | + wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION); |
|
224 | + wp_enqueue_style('wpinv_front_style'); |
|
225 | 225 | |
226 | 226 | // Register scripts |
227 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
228 | - wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array( 'jquery' ), WPINV_VERSION ); |
|
227 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
228 | + wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front.js', array('jquery'), WPINV_VERSION); |
|
229 | 229 | |
230 | 230 | $localize = array(); |
231 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
232 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
231 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
232 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
233 | 233 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
234 | 234 | $localize['currency_pos'] = wpinv_currency_position(); |
235 | 235 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
236 | 236 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
237 | 237 | $localize['decimals'] = wpinv_decimals(); |
238 | - $localize['txtComplete'] = __( 'Complete', 'invoicing' ); |
|
238 | + $localize['txtComplete'] = __('Complete', 'invoicing'); |
|
239 | 239 | $localize['UseTaxes'] = wpinv_use_taxes(); |
240 | - $localize['checkoutNonce'] = wp_create_nonce( 'wpinv_checkout_nonce' ); |
|
240 | + $localize['checkoutNonce'] = wp_create_nonce('wpinv_checkout_nonce'); |
|
241 | 241 | |
242 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
242 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
243 | 243 | |
244 | - wp_enqueue_script( 'jquery-blockui' ); |
|
244 | + wp_enqueue_script('jquery-blockui'); |
|
245 | 245 | $autofill_api = wpinv_get_option('address_autofill_api'); |
246 | 246 | $autofill_active = wpinv_get_option('address_autofill_active'); |
247 | - if ( isset( $autofill_active ) && 1 == $autofill_active && !empty( $autofill_api ) && wpinv_is_checkout() ) { |
|
248 | - if ( wp_script_is( 'google-maps-api', 'enqueued' ) ) { |
|
249 | - wp_dequeue_script( 'google-maps-api' ); |
|
247 | + if (isset($autofill_active) && 1 == $autofill_active && !empty($autofill_api) && wpinv_is_checkout()) { |
|
248 | + if (wp_script_is('google-maps-api', 'enqueued')) { |
|
249 | + wp_dequeue_script('google-maps-api'); |
|
250 | 250 | } |
251 | - wp_enqueue_script( 'google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array( 'jquery' ), '', false ); |
|
252 | - wp_enqueue_script( 'google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array( 'jquery', 'google-maps-api' ), '', true ); |
|
251 | + wp_enqueue_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=' . $autofill_api . '&libraries=places', array('jquery'), '', false); |
|
252 | + wp_enqueue_script('google-maps-init', WPINV_PLUGIN_URL . 'assets/js/gaaf.js', array('jquery', 'google-maps-api'), '', true); |
|
253 | 253 | } |
254 | 254 | |
255 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
256 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
255 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
256 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
257 | 257 | |
258 | - wp_enqueue_script( 'wpinv-front-script' ); |
|
259 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
258 | + wp_enqueue_script('wpinv-front-script'); |
|
259 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | public function admin_enqueue_scripts() { |
263 | 263 | global $post, $pagenow; |
264 | 264 | |
265 | 265 | $post_type = wpinv_admin_post_type(); |
266 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
267 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : ''; |
|
266 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
267 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : ''; |
|
268 | 268 | |
269 | 269 | $jquery_ui_css = false; |
270 | - if ( ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount' ) && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) { |
|
270 | + if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $post_type == 'wpi_discount') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
|
271 | 271 | $jquery_ui_css = true; |
272 | - } else if ( $page == 'wpinv-settings' || $page == 'wpinv-reports' ) { |
|
272 | + } else if ($page == 'wpinv-settings' || $page == 'wpinv-reports') { |
|
273 | 273 | $jquery_ui_css = true; |
274 | 274 | } |
275 | - if ( $jquery_ui_css ) { |
|
276 | - wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' ); |
|
277 | - wp_enqueue_style( 'jquery-ui-css' ); |
|
275 | + if ($jquery_ui_css) { |
|
276 | + wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16'); |
|
277 | + wp_enqueue_style('jquery-ui-css'); |
|
278 | 278 | } |
279 | 279 | |
280 | - wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION ); |
|
281 | - wp_enqueue_style( 'wpinv_meta_box_style' ); |
|
280 | + wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION); |
|
281 | + wp_enqueue_style('wpinv_meta_box_style'); |
|
282 | 282 | |
283 | - wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION ); |
|
284 | - wp_enqueue_style( 'wpinv_admin_style' ); |
|
283 | + wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION); |
|
284 | + wp_enqueue_style('wpinv_admin_style'); |
|
285 | 285 | |
286 | - $enqueue = ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ); |
|
287 | - if ( $page == 'wpinv-subscriptions' ) { |
|
288 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
286 | + $enqueue = ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')); |
|
287 | + if ($page == 'wpinv-subscriptions') { |
|
288 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
289 | 289 | } |
290 | 290 | |
291 | - if ( $enqueue_datepicker = apply_filters( 'wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue ) ) { |
|
292 | - wp_enqueue_script( 'jquery-ui-datepicker' ); |
|
291 | + if ($enqueue_datepicker = apply_filters('wpinv_admin_enqueue_jquery_ui_datepicker', $enqueue)) { |
|
292 | + wp_enqueue_script('jquery-ui-datepicker'); |
|
293 | 293 | } |
294 | 294 | |
295 | - wp_enqueue_style( 'wp-color-picker' ); |
|
296 | - wp_enqueue_script( 'wp-color-picker' ); |
|
295 | + wp_enqueue_style('wp-color-picker'); |
|
296 | + wp_enqueue_script('wp-color-picker'); |
|
297 | 297 | |
298 | - wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true ); |
|
298 | + wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true); |
|
299 | 299 | |
300 | 300 | if (($post_type == 'wpi_invoice' || $post_type == 'wpi_quote') && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) { |
301 | 301 | $autofill_api = wpinv_get_option('address_autofill_api'); |
@@ -306,20 +306,20 @@ discard block |
||
306 | 306 | } |
307 | 307 | } |
308 | 308 | |
309 | - wp_enqueue_style( "select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all' ); |
|
310 | - wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array( 'jquery' ), WPINV_VERSION ); |
|
309 | + wp_enqueue_style("select2", WPINV_PLUGIN_URL . 'assets/css/select2/select2.css', array(), WPINV_VERSION, 'all'); |
|
310 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full' . $suffix . '.js', array('jquery'), WPINV_VERSION); |
|
311 | 311 | |
312 | - wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'jquery-blockui','jquery-ui-tooltip' ), WPINV_VERSION ); |
|
313 | - wp_enqueue_script( 'wpinv-admin-script' ); |
|
312 | + wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'jquery-blockui', 'jquery-ui-tooltip'), WPINV_VERSION); |
|
313 | + wp_enqueue_script('wpinv-admin-script'); |
|
314 | 314 | |
315 | 315 | $localize = array(); |
316 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
317 | - $localize['post_ID'] = isset( $post->ID ) ? $post->ID : ''; |
|
318 | - $localize['wpinv_nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
319 | - $localize['add_invoice_note_nonce'] = wp_create_nonce( 'add-invoice-note' ); |
|
320 | - $localize['delete_invoice_note_nonce'] = wp_create_nonce( 'delete-invoice-note' ); |
|
321 | - $localize['invoice_item_nonce'] = wp_create_nonce( 'invoice-item' ); |
|
322 | - $localize['billing_details_nonce'] = wp_create_nonce( 'get-billing-details' ); |
|
316 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
317 | + $localize['post_ID'] = isset($post->ID) ? $post->ID : ''; |
|
318 | + $localize['wpinv_nonce'] = wp_create_nonce('wpinv-nonce'); |
|
319 | + $localize['add_invoice_note_nonce'] = wp_create_nonce('add-invoice-note'); |
|
320 | + $localize['delete_invoice_note_nonce'] = wp_create_nonce('delete-invoice-note'); |
|
321 | + $localize['invoice_item_nonce'] = wp_create_nonce('invoice-item'); |
|
322 | + $localize['billing_details_nonce'] = wp_create_nonce('get-billing-details'); |
|
323 | 323 | $localize['tax'] = wpinv_tax_amount(); |
324 | 324 | $localize['discount'] = wpinv_discount_amount(); |
325 | 325 | $localize['currency_symbol'] = wpinv_currency_symbol(); |
@@ -327,69 +327,69 @@ discard block |
||
327 | 327 | $localize['thousand_sep'] = wpinv_thousands_separator(); |
328 | 328 | $localize['decimal_sep'] = wpinv_decimal_separator(); |
329 | 329 | $localize['decimals'] = wpinv_decimals(); |
330 | - $localize['save_invoice'] = __( 'Save Invoice', 'invoicing' ); |
|
331 | - $localize['status_publish'] = wpinv_status_nicename( 'publish' ); |
|
332 | - $localize['status_pending'] = wpinv_status_nicename( 'wpi-pending' ); |
|
333 | - $localize['delete_tax_rate'] = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ); |
|
334 | - $localize['OneItemMin'] = __( 'Invoice must contain at least one item', 'invoicing' ); |
|
335 | - $localize['DeleteInvoiceItem'] = __( 'Are you sure you wish to delete this item?', 'invoicing' ); |
|
336 | - $localize['FillBillingDetails'] = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ); |
|
337 | - $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' ); |
|
338 | - $localize['AreYouSure'] = __( 'Are you sure?', 'invoicing' ); |
|
339 | - $localize['emptyInvoice'] = __( 'Add at least one item to save invoice!', 'invoicing' ); |
|
340 | - $localize['errDeleteItem'] = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ); |
|
341 | - $localize['delete_subscription'] = __( 'Are you sure you want to delete this subscription?', 'invoicing' ); |
|
342 | - $localize['action_edit'] = __( 'Edit', 'invoicing' ); |
|
343 | - $localize['action_cancel'] = __( 'Cancel', 'invoicing' ); |
|
330 | + $localize['save_invoice'] = __('Save Invoice', 'invoicing'); |
|
331 | + $localize['status_publish'] = wpinv_status_nicename('publish'); |
|
332 | + $localize['status_pending'] = wpinv_status_nicename('wpi-pending'); |
|
333 | + $localize['delete_tax_rate'] = __('Are you sure you wish to delete this tax rate?', 'invoicing'); |
|
334 | + $localize['OneItemMin'] = __('Invoice must contain at least one item', 'invoicing'); |
|
335 | + $localize['DeleteInvoiceItem'] = __('Are you sure you wish to delete this item?', 'invoicing'); |
|
336 | + $localize['FillBillingDetails'] = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'); |
|
337 | + $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'); |
|
338 | + $localize['AreYouSure'] = __('Are you sure?', 'invoicing'); |
|
339 | + $localize['emptyInvoice'] = __('Add at least one item to save invoice!', 'invoicing'); |
|
340 | + $localize['errDeleteItem'] = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'); |
|
341 | + $localize['delete_subscription'] = __('Are you sure you want to delete this subscription?', 'invoicing'); |
|
342 | + $localize['action_edit'] = __('Edit', 'invoicing'); |
|
343 | + $localize['action_cancel'] = __('Cancel', 'invoicing'); |
|
344 | 344 | |
345 | - $localize = apply_filters( 'wpinv_admin_js_localize', $localize ); |
|
345 | + $localize = apply_filters('wpinv_admin_js_localize', $localize); |
|
346 | 346 | |
347 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize ); |
|
347 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize); |
|
348 | 348 | |
349 | - if ( $page == 'wpinv-subscriptions' ) { |
|
350 | - wp_register_script( 'wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array( 'wpinv-admin-script' ), WPINV_VERSION ); |
|
351 | - wp_enqueue_script( 'wpinv-sub-admin-script' ); |
|
349 | + if ($page == 'wpinv-subscriptions') { |
|
350 | + wp_register_script('wpinv-sub-admin-script', WPINV_PLUGIN_URL . 'assets/js/subscriptions.js', array('wpinv-admin-script'), WPINV_VERSION); |
|
351 | + wp_enqueue_script('wpinv-sub-admin-script'); |
|
352 | 352 | } |
353 | 353 | } |
354 | 354 | |
355 | - public function admin_body_class( $classes ) { |
|
355 | + public function admin_body_class($classes) { |
|
356 | 356 | global $pagenow, $post, $current_screen; |
357 | 357 | |
358 | - if ( !empty( $current_screen->post_type ) && ( $current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote' ) ) { |
|
358 | + if (!empty($current_screen->post_type) && ($current_screen->post_type == 'wpi_invoice' || $current_screen->post_type == 'wpi_quote')) { |
|
359 | 359 | $classes .= ' wpinv-cpt'; |
360 | 360 | } |
361 | 361 | |
362 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
362 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
363 | 363 | |
364 | - $add_class = $page && $pagenow == 'admin.php' && strpos( $page, 'wpinv-' ) === 0 ? true : false; |
|
365 | - if ( $add_class ) { |
|
366 | - $classes .= ' wpi-' . wpinv_sanitize_key( $page ); |
|
364 | + $add_class = $page && $pagenow == 'admin.php' && strpos($page, 'wpinv-') === 0 ? true : false; |
|
365 | + if ($add_class) { |
|
366 | + $classes .= ' wpi-' . wpinv_sanitize_key($page); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | $settings_class = array(); |
370 | - if ( $page == 'wpinv-settings' ) { |
|
371 | - if ( !empty( $_REQUEST['tab'] ) ) { |
|
372 | - $settings_class[] = sanitize_text_field( $_REQUEST['tab'] ); |
|
370 | + if ($page == 'wpinv-settings') { |
|
371 | + if (!empty($_REQUEST['tab'])) { |
|
372 | + $settings_class[] = sanitize_text_field($_REQUEST['tab']); |
|
373 | 373 | } |
374 | 374 | |
375 | - if ( !empty( $_REQUEST['section'] ) ) { |
|
376 | - $settings_class[] = sanitize_text_field( $_REQUEST['section'] ); |
|
375 | + if (!empty($_REQUEST['section'])) { |
|
376 | + $settings_class[] = sanitize_text_field($_REQUEST['section']); |
|
377 | 377 | } |
378 | 378 | |
379 | - $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main'; |
|
379 | + $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main'; |
|
380 | 380 | } |
381 | 381 | |
382 | - if ( !empty( $settings_class ) ) { |
|
383 | - $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) ); |
|
382 | + if (!empty($settings_class)) { |
|
383 | + $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-')); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $post_type = wpinv_admin_post_type(); |
387 | 387 | |
388 | - if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) { |
|
388 | + if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) { |
|
389 | 389 | return $classes .= ' wpinv'; |
390 | 390 | } |
391 | 391 | |
392 | - if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) { |
|
392 | + if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) { |
|
393 | 393 | $classes .= ' wpi-editable-n'; |
394 | 394 | } |
395 | 395 | |
@@ -401,20 +401,20 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | public function wpinv_actions() { |
404 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
405 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
404 | + if (isset($_REQUEST['wpi_action'])) { |
|
405 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
409 | - public function pre_get_posts( $wp_query ) { |
|
410 | - 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() ) { |
|
411 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() ); |
|
409 | + public function pre_get_posts($wp_query) { |
|
410 | + 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()) { |
|
411 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses()); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | return $wp_query; |
415 | 415 | } |
416 | 416 | |
417 | 417 | public function bp_invoicing_init() { |
418 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' ); |
|
418 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php'); |
|
419 | 419 | } |
420 | 420 | } |
421 | 421 | \ No newline at end of file |