@@ -45,8 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | if($section_id=='recommended_plugins'){ |
47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
48 | - } |
|
49 | - elseif ( ! empty( $section ) ) { |
|
48 | + } elseif ( ! empty( $section ) ) { |
|
50 | 49 | if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
51 | 50 | //if ( 1==1) { |
52 | 51 | |
@@ -119,14 +118,14 @@ discard block |
||
119 | 118 | $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
120 | 119 | $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
121 | 120 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
122 | - }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
121 | + } elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
123 | 122 | include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
124 | 123 | if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
125 | 124 | $status = self::install_plugin_install_status($addon); |
126 | 125 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
127 | 126 | if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
128 | 127 | $button_args['update_url'] = "https://wpinvoicing.com"; |
129 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
128 | + } elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
130 | 129 | if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
131 | 130 | $button_args['installed'] = self::is_theme_installed($addon); |
132 | 131 | if(!in_array($button_args['slug'],$wp_org_themes)){ |
@@ -139,7 +138,7 @@ discard block |
||
139 | 138 | if(is_object($addon->pricing)){ |
140 | 139 | $prices = (Array)$addon->pricing; |
141 | 140 | $button_args['price'] = reset($prices); |
142 | - }elseif(isset($addon->pricing)){ |
|
141 | + } elseif(isset($addon->pricing)){ |
|
143 | 142 | $button_args['price'] = $addon->pricing; |
144 | 143 | } |
145 | 144 | } |
@@ -160,7 +159,7 @@ discard block |
||
160 | 159 | if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
161 | 160 | if($button_args['type'] != 'themes'){ |
162 | 161 | $button_args['active'] = is_plugin_active($button_args['file']); |
163 | - }else{ |
|
162 | + } else{ |
|
164 | 163 | $button_args['active'] = self::is_theme_active($addon); |
165 | 164 | } |
166 | 165 | } |
@@ -169,27 +168,27 @@ discard block |
||
169 | 168 | if($button_args['active']){ |
170 | 169 | $button_args['button_text'] = __('Active','invoicing'); |
171 | 170 | $button_args['class'] = ' button-secondary disabled '; |
172 | - }elseif($button_args['installed']){ |
|
171 | + } elseif($button_args['installed']){ |
|
173 | 172 | $button_args['button_text'] = __('Activate','invoicing'); |
174 | 173 | |
175 | 174 | if($button_args['type'] != 'themes'){ |
176 | 175 | if ( current_user_can( 'manage_options' ) ) { |
177 | 176 | $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
178 | - }else{ |
|
177 | + } else{ |
|
179 | 178 | $button_args['url'] = '#'; |
180 | 179 | } |
181 | - }else{ |
|
180 | + } else{ |
|
182 | 181 | if ( current_user_can( 'switch_themes' ) ) { |
183 | 182 | $button_args['url'] = self::get_theme_activation_url($addon); |
184 | - }else{ |
|
183 | + } else{ |
|
185 | 184 | $button_args['url'] = '#'; |
186 | 185 | } |
187 | 186 | } |
188 | 187 | |
189 | - }else{ |
|
188 | + } else{ |
|
190 | 189 | if($button_args['type'] == 'recommended_plugins'){ |
191 | 190 | $button_args['button_text'] = __('Install','invoicing'); |
192 | - }else{ |
|
191 | + } else{ |
|
193 | 192 | $button_args['button_text'] = __('Get it','invoicing'); |
194 | 193 | |
195 | 194 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | if ( ! defined( 'ABSPATH' ) ) { |
9 | - exit; |
|
9 | + exit; |
|
10 | 10 | } |
11 | 11 | |
12 | 12 | /** |
@@ -15,85 +15,85 @@ discard block |
||
15 | 15 | class WPInv_Admin_Addons extends Ayecode_Addons { |
16 | 16 | |
17 | 17 | |
18 | - /** |
|
19 | - * Get the extensions page tabs. |
|
20 | - * |
|
21 | - * @return array of tabs. |
|
22 | - */ |
|
23 | - public function get_tabs(){ |
|
24 | - $tabs = array( |
|
25 | - 'addons' => __("Addons", "invoicing"), |
|
18 | + /** |
|
19 | + * Get the extensions page tabs. |
|
20 | + * |
|
21 | + * @return array of tabs. |
|
22 | + */ |
|
23 | + public function get_tabs(){ |
|
24 | + $tabs = array( |
|
25 | + 'addons' => __("Addons", "invoicing"), |
|
26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
27 | 27 | 'recommended_plugins' => __("Recommended plugins", "invoicing"), |
28 | 28 | 'membership' => __("Membership", "invoicing"), |
29 | - ); |
|
30 | - |
|
31 | - return $tabs; |
|
32 | - } |
|
33 | - |
|
34 | - /** |
|
35 | - * Get section content for the addons screen. |
|
36 | - * |
|
37 | - * @param string $section_id |
|
38 | - * |
|
39 | - * @return array |
|
40 | - */ |
|
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
43 | - $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
44 | - $section_data = new stdClass(); |
|
45 | - |
|
46 | - if($section_id=='recommended_plugins'){ |
|
47 | - $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | - } |
|
49 | - elseif ( ! empty( $section ) ) { |
|
50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
51 | - //if ( 1==1) { |
|
52 | - |
|
53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
55 | - |
|
56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
57 | - |
|
58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
60 | - |
|
61 | - if ( ! empty( $section_data->products ) ) { |
|
62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
63 | - } |
|
64 | - } |
|
65 | - } |
|
66 | - |
|
67 | - } |
|
68 | - |
|
69 | - $products = isset($section_data->products) ? $section_data->products : array(); |
|
70 | - if ( 'addons' == $section_id ) { |
|
71 | - |
|
72 | - $quotes = new stdClass(); |
|
73 | - $quotes->info = new stdClass(); |
|
74 | - $quotes->info->id = ''; |
|
75 | - $quotes->info->slug = 'invoicing-quotes'; |
|
76 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
77 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
78 | - $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
79 | - $quotes->info->thumbnail = 'https://wpgetpaid.com/wp-content/uploads/sites/13/edd/2019/11/Quotes-1-768x384.png'; |
|
80 | - |
|
81 | - $products[] = $quotes; |
|
82 | - } |
|
29 | + ); |
|
30 | + |
|
31 | + return $tabs; |
|
32 | + } |
|
33 | + |
|
34 | + /** |
|
35 | + * Get section content for the addons screen. |
|
36 | + * |
|
37 | + * @param string $section_id |
|
38 | + * |
|
39 | + * @return array |
|
40 | + */ |
|
41 | + public function get_section_data( $section_id ) { |
|
42 | + $section = self::get_tab( $section_id ); |
|
43 | + $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
|
44 | + $section_data = new stdClass(); |
|
45 | + |
|
46 | + if($section_id=='recommended_plugins'){ |
|
47 | + $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
|
48 | + } |
|
49 | + elseif ( ! empty( $section ) ) { |
|
50 | + if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
51 | + //if ( 1==1) { |
|
52 | + |
|
53 | + $query_args = array( 'category' => $section_id, 'number' => 100); |
|
54 | + $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
55 | + |
|
56 | + $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
57 | + |
|
58 | + if ( ! is_wp_error( $raw_section ) ) { |
|
59 | + $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
60 | + |
|
61 | + if ( ! empty( $section_data->products ) ) { |
|
62 | + set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
63 | + } |
|
64 | + } |
|
65 | + } |
|
66 | + |
|
67 | + } |
|
68 | + |
|
69 | + $products = isset($section_data->products) ? $section_data->products : array(); |
|
70 | + if ( 'addons' == $section_id ) { |
|
71 | + |
|
72 | + $quotes = new stdClass(); |
|
73 | + $quotes->info = new stdClass(); |
|
74 | + $quotes->info->id = ''; |
|
75 | + $quotes->info->slug = 'invoicing-quotes'; |
|
76 | + $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
77 | + $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
78 | + $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
|
79 | + $quotes->info->thumbnail = 'https://wpgetpaid.com/wp-content/uploads/sites/13/edd/2019/11/Quotes-1-768x384.png'; |
|
80 | + |
|
81 | + $products[] = $quotes; |
|
82 | + } |
|
83 | 83 | |
84 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Outputs a button. |
|
89 | - *ccc |
|
90 | - * @param string $url |
|
91 | - * @param string $text |
|
92 | - * @param string $theme |
|
93 | - * @param string $plugin |
|
94 | - */ |
|
95 | - public function output_button( $addon ) { |
|
96 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
84 | + return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Outputs a button. |
|
89 | + *ccc |
|
90 | + * @param string $url |
|
91 | + * @param string $text |
|
92 | + * @param string $theme |
|
93 | + * @param string $plugin |
|
94 | + */ |
|
95 | + public function output_button( $addon ) { |
|
96 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
97 | 97 | // $button_text = __('Free','invoicing'); |
98 | 98 | // $licensing = false; |
99 | 99 | // $installed = false; |
@@ -105,123 +105,123 @@ discard block |
||
105 | 105 | // $install_status = 'get'; |
106 | 106 | // $onclick = ''; |
107 | 107 | |
108 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
109 | - |
|
110 | - $button_args = array( |
|
111 | - 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
112 | - 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
113 | - 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
114 | - 'button_text' => __('Free','invoicing'), |
|
115 | - 'price_text' => __('Free','invoicing'), |
|
116 | - 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
117 | - 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
118 | - 'class' => 'button-primary', |
|
119 | - 'install_status' => 'get', |
|
120 | - 'installed' => false, |
|
121 | - 'price' => '', |
|
122 | - 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
123 | - 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
124 | - 'onclick' => '', |
|
125 | - 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
126 | - 'active' => false, |
|
127 | - 'file' => '', |
|
128 | - 'update_url' => '', |
|
129 | - ); |
|
130 | - |
|
131 | - if( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){ |
|
132 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
133 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
134 | - $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
135 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
136 | - }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
137 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
138 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
139 | - $status = self::install_plugin_install_status($addon); |
|
140 | - $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
141 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
142 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
143 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
144 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
145 | - $button_args['installed'] = self::is_theme_installed($addon); |
|
146 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
147 | - $button_args['update_url'] = "https://wpinvoicing.com"; |
|
148 | - } |
|
149 | - } |
|
150 | - |
|
151 | - // set price |
|
152 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
153 | - if(is_object($addon->pricing)){ |
|
154 | - $prices = (Array)$addon->pricing; |
|
155 | - $button_args['price'] = reset($prices); |
|
156 | - }elseif(isset($addon->pricing)){ |
|
157 | - $button_args['price'] = $addon->pricing; |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - // set price text |
|
162 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
163 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - // set if installed |
|
168 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
169 | - $button_args['installed'] = true; |
|
170 | - } |
|
108 | + $wp_org_themes = array('supreme-directory','directory-starter'); |
|
109 | + |
|
110 | + $button_args = array( |
|
111 | + 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
112 | + 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
|
113 | + 'title' => isset($addon->info->title) ? $addon->info->title : '', |
|
114 | + 'button_text' => __('Free','invoicing'), |
|
115 | + 'price_text' => __('Free','invoicing'), |
|
116 | + 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
|
117 | + 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
|
118 | + 'class' => 'button-primary', |
|
119 | + 'install_status' => 'get', |
|
120 | + 'installed' => false, |
|
121 | + 'price' => '', |
|
122 | + 'licensing' => isset($addon->licensing->enabled) && $addon->licensing->enabled ? true : false, |
|
123 | + 'license' => isset($addon->licensing->license) && $addon->licensing->license ? $addon->licensing->license : '', |
|
124 | + 'onclick' => '', |
|
125 | + 'slug' => isset($addon->info->slug) ? $addon->info->slug : '', |
|
126 | + 'active' => false, |
|
127 | + 'file' => '', |
|
128 | + 'update_url' => '', |
|
129 | + ); |
|
130 | + |
|
131 | + if( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){ |
|
132 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
133 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
134 | + $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
|
135 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
136 | + }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
137 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
138 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
139 | + $status = self::install_plugin_install_status($addon); |
|
140 | + $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
|
141 | + if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
142 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
143 | + }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
144 | + if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
145 | + $button_args['installed'] = self::is_theme_installed($addon); |
|
146 | + if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
147 | + $button_args['update_url'] = "https://wpinvoicing.com"; |
|
148 | + } |
|
149 | + } |
|
150 | + |
|
151 | + // set price |
|
152 | + if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
153 | + if(is_object($addon->pricing)){ |
|
154 | + $prices = (Array)$addon->pricing; |
|
155 | + $button_args['price'] = reset($prices); |
|
156 | + }elseif(isset($addon->pricing)){ |
|
157 | + $button_args['price'] = $addon->pricing; |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + // set price text |
|
162 | + if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
163 | + $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + // set if installed |
|
168 | + if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
169 | + $button_args['installed'] = true; |
|
170 | + } |
|
171 | 171 | |
172 | 172 | // print_r($button_args); |
173 | - // set if active |
|
174 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
175 | - if($button_args['type'] != 'themes'){ |
|
176 | - $button_args['active'] = is_plugin_active($button_args['file']); |
|
177 | - }else{ |
|
178 | - $button_args['active'] = self::is_theme_active($addon); |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - // set button text and class |
|
183 | - if($button_args['active']){ |
|
184 | - $button_args['button_text'] = __('Active','invoicing'); |
|
185 | - $button_args['class'] = ' button-secondary disabled '; |
|
186 | - }elseif($button_args['installed']){ |
|
187 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
188 | - |
|
189 | - if($button_args['type'] != 'themes'){ |
|
190 | - if ( current_user_can( 'manage_options' ) ) { |
|
191 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
192 | - }else{ |
|
193 | - $button_args['url'] = '#'; |
|
194 | - } |
|
195 | - }else{ |
|
196 | - if ( current_user_can( 'switch_themes' ) ) { |
|
197 | - $button_args['url'] = self::get_theme_activation_url($addon); |
|
198 | - }else{ |
|
199 | - $button_args['url'] = '#'; |
|
200 | - } |
|
201 | - } |
|
202 | - |
|
203 | - }else{ |
|
204 | - if($button_args['type'] == 'recommended_plugins'){ |
|
205 | - $button_args['button_text'] = __('Install','invoicing'); |
|
206 | - }else{ |
|
207 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
208 | - |
|
209 | - /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
173 | + // set if active |
|
174 | + if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
175 | + if($button_args['type'] != 'themes'){ |
|
176 | + $button_args['active'] = is_plugin_active($button_args['file']); |
|
177 | + }else{ |
|
178 | + $button_args['active'] = self::is_theme_active($addon); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + // set button text and class |
|
183 | + if($button_args['active']){ |
|
184 | + $button_args['button_text'] = __('Active','invoicing'); |
|
185 | + $button_args['class'] = ' button-secondary disabled '; |
|
186 | + }elseif($button_args['installed']){ |
|
187 | + $button_args['button_text'] = __('Activate','invoicing'); |
|
188 | + |
|
189 | + if($button_args['type'] != 'themes'){ |
|
190 | + if ( current_user_can( 'manage_options' ) ) { |
|
191 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
192 | + }else{ |
|
193 | + $button_args['url'] = '#'; |
|
194 | + } |
|
195 | + }else{ |
|
196 | + if ( current_user_can( 'switch_themes' ) ) { |
|
197 | + $button_args['url'] = self::get_theme_activation_url($addon); |
|
198 | + }else{ |
|
199 | + $button_args['url'] = '#'; |
|
200 | + } |
|
201 | + } |
|
202 | + |
|
203 | + }else{ |
|
204 | + if($button_args['type'] == 'recommended_plugins'){ |
|
205 | + $button_args['button_text'] = __('Install','invoicing'); |
|
206 | + }else{ |
|
207 | + $button_args['button_text'] = __('Get it','invoicing'); |
|
208 | + |
|
209 | + /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
|
210 | 210 | $button_args['button_text'] = __('Install','invoicing'); |
211 | 211 | $button_args['url'] = self::get_theme_install_url($button_args['slug']); |
212 | 212 | $button_args['onclick'] = 'gd_set_button_installing(this);'; |
213 | 213 | }*/ |
214 | 214 | |
215 | - } |
|
216 | - } |
|
215 | + } |
|
216 | + } |
|
217 | 217 | |
218 | 218 | |
219 | - // filter the button arguments |
|
220 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
219 | + // filter the button arguments |
|
220 | + $button_args = apply_filters('edd_api_button_args',$button_args); |
|
221 | 221 | // print_r($button_args); |
222 | - // set price text |
|
223 | - if(isset($button_args['price_text'])){ |
|
224 | - ?> |
|
222 | + // set price text |
|
223 | + if(isset($button_args['price_text'])){ |
|
224 | + ?> |
|
225 | 225 | <a |
226 | 226 | target="_blank" |
227 | 227 | class="addons-price-text" |
@@ -229,15 +229,15 @@ discard block |
||
229 | 229 | <?php echo esc_html( $button_args['price_text'] ); ?> |
230 | 230 | </a> |
231 | 231 | <?php |
232 | - } |
|
232 | + } |
|
233 | 233 | |
234 | 234 | |
235 | - $target = ''; |
|
236 | - if ( ! empty( $button_args['url'] ) ) { |
|
237 | - $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
238 | - } |
|
235 | + $target = ''; |
|
236 | + if ( ! empty( $button_args['url'] ) ) { |
|
237 | + $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
|
238 | + } |
|
239 | 239 | |
240 | - ?> |
|
240 | + ?> |
|
241 | 241 | <a |
242 | 242 | data-licence="<?php echo esc_attr($button_args['license']);?>" |
243 | 243 | data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
@@ -260,33 +260,33 @@ discard block |
||
260 | 260 | <?php |
261 | 261 | |
262 | 262 | |
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * Handles output of the addons page in admin. |
|
268 | - */ |
|
269 | - public function output() { |
|
270 | - $tabs = self::get_tabs(); |
|
271 | - $sections = self::get_sections(); |
|
272 | - $theme = wp_get_theme(); |
|
273 | - $section_keys = array_keys( $sections ); |
|
274 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
275 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
276 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
277 | - } |
|
278 | - |
|
279 | - /** |
|
280 | - * A list of recommended wp.org plugins. |
|
281 | - * @return array |
|
282 | - */ |
|
283 | - public function get_recommend_wp_plugins(){ |
|
284 | - $plugins = array( |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * Handles output of the addons page in admin. |
|
268 | + */ |
|
269 | + public function output() { |
|
270 | + $tabs = self::get_tabs(); |
|
271 | + $sections = self::get_sections(); |
|
272 | + $theme = wp_get_theme(); |
|
273 | + $section_keys = array_keys( $sections ); |
|
274 | + $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
275 | + $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
276 | + include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
277 | + } |
|
278 | + |
|
279 | + /** |
|
280 | + * A list of recommended wp.org plugins. |
|
281 | + * @return array |
|
282 | + */ |
|
283 | + public function get_recommend_wp_plugins(){ |
|
284 | + $plugins = array( |
|
285 | 285 | 'invoicing-quotes' => array( |
286 | 286 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
287 | 287 | 'slug' => 'invoicing-quotes', |
288 | - 'name' => 'Quotes', |
|
289 | - 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
288 | + 'name' => 'Quotes', |
|
289 | + 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
|
290 | 290 | 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'), |
291 | 291 | ), |
292 | 292 | 'geodirectory' => array( |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | 'name' => 'UsersWP', |
302 | 302 | 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
303 | 303 | ), |
304 | - ); |
|
304 | + ); |
|
305 | 305 | |
306 | - return $plugins; |
|
307 | - } |
|
306 | + return $plugins; |
|
307 | + } |
|
308 | 308 | } |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * All Invoicing extensions screen related functions can be found here. |
6 | 6 | * |
7 | 7 | */ |
8 | -if ( ! defined( 'ABSPATH' ) ) { |
|
8 | +if (!defined('ABSPATH')) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | 11 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @return array of tabs. |
22 | 22 | */ |
23 | - public function get_tabs(){ |
|
23 | + public function get_tabs() { |
|
24 | 24 | $tabs = array( |
25 | 25 | 'addons' => __("Addons", "invoicing"), |
26 | 26 | 'gateways' => __("Payment Gateways", "invoicing"), |
@@ -38,28 +38,28 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_section_data( $section_id ) { |
|
42 | - $section = self::get_tab( $section_id ); |
|
41 | + public function get_section_data($section_id) { |
|
42 | + $section = self::get_tab($section_id); |
|
43 | 43 | $api_url = "https://wpinvoicing.com/edd-api/v2/products/"; |
44 | 44 | $section_data = new stdClass(); |
45 | 45 | |
46 | - if($section_id=='recommended_plugins'){ |
|
46 | + if ($section_id == 'recommended_plugins') { |
|
47 | 47 | $section_data->products = self::get_recommend_wp_plugins_edd_formatted(); |
48 | 48 | } |
49 | - elseif ( ! empty( $section ) ) { |
|
50 | - if ( false === ( $section_data = get_transient( 'wpi_addons_section_' . $section_id ) ) ) { //@todo restore after testing |
|
49 | + elseif (!empty($section)) { |
|
50 | + if (false === ($section_data = get_transient('wpi_addons_section_' . $section_id))) { //@todo restore after testing |
|
51 | 51 | //if ( 1==1) { |
52 | 52 | |
53 | - $query_args = array( 'category' => $section_id, 'number' => 100); |
|
54 | - $query_args = apply_filters('wpeu_edd_api_query_args',$query_args,$api_url,$section_id); |
|
53 | + $query_args = array('category' => $section_id, 'number' => 100); |
|
54 | + $query_args = apply_filters('wpeu_edd_api_query_args', $query_args, $api_url, $section_id); |
|
55 | 55 | |
56 | - $raw_section = wp_safe_remote_get( esc_url_raw( add_query_arg($query_args ,$api_url) ), array( 'user-agent' => 'Invoicing Addons Page','timeout' => 15, ) ); |
|
56 | + $raw_section = wp_safe_remote_get(esc_url_raw(add_query_arg($query_args, $api_url)), array('user-agent' => 'Invoicing Addons Page', 'timeout' => 15,)); |
|
57 | 57 | |
58 | - if ( ! is_wp_error( $raw_section ) ) { |
|
59 | - $section_data = json_decode( wp_remote_retrieve_body( $raw_section ) ); |
|
58 | + if (!is_wp_error($raw_section)) { |
|
59 | + $section_data = json_decode(wp_remote_retrieve_body($raw_section)); |
|
60 | 60 | |
61 | - if ( ! empty( $section_data->products ) ) { |
|
62 | - set_transient( 'wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS ); |
|
61 | + if (!empty($section_data->products)) { |
|
62 | + set_transient('wpi_addons_section_' . $section_id, $section_data, DAY_IN_SECONDS); |
|
63 | 63 | } |
64 | 64 | } |
65 | 65 | } |
@@ -67,21 +67,21 @@ discard block |
||
67 | 67 | } |
68 | 68 | |
69 | 69 | $products = isset($section_data->products) ? $section_data->products : array(); |
70 | - if ( 'addons' == $section_id ) { |
|
70 | + if ('addons' == $section_id) { |
|
71 | 71 | |
72 | 72 | $quotes = new stdClass(); |
73 | 73 | $quotes->info = new stdClass(); |
74 | 74 | $quotes->info->id = ''; |
75 | 75 | $quotes->info->slug = 'invoicing-quotes'; |
76 | - $quotes->info->title = __( 'Quotes', 'invoicing' ); |
|
77 | - $quotes->info->excerpt = __( 'Create quotes and estimates', 'invoicing' ); |
|
76 | + $quotes->info->title = __('Quotes', 'invoicing'); |
|
77 | + $quotes->info->excerpt = __('Create quotes and estimates', 'invoicing'); |
|
78 | 78 | $quotes->info->link = 'https://wordpress.org/plugins/invoicing-quotes/'; |
79 | 79 | $quotes->info->thumbnail = 'https://wpgetpaid.com/wp-content/uploads/sites/13/edd/2019/11/Quotes-1-768x384.png'; |
80 | 80 | |
81 | 81 | $products[] = $quotes; |
82 | 82 | } |
83 | 83 | |
84 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
84 | + return apply_filters('wpi_addons_section_data', $products, $section_id); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -92,8 +92,8 @@ discard block |
||
92 | 92 | * @param string $theme |
93 | 93 | * @param string $plugin |
94 | 94 | */ |
95 | - public function output_button( $addon ) { |
|
96 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
95 | + public function output_button($addon) { |
|
96 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
97 | 97 | // $button_text = __('Free','invoicing'); |
98 | 98 | // $licensing = false; |
99 | 99 | // $installed = false; |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | // $install_status = 'get'; |
106 | 106 | // $onclick = ''; |
107 | 107 | |
108 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
108 | + $wp_org_themes = array('supreme-directory', 'directory-starter'); |
|
109 | 109 | |
110 | 110 | $button_args = array( |
111 | - 'type' => ($current_tab == 'addons' || $current_tab =='gateways') ? 'addons' : $current_tab, |
|
111 | + 'type' => ($current_tab == 'addons' || $current_tab == 'gateways') ? 'addons' : $current_tab, |
|
112 | 112 | 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
113 | 113 | 'title' => isset($addon->info->title) ? $addon->info->title : '', |
114 | - 'button_text' => __('Free','invoicing'), |
|
115 | - 'price_text' => __('Free','invoicing'), |
|
114 | + 'button_text' => __('Free', 'invoicing'), |
|
115 | + 'price_text' => __('Free', 'invoicing'), |
|
116 | 116 | 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
117 | 117 | 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
118 | 118 | 'class' => 'button-primary', |
@@ -128,83 +128,83 @@ discard block |
||
128 | 128 | 'update_url' => '', |
129 | 129 | ); |
130 | 130 | |
131 | - if( 'invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ( $current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug )){ |
|
132 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
133 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
131 | + if ('invoicing-quotes' == $addon->info->slug || 'getpaid-stripe-payments' == $addon->info->slug || ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug)) { |
|
132 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
133 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>"")); |
|
134 | 134 | $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
135 | 135 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
136 | - }elseif( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
137 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
138 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
136 | + }elseif (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) { |
|
137 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
138 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
139 | 139 | $status = self::install_plugin_install_status($addon); |
140 | 140 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
141 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
141 | + if (isset($status['status'])) {$button_args['install_status'] = $status['status']; } |
|
142 | 142 | $button_args['update_url'] = "https://wpinvoicing.com"; |
143 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
144 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
143 | + }elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
144 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
145 | 145 | $button_args['installed'] = self::is_theme_installed($addon); |
146 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
146 | + if (!in_array($button_args['slug'], $wp_org_themes)) { |
|
147 | 147 | $button_args['update_url'] = "https://wpinvoicing.com"; |
148 | 148 | } |
149 | 149 | } |
150 | 150 | |
151 | 151 | // set price |
152 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
153 | - if(is_object($addon->pricing)){ |
|
154 | - $prices = (Array)$addon->pricing; |
|
152 | + if (isset($addon->pricing) && !empty($addon->pricing)) { |
|
153 | + if (is_object($addon->pricing)) { |
|
154 | + $prices = (Array) $addon->pricing; |
|
155 | 155 | $button_args['price'] = reset($prices); |
156 | - }elseif(isset($addon->pricing)){ |
|
156 | + }elseif (isset($addon->pricing)) { |
|
157 | 157 | $button_args['price'] = $addon->pricing; |
158 | 158 | } |
159 | 159 | } |
160 | 160 | |
161 | 161 | // set price text |
162 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
163 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
162 | + if ($button_args['price'] && $button_args['price'] != '0.00') { |
|
163 | + $button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | |
167 | 167 | // set if installed |
168 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
168 | + if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) { |
|
169 | 169 | $button_args['installed'] = true; |
170 | 170 | } |
171 | 171 | |
172 | 172 | // print_r($button_args); |
173 | 173 | // set if active |
174 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
175 | - if($button_args['type'] != 'themes'){ |
|
174 | + if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) { |
|
175 | + if ($button_args['type'] != 'themes') { |
|
176 | 176 | $button_args['active'] = is_plugin_active($button_args['file']); |
177 | - }else{ |
|
177 | + } else { |
|
178 | 178 | $button_args['active'] = self::is_theme_active($addon); |
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | // set button text and class |
183 | - if($button_args['active']){ |
|
184 | - $button_args['button_text'] = __('Active','invoicing'); |
|
183 | + if ($button_args['active']) { |
|
184 | + $button_args['button_text'] = __('Active', 'invoicing'); |
|
185 | 185 | $button_args['class'] = ' button-secondary disabled '; |
186 | - }elseif($button_args['installed']){ |
|
187 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
186 | + }elseif ($button_args['installed']) { |
|
187 | + $button_args['button_text'] = __('Activate', 'invoicing'); |
|
188 | 188 | |
189 | - if($button_args['type'] != 'themes'){ |
|
190 | - if ( current_user_can( 'manage_options' ) ) { |
|
191 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
192 | - }else{ |
|
189 | + if ($button_args['type'] != 'themes') { |
|
190 | + if (current_user_can('manage_options')) { |
|
191 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
192 | + } else { |
|
193 | 193 | $button_args['url'] = '#'; |
194 | 194 | } |
195 | - }else{ |
|
196 | - if ( current_user_can( 'switch_themes' ) ) { |
|
195 | + } else { |
|
196 | + if (current_user_can('switch_themes')) { |
|
197 | 197 | $button_args['url'] = self::get_theme_activation_url($addon); |
198 | - }else{ |
|
198 | + } else { |
|
199 | 199 | $button_args['url'] = '#'; |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - }else{ |
|
204 | - if($button_args['type'] == 'recommended_plugins'){ |
|
205 | - $button_args['button_text'] = __('Install','invoicing'); |
|
206 | - }else{ |
|
207 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
203 | + } else { |
|
204 | + if ($button_args['type'] == 'recommended_plugins') { |
|
205 | + $button_args['button_text'] = __('Install', 'invoicing'); |
|
206 | + } else { |
|
207 | + $button_args['button_text'] = __('Get it', 'invoicing'); |
|
208 | 208 | |
209 | 209 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
210 | 210 | $button_args['button_text'] = __('Install','invoicing'); |
@@ -217,45 +217,45 @@ discard block |
||
217 | 217 | |
218 | 218 | |
219 | 219 | // filter the button arguments |
220 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
220 | + $button_args = apply_filters('edd_api_button_args', $button_args); |
|
221 | 221 | // print_r($button_args); |
222 | 222 | // set price text |
223 | - if(isset($button_args['price_text'])){ |
|
223 | + if (isset($button_args['price_text'])) { |
|
224 | 224 | ?> |
225 | 225 | <a |
226 | 226 | target="_blank" |
227 | 227 | class="addons-price-text" |
228 | - href="<?php echo esc_url( $button_args['link'] ); ?>"> |
|
229 | - <?php echo esc_html( $button_args['price_text'] ); ?> |
|
228 | + href="<?php echo esc_url($button_args['link']); ?>"> |
|
229 | + <?php echo esc_html($button_args['price_text']); ?> |
|
230 | 230 | </a> |
231 | 231 | <?php |
232 | 232 | } |
233 | 233 | |
234 | 234 | |
235 | 235 | $target = ''; |
236 | - if ( ! empty( $button_args['url'] ) ) { |
|
236 | + if (!empty($button_args['url'])) { |
|
237 | 237 | $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
238 | 238 | } |
239 | 239 | |
240 | 240 | ?> |
241 | 241 | <a |
242 | - data-licence="<?php echo esc_attr($button_args['license']);?>" |
|
243 | - data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
|
244 | - data-title="<?php echo esc_attr($button_args['title']);?>" |
|
245 | - data-type="<?php echo esc_attr($button_args['type']);?>" |
|
246 | - data-text-error-message="<?php _e('Something went wrong!','invoicing');?>" |
|
247 | - data-text-activate="<?php _e('Activate','invoicing');?>" |
|
248 | - data-text-activating="<?php _e('Activating','invoicing');?>" |
|
249 | - data-text-deactivate="<?php _e('Deactivate','invoicing');?>" |
|
250 | - data-text-installed="<?php _e('Installed','invoicing');?>" |
|
251 | - data-text-install="<?php _e('Install','invoicing');?>" |
|
252 | - data-text-installing="<?php _e('Installing','invoicing');?>" |
|
253 | - data-text-error="<?php _e('Error','invoicing');?>" |
|
254 | - <?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?> |
|
255 | - <?php echo $target;?> |
|
256 | - class="addons-button <?php echo esc_attr( $button_args['class'] ); ?>" |
|
257 | - href="<?php echo esc_url( $button_args['url'] ); ?>"> |
|
258 | - <?php echo esc_html( $button_args['button_text'] ); ?> |
|
242 | + data-licence="<?php echo esc_attr($button_args['license']); ?>" |
|
243 | + data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
|
244 | + data-title="<?php echo esc_attr($button_args['title']); ?>" |
|
245 | + data-type="<?php echo esc_attr($button_args['type']); ?>" |
|
246 | + data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>" |
|
247 | + data-text-activate="<?php _e('Activate', 'invoicing'); ?>" |
|
248 | + data-text-activating="<?php _e('Activating', 'invoicing'); ?>" |
|
249 | + data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>" |
|
250 | + data-text-installed="<?php _e('Installed', 'invoicing'); ?>" |
|
251 | + data-text-install="<?php _e('Install', 'invoicing'); ?>" |
|
252 | + data-text-installing="<?php _e('Installing', 'invoicing'); ?>" |
|
253 | + data-text-error="<?php _e('Error', 'invoicing'); ?>" |
|
254 | + <?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?> |
|
255 | + <?php echo $target; ?> |
|
256 | + class="addons-button <?php echo esc_attr($button_args['class']); ?>" |
|
257 | + href="<?php echo esc_url($button_args['url']); ?>"> |
|
258 | + <?php echo esc_html($button_args['button_text']); ?> |
|
259 | 259 | </a> |
260 | 260 | <?php |
261 | 261 | |
@@ -270,36 +270,36 @@ discard block |
||
270 | 270 | $tabs = self::get_tabs(); |
271 | 271 | $sections = self::get_sections(); |
272 | 272 | $theme = wp_get_theme(); |
273 | - $section_keys = array_keys( $sections ); |
|
274 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
275 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
276 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
273 | + $section_keys = array_keys($sections); |
|
274 | + $current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys); |
|
275 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
276 | + include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | /** |
280 | 280 | * A list of recommended wp.org plugins. |
281 | 281 | * @return array |
282 | 282 | */ |
283 | - public function get_recommend_wp_plugins(){ |
|
283 | + public function get_recommend_wp_plugins() { |
|
284 | 284 | $plugins = array( |
285 | 285 | 'invoicing-quotes' => array( |
286 | 286 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
287 | 287 | 'slug' => 'invoicing-quotes', |
288 | 288 | 'name' => 'Quotes', |
289 | 289 | 'thumbnail' => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png', |
290 | - 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'), |
|
290 | + 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'), |
|
291 | 291 | ), |
292 | 292 | 'geodirectory' => array( |
293 | 293 | 'url' => 'https://wordpress.org/plugins/geodirectory/', |
294 | 294 | 'slug' => 'geodirectory', |
295 | 295 | 'name' => 'GeoDirectory', |
296 | - 'desc' => __('Turn any WordPress theme into a global business directory portal.','invoicing'), |
|
296 | + 'desc' => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'), |
|
297 | 297 | ), |
298 | 298 | 'userswp' => array( |
299 | 299 | 'url' => 'https://wordpress.org/plugins/userswp/', |
300 | 300 | 'slug' => 'userswp', |
301 | 301 | 'name' => 'UsersWP', |
302 | - 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
|
302 | + 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'), |
|
303 | 303 | ), |
304 | 304 | ); |
305 | 305 |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | */ |
10 | 10 | |
11 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
12 | - exit; |
|
12 | + exit; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 | /** |
@@ -21,356 +21,356 @@ discard block |
||
21 | 21 | */ |
22 | 22 | abstract class GetPaid_Data { |
23 | 23 | |
24 | - /** |
|
25 | - * ID for this object. |
|
26 | - * |
|
27 | - * @since 1.0.19 |
|
28 | - * @var int |
|
29 | - */ |
|
30 | - protected $id = 0; |
|
31 | - |
|
32 | - /** |
|
33 | - * Core data for this object. Name value pairs (name + default value). |
|
34 | - * |
|
35 | - * @since 1.0.19 |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $data = array(); |
|
39 | - |
|
40 | - /** |
|
41 | - * Core data changes for this object. |
|
42 | - * |
|
43 | - * @since 1.0.19 |
|
44 | - * @var array |
|
45 | - */ |
|
46 | - protected $changes = array(); |
|
47 | - |
|
48 | - /** |
|
49 | - * This is false until the object is read from the DB. |
|
50 | - * |
|
51 | - * @since 1.0.19 |
|
52 | - * @var bool |
|
53 | - */ |
|
54 | - protected $object_read = false; |
|
55 | - |
|
56 | - /** |
|
57 | - * This is the name of this object type. |
|
58 | - * |
|
59 | - * @since 1.0.19 |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - protected $object_type = 'data'; |
|
63 | - |
|
64 | - /** |
|
65 | - * Extra data for this object. Name value pairs (name + default value). |
|
66 | - * Used as a standard way for sub classes (like item types) to add |
|
67 | - * additional information to an inherited class. |
|
68 | - * |
|
69 | - * @since 1.0.19 |
|
70 | - * @var array |
|
71 | - */ |
|
72 | - protected $extra_data = array(); |
|
73 | - |
|
74 | - /** |
|
75 | - * Set to _data on construct so we can track and reset data if needed. |
|
76 | - * |
|
77 | - * @since 1.0.19 |
|
78 | - * @var array |
|
79 | - */ |
|
80 | - protected $default_data = array(); |
|
81 | - |
|
82 | - /** |
|
83 | - * Contains a reference to the data store for this class. |
|
84 | - * |
|
85 | - * @since 1.0.19 |
|
86 | - * @var GetPaid_Data_Store |
|
87 | - */ |
|
88 | - protected $data_store; |
|
89 | - |
|
90 | - /** |
|
91 | - * Stores meta in cache for future reads. |
|
92 | - * A group must be set to to enable caching. |
|
93 | - * |
|
94 | - * @since 1.0.19 |
|
95 | - * @var string |
|
96 | - */ |
|
97 | - protected $cache_group = ''; |
|
98 | - |
|
99 | - /** |
|
100 | - * Stores the last error. |
|
101 | - * |
|
102 | - * @since 1.0.19 |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $last_error = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Stores additional meta data. |
|
109 | - * |
|
110 | - * @since 1.0.19 |
|
111 | - * @var array |
|
112 | - */ |
|
113 | - protected $meta_data = null; |
|
114 | - |
|
115 | - /** |
|
116 | - * Default constructor. |
|
117 | - * |
|
118 | - * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
|
119 | - */ |
|
120 | - public function __construct( $read = 0 ) { |
|
121 | - $this->data = array_merge( $this->data, $this->extra_data ); |
|
122 | - $this->default_data = $this->data; |
|
123 | - } |
|
124 | - |
|
125 | - /** |
|
126 | - * Only store the object ID to avoid serializing the data object instance. |
|
127 | - * |
|
128 | - * @return array |
|
129 | - */ |
|
130 | - public function __sleep() { |
|
131 | - return array( 'id' ); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Re-run the constructor with the object ID. |
|
136 | - * |
|
137 | - * If the object no longer exists, remove the ID. |
|
138 | - */ |
|
139 | - public function __wakeup() { |
|
140 | - $this->__construct( absint( $this->id ) ); |
|
141 | - |
|
142 | - if ( ! empty( $this->last_error ) ) { |
|
143 | - $this->set_id( 0 ); |
|
144 | - } |
|
145 | - |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * When the object is cloned, make sure meta is duplicated correctly. |
|
150 | - * |
|
151 | - * @since 1.0.19 |
|
152 | - */ |
|
153 | - public function __clone() { |
|
154 | - $this->maybe_read_meta_data(); |
|
155 | - if ( ! empty( $this->meta_data ) ) { |
|
156 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | - $this->meta_data[ $array_key ] = clone $meta; |
|
158 | - if ( ! empty( $meta->id ) ) { |
|
159 | - $this->meta_data[ $array_key ]->id = null; |
|
160 | - } |
|
161 | - } |
|
162 | - } |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Get the data store. |
|
167 | - * |
|
168 | - * @since 1.0.19 |
|
169 | - * @return object |
|
170 | - */ |
|
171 | - public function get_data_store() { |
|
172 | - return $this->data_store; |
|
173 | - } |
|
174 | - |
|
175 | - /** |
|
176 | - * Get the object type. |
|
177 | - * |
|
178 | - * @since 1.0.19 |
|
179 | - * @return string |
|
180 | - */ |
|
181 | - public function get_object_type() { |
|
182 | - return $this->object_type; |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Returns the unique ID for this object. |
|
187 | - * |
|
188 | - * @since 1.0.19 |
|
189 | - * @return int |
|
190 | - */ |
|
191 | - public function get_id() { |
|
192 | - return $this->id; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Get form status. |
|
197 | - * |
|
198 | - * @since 1.0.19 |
|
199 | - * @param string $context View or edit context. |
|
200 | - * @return string |
|
201 | - */ |
|
202 | - public function get_status( $context = 'view' ) { |
|
203 | - return $this->get_prop( 'status', $context ); |
|
204 | - } |
|
205 | - |
|
206 | - /** |
|
207 | - * Delete an object, set the ID to 0, and return result. |
|
208 | - * |
|
209 | - * @since 1.0.19 |
|
210 | - * @param bool $force_delete Should the data be deleted permanently. |
|
211 | - * @return bool result |
|
212 | - */ |
|
213 | - public function delete( $force_delete = false ) { |
|
214 | - if ( $this->data_store && $this->exists() ) { |
|
215 | - $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | - $this->set_id( 0 ); |
|
217 | - return true; |
|
218 | - } |
|
219 | - return false; |
|
220 | - } |
|
221 | - |
|
222 | - /** |
|
223 | - * Save should create or update based on object existence. |
|
224 | - * |
|
225 | - * @since 1.0.19 |
|
226 | - * @return int |
|
227 | - */ |
|
228 | - public function save() { |
|
229 | - if ( ! $this->data_store ) { |
|
230 | - return $this->get_id(); |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Trigger action before saving to the DB. Allows you to adjust object props before save. |
|
235 | - * |
|
236 | - * @param GetPaid_Data $this The object being saved. |
|
237 | - * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
|
238 | - */ |
|
239 | - do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
240 | - |
|
241 | - if ( $this->get_id() ) { |
|
242 | - $this->data_store->update( $this ); |
|
243 | - } else { |
|
244 | - $this->data_store->create( $this ); |
|
245 | - } |
|
246 | - |
|
247 | - /** |
|
248 | - * Trigger action after saving to the DB. |
|
249 | - * |
|
250 | - * @param GetPaid_Data $this The object being saved. |
|
251 | - * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
|
252 | - */ |
|
253 | - do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
254 | - |
|
255 | - return $this->get_id(); |
|
256 | - } |
|
257 | - |
|
258 | - /** |
|
259 | - * Change data to JSON format. |
|
260 | - * |
|
261 | - * @since 1.0.19 |
|
262 | - * @return string Data in JSON format. |
|
263 | - */ |
|
264 | - public function __toString() { |
|
265 | - return wp_json_encode( $this->get_data() ); |
|
266 | - } |
|
267 | - |
|
268 | - /** |
|
269 | - * Returns all data for this object. |
|
270 | - * |
|
271 | - * @since 1.0.19 |
|
272 | - * @return array |
|
273 | - */ |
|
274 | - public function get_data() { |
|
275 | - return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
276 | - } |
|
277 | - |
|
278 | - /** |
|
279 | - * Returns array of expected data keys for this object. |
|
280 | - * |
|
281 | - * @since 1.0.19 |
|
282 | - * @return array |
|
283 | - */ |
|
284 | - public function get_data_keys() { |
|
285 | - return array_keys( $this->data ); |
|
286 | - } |
|
287 | - |
|
288 | - /** |
|
289 | - * Returns all "extra" data keys for an object (for sub objects like item types). |
|
290 | - * |
|
291 | - * @since 1.0.19 |
|
292 | - * @return array |
|
293 | - */ |
|
294 | - public function get_extra_data_keys() { |
|
295 | - return array_keys( $this->extra_data ); |
|
296 | - } |
|
297 | - |
|
298 | - /** |
|
299 | - * Filter null meta values from array. |
|
300 | - * |
|
301 | - * @since 1.0.19 |
|
302 | - * @param mixed $meta Meta value to check. |
|
303 | - * @return bool |
|
304 | - */ |
|
305 | - protected function filter_null_meta( $meta ) { |
|
306 | - return ! is_null( $meta->value ); |
|
307 | - } |
|
308 | - |
|
309 | - /** |
|
310 | - * Get All Meta Data. |
|
311 | - * |
|
312 | - * @since 1.0.19 |
|
313 | - * @return array of objects. |
|
314 | - */ |
|
315 | - public function get_meta_data() { |
|
316 | - $this->maybe_read_meta_data(); |
|
317 | - return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
318 | - } |
|
319 | - |
|
320 | - /** |
|
321 | - * Check if the key is an internal one. |
|
322 | - * |
|
323 | - * @since 1.0.19 |
|
324 | - * @param string $key Key to check. |
|
325 | - * @return bool true if it's an internal key, false otherwise |
|
326 | - */ |
|
327 | - protected function is_internal_meta_key( $key ) { |
|
328 | - $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
329 | - |
|
330 | - if ( ! $internal_meta_key ) { |
|
331 | - return false; |
|
332 | - } |
|
333 | - |
|
334 | - $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
335 | - |
|
336 | - if ( ! $has_setter_or_getter ) { |
|
337 | - return false; |
|
338 | - } |
|
339 | - |
|
340 | - /* translators: %s: $key Key to check */ |
|
341 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
342 | - |
|
343 | - return true; |
|
344 | - } |
|
345 | - |
|
346 | - /** |
|
347 | - * Magic method for setting data fields. |
|
348 | - * |
|
349 | - * This method does not update custom fields in the database. |
|
350 | - * |
|
351 | - * @since 1.0.19 |
|
352 | - * @access public |
|
353 | - * |
|
354 | - */ |
|
355 | - public function __set( $key, $value ) { |
|
356 | - |
|
357 | - if ( 'id' == strtolower( $key ) ) { |
|
358 | - return $this->set_id( $value ); |
|
359 | - } |
|
360 | - |
|
361 | - if ( method_exists( $this, "set_$key") ) { |
|
362 | - |
|
363 | - /* translators: %s: $key Key to set */ |
|
364 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
365 | - |
|
366 | - call_user_func( array( $this, "set_$key" ), $value ); |
|
367 | - } else { |
|
368 | - $this->set_prop( $key, $value ); |
|
369 | - } |
|
370 | - |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
24 | + /** |
|
25 | + * ID for this object. |
|
26 | + * |
|
27 | + * @since 1.0.19 |
|
28 | + * @var int |
|
29 | + */ |
|
30 | + protected $id = 0; |
|
31 | + |
|
32 | + /** |
|
33 | + * Core data for this object. Name value pairs (name + default value). |
|
34 | + * |
|
35 | + * @since 1.0.19 |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $data = array(); |
|
39 | + |
|
40 | + /** |
|
41 | + * Core data changes for this object. |
|
42 | + * |
|
43 | + * @since 1.0.19 |
|
44 | + * @var array |
|
45 | + */ |
|
46 | + protected $changes = array(); |
|
47 | + |
|
48 | + /** |
|
49 | + * This is false until the object is read from the DB. |
|
50 | + * |
|
51 | + * @since 1.0.19 |
|
52 | + * @var bool |
|
53 | + */ |
|
54 | + protected $object_read = false; |
|
55 | + |
|
56 | + /** |
|
57 | + * This is the name of this object type. |
|
58 | + * |
|
59 | + * @since 1.0.19 |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + protected $object_type = 'data'; |
|
63 | + |
|
64 | + /** |
|
65 | + * Extra data for this object. Name value pairs (name + default value). |
|
66 | + * Used as a standard way for sub classes (like item types) to add |
|
67 | + * additional information to an inherited class. |
|
68 | + * |
|
69 | + * @since 1.0.19 |
|
70 | + * @var array |
|
71 | + */ |
|
72 | + protected $extra_data = array(); |
|
73 | + |
|
74 | + /** |
|
75 | + * Set to _data on construct so we can track and reset data if needed. |
|
76 | + * |
|
77 | + * @since 1.0.19 |
|
78 | + * @var array |
|
79 | + */ |
|
80 | + protected $default_data = array(); |
|
81 | + |
|
82 | + /** |
|
83 | + * Contains a reference to the data store for this class. |
|
84 | + * |
|
85 | + * @since 1.0.19 |
|
86 | + * @var GetPaid_Data_Store |
|
87 | + */ |
|
88 | + protected $data_store; |
|
89 | + |
|
90 | + /** |
|
91 | + * Stores meta in cache for future reads. |
|
92 | + * A group must be set to to enable caching. |
|
93 | + * |
|
94 | + * @since 1.0.19 |
|
95 | + * @var string |
|
96 | + */ |
|
97 | + protected $cache_group = ''; |
|
98 | + |
|
99 | + /** |
|
100 | + * Stores the last error. |
|
101 | + * |
|
102 | + * @since 1.0.19 |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $last_error = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Stores additional meta data. |
|
109 | + * |
|
110 | + * @since 1.0.19 |
|
111 | + * @var array |
|
112 | + */ |
|
113 | + protected $meta_data = null; |
|
114 | + |
|
115 | + /** |
|
116 | + * Default constructor. |
|
117 | + * |
|
118 | + * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
|
119 | + */ |
|
120 | + public function __construct( $read = 0 ) { |
|
121 | + $this->data = array_merge( $this->data, $this->extra_data ); |
|
122 | + $this->default_data = $this->data; |
|
123 | + } |
|
124 | + |
|
125 | + /** |
|
126 | + * Only store the object ID to avoid serializing the data object instance. |
|
127 | + * |
|
128 | + * @return array |
|
129 | + */ |
|
130 | + public function __sleep() { |
|
131 | + return array( 'id' ); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Re-run the constructor with the object ID. |
|
136 | + * |
|
137 | + * If the object no longer exists, remove the ID. |
|
138 | + */ |
|
139 | + public function __wakeup() { |
|
140 | + $this->__construct( absint( $this->id ) ); |
|
141 | + |
|
142 | + if ( ! empty( $this->last_error ) ) { |
|
143 | + $this->set_id( 0 ); |
|
144 | + } |
|
145 | + |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * When the object is cloned, make sure meta is duplicated correctly. |
|
150 | + * |
|
151 | + * @since 1.0.19 |
|
152 | + */ |
|
153 | + public function __clone() { |
|
154 | + $this->maybe_read_meta_data(); |
|
155 | + if ( ! empty( $this->meta_data ) ) { |
|
156 | + foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | + $this->meta_data[ $array_key ] = clone $meta; |
|
158 | + if ( ! empty( $meta->id ) ) { |
|
159 | + $this->meta_data[ $array_key ]->id = null; |
|
160 | + } |
|
161 | + } |
|
162 | + } |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Get the data store. |
|
167 | + * |
|
168 | + * @since 1.0.19 |
|
169 | + * @return object |
|
170 | + */ |
|
171 | + public function get_data_store() { |
|
172 | + return $this->data_store; |
|
173 | + } |
|
174 | + |
|
175 | + /** |
|
176 | + * Get the object type. |
|
177 | + * |
|
178 | + * @since 1.0.19 |
|
179 | + * @return string |
|
180 | + */ |
|
181 | + public function get_object_type() { |
|
182 | + return $this->object_type; |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Returns the unique ID for this object. |
|
187 | + * |
|
188 | + * @since 1.0.19 |
|
189 | + * @return int |
|
190 | + */ |
|
191 | + public function get_id() { |
|
192 | + return $this->id; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Get form status. |
|
197 | + * |
|
198 | + * @since 1.0.19 |
|
199 | + * @param string $context View or edit context. |
|
200 | + * @return string |
|
201 | + */ |
|
202 | + public function get_status( $context = 'view' ) { |
|
203 | + return $this->get_prop( 'status', $context ); |
|
204 | + } |
|
205 | + |
|
206 | + /** |
|
207 | + * Delete an object, set the ID to 0, and return result. |
|
208 | + * |
|
209 | + * @since 1.0.19 |
|
210 | + * @param bool $force_delete Should the data be deleted permanently. |
|
211 | + * @return bool result |
|
212 | + */ |
|
213 | + public function delete( $force_delete = false ) { |
|
214 | + if ( $this->data_store && $this->exists() ) { |
|
215 | + $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | + $this->set_id( 0 ); |
|
217 | + return true; |
|
218 | + } |
|
219 | + return false; |
|
220 | + } |
|
221 | + |
|
222 | + /** |
|
223 | + * Save should create or update based on object existence. |
|
224 | + * |
|
225 | + * @since 1.0.19 |
|
226 | + * @return int |
|
227 | + */ |
|
228 | + public function save() { |
|
229 | + if ( ! $this->data_store ) { |
|
230 | + return $this->get_id(); |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Trigger action before saving to the DB. Allows you to adjust object props before save. |
|
235 | + * |
|
236 | + * @param GetPaid_Data $this The object being saved. |
|
237 | + * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
|
238 | + */ |
|
239 | + do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
240 | + |
|
241 | + if ( $this->get_id() ) { |
|
242 | + $this->data_store->update( $this ); |
|
243 | + } else { |
|
244 | + $this->data_store->create( $this ); |
|
245 | + } |
|
246 | + |
|
247 | + /** |
|
248 | + * Trigger action after saving to the DB. |
|
249 | + * |
|
250 | + * @param GetPaid_Data $this The object being saved. |
|
251 | + * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
|
252 | + */ |
|
253 | + do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
254 | + |
|
255 | + return $this->get_id(); |
|
256 | + } |
|
257 | + |
|
258 | + /** |
|
259 | + * Change data to JSON format. |
|
260 | + * |
|
261 | + * @since 1.0.19 |
|
262 | + * @return string Data in JSON format. |
|
263 | + */ |
|
264 | + public function __toString() { |
|
265 | + return wp_json_encode( $this->get_data() ); |
|
266 | + } |
|
267 | + |
|
268 | + /** |
|
269 | + * Returns all data for this object. |
|
270 | + * |
|
271 | + * @since 1.0.19 |
|
272 | + * @return array |
|
273 | + */ |
|
274 | + public function get_data() { |
|
275 | + return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
276 | + } |
|
277 | + |
|
278 | + /** |
|
279 | + * Returns array of expected data keys for this object. |
|
280 | + * |
|
281 | + * @since 1.0.19 |
|
282 | + * @return array |
|
283 | + */ |
|
284 | + public function get_data_keys() { |
|
285 | + return array_keys( $this->data ); |
|
286 | + } |
|
287 | + |
|
288 | + /** |
|
289 | + * Returns all "extra" data keys for an object (for sub objects like item types). |
|
290 | + * |
|
291 | + * @since 1.0.19 |
|
292 | + * @return array |
|
293 | + */ |
|
294 | + public function get_extra_data_keys() { |
|
295 | + return array_keys( $this->extra_data ); |
|
296 | + } |
|
297 | + |
|
298 | + /** |
|
299 | + * Filter null meta values from array. |
|
300 | + * |
|
301 | + * @since 1.0.19 |
|
302 | + * @param mixed $meta Meta value to check. |
|
303 | + * @return bool |
|
304 | + */ |
|
305 | + protected function filter_null_meta( $meta ) { |
|
306 | + return ! is_null( $meta->value ); |
|
307 | + } |
|
308 | + |
|
309 | + /** |
|
310 | + * Get All Meta Data. |
|
311 | + * |
|
312 | + * @since 1.0.19 |
|
313 | + * @return array of objects. |
|
314 | + */ |
|
315 | + public function get_meta_data() { |
|
316 | + $this->maybe_read_meta_data(); |
|
317 | + return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
318 | + } |
|
319 | + |
|
320 | + /** |
|
321 | + * Check if the key is an internal one. |
|
322 | + * |
|
323 | + * @since 1.0.19 |
|
324 | + * @param string $key Key to check. |
|
325 | + * @return bool true if it's an internal key, false otherwise |
|
326 | + */ |
|
327 | + protected function is_internal_meta_key( $key ) { |
|
328 | + $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
329 | + |
|
330 | + if ( ! $internal_meta_key ) { |
|
331 | + return false; |
|
332 | + } |
|
333 | + |
|
334 | + $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
335 | + |
|
336 | + if ( ! $has_setter_or_getter ) { |
|
337 | + return false; |
|
338 | + } |
|
339 | + |
|
340 | + /* translators: %s: $key Key to check */ |
|
341 | + getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
342 | + |
|
343 | + return true; |
|
344 | + } |
|
345 | + |
|
346 | + /** |
|
347 | + * Magic method for setting data fields. |
|
348 | + * |
|
349 | + * This method does not update custom fields in the database. |
|
350 | + * |
|
351 | + * @since 1.0.19 |
|
352 | + * @access public |
|
353 | + * |
|
354 | + */ |
|
355 | + public function __set( $key, $value ) { |
|
356 | + |
|
357 | + if ( 'id' == strtolower( $key ) ) { |
|
358 | + return $this->set_id( $value ); |
|
359 | + } |
|
360 | + |
|
361 | + if ( method_exists( $this, "set_$key") ) { |
|
362 | + |
|
363 | + /* translators: %s: $key Key to set */ |
|
364 | + getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
365 | + |
|
366 | + call_user_func( array( $this, "set_$key" ), $value ); |
|
367 | + } else { |
|
368 | + $this->set_prop( $key, $value ); |
|
369 | + } |
|
370 | + |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | 374 | * Margic method for retrieving a property. |
375 | 375 | */ |
376 | 376 | public function __get( $key ) { |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | // Check if we have a helper method for that. |
379 | 379 | if ( method_exists( $this, 'get_' . $key ) ) { |
380 | 380 | |
381 | - if ( 'post_type' != $key ) { |
|
382 | - /* translators: %s: $key Key to set */ |
|
383 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
384 | - } |
|
381 | + if ( 'post_type' != $key ) { |
|
382 | + /* translators: %s: $key Key to set */ |
|
383 | + getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
384 | + } |
|
385 | 385 | |
386 | 386 | return call_user_func( array( $this, 'get_' . $key ) ); |
387 | 387 | } |
@@ -391,515 +391,515 @@ discard block |
||
391 | 391 | return $this->post->$key; |
392 | 392 | } |
393 | 393 | |
394 | - return $this->get_prop( $key ); |
|
395 | - |
|
396 | - } |
|
397 | - |
|
398 | - /** |
|
399 | - * Get Meta Data by Key. |
|
400 | - * |
|
401 | - * @since 1.0.19 |
|
402 | - * @param string $key Meta Key. |
|
403 | - * @param bool $single return first found meta with key, or all with $key. |
|
404 | - * @param string $context What the value is for. Valid values are view and edit. |
|
405 | - * @return mixed |
|
406 | - */ |
|
407 | - public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
408 | - |
|
409 | - // Check if this is an internal meta key. |
|
410 | - $_key = str_replace( '_wpinv', '', $key ); |
|
411 | - $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
413 | - $function = 'get_' . $_key; |
|
414 | - |
|
415 | - if ( is_callable( array( $this, $function ) ) ) { |
|
416 | - return $this->{$function}(); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - // Read the meta data if not yet read. |
|
421 | - $this->maybe_read_meta_data(); |
|
422 | - $meta_data = $this->get_meta_data(); |
|
423 | - $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
424 | - $value = $single ? '' : array(); |
|
425 | - |
|
426 | - if ( ! empty( $array_keys ) ) { |
|
427 | - // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
|
428 | - if ( $single ) { |
|
429 | - $value = $meta_data[ current( $array_keys ) ]->value; |
|
430 | - } else { |
|
431 | - $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
432 | - } |
|
433 | - } |
|
434 | - |
|
435 | - if ( 'view' === $context ) { |
|
436 | - $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
437 | - } |
|
438 | - |
|
439 | - return $value; |
|
440 | - } |
|
441 | - |
|
442 | - /** |
|
443 | - * See if meta data exists, since get_meta always returns a '' or array(). |
|
444 | - * |
|
445 | - * @since 1.0.19 |
|
446 | - * @param string $key Meta Key. |
|
447 | - * @return boolean |
|
448 | - */ |
|
449 | - public function meta_exists( $key = '' ) { |
|
450 | - $this->maybe_read_meta_data(); |
|
451 | - $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | - return in_array( $key, $array_keys, true ); |
|
453 | - } |
|
454 | - |
|
455 | - /** |
|
456 | - * Set all meta data from array. |
|
457 | - * |
|
458 | - * @since 1.0.19 |
|
459 | - * @param array $data Key/Value pairs. |
|
460 | - */ |
|
461 | - public function set_meta_data( $data ) { |
|
462 | - if ( ! empty( $data ) && is_array( $data ) ) { |
|
463 | - $this->maybe_read_meta_data(); |
|
464 | - foreach ( $data as $meta ) { |
|
465 | - $meta = (array) $meta; |
|
466 | - if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
467 | - $this->meta_data[] = new GetPaid_Meta_Data( |
|
468 | - array( |
|
469 | - 'id' => $meta['id'], |
|
470 | - 'key' => $meta['key'], |
|
471 | - 'value' => $meta['value'], |
|
472 | - ) |
|
473 | - ); |
|
474 | - } |
|
475 | - } |
|
476 | - } |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Add meta data. |
|
481 | - * |
|
482 | - * @since 1.0.19 |
|
483 | - * |
|
484 | - * @param string $key Meta key. |
|
485 | - * @param string|array $value Meta value. |
|
486 | - * @param bool $unique Should this be a unique key?. |
|
487 | - */ |
|
488 | - public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
490 | - $function = 'set_' . $key; |
|
491 | - |
|
492 | - if ( is_callable( array( $this, $function ) ) ) { |
|
493 | - return $this->{$function}( $value ); |
|
494 | - } |
|
495 | - } |
|
496 | - |
|
497 | - $this->maybe_read_meta_data(); |
|
498 | - if ( $unique ) { |
|
499 | - $this->delete_meta_data( $key ); |
|
500 | - } |
|
501 | - $this->meta_data[] = new GetPaid_Meta_Data( |
|
502 | - array( |
|
503 | - 'key' => $key, |
|
504 | - 'value' => $value, |
|
505 | - ) |
|
506 | - ); |
|
507 | - |
|
508 | - $this->save(); |
|
509 | - } |
|
510 | - |
|
511 | - /** |
|
512 | - * Update meta data by key or ID, if provided. |
|
513 | - * |
|
514 | - * @since 1.0.19 |
|
515 | - * |
|
516 | - * @param string $key Meta key. |
|
517 | - * @param string|array $value Meta value. |
|
518 | - * @param int $meta_id Meta ID. |
|
519 | - */ |
|
520 | - public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
521 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
522 | - $function = 'set_' . $key; |
|
523 | - |
|
524 | - if ( is_callable( array( $this, $function ) ) ) { |
|
525 | - return $this->{$function}( $value ); |
|
526 | - } |
|
527 | - } |
|
528 | - |
|
529 | - $this->maybe_read_meta_data(); |
|
530 | - |
|
531 | - $array_key = false; |
|
532 | - |
|
533 | - if ( $meta_id ) { |
|
534 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
535 | - $array_key = $array_keys ? current( $array_keys ) : false; |
|
536 | - } else { |
|
537 | - // Find matches by key. |
|
538 | - $matches = array(); |
|
539 | - foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
540 | - if ( $meta->key === $key ) { |
|
541 | - $matches[] = $meta_data_array_key; |
|
542 | - } |
|
543 | - } |
|
544 | - |
|
545 | - if ( ! empty( $matches ) ) { |
|
546 | - // Set matches to null so only one key gets the new value. |
|
547 | - foreach ( $matches as $meta_data_array_key ) { |
|
548 | - $this->meta_data[ $meta_data_array_key ]->value = null; |
|
549 | - } |
|
550 | - $array_key = current( $matches ); |
|
551 | - } |
|
552 | - } |
|
553 | - |
|
554 | - if ( false !== $array_key ) { |
|
555 | - $meta = $this->meta_data[ $array_key ]; |
|
556 | - $meta->key = $key; |
|
557 | - $meta->value = $value; |
|
558 | - } else { |
|
559 | - $this->add_meta_data( $key, $value, true ); |
|
560 | - } |
|
561 | - } |
|
562 | - |
|
563 | - /** |
|
564 | - * Delete meta data. |
|
565 | - * |
|
566 | - * @since 1.0.19 |
|
567 | - * @param string $key Meta key. |
|
568 | - */ |
|
569 | - public function delete_meta_data( $key ) { |
|
570 | - $this->maybe_read_meta_data(); |
|
571 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
572 | - |
|
573 | - if ( $array_keys ) { |
|
574 | - foreach ( $array_keys as $array_key ) { |
|
575 | - $this->meta_data[ $array_key ]->value = null; |
|
576 | - } |
|
577 | - } |
|
578 | - } |
|
579 | - |
|
580 | - /** |
|
581 | - * Delete meta data. |
|
582 | - * |
|
583 | - * @since 1.0.19 |
|
584 | - * @param int $mid Meta ID. |
|
585 | - */ |
|
586 | - public function delete_meta_data_by_mid( $mid ) { |
|
587 | - $this->maybe_read_meta_data(); |
|
588 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
589 | - |
|
590 | - if ( $array_keys ) { |
|
591 | - foreach ( $array_keys as $array_key ) { |
|
592 | - $this->meta_data[ $array_key ]->value = null; |
|
593 | - } |
|
594 | - } |
|
595 | - } |
|
596 | - |
|
597 | - /** |
|
598 | - * Read meta data if null. |
|
599 | - * |
|
600 | - * @since 1.0.19 |
|
601 | - */ |
|
602 | - protected function maybe_read_meta_data() { |
|
603 | - if ( is_null( $this->meta_data ) ) { |
|
604 | - $this->read_meta_data(); |
|
605 | - } |
|
606 | - } |
|
607 | - |
|
608 | - /** |
|
609 | - * Read Meta Data from the database. Ignore any internal properties. |
|
610 | - * Uses it's own caches because get_metadata does not provide meta_ids. |
|
611 | - * |
|
612 | - * @since 1.0.19 |
|
613 | - * @param bool $force_read True to force a new DB read (and update cache). |
|
614 | - */ |
|
615 | - public function read_meta_data( $force_read = false ) { |
|
616 | - |
|
617 | - // Reset meta data. |
|
618 | - $this->meta_data = array(); |
|
619 | - |
|
620 | - // Maybe abort early. |
|
621 | - if ( ! $this->get_id() || ! $this->data_store ) { |
|
622 | - return; |
|
623 | - } |
|
624 | - |
|
625 | - // Only read from cache if the cache key is set. |
|
626 | - $cache_key = null; |
|
627 | - if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
628 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
629 | - $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
630 | - } |
|
631 | - |
|
632 | - // Should we force read? |
|
633 | - if ( empty( $raw_meta_data ) ) { |
|
634 | - $raw_meta_data = $this->data_store->read_meta( $this ); |
|
635 | - |
|
636 | - if ( ! empty( $cache_key ) ) { |
|
637 | - wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
638 | - } |
|
639 | - |
|
640 | - } |
|
641 | - |
|
642 | - // Set meta data. |
|
643 | - if ( is_array( $raw_meta_data ) ) { |
|
644 | - |
|
645 | - foreach ( $raw_meta_data as $meta ) { |
|
646 | - $this->meta_data[] = new GetPaid_Meta_Data( |
|
647 | - array( |
|
648 | - 'id' => (int) $meta->meta_id, |
|
649 | - 'key' => $meta->meta_key, |
|
650 | - 'value' => maybe_unserialize( $meta->meta_value ), |
|
651 | - ) |
|
652 | - ); |
|
653 | - } |
|
654 | - |
|
655 | - } |
|
656 | - |
|
657 | - } |
|
658 | - |
|
659 | - /** |
|
660 | - * Update Meta Data in the database. |
|
661 | - * |
|
662 | - * @since 1.0.19 |
|
663 | - */ |
|
664 | - public function save_meta_data() { |
|
665 | - if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
666 | - return; |
|
667 | - } |
|
668 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
669 | - if ( is_null( $meta->value ) ) { |
|
670 | - if ( ! empty( $meta->id ) ) { |
|
671 | - $this->data_store->delete_meta( $this, $meta ); |
|
672 | - unset( $this->meta_data[ $array_key ] ); |
|
673 | - } |
|
674 | - } elseif ( empty( $meta->id ) ) { |
|
675 | - $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
676 | - $meta->apply_changes(); |
|
677 | - } else { |
|
678 | - if ( $meta->get_changes() ) { |
|
679 | - $this->data_store->update_meta( $this, $meta ); |
|
680 | - $meta->apply_changes(); |
|
681 | - } |
|
682 | - } |
|
683 | - } |
|
684 | - if ( ! empty( $this->cache_group ) ) { |
|
685 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
686 | - wp_cache_delete( $cache_key, $this->cache_group ); |
|
687 | - } |
|
688 | - } |
|
689 | - |
|
690 | - /** |
|
691 | - * Set ID. |
|
692 | - * |
|
693 | - * @since 1.0.19 |
|
694 | - * @param int $id ID. |
|
695 | - */ |
|
696 | - public function set_id( $id ) { |
|
697 | - $this->id = absint( $id ); |
|
698 | - } |
|
699 | - |
|
700 | - /** |
|
701 | - * Sets item status. |
|
702 | - * |
|
703 | - * @since 1.0.19 |
|
704 | - * @param string $status New status. |
|
705 | - * @return array details of change. |
|
706 | - */ |
|
707 | - public function set_status( $status ) { |
|
394 | + return $this->get_prop( $key ); |
|
395 | + |
|
396 | + } |
|
397 | + |
|
398 | + /** |
|
399 | + * Get Meta Data by Key. |
|
400 | + * |
|
401 | + * @since 1.0.19 |
|
402 | + * @param string $key Meta Key. |
|
403 | + * @param bool $single return first found meta with key, or all with $key. |
|
404 | + * @param string $context What the value is for. Valid values are view and edit. |
|
405 | + * @return mixed |
|
406 | + */ |
|
407 | + public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
408 | + |
|
409 | + // Check if this is an internal meta key. |
|
410 | + $_key = str_replace( '_wpinv', '', $key ); |
|
411 | + $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | + if ( $this->is_internal_meta_key( $key ) ) { |
|
413 | + $function = 'get_' . $_key; |
|
414 | + |
|
415 | + if ( is_callable( array( $this, $function ) ) ) { |
|
416 | + return $this->{$function}(); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + // Read the meta data if not yet read. |
|
421 | + $this->maybe_read_meta_data(); |
|
422 | + $meta_data = $this->get_meta_data(); |
|
423 | + $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
424 | + $value = $single ? '' : array(); |
|
425 | + |
|
426 | + if ( ! empty( $array_keys ) ) { |
|
427 | + // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
|
428 | + if ( $single ) { |
|
429 | + $value = $meta_data[ current( $array_keys ) ]->value; |
|
430 | + } else { |
|
431 | + $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
432 | + } |
|
433 | + } |
|
434 | + |
|
435 | + if ( 'view' === $context ) { |
|
436 | + $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
437 | + } |
|
438 | + |
|
439 | + return $value; |
|
440 | + } |
|
441 | + |
|
442 | + /** |
|
443 | + * See if meta data exists, since get_meta always returns a '' or array(). |
|
444 | + * |
|
445 | + * @since 1.0.19 |
|
446 | + * @param string $key Meta Key. |
|
447 | + * @return boolean |
|
448 | + */ |
|
449 | + public function meta_exists( $key = '' ) { |
|
450 | + $this->maybe_read_meta_data(); |
|
451 | + $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | + return in_array( $key, $array_keys, true ); |
|
453 | + } |
|
454 | + |
|
455 | + /** |
|
456 | + * Set all meta data from array. |
|
457 | + * |
|
458 | + * @since 1.0.19 |
|
459 | + * @param array $data Key/Value pairs. |
|
460 | + */ |
|
461 | + public function set_meta_data( $data ) { |
|
462 | + if ( ! empty( $data ) && is_array( $data ) ) { |
|
463 | + $this->maybe_read_meta_data(); |
|
464 | + foreach ( $data as $meta ) { |
|
465 | + $meta = (array) $meta; |
|
466 | + if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
467 | + $this->meta_data[] = new GetPaid_Meta_Data( |
|
468 | + array( |
|
469 | + 'id' => $meta['id'], |
|
470 | + 'key' => $meta['key'], |
|
471 | + 'value' => $meta['value'], |
|
472 | + ) |
|
473 | + ); |
|
474 | + } |
|
475 | + } |
|
476 | + } |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Add meta data. |
|
481 | + * |
|
482 | + * @since 1.0.19 |
|
483 | + * |
|
484 | + * @param string $key Meta key. |
|
485 | + * @param string|array $value Meta value. |
|
486 | + * @param bool $unique Should this be a unique key?. |
|
487 | + */ |
|
488 | + public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | + if ( $this->is_internal_meta_key( $key ) ) { |
|
490 | + $function = 'set_' . $key; |
|
491 | + |
|
492 | + if ( is_callable( array( $this, $function ) ) ) { |
|
493 | + return $this->{$function}( $value ); |
|
494 | + } |
|
495 | + } |
|
496 | + |
|
497 | + $this->maybe_read_meta_data(); |
|
498 | + if ( $unique ) { |
|
499 | + $this->delete_meta_data( $key ); |
|
500 | + } |
|
501 | + $this->meta_data[] = new GetPaid_Meta_Data( |
|
502 | + array( |
|
503 | + 'key' => $key, |
|
504 | + 'value' => $value, |
|
505 | + ) |
|
506 | + ); |
|
507 | + |
|
508 | + $this->save(); |
|
509 | + } |
|
510 | + |
|
511 | + /** |
|
512 | + * Update meta data by key or ID, if provided. |
|
513 | + * |
|
514 | + * @since 1.0.19 |
|
515 | + * |
|
516 | + * @param string $key Meta key. |
|
517 | + * @param string|array $value Meta value. |
|
518 | + * @param int $meta_id Meta ID. |
|
519 | + */ |
|
520 | + public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
521 | + if ( $this->is_internal_meta_key( $key ) ) { |
|
522 | + $function = 'set_' . $key; |
|
523 | + |
|
524 | + if ( is_callable( array( $this, $function ) ) ) { |
|
525 | + return $this->{$function}( $value ); |
|
526 | + } |
|
527 | + } |
|
528 | + |
|
529 | + $this->maybe_read_meta_data(); |
|
530 | + |
|
531 | + $array_key = false; |
|
532 | + |
|
533 | + if ( $meta_id ) { |
|
534 | + $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
535 | + $array_key = $array_keys ? current( $array_keys ) : false; |
|
536 | + } else { |
|
537 | + // Find matches by key. |
|
538 | + $matches = array(); |
|
539 | + foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
540 | + if ( $meta->key === $key ) { |
|
541 | + $matches[] = $meta_data_array_key; |
|
542 | + } |
|
543 | + } |
|
544 | + |
|
545 | + if ( ! empty( $matches ) ) { |
|
546 | + // Set matches to null so only one key gets the new value. |
|
547 | + foreach ( $matches as $meta_data_array_key ) { |
|
548 | + $this->meta_data[ $meta_data_array_key ]->value = null; |
|
549 | + } |
|
550 | + $array_key = current( $matches ); |
|
551 | + } |
|
552 | + } |
|
553 | + |
|
554 | + if ( false !== $array_key ) { |
|
555 | + $meta = $this->meta_data[ $array_key ]; |
|
556 | + $meta->key = $key; |
|
557 | + $meta->value = $value; |
|
558 | + } else { |
|
559 | + $this->add_meta_data( $key, $value, true ); |
|
560 | + } |
|
561 | + } |
|
562 | + |
|
563 | + /** |
|
564 | + * Delete meta data. |
|
565 | + * |
|
566 | + * @since 1.0.19 |
|
567 | + * @param string $key Meta key. |
|
568 | + */ |
|
569 | + public function delete_meta_data( $key ) { |
|
570 | + $this->maybe_read_meta_data(); |
|
571 | + $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
572 | + |
|
573 | + if ( $array_keys ) { |
|
574 | + foreach ( $array_keys as $array_key ) { |
|
575 | + $this->meta_data[ $array_key ]->value = null; |
|
576 | + } |
|
577 | + } |
|
578 | + } |
|
579 | + |
|
580 | + /** |
|
581 | + * Delete meta data. |
|
582 | + * |
|
583 | + * @since 1.0.19 |
|
584 | + * @param int $mid Meta ID. |
|
585 | + */ |
|
586 | + public function delete_meta_data_by_mid( $mid ) { |
|
587 | + $this->maybe_read_meta_data(); |
|
588 | + $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
589 | + |
|
590 | + if ( $array_keys ) { |
|
591 | + foreach ( $array_keys as $array_key ) { |
|
592 | + $this->meta_data[ $array_key ]->value = null; |
|
593 | + } |
|
594 | + } |
|
595 | + } |
|
596 | + |
|
597 | + /** |
|
598 | + * Read meta data if null. |
|
599 | + * |
|
600 | + * @since 1.0.19 |
|
601 | + */ |
|
602 | + protected function maybe_read_meta_data() { |
|
603 | + if ( is_null( $this->meta_data ) ) { |
|
604 | + $this->read_meta_data(); |
|
605 | + } |
|
606 | + } |
|
607 | + |
|
608 | + /** |
|
609 | + * Read Meta Data from the database. Ignore any internal properties. |
|
610 | + * Uses it's own caches because get_metadata does not provide meta_ids. |
|
611 | + * |
|
612 | + * @since 1.0.19 |
|
613 | + * @param bool $force_read True to force a new DB read (and update cache). |
|
614 | + */ |
|
615 | + public function read_meta_data( $force_read = false ) { |
|
616 | + |
|
617 | + // Reset meta data. |
|
618 | + $this->meta_data = array(); |
|
619 | + |
|
620 | + // Maybe abort early. |
|
621 | + if ( ! $this->get_id() || ! $this->data_store ) { |
|
622 | + return; |
|
623 | + } |
|
624 | + |
|
625 | + // Only read from cache if the cache key is set. |
|
626 | + $cache_key = null; |
|
627 | + if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
628 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
629 | + $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
630 | + } |
|
631 | + |
|
632 | + // Should we force read? |
|
633 | + if ( empty( $raw_meta_data ) ) { |
|
634 | + $raw_meta_data = $this->data_store->read_meta( $this ); |
|
635 | + |
|
636 | + if ( ! empty( $cache_key ) ) { |
|
637 | + wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
638 | + } |
|
639 | + |
|
640 | + } |
|
641 | + |
|
642 | + // Set meta data. |
|
643 | + if ( is_array( $raw_meta_data ) ) { |
|
644 | + |
|
645 | + foreach ( $raw_meta_data as $meta ) { |
|
646 | + $this->meta_data[] = new GetPaid_Meta_Data( |
|
647 | + array( |
|
648 | + 'id' => (int) $meta->meta_id, |
|
649 | + 'key' => $meta->meta_key, |
|
650 | + 'value' => maybe_unserialize( $meta->meta_value ), |
|
651 | + ) |
|
652 | + ); |
|
653 | + } |
|
654 | + |
|
655 | + } |
|
656 | + |
|
657 | + } |
|
658 | + |
|
659 | + /** |
|
660 | + * Update Meta Data in the database. |
|
661 | + * |
|
662 | + * @since 1.0.19 |
|
663 | + */ |
|
664 | + public function save_meta_data() { |
|
665 | + if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
666 | + return; |
|
667 | + } |
|
668 | + foreach ( $this->meta_data as $array_key => $meta ) { |
|
669 | + if ( is_null( $meta->value ) ) { |
|
670 | + if ( ! empty( $meta->id ) ) { |
|
671 | + $this->data_store->delete_meta( $this, $meta ); |
|
672 | + unset( $this->meta_data[ $array_key ] ); |
|
673 | + } |
|
674 | + } elseif ( empty( $meta->id ) ) { |
|
675 | + $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
676 | + $meta->apply_changes(); |
|
677 | + } else { |
|
678 | + if ( $meta->get_changes() ) { |
|
679 | + $this->data_store->update_meta( $this, $meta ); |
|
680 | + $meta->apply_changes(); |
|
681 | + } |
|
682 | + } |
|
683 | + } |
|
684 | + if ( ! empty( $this->cache_group ) ) { |
|
685 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
686 | + wp_cache_delete( $cache_key, $this->cache_group ); |
|
687 | + } |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Set ID. |
|
692 | + * |
|
693 | + * @since 1.0.19 |
|
694 | + * @param int $id ID. |
|
695 | + */ |
|
696 | + public function set_id( $id ) { |
|
697 | + $this->id = absint( $id ); |
|
698 | + } |
|
699 | + |
|
700 | + /** |
|
701 | + * Sets item status. |
|
702 | + * |
|
703 | + * @since 1.0.19 |
|
704 | + * @param string $status New status. |
|
705 | + * @return array details of change. |
|
706 | + */ |
|
707 | + public function set_status( $status ) { |
|
708 | 708 | $old_status = $this->get_status(); |
709 | 709 | |
710 | - $this->set_prop( 'status', $status ); |
|
711 | - |
|
712 | - return array( |
|
713 | - 'from' => $old_status, |
|
714 | - 'to' => $status, |
|
715 | - ); |
|
716 | - } |
|
717 | - |
|
718 | - /** |
|
719 | - * Set all props to default values. |
|
720 | - * |
|
721 | - * @since 1.0.19 |
|
722 | - */ |
|
723 | - public function set_defaults() { |
|
724 | - $this->data = $this->default_data; |
|
725 | - $this->changes = array(); |
|
726 | - $this->set_object_read( false ); |
|
727 | - } |
|
728 | - |
|
729 | - /** |
|
730 | - * Set object read property. |
|
731 | - * |
|
732 | - * @since 1.0.19 |
|
733 | - * @param boolean $read Should read?. |
|
734 | - */ |
|
735 | - public function set_object_read( $read = true ) { |
|
736 | - $this->object_read = (bool) $read; |
|
737 | - } |
|
738 | - |
|
739 | - /** |
|
740 | - * Get object read property. |
|
741 | - * |
|
742 | - * @since 1.0.19 |
|
743 | - * @return boolean |
|
744 | - */ |
|
745 | - public function get_object_read() { |
|
746 | - return (bool) $this->object_read; |
|
747 | - } |
|
748 | - |
|
749 | - /** |
|
750 | - * Set a collection of props in one go, collect any errors, and return the result. |
|
751 | - * Only sets using public methods. |
|
752 | - * |
|
753 | - * @since 1.0.19 |
|
754 | - * |
|
755 | - * @param array $props Key value pairs to set. Key is the prop and should map to a setter function name. |
|
756 | - * @param string $context In what context to run this. |
|
757 | - * |
|
758 | - * @return bool|WP_Error |
|
759 | - */ |
|
760 | - public function set_props( $props, $context = 'set' ) { |
|
761 | - $errors = false; |
|
762 | - |
|
763 | - $props = wp_unslash( $props ); |
|
764 | - foreach ( $props as $prop => $value ) { |
|
765 | - try { |
|
766 | - /** |
|
767 | - * Checks if the prop being set is allowed, and the value is not null. |
|
768 | - */ |
|
769 | - if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
770 | - continue; |
|
771 | - } |
|
772 | - $setter = "set_$prop"; |
|
773 | - |
|
774 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
775 | - $this->{$setter}( $value ); |
|
776 | - } |
|
777 | - } catch ( Exception $e ) { |
|
778 | - if ( ! $errors ) { |
|
779 | - $errors = new WP_Error(); |
|
780 | - } |
|
781 | - $errors->add( $e->getCode(), $e->getMessage() ); |
|
782 | - $this->last_error = $e->getMessage(); |
|
783 | - } |
|
784 | - } |
|
785 | - |
|
786 | - return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
787 | - } |
|
788 | - |
|
789 | - /** |
|
790 | - * Sets a prop for a setter method. |
|
791 | - * |
|
792 | - * This stores changes in a special array so we can track what needs saving |
|
793 | - * the the DB later. |
|
794 | - * |
|
795 | - * @since 1.0.19 |
|
796 | - * @param string $prop Name of prop to set. |
|
797 | - * @param mixed $value Value of the prop. |
|
798 | - */ |
|
799 | - protected function set_prop( $prop, $value ) { |
|
800 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
801 | - if ( true === $this->object_read ) { |
|
802 | - if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
803 | - $this->changes[ $prop ] = $value; |
|
804 | - } |
|
805 | - } else { |
|
806 | - $this->data[ $prop ] = $value; |
|
807 | - } |
|
808 | - } |
|
809 | - } |
|
810 | - |
|
811 | - /** |
|
812 | - * Return data changes only. |
|
813 | - * |
|
814 | - * @since 1.0.19 |
|
815 | - * @return array |
|
816 | - */ |
|
817 | - public function get_changes() { |
|
818 | - return $this->changes; |
|
819 | - } |
|
820 | - |
|
821 | - /** |
|
822 | - * Merge changes with data and clear. |
|
823 | - * |
|
824 | - * @since 1.0.19 |
|
825 | - */ |
|
826 | - public function apply_changes() { |
|
827 | - $this->data = array_replace( $this->data, $this->changes ); |
|
828 | - $this->changes = array(); |
|
829 | - } |
|
830 | - |
|
831 | - /** |
|
832 | - * Prefix for action and filter hooks on data. |
|
833 | - * |
|
834 | - * @since 1.0.19 |
|
835 | - * @return string |
|
836 | - */ |
|
837 | - protected function get_hook_prefix() { |
|
838 | - return 'wpinv_get_' . $this->object_type . '_'; |
|
839 | - } |
|
840 | - |
|
841 | - /** |
|
842 | - * Gets a prop for a getter method. |
|
843 | - * |
|
844 | - * Gets the value from either current pending changes, or the data itself. |
|
845 | - * Context controls what happens to the value before it's returned. |
|
846 | - * |
|
847 | - * @since 1.0.19 |
|
848 | - * @param string $prop Name of prop to get. |
|
849 | - * @param string $context What the value is for. Valid values are view and edit. |
|
850 | - * @return mixed |
|
851 | - */ |
|
852 | - protected function get_prop( $prop, $context = 'view' ) { |
|
853 | - $value = null; |
|
854 | - |
|
855 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
856 | - $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
857 | - |
|
858 | - if ( 'view' === $context ) { |
|
859 | - $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
860 | - } |
|
861 | - } |
|
862 | - |
|
863 | - return $value; |
|
864 | - } |
|
865 | - |
|
866 | - /** |
|
867 | - * Sets a date prop whilst handling formatting and datetime objects. |
|
868 | - * |
|
869 | - * @since 1.0.19 |
|
870 | - * @param string $prop Name of prop to set. |
|
871 | - * @param string|integer $value Value of the prop. |
|
872 | - */ |
|
873 | - protected function set_date_prop( $prop, $value ) { |
|
874 | - |
|
875 | - if ( empty( $value ) ) { |
|
876 | - $this->set_prop( $prop, null ); |
|
877 | - return; |
|
878 | - } |
|
879 | - $this->set_prop( $prop, $value ); |
|
880 | - |
|
881 | - } |
|
882 | - |
|
883 | - /** |
|
884 | - * When invalid data is found, throw an exception unless reading from the DB. |
|
885 | - * |
|
886 | - * @since 1.0.19 |
|
887 | - * @param string $code Error code. |
|
888 | - * @param string $message Error message. |
|
889 | - */ |
|
890 | - protected function error( $code, $message ) { |
|
891 | - $this->last_error = $message; |
|
892 | - } |
|
893 | - |
|
894 | - /** |
|
895 | - * Checks if the object is saved in the database |
|
896 | - * |
|
897 | - * @since 1.0.19 |
|
898 | - * @return bool |
|
899 | - */ |
|
900 | - public function exists() { |
|
901 | - $id = $this->get_id(); |
|
902 | - return ! empty( $id ); |
|
903 | - } |
|
710 | + $this->set_prop( 'status', $status ); |
|
711 | + |
|
712 | + return array( |
|
713 | + 'from' => $old_status, |
|
714 | + 'to' => $status, |
|
715 | + ); |
|
716 | + } |
|
717 | + |
|
718 | + /** |
|
719 | + * Set all props to default values. |
|
720 | + * |
|
721 | + * @since 1.0.19 |
|
722 | + */ |
|
723 | + public function set_defaults() { |
|
724 | + $this->data = $this->default_data; |
|
725 | + $this->changes = array(); |
|
726 | + $this->set_object_read( false ); |
|
727 | + } |
|
728 | + |
|
729 | + /** |
|
730 | + * Set object read property. |
|
731 | + * |
|
732 | + * @since 1.0.19 |
|
733 | + * @param boolean $read Should read?. |
|
734 | + */ |
|
735 | + public function set_object_read( $read = true ) { |
|
736 | + $this->object_read = (bool) $read; |
|
737 | + } |
|
738 | + |
|
739 | + /** |
|
740 | + * Get object read property. |
|
741 | + * |
|
742 | + * @since 1.0.19 |
|
743 | + * @return boolean |
|
744 | + */ |
|
745 | + public function get_object_read() { |
|
746 | + return (bool) $this->object_read; |
|
747 | + } |
|
748 | + |
|
749 | + /** |
|
750 | + * Set a collection of props in one go, collect any errors, and return the result. |
|
751 | + * Only sets using public methods. |
|
752 | + * |
|
753 | + * @since 1.0.19 |
|
754 | + * |
|
755 | + * @param array $props Key value pairs to set. Key is the prop and should map to a setter function name. |
|
756 | + * @param string $context In what context to run this. |
|
757 | + * |
|
758 | + * @return bool|WP_Error |
|
759 | + */ |
|
760 | + public function set_props( $props, $context = 'set' ) { |
|
761 | + $errors = false; |
|
762 | + |
|
763 | + $props = wp_unslash( $props ); |
|
764 | + foreach ( $props as $prop => $value ) { |
|
765 | + try { |
|
766 | + /** |
|
767 | + * Checks if the prop being set is allowed, and the value is not null. |
|
768 | + */ |
|
769 | + if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
770 | + continue; |
|
771 | + } |
|
772 | + $setter = "set_$prop"; |
|
773 | + |
|
774 | + if ( is_callable( array( $this, $setter ) ) ) { |
|
775 | + $this->{$setter}( $value ); |
|
776 | + } |
|
777 | + } catch ( Exception $e ) { |
|
778 | + if ( ! $errors ) { |
|
779 | + $errors = new WP_Error(); |
|
780 | + } |
|
781 | + $errors->add( $e->getCode(), $e->getMessage() ); |
|
782 | + $this->last_error = $e->getMessage(); |
|
783 | + } |
|
784 | + } |
|
785 | + |
|
786 | + return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
787 | + } |
|
788 | + |
|
789 | + /** |
|
790 | + * Sets a prop for a setter method. |
|
791 | + * |
|
792 | + * This stores changes in a special array so we can track what needs saving |
|
793 | + * the the DB later. |
|
794 | + * |
|
795 | + * @since 1.0.19 |
|
796 | + * @param string $prop Name of prop to set. |
|
797 | + * @param mixed $value Value of the prop. |
|
798 | + */ |
|
799 | + protected function set_prop( $prop, $value ) { |
|
800 | + if ( array_key_exists( $prop, $this->data ) ) { |
|
801 | + if ( true === $this->object_read ) { |
|
802 | + if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
803 | + $this->changes[ $prop ] = $value; |
|
804 | + } |
|
805 | + } else { |
|
806 | + $this->data[ $prop ] = $value; |
|
807 | + } |
|
808 | + } |
|
809 | + } |
|
810 | + |
|
811 | + /** |
|
812 | + * Return data changes only. |
|
813 | + * |
|
814 | + * @since 1.0.19 |
|
815 | + * @return array |
|
816 | + */ |
|
817 | + public function get_changes() { |
|
818 | + return $this->changes; |
|
819 | + } |
|
820 | + |
|
821 | + /** |
|
822 | + * Merge changes with data and clear. |
|
823 | + * |
|
824 | + * @since 1.0.19 |
|
825 | + */ |
|
826 | + public function apply_changes() { |
|
827 | + $this->data = array_replace( $this->data, $this->changes ); |
|
828 | + $this->changes = array(); |
|
829 | + } |
|
830 | + |
|
831 | + /** |
|
832 | + * Prefix for action and filter hooks on data. |
|
833 | + * |
|
834 | + * @since 1.0.19 |
|
835 | + * @return string |
|
836 | + */ |
|
837 | + protected function get_hook_prefix() { |
|
838 | + return 'wpinv_get_' . $this->object_type . '_'; |
|
839 | + } |
|
840 | + |
|
841 | + /** |
|
842 | + * Gets a prop for a getter method. |
|
843 | + * |
|
844 | + * Gets the value from either current pending changes, or the data itself. |
|
845 | + * Context controls what happens to the value before it's returned. |
|
846 | + * |
|
847 | + * @since 1.0.19 |
|
848 | + * @param string $prop Name of prop to get. |
|
849 | + * @param string $context What the value is for. Valid values are view and edit. |
|
850 | + * @return mixed |
|
851 | + */ |
|
852 | + protected function get_prop( $prop, $context = 'view' ) { |
|
853 | + $value = null; |
|
854 | + |
|
855 | + if ( array_key_exists( $prop, $this->data ) ) { |
|
856 | + $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
857 | + |
|
858 | + if ( 'view' === $context ) { |
|
859 | + $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
860 | + } |
|
861 | + } |
|
862 | + |
|
863 | + return $value; |
|
864 | + } |
|
865 | + |
|
866 | + /** |
|
867 | + * Sets a date prop whilst handling formatting and datetime objects. |
|
868 | + * |
|
869 | + * @since 1.0.19 |
|
870 | + * @param string $prop Name of prop to set. |
|
871 | + * @param string|integer $value Value of the prop. |
|
872 | + */ |
|
873 | + protected function set_date_prop( $prop, $value ) { |
|
874 | + |
|
875 | + if ( empty( $value ) ) { |
|
876 | + $this->set_prop( $prop, null ); |
|
877 | + return; |
|
878 | + } |
|
879 | + $this->set_prop( $prop, $value ); |
|
880 | + |
|
881 | + } |
|
882 | + |
|
883 | + /** |
|
884 | + * When invalid data is found, throw an exception unless reading from the DB. |
|
885 | + * |
|
886 | + * @since 1.0.19 |
|
887 | + * @param string $code Error code. |
|
888 | + * @param string $message Error message. |
|
889 | + */ |
|
890 | + protected function error( $code, $message ) { |
|
891 | + $this->last_error = $message; |
|
892 | + } |
|
893 | + |
|
894 | + /** |
|
895 | + * Checks if the object is saved in the database |
|
896 | + * |
|
897 | + * @since 1.0.19 |
|
898 | + * @return bool |
|
899 | + */ |
|
900 | + public function exists() { |
|
901 | + $id = $this->get_id(); |
|
902 | + return ! empty( $id ); |
|
903 | + } |
|
904 | 904 | |
905 | 905 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if (!defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
119 | 119 | */ |
120 | - public function __construct( $read = 0 ) { |
|
121 | - $this->data = array_merge( $this->data, $this->extra_data ); |
|
120 | + public function __construct($read = 0) { |
|
121 | + $this->data = array_merge($this->data, $this->extra_data); |
|
122 | 122 | $this->default_data = $this->data; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function __sleep() { |
131 | - return array( 'id' ); |
|
131 | + return array('id'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * If the object no longer exists, remove the ID. |
138 | 138 | */ |
139 | 139 | public function __wakeup() { |
140 | - $this->__construct( absint( $this->id ) ); |
|
140 | + $this->__construct(absint($this->id)); |
|
141 | 141 | |
142 | - if ( ! empty( $this->last_error ) ) { |
|
143 | - $this->set_id( 0 ); |
|
142 | + if (!empty($this->last_error)) { |
|
143 | + $this->set_id(0); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function __clone() { |
154 | 154 | $this->maybe_read_meta_data(); |
155 | - if ( ! empty( $this->meta_data ) ) { |
|
156 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | - $this->meta_data[ $array_key ] = clone $meta; |
|
158 | - if ( ! empty( $meta->id ) ) { |
|
159 | - $this->meta_data[ $array_key ]->id = null; |
|
155 | + if (!empty($this->meta_data)) { |
|
156 | + foreach ($this->meta_data as $array_key => $meta) { |
|
157 | + $this->meta_data[$array_key] = clone $meta; |
|
158 | + if (!empty($meta->id)) { |
|
159 | + $this->meta_data[$array_key]->id = null; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_status( $context = 'view' ) { |
|
203 | - return $this->get_prop( 'status', $context ); |
|
202 | + public function get_status($context = 'view') { |
|
203 | + return $this->get_prop('status', $context); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * @param bool $force_delete Should the data be deleted permanently. |
211 | 211 | * @return bool result |
212 | 212 | */ |
213 | - public function delete( $force_delete = false ) { |
|
214 | - if ( $this->data_store && $this->exists() ) { |
|
215 | - $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | - $this->set_id( 0 ); |
|
213 | + public function delete($force_delete = false) { |
|
214 | + if ($this->data_store && $this->exists()) { |
|
215 | + $this->data_store->delete($this, array('force_delete' => $force_delete)); |
|
216 | + $this->set_id(0); |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return int |
227 | 227 | */ |
228 | 228 | public function save() { |
229 | - if ( ! $this->data_store ) { |
|
229 | + if (!$this->data_store) { |
|
230 | 230 | return $this->get_id(); |
231 | 231 | } |
232 | 232 | |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @param GetPaid_Data $this The object being saved. |
237 | 237 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
238 | 238 | */ |
239 | - do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
239 | + do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
240 | 240 | |
241 | - if ( $this->get_id() ) { |
|
242 | - $this->data_store->update( $this ); |
|
241 | + if ($this->get_id()) { |
|
242 | + $this->data_store->update($this); |
|
243 | 243 | } else { |
244 | - $this->data_store->create( $this ); |
|
244 | + $this->data_store->create($this); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param GetPaid_Data $this The object being saved. |
251 | 251 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
252 | 252 | */ |
253 | - do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
253 | + do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
254 | 254 | |
255 | 255 | return $this->get_id(); |
256 | 256 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return string Data in JSON format. |
263 | 263 | */ |
264 | 264 | public function __toString() { |
265 | - return wp_json_encode( $this->get_data() ); |
|
265 | + return wp_json_encode($this->get_data()); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return array |
273 | 273 | */ |
274 | 274 | public function get_data() { |
275 | - return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
275 | + return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data())); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return array |
283 | 283 | */ |
284 | 284 | public function get_data_keys() { |
285 | - return array_keys( $this->data ); |
|
285 | + return array_keys($this->data); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return array |
293 | 293 | */ |
294 | 294 | public function get_extra_data_keys() { |
295 | - return array_keys( $this->extra_data ); |
|
295 | + return array_keys($this->extra_data); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param mixed $meta Meta value to check. |
303 | 303 | * @return bool |
304 | 304 | */ |
305 | - protected function filter_null_meta( $meta ) { |
|
306 | - return ! is_null( $meta->value ); |
|
305 | + protected function filter_null_meta($meta) { |
|
306 | + return !is_null($meta->value); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_meta_data() { |
316 | 316 | $this->maybe_read_meta_data(); |
317 | - return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
317 | + return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta'))); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * @param string $key Key to check. |
325 | 325 | * @return bool true if it's an internal key, false otherwise |
326 | 326 | */ |
327 | - protected function is_internal_meta_key( $key ) { |
|
328 | - $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
327 | + protected function is_internal_meta_key($key) { |
|
328 | + $internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true); |
|
329 | 329 | |
330 | - if ( ! $internal_meta_key ) { |
|
330 | + if (!$internal_meta_key) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
334 | - $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
334 | + $has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key)); |
|
335 | 335 | |
336 | - if ( ! $has_setter_or_getter ) { |
|
336 | + if (!$has_setter_or_getter) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | 340 | /* translators: %s: $key Key to check */ |
341 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
341 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
342 | 342 | |
343 | 343 | return true; |
344 | 344 | } |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | * @access public |
353 | 353 | * |
354 | 354 | */ |
355 | - public function __set( $key, $value ) { |
|
355 | + public function __set($key, $value) { |
|
356 | 356 | |
357 | - if ( 'id' == strtolower( $key ) ) { |
|
358 | - return $this->set_id( $value ); |
|
357 | + if ('id' == strtolower($key)) { |
|
358 | + return $this->set_id($value); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( method_exists( $this, "set_$key") ) { |
|
361 | + if (method_exists($this, "set_$key")) { |
|
362 | 362 | |
363 | 363 | /* translators: %s: $key Key to set */ |
364 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
364 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
365 | 365 | |
366 | - call_user_func( array( $this, "set_$key" ), $value ); |
|
366 | + call_user_func(array($this, "set_$key"), $value); |
|
367 | 367 | } else { |
368 | - $this->set_prop( $key, $value ); |
|
368 | + $this->set_prop($key, $value); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
@@ -373,25 +373,25 @@ discard block |
||
373 | 373 | /** |
374 | 374 | * Margic method for retrieving a property. |
375 | 375 | */ |
376 | - public function __get( $key ) { |
|
376 | + public function __get($key) { |
|
377 | 377 | |
378 | 378 | // Check if we have a helper method for that. |
379 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
379 | + if (method_exists($this, 'get_' . $key)) { |
|
380 | 380 | |
381 | - if ( 'post_type' != $key ) { |
|
381 | + if ('post_type' != $key) { |
|
382 | 382 | /* translators: %s: $key Key to set */ |
383 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
383 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
384 | 384 | } |
385 | 385 | |
386 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
386 | + return call_user_func(array($this, 'get_' . $key)); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Check if the key is in the associated $post object. |
390 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
390 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
391 | 391 | return $this->post->$key; |
392 | 392 | } |
393 | 393 | |
394 | - return $this->get_prop( $key ); |
|
394 | + return $this->get_prop($key); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | * @param string $context What the value is for. Valid values are view and edit. |
405 | 405 | * @return mixed |
406 | 406 | */ |
407 | - public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
407 | + public function get_meta($key = '', $single = true, $context = 'view') { |
|
408 | 408 | |
409 | 409 | // Check if this is an internal meta key. |
410 | - $_key = str_replace( '_wpinv', '', $key ); |
|
411 | - $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
410 | + $_key = str_replace('_wpinv', '', $key); |
|
411 | + $_key = str_replace('wpinv', '', $_key); |
|
412 | + if ($this->is_internal_meta_key($key)) { |
|
413 | 413 | $function = 'get_' . $_key; |
414 | 414 | |
415 | - if ( is_callable( array( $this, $function ) ) ) { |
|
415 | + if (is_callable(array($this, $function))) { |
|
416 | 416 | return $this->{$function}(); |
417 | 417 | } |
418 | 418 | } |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | // Read the meta data if not yet read. |
421 | 421 | $this->maybe_read_meta_data(); |
422 | 422 | $meta_data = $this->get_meta_data(); |
423 | - $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
423 | + $array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true); |
|
424 | 424 | $value = $single ? '' : array(); |
425 | 425 | |
426 | - if ( ! empty( $array_keys ) ) { |
|
426 | + if (!empty($array_keys)) { |
|
427 | 427 | // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
428 | - if ( $single ) { |
|
429 | - $value = $meta_data[ current( $array_keys ) ]->value; |
|
428 | + if ($single) { |
|
429 | + $value = $meta_data[current($array_keys)]->value; |
|
430 | 430 | } else { |
431 | - $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
431 | + $value = array_intersect_key($meta_data, array_flip($array_keys)); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( 'view' === $context ) { |
|
436 | - $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
435 | + if ('view' === $context) { |
|
436 | + $value = apply_filters($this->get_hook_prefix() . $key, $value, $this); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $value; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * @param string $key Meta Key. |
447 | 447 | * @return boolean |
448 | 448 | */ |
449 | - public function meta_exists( $key = '' ) { |
|
449 | + public function meta_exists($key = '') { |
|
450 | 450 | $this->maybe_read_meta_data(); |
451 | - $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | - return in_array( $key, $array_keys, true ); |
|
451 | + $array_keys = wp_list_pluck($this->get_meta_data(), 'key'); |
|
452 | + return in_array($key, $array_keys, true); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * @since 1.0.19 |
459 | 459 | * @param array $data Key/Value pairs. |
460 | 460 | */ |
461 | - public function set_meta_data( $data ) { |
|
462 | - if ( ! empty( $data ) && is_array( $data ) ) { |
|
461 | + public function set_meta_data($data) { |
|
462 | + if (!empty($data) && is_array($data)) { |
|
463 | 463 | $this->maybe_read_meta_data(); |
464 | - foreach ( $data as $meta ) { |
|
464 | + foreach ($data as $meta) { |
|
465 | 465 | $meta = (array) $meta; |
466 | - if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
466 | + if (isset($meta['key'], $meta['value'], $meta['id'])) { |
|
467 | 467 | $this->meta_data[] = new GetPaid_Meta_Data( |
468 | 468 | array( |
469 | 469 | 'id' => $meta['id'], |
@@ -485,18 +485,18 @@ discard block |
||
485 | 485 | * @param string|array $value Meta value. |
486 | 486 | * @param bool $unique Should this be a unique key?. |
487 | 487 | */ |
488 | - public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
488 | + public function add_meta_data($key, $value, $unique = false) { |
|
489 | + if ($this->is_internal_meta_key($key)) { |
|
490 | 490 | $function = 'set_' . $key; |
491 | 491 | |
492 | - if ( is_callable( array( $this, $function ) ) ) { |
|
493 | - return $this->{$function}( $value ); |
|
492 | + if (is_callable(array($this, $function))) { |
|
493 | + return $this->{$function}($value); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | $this->maybe_read_meta_data(); |
498 | - if ( $unique ) { |
|
499 | - $this->delete_meta_data( $key ); |
|
498 | + if ($unique) { |
|
499 | + $this->delete_meta_data($key); |
|
500 | 500 | } |
501 | 501 | $this->meta_data[] = new GetPaid_Meta_Data( |
502 | 502 | array( |
@@ -517,12 +517,12 @@ discard block |
||
517 | 517 | * @param string|array $value Meta value. |
518 | 518 | * @param int $meta_id Meta ID. |
519 | 519 | */ |
520 | - public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
521 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
520 | + public function update_meta_data($key, $value, $meta_id = 0) { |
|
521 | + if ($this->is_internal_meta_key($key)) { |
|
522 | 522 | $function = 'set_' . $key; |
523 | 523 | |
524 | - if ( is_callable( array( $this, $function ) ) ) { |
|
525 | - return $this->{$function}( $value ); |
|
524 | + if (is_callable(array($this, $function))) { |
|
525 | + return $this->{$function}($value); |
|
526 | 526 | } |
527 | 527 | } |
528 | 528 | |
@@ -530,33 +530,33 @@ discard block |
||
530 | 530 | |
531 | 531 | $array_key = false; |
532 | 532 | |
533 | - if ( $meta_id ) { |
|
534 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
535 | - $array_key = $array_keys ? current( $array_keys ) : false; |
|
533 | + if ($meta_id) { |
|
534 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true); |
|
535 | + $array_key = $array_keys ? current($array_keys) : false; |
|
536 | 536 | } else { |
537 | 537 | // Find matches by key. |
538 | 538 | $matches = array(); |
539 | - foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
540 | - if ( $meta->key === $key ) { |
|
539 | + foreach ($this->meta_data as $meta_data_array_key => $meta) { |
|
540 | + if ($meta->key === $key) { |
|
541 | 541 | $matches[] = $meta_data_array_key; |
542 | 542 | } |
543 | 543 | } |
544 | 544 | |
545 | - if ( ! empty( $matches ) ) { |
|
545 | + if (!empty($matches)) { |
|
546 | 546 | // Set matches to null so only one key gets the new value. |
547 | - foreach ( $matches as $meta_data_array_key ) { |
|
548 | - $this->meta_data[ $meta_data_array_key ]->value = null; |
|
547 | + foreach ($matches as $meta_data_array_key) { |
|
548 | + $this->meta_data[$meta_data_array_key]->value = null; |
|
549 | 549 | } |
550 | - $array_key = current( $matches ); |
|
550 | + $array_key = current($matches); |
|
551 | 551 | } |
552 | 552 | } |
553 | 553 | |
554 | - if ( false !== $array_key ) { |
|
555 | - $meta = $this->meta_data[ $array_key ]; |
|
554 | + if (false !== $array_key) { |
|
555 | + $meta = $this->meta_data[$array_key]; |
|
556 | 556 | $meta->key = $key; |
557 | 557 | $meta->value = $value; |
558 | 558 | } else { |
559 | - $this->add_meta_data( $key, $value, true ); |
|
559 | + $this->add_meta_data($key, $value, true); |
|
560 | 560 | } |
561 | 561 | } |
562 | 562 | |
@@ -566,13 +566,13 @@ discard block |
||
566 | 566 | * @since 1.0.19 |
567 | 567 | * @param string $key Meta key. |
568 | 568 | */ |
569 | - public function delete_meta_data( $key ) { |
|
569 | + public function delete_meta_data($key) { |
|
570 | 570 | $this->maybe_read_meta_data(); |
571 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
571 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true); |
|
572 | 572 | |
573 | - if ( $array_keys ) { |
|
574 | - foreach ( $array_keys as $array_key ) { |
|
575 | - $this->meta_data[ $array_key ]->value = null; |
|
573 | + if ($array_keys) { |
|
574 | + foreach ($array_keys as $array_key) { |
|
575 | + $this->meta_data[$array_key]->value = null; |
|
576 | 576 | } |
577 | 577 | } |
578 | 578 | } |
@@ -583,13 +583,13 @@ discard block |
||
583 | 583 | * @since 1.0.19 |
584 | 584 | * @param int $mid Meta ID. |
585 | 585 | */ |
586 | - public function delete_meta_data_by_mid( $mid ) { |
|
586 | + public function delete_meta_data_by_mid($mid) { |
|
587 | 587 | $this->maybe_read_meta_data(); |
588 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
588 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true); |
|
589 | 589 | |
590 | - if ( $array_keys ) { |
|
591 | - foreach ( $array_keys as $array_key ) { |
|
592 | - $this->meta_data[ $array_key ]->value = null; |
|
590 | + if ($array_keys) { |
|
591 | + foreach ($array_keys as $array_key) { |
|
592 | + $this->meta_data[$array_key]->value = null; |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | } |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | */ |
602 | 602 | protected function maybe_read_meta_data() { |
603 | - if ( is_null( $this->meta_data ) ) { |
|
603 | + if (is_null($this->meta_data)) { |
|
604 | 604 | $this->read_meta_data(); |
605 | 605 | } |
606 | 606 | } |
@@ -612,42 +612,42 @@ discard block |
||
612 | 612 | * @since 1.0.19 |
613 | 613 | * @param bool $force_read True to force a new DB read (and update cache). |
614 | 614 | */ |
615 | - public function read_meta_data( $force_read = false ) { |
|
615 | + public function read_meta_data($force_read = false) { |
|
616 | 616 | |
617 | 617 | // Reset meta data. |
618 | 618 | $this->meta_data = array(); |
619 | 619 | |
620 | 620 | // Maybe abort early. |
621 | - if ( ! $this->get_id() || ! $this->data_store ) { |
|
621 | + if (!$this->get_id() || !$this->data_store) { |
|
622 | 622 | return; |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Only read from cache if the cache key is set. |
626 | 626 | $cache_key = null; |
627 | - if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
628 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
629 | - $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
627 | + if (!$force_read && !empty($this->cache_group)) { |
|
628 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
629 | + $raw_meta_data = wp_cache_get($cache_key, $this->cache_group); |
|
630 | 630 | } |
631 | 631 | |
632 | 632 | // Should we force read? |
633 | - if ( empty( $raw_meta_data ) ) { |
|
634 | - $raw_meta_data = $this->data_store->read_meta( $this ); |
|
633 | + if (empty($raw_meta_data)) { |
|
634 | + $raw_meta_data = $this->data_store->read_meta($this); |
|
635 | 635 | |
636 | - if ( ! empty( $cache_key ) ) { |
|
637 | - wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
636 | + if (!empty($cache_key)) { |
|
637 | + wp_cache_set($cache_key, $raw_meta_data, $this->cache_group); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | } |
641 | 641 | |
642 | 642 | // Set meta data. |
643 | - if ( is_array( $raw_meta_data ) ) { |
|
643 | + if (is_array($raw_meta_data)) { |
|
644 | 644 | |
645 | - foreach ( $raw_meta_data as $meta ) { |
|
645 | + foreach ($raw_meta_data as $meta) { |
|
646 | 646 | $this->meta_data[] = new GetPaid_Meta_Data( |
647 | 647 | array( |
648 | 648 | 'id' => (int) $meta->meta_id, |
649 | 649 | 'key' => $meta->meta_key, |
650 | - 'value' => maybe_unserialize( $meta->meta_value ), |
|
650 | + 'value' => maybe_unserialize($meta->meta_value), |
|
651 | 651 | ) |
652 | 652 | ); |
653 | 653 | } |
@@ -662,28 +662,28 @@ discard block |
||
662 | 662 | * @since 1.0.19 |
663 | 663 | */ |
664 | 664 | public function save_meta_data() { |
665 | - if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
665 | + if (!$this->data_store || is_null($this->meta_data)) { |
|
666 | 666 | return; |
667 | 667 | } |
668 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
669 | - if ( is_null( $meta->value ) ) { |
|
670 | - if ( ! empty( $meta->id ) ) { |
|
671 | - $this->data_store->delete_meta( $this, $meta ); |
|
672 | - unset( $this->meta_data[ $array_key ] ); |
|
668 | + foreach ($this->meta_data as $array_key => $meta) { |
|
669 | + if (is_null($meta->value)) { |
|
670 | + if (!empty($meta->id)) { |
|
671 | + $this->data_store->delete_meta($this, $meta); |
|
672 | + unset($this->meta_data[$array_key]); |
|
673 | 673 | } |
674 | - } elseif ( empty( $meta->id ) ) { |
|
675 | - $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
674 | + } elseif (empty($meta->id)) { |
|
675 | + $meta->id = $this->data_store->add_meta($this, $meta); |
|
676 | 676 | $meta->apply_changes(); |
677 | 677 | } else { |
678 | - if ( $meta->get_changes() ) { |
|
679 | - $this->data_store->update_meta( $this, $meta ); |
|
678 | + if ($meta->get_changes()) { |
|
679 | + $this->data_store->update_meta($this, $meta); |
|
680 | 680 | $meta->apply_changes(); |
681 | 681 | } |
682 | 682 | } |
683 | 683 | } |
684 | - if ( ! empty( $this->cache_group ) ) { |
|
685 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
686 | - wp_cache_delete( $cache_key, $this->cache_group ); |
|
684 | + if (!empty($this->cache_group)) { |
|
685 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
686 | + wp_cache_delete($cache_key, $this->cache_group); |
|
687 | 687 | } |
688 | 688 | } |
689 | 689 | |
@@ -693,8 +693,8 @@ discard block |
||
693 | 693 | * @since 1.0.19 |
694 | 694 | * @param int $id ID. |
695 | 695 | */ |
696 | - public function set_id( $id ) { |
|
697 | - $this->id = absint( $id ); |
|
696 | + public function set_id($id) { |
|
697 | + $this->id = absint($id); |
|
698 | 698 | } |
699 | 699 | |
700 | 700 | /** |
@@ -704,10 +704,10 @@ discard block |
||
704 | 704 | * @param string $status New status. |
705 | 705 | * @return array details of change. |
706 | 706 | */ |
707 | - public function set_status( $status ) { |
|
707 | + public function set_status($status) { |
|
708 | 708 | $old_status = $this->get_status(); |
709 | 709 | |
710 | - $this->set_prop( 'status', $status ); |
|
710 | + $this->set_prop('status', $status); |
|
711 | 711 | |
712 | 712 | return array( |
713 | 713 | 'from' => $old_status, |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | public function set_defaults() { |
724 | 724 | $this->data = $this->default_data; |
725 | 725 | $this->changes = array(); |
726 | - $this->set_object_read( false ); |
|
726 | + $this->set_object_read(false); |
|
727 | 727 | } |
728 | 728 | |
729 | 729 | /** |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | * @since 1.0.19 |
733 | 733 | * @param boolean $read Should read?. |
734 | 734 | */ |
735 | - public function set_object_read( $read = true ) { |
|
735 | + public function set_object_read($read = true) { |
|
736 | 736 | $this->object_read = (bool) $read; |
737 | 737 | } |
738 | 738 | |
@@ -757,33 +757,33 @@ discard block |
||
757 | 757 | * |
758 | 758 | * @return bool|WP_Error |
759 | 759 | */ |
760 | - public function set_props( $props, $context = 'set' ) { |
|
760 | + public function set_props($props, $context = 'set') { |
|
761 | 761 | $errors = false; |
762 | 762 | |
763 | - $props = wp_unslash( $props ); |
|
764 | - foreach ( $props as $prop => $value ) { |
|
763 | + $props = wp_unslash($props); |
|
764 | + foreach ($props as $prop => $value) { |
|
765 | 765 | try { |
766 | 766 | /** |
767 | 767 | * Checks if the prop being set is allowed, and the value is not null. |
768 | 768 | */ |
769 | - if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
769 | + if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) { |
|
770 | 770 | continue; |
771 | 771 | } |
772 | 772 | $setter = "set_$prop"; |
773 | 773 | |
774 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
775 | - $this->{$setter}( $value ); |
|
774 | + if (is_callable(array($this, $setter))) { |
|
775 | + $this->{$setter}($value); |
|
776 | 776 | } |
777 | - } catch ( Exception $e ) { |
|
778 | - if ( ! $errors ) { |
|
777 | + } catch (Exception $e) { |
|
778 | + if (!$errors) { |
|
779 | 779 | $errors = new WP_Error(); |
780 | 780 | } |
781 | - $errors->add( $e->getCode(), $e->getMessage() ); |
|
781 | + $errors->add($e->getCode(), $e->getMessage()); |
|
782 | 782 | $this->last_error = $e->getMessage(); |
783 | 783 | } |
784 | 784 | } |
785 | 785 | |
786 | - return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
786 | + return $errors && count($errors->get_error_codes()) ? $errors : true; |
|
787 | 787 | } |
788 | 788 | |
789 | 789 | /** |
@@ -796,14 +796,14 @@ discard block |
||
796 | 796 | * @param string $prop Name of prop to set. |
797 | 797 | * @param mixed $value Value of the prop. |
798 | 798 | */ |
799 | - protected function set_prop( $prop, $value ) { |
|
800 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
801 | - if ( true === $this->object_read ) { |
|
802 | - if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
803 | - $this->changes[ $prop ] = $value; |
|
799 | + protected function set_prop($prop, $value) { |
|
800 | + if (array_key_exists($prop, $this->data)) { |
|
801 | + if (true === $this->object_read) { |
|
802 | + if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) { |
|
803 | + $this->changes[$prop] = $value; |
|
804 | 804 | } |
805 | 805 | } else { |
806 | - $this->data[ $prop ] = $value; |
|
806 | + $this->data[$prop] = $value; |
|
807 | 807 | } |
808 | 808 | } |
809 | 809 | } |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | * @since 1.0.19 |
825 | 825 | */ |
826 | 826 | public function apply_changes() { |
827 | - $this->data = array_replace( $this->data, $this->changes ); |
|
827 | + $this->data = array_replace($this->data, $this->changes); |
|
828 | 828 | $this->changes = array(); |
829 | 829 | } |
830 | 830 | |
@@ -849,14 +849,14 @@ discard block |
||
849 | 849 | * @param string $context What the value is for. Valid values are view and edit. |
850 | 850 | * @return mixed |
851 | 851 | */ |
852 | - protected function get_prop( $prop, $context = 'view' ) { |
|
852 | + protected function get_prop($prop, $context = 'view') { |
|
853 | 853 | $value = null; |
854 | 854 | |
855 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
856 | - $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
855 | + if (array_key_exists($prop, $this->data)) { |
|
856 | + $value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop]; |
|
857 | 857 | |
858 | - if ( 'view' === $context ) { |
|
859 | - $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
858 | + if ('view' === $context) { |
|
859 | + $value = apply_filters($this->get_hook_prefix() . $prop, $value, $this); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
@@ -870,13 +870,13 @@ discard block |
||
870 | 870 | * @param string $prop Name of prop to set. |
871 | 871 | * @param string|integer $value Value of the prop. |
872 | 872 | */ |
873 | - protected function set_date_prop( $prop, $value ) { |
|
873 | + protected function set_date_prop($prop, $value) { |
|
874 | 874 | |
875 | - if ( empty( $value ) ) { |
|
876 | - $this->set_prop( $prop, null ); |
|
875 | + if (empty($value)) { |
|
876 | + $this->set_prop($prop, null); |
|
877 | 877 | return; |
878 | 878 | } |
879 | - $this->set_prop( $prop, $value ); |
|
879 | + $this->set_prop($prop, $value); |
|
880 | 880 | |
881 | 881 | } |
882 | 882 | |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * @param string $code Error code. |
888 | 888 | * @param string $message Error message. |
889 | 889 | */ |
890 | - protected function error( $code, $message ) { |
|
890 | + protected function error($code, $message) { |
|
891 | 891 | $this->last_error = $message; |
892 | 892 | } |
893 | 893 | |
@@ -899,7 +899,7 @@ discard block |
||
899 | 899 | */ |
900 | 900 | public function exists() { |
901 | 901 | $id = $this->get_id(); |
902 | - return ! empty( $id ); |
|
902 | + return !empty($id); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | } |
@@ -8,99 +8,99 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | $getpaid_pages = GetPaid_Installer::get_pages(); |
14 | -$pages = wpinv_get_pages( true ); |
|
14 | +$pages = wpinv_get_pages(true); |
|
15 | 15 | |
16 | 16 | $currencies = wpinv_get_currencies(); |
17 | 17 | |
18 | 18 | $currency_code_options = array(); |
19 | -foreach ( $currencies as $code => $name ) { |
|
20 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
19 | +foreach ($currencies as $code => $name) { |
|
20 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $invoice_number_padd_options = array(); |
24 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
24 | +for ($i = 0; $i <= 20; $i++) { |
|
25 | 25 | $invoice_number_padd_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $currency_symbol = wpinv_currency_symbol(); |
29 | 29 | |
30 | 30 | $last_number = $reset_number = ''; |
31 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
32 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
31 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
32 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
33 | 33 | |
34 | - if ( !empty( $last_invoice_number ) ) { |
|
35 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
34 | + if (!empty($last_invoice_number)) { |
|
35 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $nonce = wp_create_nonce('reset_invoice_count'); |
39 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
39 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $alert_wrapper_start = '<p style="color: #F00">'; |
43 | 43 | $alert_wrapper_close = '</p>'; |
44 | 44 | |
45 | 45 | return array( |
46 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
46 | + 'general' => apply_filters('wpinv_settings_general', |
|
47 | 47 | array( |
48 | 48 | 'main' => array( |
49 | 49 | 'location_settings' => array( |
50 | 50 | 'id' => 'location_settings', |
51 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
51 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
52 | 52 | 'desc' => '', |
53 | 53 | 'type' => 'header', |
54 | 54 | ), |
55 | 55 | 'default_country' => array( |
56 | 56 | 'id' => 'default_country', |
57 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
58 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
57 | + 'name' => __('Default Country', 'invoicing'), |
|
58 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => wpinv_get_country_list(), |
61 | 61 | 'std' => 'GB', |
62 | 62 | 'class' => 'wpi_select2', |
63 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
63 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
64 | 64 | ), |
65 | 65 | 'default_state' => array( |
66 | 66 | 'id' => 'default_state', |
67 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
68 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
67 | + 'name' => __('Default State / Province', 'invoicing'), |
|
68 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
69 | 69 | 'type' => 'country_states', |
70 | 70 | 'class' => 'wpi_select2', |
71 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
71 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
72 | 72 | ), |
73 | 73 | 'store_name' => array( |
74 | 74 | 'id' => 'store_name', |
75 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
76 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
75 | + 'name' => __('Store Name', 'invoicing'), |
|
76 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
77 | 77 | 'std' => get_option('blogname'), |
78 | 78 | 'type' => 'text', |
79 | 79 | ), |
80 | 80 | 'logo' => array( |
81 | 81 | 'id' => 'logo', |
82 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
83 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
82 | + 'name' => __('Logo URL', 'invoicing'), |
|
83 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
84 | 84 | 'type' => 'text', |
85 | 85 | ), |
86 | 86 | 'logo_width' => array( |
87 | 87 | 'id' => 'logo_width', |
88 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
89 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
88 | + 'name' => __('Logo width', 'invoicing'), |
|
89 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
90 | 90 | 'type' => 'number', |
91 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
91 | + 'placeholder' => __('Auto', 'invoicing'), |
|
92 | 92 | ), |
93 | 93 | 'logo_height' => array( |
94 | 94 | 'id' => 'logo_height', |
95 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
96 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
95 | + 'name' => __('Logo height', 'invoicing'), |
|
96 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
97 | 97 | 'type' => 'number', |
98 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
98 | + 'placeholder' => __('Auto', 'invoicing'), |
|
99 | 99 | ), |
100 | 100 | 'store_address' => array( |
101 | 101 | 'id' => 'store_address', |
102 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
103 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
102 | + 'name' => __('Store Address', 'invoicing'), |
|
103 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
104 | 104 | 'type' => 'textarea', |
105 | 105 | ), |
106 | 106 | |
@@ -108,114 +108,114 @@ discard block |
||
108 | 108 | 'page_section' => array( |
109 | 109 | 'page_settings' => array( |
110 | 110 | 'id' => 'page_settings', |
111 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
111 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
112 | 112 | 'desc' => '', |
113 | 113 | 'type' => 'header', |
114 | 114 | ), |
115 | 115 | 'checkout_page' => array( |
116 | 116 | 'id' => 'checkout_page', |
117 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
118 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
117 | + 'name' => __('Checkout Page', 'invoicing'), |
|
118 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
119 | 119 | 'type' => 'select', |
120 | 120 | 'options' => $pages, |
121 | 121 | 'class' => 'wpi_select2', |
122 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
123 | - 'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'], |
|
122 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
123 | + 'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'], |
|
124 | 124 | 'help-tip' => true, |
125 | 125 | ), |
126 | 126 | 'success_page' => array( |
127 | 127 | 'id' => 'success_page', |
128 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
129 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
128 | + 'name' => __('Success Page', 'invoicing'), |
|
129 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
130 | 130 | 'type' => 'select', |
131 | 131 | 'options' => $pages, |
132 | 132 | 'class' => 'wpi_select2', |
133 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
134 | - 'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'], |
|
133 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
134 | + 'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'], |
|
135 | 135 | 'help-tip' => true, |
136 | 136 | ), |
137 | 137 | 'failure_page' => array( |
138 | 138 | 'id' => 'failure_page', |
139 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
140 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
139 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
140 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
141 | 141 | 'type' => 'select', |
142 | 142 | 'options' => $pages, |
143 | 143 | 'class' => 'wpi_select2', |
144 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
145 | - 'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'], |
|
144 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
145 | + 'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'], |
|
146 | 146 | 'help-tip' => true, |
147 | 147 | ), |
148 | 148 | 'invoice_history_page' => array( |
149 | 149 | 'id' => 'invoice_history_page', |
150 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
151 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
150 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
151 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
152 | 152 | 'type' => 'select', |
153 | 153 | 'options' => $pages, |
154 | 154 | 'class' => 'wpi_select2', |
155 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
156 | - 'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
155 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
156 | + 'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
157 | 157 | 'help-tip' => true, |
158 | 158 | ), |
159 | 159 | 'invoice_subscription_page' => array( |
160 | 160 | 'id' => 'invoice_subscription_page', |
161 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
162 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
161 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
162 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
163 | 163 | 'type' => 'select', |
164 | 164 | 'options' => $pages, |
165 | 165 | 'class' => 'wpi_select2', |
166 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
167 | - 'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
166 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
167 | + 'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
168 | 168 | 'help-tip' => true, |
169 | 169 | ), |
170 | 170 | ), |
171 | 171 | 'currency_section' => array( |
172 | 172 | 'currency_settings' => array( |
173 | 173 | 'id' => 'currency_settings', |
174 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
174 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
175 | 175 | 'desc' => '', |
176 | 176 | 'type' => 'header', |
177 | 177 | ), |
178 | 178 | 'currency' => array( |
179 | 179 | 'id' => 'currency', |
180 | - 'name' => __( 'Currency', 'invoicing' ), |
|
181 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
180 | + 'name' => __('Currency', 'invoicing'), |
|
181 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
182 | 182 | 'type' => 'select', |
183 | 183 | 'class' => 'wpi_select2', |
184 | 184 | 'options' => $currency_code_options, |
185 | 185 | ), |
186 | 186 | 'currency_position' => array( |
187 | 187 | 'id' => 'currency_position', |
188 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
189 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
188 | + 'name' => __('Currency Position', 'invoicing'), |
|
189 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
190 | 190 | 'type' => 'select', |
191 | 191 | 'class' => 'wpi_select2', |
192 | 192 | 'options' => array( |
193 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
194 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
195 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
196 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
193 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
194 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
195 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
196 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
197 | 197 | ) |
198 | 198 | ), |
199 | 199 | 'thousands_separator' => array( |
200 | 200 | 'id' => 'thousands_separator', |
201 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
202 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
201 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
202 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
203 | 203 | 'type' => 'text', |
204 | 204 | 'size' => 'small', |
205 | 205 | 'std' => ',', |
206 | 206 | ), |
207 | 207 | 'decimal_separator' => array( |
208 | 208 | 'id' => 'decimal_separator', |
209 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
210 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
209 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
210 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
211 | 211 | 'type' => 'text', |
212 | 212 | 'size' => 'small', |
213 | 213 | 'std' => '.', |
214 | 214 | ), |
215 | 215 | 'decimals' => array( |
216 | 216 | 'id' => 'decimals', |
217 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
218 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
217 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
218 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
219 | 219 | 'type' => 'number', |
220 | 220 | 'size' => 'small', |
221 | 221 | 'std' => '2', |
@@ -227,21 +227,21 @@ discard block |
||
227 | 227 | 'labels' => array( |
228 | 228 | 'labels' => array( |
229 | 229 | 'id' => 'labels_settings', |
230 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
230 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
231 | 231 | 'desc' => '', |
232 | 232 | 'type' => 'header', |
233 | 233 | ), |
234 | 234 | 'vat_invoice_notice_label' => array( |
235 | 235 | 'id' => 'vat_invoice_notice_label', |
236 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
237 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
236 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
237 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
238 | 238 | 'type' => 'text', |
239 | 239 | 'size' => 'regular', |
240 | 240 | ), |
241 | 241 | 'vat_invoice_notice' => array( |
242 | 242 | 'id' => 'vat_invoice_notice', |
243 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
244 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
243 | + 'name' => __('Invoice notice', 'invoicing'), |
|
244 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
245 | 245 | 'type' => 'text', |
246 | 246 | 'size' => 'regular', |
247 | 247 | ), |
@@ -253,22 +253,22 @@ discard block |
||
253 | 253 | 'main' => array( |
254 | 254 | 'gateway_settings' => array( |
255 | 255 | 'id' => 'api_header', |
256 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
256 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
257 | 257 | 'desc' => '', |
258 | 258 | 'type' => 'header', |
259 | 259 | ), |
260 | 260 | 'gateways' => array( |
261 | 261 | 'id' => 'gateways', |
262 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
263 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
262 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
263 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
264 | 264 | 'type' => 'gateways', |
265 | - 'std' => array( 'manual'=>1 ), |
|
265 | + 'std' => array('manual'=>1), |
|
266 | 266 | 'options' => wpinv_get_payment_gateways(), |
267 | 267 | ), |
268 | 268 | 'default_gateway' => array( |
269 | 269 | 'id' => 'default_gateway', |
270 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
271 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
270 | + 'name' => __('Default Gateway', 'invoicing'), |
|
271 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
272 | 272 | 'type' => 'gateway_select', |
273 | 273 | 'std' => 'manual', |
274 | 274 | 'class' => 'wpi_select2', |
@@ -283,32 +283,32 @@ discard block |
||
283 | 283 | 'main' => array( |
284 | 284 | 'tax_settings' => array( |
285 | 285 | 'id' => 'tax_settings', |
286 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
286 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
287 | 287 | 'type' => 'header', |
288 | 288 | ), |
289 | 289 | |
290 | 290 | 'enable_taxes' => array( |
291 | 291 | 'id' => 'enable_taxes', |
292 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
293 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
292 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
293 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
294 | 294 | 'type' => 'checkbox', |
295 | 295 | 'std' => 0, |
296 | 296 | ), |
297 | 297 | |
298 | 298 | 'tax_subtotal_rounding' => array( |
299 | 299 | 'id' => 'tax_subtotal_rounding', |
300 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
301 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
300 | + 'name' => __('Rounding', 'invoicing'), |
|
301 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
302 | 302 | 'type' => 'checkbox', |
303 | 303 | 'std' => 1, |
304 | 304 | ), |
305 | 305 | |
306 | 306 | 'prices_include_tax' => array( |
307 | 307 | 'id' => 'prices_include_tax', |
308 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
308 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
309 | 309 | 'options' => array( |
310 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
311 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
310 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
311 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
312 | 312 | ), |
313 | 313 | 'type' => 'select', |
314 | 314 | 'std' => 'no', |
@@ -316,10 +316,10 @@ discard block |
||
316 | 316 | |
317 | 317 | 'tax_base' => array( |
318 | 318 | 'id' => 'tax_base', |
319 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
319 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
320 | 320 | 'options' => array( |
321 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
322 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
321 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
322 | + 'base' => __('Shop base address', 'invoicing'), |
|
323 | 323 | ), |
324 | 324 | 'type' => 'select', |
325 | 325 | 'std' => 'billing', |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | |
328 | 328 | 'tax_display_totals' => array( |
329 | 329 | 'id' => 'tax_display_totals', |
330 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
330 | + 'name' => __('Display tax totals', 'invoicing'), |
|
331 | 331 | 'options' => array( |
332 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
333 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
332 | + 'single' => __('As a single total', 'invoicing'), |
|
333 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
334 | 334 | ), |
335 | 335 | 'type' => 'select', |
336 | 336 | 'std' => 'individual', |
@@ -338,8 +338,8 @@ discard block |
||
338 | 338 | |
339 | 339 | 'tax_rate' => array( |
340 | 340 | 'id' => 'tax_rate', |
341 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
342 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
341 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
342 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
343 | 343 | 'type' => 'number', |
344 | 344 | 'size' => 'small', |
345 | 345 | 'min' => '0', |
@@ -351,8 +351,8 @@ discard block |
||
351 | 351 | 'rates' => array( |
352 | 352 | 'tax_rates' => array( |
353 | 353 | 'id' => 'tax_rates', |
354 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
355 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
354 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
355 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
356 | 356 | 'type' => 'tax_rates', |
357 | 357 | ), |
358 | 358 | ), |
@@ -361,45 +361,45 @@ discard block |
||
361 | 361 | |
362 | 362 | 'vat_company_name' => array( |
363 | 363 | 'id' => 'vat_company_name', |
364 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
365 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
364 | + 'name' => __('Company Name', 'invoicing'), |
|
365 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
366 | 366 | 'type' => 'text', |
367 | 367 | 'size' => 'regular', |
368 | 368 | ), |
369 | 369 | |
370 | 370 | 'vat_number' => array( |
371 | 371 | 'id' => 'vat_number', |
372 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
373 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
372 | + 'name' => __('VAT Number', 'invoicing'), |
|
373 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
374 | 374 | 'type' => 'text', |
375 | 375 | 'size' => 'regular', |
376 | 376 | ), |
377 | 377 | |
378 | 378 | 'vat_prevent_b2c_purchase' => array( |
379 | 379 | 'id' => 'vat_prevent_b2c_purchase', |
380 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
381 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
380 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
381 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
382 | 382 | 'type' => 'checkbox' |
383 | 383 | ), |
384 | 384 | |
385 | 385 | 'validate_vat_number' => array( |
386 | 386 | 'id' => 'validate_vat_number', |
387 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
388 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
387 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
388 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
389 | 389 | 'type' => 'checkbox' |
390 | 390 | ), |
391 | 391 | |
392 | 392 | 'vat_same_country_rule' => array( |
393 | 393 | 'id' => 'vat_same_country_rule', |
394 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
395 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
394 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
395 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
396 | 396 | 'type' => 'select', |
397 | 397 | 'options' => array( |
398 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
399 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
400 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
398 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
399 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
400 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
401 | 401 | ), |
402 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
402 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
403 | 403 | 'std' => 'vat_too', |
404 | 404 | ), |
405 | 405 | |
@@ -413,66 +413,66 @@ discard block |
||
413 | 413 | 'main' => array( |
414 | 414 | 'email_settings_header' => array( |
415 | 415 | 'id' => 'email_settings_header', |
416 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
416 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
417 | 417 | 'type' => 'header', |
418 | 418 | ), |
419 | 419 | 'email_from_name' => array( |
420 | 420 | 'id' => 'email_from_name', |
421 | - 'name' => __( 'From Name', 'invoicing' ), |
|
422 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
423 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
421 | + 'name' => __('From Name', 'invoicing'), |
|
422 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
423 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
424 | 424 | 'type' => 'text', |
425 | 425 | ), |
426 | 426 | 'email_from' => array( |
427 | 427 | 'id' => 'email_from', |
428 | - 'name' => __( 'From Email', 'invoicing' ), |
|
429 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
430 | - 'std' => get_option( 'admin_email' ), |
|
428 | + 'name' => __('From Email', 'invoicing'), |
|
429 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
430 | + 'std' => get_option('admin_email'), |
|
431 | 431 | 'type' => 'text', |
432 | 432 | ), |
433 | 433 | 'admin_email' => array( |
434 | 434 | 'id' => 'admin_email', |
435 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
436 | - 'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ), |
|
437 | - 'std' => get_option( 'admin_email' ), |
|
435 | + 'name' => __('Admin Email', 'invoicing'), |
|
436 | + 'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'), |
|
437 | + 'std' => get_option('admin_email'), |
|
438 | 438 | 'type' => 'text', |
439 | 439 | ), |
440 | 440 | 'skip_email_free_invoice' => array( |
441 | 441 | 'id' => 'skip_email_free_invoice', |
442 | - 'name' => __( 'Skip Free Invoices', 'invoicing' ), |
|
443 | - 'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ), |
|
442 | + 'name' => __('Skip Free Invoices', 'invoicing'), |
|
443 | + 'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'), |
|
444 | 444 | 'type' => 'checkbox', |
445 | 445 | 'std' => false, |
446 | 446 | ), |
447 | 447 | 'overdue_settings_header' => array( |
448 | 448 | 'id' => 'overdue_settings_header', |
449 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
449 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
450 | 450 | 'type' => 'header', |
451 | 451 | ), |
452 | 452 | 'overdue_active' => array( |
453 | 453 | 'id' => 'overdue_active', |
454 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
455 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
454 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
455 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
456 | 456 | 'type' => 'checkbox', |
457 | 457 | 'std' => false, |
458 | 458 | ), |
459 | 459 | 'email_template_header' => array( |
460 | 460 | 'id' => 'email_template_header', |
461 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
461 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
462 | 462 | 'type' => 'header', |
463 | 463 | ), |
464 | 464 | 'email_header_image' => array( |
465 | 465 | 'id' => 'email_header_image', |
466 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
467 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
466 | + 'name' => __('Header Image', 'invoicing'), |
|
467 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
468 | 468 | 'std' => '', |
469 | 469 | 'type' => 'text', |
470 | 470 | ), |
471 | 471 | 'email_footer_text' => array( |
472 | 472 | 'id' => 'email_footer_text', |
473 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
474 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
475 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
473 | + 'name' => __('Footer Text', 'invoicing'), |
|
474 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
475 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
476 | 476 | 'type' => 'textarea', |
477 | 477 | 'class' => 'regular-text', |
478 | 478 | 'rows' => 2, |
@@ -480,29 +480,29 @@ discard block |
||
480 | 480 | ), |
481 | 481 | 'email_base_color' => array( |
482 | 482 | 'id' => 'email_base_color', |
483 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
484 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
483 | + 'name' => __('Base Color', 'invoicing'), |
|
484 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
485 | 485 | 'std' => '#557da2', |
486 | 486 | 'type' => 'color', |
487 | 487 | ), |
488 | 488 | 'email_background_color' => array( |
489 | 489 | 'id' => 'email_background_color', |
490 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
491 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
490 | + 'name' => __('Background Color', 'invoicing'), |
|
491 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
492 | 492 | 'std' => '#f5f5f5', |
493 | 493 | 'type' => 'color', |
494 | 494 | ), |
495 | 495 | 'email_body_background_color' => array( |
496 | 496 | 'id' => 'email_body_background_color', |
497 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
498 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
497 | + 'name' => __('Body Background Color', 'invoicing'), |
|
498 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
499 | 499 | 'std' => '#fdfdfd', |
500 | 500 | 'type' => 'color', |
501 | 501 | ), |
502 | 502 | 'email_text_color' => array( |
503 | 503 | 'id' => 'email_text_color', |
504 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
505 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
504 | + 'name' => __('Body Text Color', 'invoicing'), |
|
505 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
506 | 506 | 'std' => '#505050', |
507 | 507 | 'type' => 'color', |
508 | 508 | ), |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | ), |
518 | 518 | |
519 | 519 | // Integrations. |
520 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
520 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
521 | 521 | |
522 | 522 | /** Privacy Settings */ |
523 | 523 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -525,17 +525,17 @@ discard block |
||
525 | 525 | 'main' => array( |
526 | 526 | 'invoicing_privacy_policy_settings' => array( |
527 | 527 | 'id' => 'invoicing_privacy_policy_settings', |
528 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
528 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
529 | 529 | 'type' => 'header', |
530 | 530 | ), |
531 | 531 | 'privacy_page' => array( |
532 | 532 | 'id' => 'privacy_page', |
533 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
534 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
533 | + 'name' => __('Privacy Page', 'invoicing'), |
|
534 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
535 | 535 | 'type' => 'select', |
536 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
536 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
537 | 537 | 'class' => 'wpi_select2', |
538 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
538 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
539 | 539 | ), |
540 | 540 | ), |
541 | 541 | ) |
@@ -546,19 +546,19 @@ discard block |
||
546 | 546 | 'main' => array( |
547 | 547 | 'invoice_number_format_settings' => array( |
548 | 548 | 'id' => 'invoice_number_format_settings', |
549 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
549 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
550 | 550 | 'type' => 'header', |
551 | 551 | ), |
552 | 552 | 'sequential_invoice_number' => array( |
553 | 553 | 'id' => 'sequential_invoice_number', |
554 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
555 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
554 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
555 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
556 | 556 | 'type' => 'checkbox', |
557 | 557 | ), |
558 | 558 | 'invoice_sequence_start' => array( |
559 | 559 | 'id' => 'invoice_sequence_start', |
560 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
561 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
560 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
561 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
562 | 562 | 'type' => 'number', |
563 | 563 | 'size' => 'small', |
564 | 564 | 'std' => '1', |
@@ -566,8 +566,8 @@ discard block |
||
566 | 566 | ), |
567 | 567 | 'invoice_number_padd' => array( |
568 | 568 | 'id' => 'invoice_number_padd', |
569 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
570 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
569 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
570 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
571 | 571 | 'type' => 'select', |
572 | 572 | 'options' => $invoice_number_padd_options, |
573 | 573 | 'std' => 5, |
@@ -575,8 +575,8 @@ discard block |
||
575 | 575 | ), |
576 | 576 | 'invoice_number_prefix' => array( |
577 | 577 | 'id' => 'invoice_number_prefix', |
578 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
579 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
578 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
579 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
580 | 580 | 'type' => 'text', |
581 | 581 | 'size' => 'regular', |
582 | 582 | 'std' => 'INV-', |
@@ -584,46 +584,46 @@ discard block |
||
584 | 584 | ), |
585 | 585 | 'invoice_number_postfix' => array( |
586 | 586 | 'id' => 'invoice_number_postfix', |
587 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
588 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
587 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
588 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
589 | 589 | 'type' => 'text', |
590 | 590 | 'size' => 'regular', |
591 | 591 | 'std' => '' |
592 | 592 | ), |
593 | 593 | 'checkout_settings' => array( |
594 | 594 | 'id' => 'checkout_settings', |
595 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
595 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
596 | 596 | 'type' => 'header', |
597 | 597 | ), |
598 | 598 | 'disable_new_user_emails' => array( |
599 | 599 | 'id' => 'disable_new_user_emails', |
600 | - 'name' => __( 'Disable new user emails', 'invoicing' ), |
|
601 | - 'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ), |
|
600 | + 'name' => __('Disable new user emails', 'invoicing'), |
|
601 | + 'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'), |
|
602 | 602 | 'type' => 'checkbox', |
603 | 603 | ), |
604 | 604 | 'login_to_checkout' => array( |
605 | 605 | 'id' => 'login_to_checkout', |
606 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
607 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
606 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
607 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
608 | 608 | 'type' => 'checkbox', |
609 | 609 | ), |
610 | 610 | 'maxmind_license_key' => array( |
611 | 611 | 'id' => 'maxmind_license_key', |
612 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
612 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
613 | 613 | 'type' => 'text', |
614 | 614 | 'size' => 'regular', |
615 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
615 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
616 | 616 | ), |
617 | 617 | |
618 | 618 | 'uninstall_settings' => array( |
619 | 619 | 'id' => 'uninstall_settings', |
620 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
620 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
621 | 621 | 'type' => 'header', |
622 | 622 | ), |
623 | 623 | 'remove_data_on_unistall' => array( |
624 | 624 | 'id' => 'remove_data_on_unistall', |
625 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
626 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
625 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
626 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
627 | 627 | 'type' => 'checkbox', |
628 | 628 | 'std' => '' |
629 | 629 | ), |
@@ -632,13 +632,13 @@ discard block |
||
632 | 632 | 'custom-css' => array( |
633 | 633 | 'css_settings' => array( |
634 | 634 | 'id' => 'css_settings', |
635 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
635 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
636 | 636 | 'type' => 'header', |
637 | 637 | ), |
638 | 638 | 'template_custom_css' => array( |
639 | 639 | 'id' => 'template_custom_css', |
640 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
641 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
640 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
641 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
642 | 642 | 'type' => 'textarea', |
643 | 643 | 'class'=> 'regular-text', |
644 | 644 | 'rows' => 10, |
@@ -652,8 +652,8 @@ discard block |
||
652 | 652 | 'main' => array( |
653 | 653 | 'tool_settings' => array( |
654 | 654 | 'id' => 'tool_settings', |
655 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
656 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
655 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
656 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
657 | 657 | 'type' => 'tools', |
658 | 658 | ), |
659 | 659 | ), |
@@ -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><?php _e("Have a membership key?","invoicing");?></h2> |
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
40 | - echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351)); |
|
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,12351)); |
|
41 | + ?> |
|
42 | 42 | </p> |
43 | 43 | <?php }?> |
44 | 44 | |
@@ -48,13 +48,13 @@ discard block |
||
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | - $addon_obj = new WPInv_Admin_Addons(); |
|
52 | - if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
55 | - } |
|
56 | - } |
|
57 | - ?> |
|
51 | + $addon_obj = new WPInv_Admin_Addons(); |
|
52 | + if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | + foreach ( $addons as $addon ) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
55 | + } |
|
56 | + } |
|
57 | + ?> |
|
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
@@ -65,12 +65,12 @@ discard block |
||
65 | 65 | <h3><?php _e("Included Gateways:","invoicing");?></h3> |
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
71 | - } |
|
72 | - } |
|
73 | - ?> |
|
68 | + if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | + foreach ( $addons as $addon ) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
71 | + } |
|
72 | + } |
|
73 | + ?> |
|
74 | 74 | </ul> |
75 | 75 | </div> |
76 | 76 | |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
85 | - ?> |
|
84 | + echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
85 | + ?> |
|
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
88 | 88 | <p> |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
105 | - ?> |
|
104 | + echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
105 | + ?> |
|
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
108 | 108 | <p> |
@@ -126,21 +126,21 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - }else{ |
|
130 | - $installed_plugins = get_plugins(); |
|
129 | + }else{ |
|
130 | + $installed_plugins = get_plugins(); |
|
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | - //print_r($addons); |
|
134 | - ?> |
|
132 | + if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
133 | + //print_r($addons); |
|
134 | + ?> |
|
135 | 135 | <ul class="wpi-products"><?php foreach ( $addons as $addon ) : |
136 | 136 | if(965==$addon->info->id){continue;}// don't show quote add on |
137 | - ?><li class="wpi-product"> |
|
137 | + ?><li class="wpi-product"> |
|
138 | 138 | <div class="wpi-product-title"> |
139 | 139 | <h3><?php |
140 | - if ( ! empty( $addon->info->excerpt) ){ |
|
141 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
142 | - } |
|
143 | - echo esc_html( $addon->info->title ); ?></h3> |
|
140 | + if ( ! empty( $addon->info->excerpt) ){ |
|
141 | + echo wpi_help_tip( $addon->info->excerpt ); |
|
142 | + } |
|
143 | + echo esc_html( $addon->info->title ); ?></h3> |
|
144 | 144 | </div> |
145 | 145 | |
146 | 146 | <span class="wpi-product-image"> |
@@ -148,32 +148,32 @@ discard block |
||
148 | 148 | <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
149 | 149 | <?php endif; |
150 | 150 | |
151 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
152 | - $addon->info->slug = 'getpaid-stripe-payments'; |
|
153 | - $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
154 | - } |
|
155 | - |
|
156 | - if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
157 | - echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
158 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
159 | - echo '</a>'; |
|
160 | - }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){ |
|
161 | - if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
162 | - $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
163 | - }else{ |
|
164 | - // if installed show activation link |
|
165 | - if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
166 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
167 | - }else{ |
|
168 | - $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
169 | - } |
|
170 | - } |
|
171 | - echo '<a href="'.$url.'" class="thickbox">'; |
|
172 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
173 | - echo '</a>'; |
|
174 | - } |
|
175 | - |
|
176 | - ?> |
|
151 | + if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
152 | + $addon->info->slug = 'getpaid-stripe-payments'; |
|
153 | + $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
|
154 | + } |
|
155 | + |
|
156 | + if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
157 | + echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
158 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
159 | + echo '</a>'; |
|
160 | + }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){ |
|
161 | + if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
162 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
163 | + }else{ |
|
164 | + // if installed show activation link |
|
165 | + if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
166 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
|
167 | + }else{ |
|
168 | + $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
|
169 | + } |
|
170 | + } |
|
171 | + echo '<a href="'.$url.'" class="thickbox">'; |
|
172 | + echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
173 | + echo '</a>'; |
|
174 | + } |
|
175 | + |
|
176 | + ?> |
|
177 | 177 | |
178 | 178 | </span> |
179 | 179 | |
@@ -181,15 +181,15 @@ discard block |
||
181 | 181 | <span class="wpi-product-button"> |
182 | 182 | <?php |
183 | 183 | $addon_obj->output_button( $addon ); |
184 | - ?> |
|
184 | + ?> |
|
185 | 185 | </span> |
186 | 186 | |
187 | 187 | <span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul> |
188 | 188 | <?php endif; |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | - } |
|
192 | - ?> |
|
191 | + } |
|
192 | + ?> |
|
193 | 193 | |
194 | 194 | |
195 | 195 | <div class="clearfix" ></div> |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | <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 | 209 | <br> |
210 | 210 | <?php |
211 | - 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>' ); |
|
212 | - ?> |
|
211 | + 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>' ); |
|
212 | + ?> |
|
213 | 213 | </span> |
214 | 214 | </div> |
215 | 215 |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Admin View: Page - Addons |
4 | 4 | * |
5 | 5 | */ |
6 | -if ( ! defined( 'ABSPATH' ) ) { |
|
6 | +if (!defined('ABSPATH')) { |
|
7 | 7 | exit; |
8 | 8 | } |
9 | 9 | add_ThickBox(); |
@@ -11,19 +11,19 @@ discard block |
||
11 | 11 | <div class="wrap wpi_addons_wrap"> |
12 | 12 | <h1><?php echo get_admin_page_title(); ?></h1> |
13 | 13 | |
14 | - <?php if ( $tabs ){ ?> |
|
14 | + <?php if ($tabs) { ?> |
|
15 | 15 | <nav class="nav-tab-wrapper wpi-nav-tab-wrapper"> |
16 | 16 | <?php |
17 | - foreach ( $tabs as $name => $label ) { |
|
18 | - echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
17 | + foreach ($tabs as $name => $label) { |
|
18 | + echo '<a href="' . admin_url('admin.php?page=wpi-addons&tab=' . $name) . '" class="nav-tab ' . ($current_tab == $name ? 'nav-tab-active' : '') . '">' . $label . '</a>'; |
|
19 | 19 | } |
20 | - do_action( 'wpi_addons_tabs' ); |
|
20 | + do_action('wpi_addons_tabs'); |
|
21 | 21 | ?> |
22 | 22 | </nav> |
23 | 23 | |
24 | 24 | <?php |
25 | 25 | |
26 | - if($current_tab == 'membership'){ |
|
26 | + if ($current_tab == 'membership') { |
|
27 | 27 | |
28 | 28 | ?> |
29 | 29 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | <!-- |
33 | 33 | <h2>With our WPInvoicing Membership you get access to all our products!</h2> |
34 | 34 | <p><a class="button button-primary" href="https://wpinvoicing.com/downloads/membership/">View Memberships</a></p>--> |
35 | - <?php if(defined('WP_EASY_UPDATES_ACTIVE')){?> |
|
36 | - <h2><?php _e("Have a membership key?","invoicing");?></h2> |
|
35 | + <?php if (defined('WP_EASY_UPDATES_ACTIVE')) {?> |
|
36 | + <h2><?php _e("Have a membership key?", "invoicing"); ?></h2> |
|
37 | 37 | <p> |
38 | 38 | <?php |
39 | - $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1'); |
|
40 | - echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351)); |
|
39 | + $wpeu_admin = new External_Updates_Admin('wpinvoicing.com', '1'); |
|
40 | + echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership', array(95, 106, 108, 12351)); |
|
41 | 41 | ?> |
42 | 42 | </p> |
43 | 43 | <?php }?> |
44 | 44 | |
45 | 45 | <div class="membership-cta-contet"> |
46 | 46 | <div class="main-cta"> |
47 | - <h2><?php _e("Membership benefits Include:","invoicing");?></h2> |
|
47 | + <h2><?php _e("Membership benefits Include:", "invoicing"); ?></h2> |
|
48 | 48 | <div class="feature-list"> |
49 | 49 | <ul> |
50 | 50 | <?php |
51 | 51 | $addon_obj = new WPInv_Admin_Addons(); |
52 | - if ($addons = $addon_obj->get_section_data( 'addons' ) ) { |
|
53 | - foreach ( $addons as $addon ) { |
|
54 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
52 | + if ($addons = $addon_obj->get_section_data('addons')) { |
|
53 | + foreach ($addons as $addon) { |
|
54 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
55 | 55 | } |
56 | 56 | } |
57 | 57 | ?> |
58 | 58 | </ul> |
59 | 59 | |
60 | 60 | <div class="feature-cta"> |
61 | - <h3><?php _e("Membership Starts from","invoicing");?></h3> |
|
61 | + <h3><?php _e("Membership Starts from", "invoicing"); ?></h3> |
|
62 | 62 | <h4>$99</h4> |
63 | - <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a> |
|
63 | + <a href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a> |
|
64 | 64 | </div> |
65 | - <h3><?php _e("Included Gateways:","invoicing");?></h3> |
|
65 | + <h3><?php _e("Included Gateways:", "invoicing"); ?></h3> |
|
66 | 66 | <ul> |
67 | 67 | <?php |
68 | - if ($addons = $addon_obj->get_section_data( 'gateways' ) ) { |
|
69 | - foreach ( $addons as $addon ) { |
|
70 | - echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>'; |
|
68 | + if ($addons = $addon_obj->get_section_data('gateways')) { |
|
69 | + foreach ($addons as $addon) { |
|
70 | + echo '<li><i class="far fa-check-circle fa-sm"></i> ' . esc_html($addon->info->title) . '</li>'; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | ?> |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | <div class="testimonial-content"> |
82 | 82 | <div class="t-image"> |
83 | 83 | <?php |
84 | - echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > '; |
|
84 | + echo '<img src="' . plugins_url('images/t-image2.png', dirname(__FILE__)) . '" > '; |
|
85 | 85 | ?> |
86 | 86 | </div> |
87 | 87 | <div class="t-content"> |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | <div class="testimonial-content"> |
102 | 102 | <div class="t-image"> |
103 | 103 | <?php |
104 | - echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > '; |
|
104 | + echo '<img src="' . plugins_url('images/t-image1.png', dirname(__FILE__)) . '" > '; |
|
105 | 105 | ?> |
106 | 106 | </div> |
107 | 107 | <div class="t-content"> |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | </div> |
118 | 118 | </div> |
119 | 119 | <div class="member-footer"> |
120 | - <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership","invoicing");?></a> |
|
121 | - <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice","invoicing");?></a> |
|
120 | + <a class="footer-btn" href="https://wpinvoicing.com/downloads/membership/" target="_blank"><?php _e("Buy Membership", "invoicing"); ?></a> |
|
121 | + <a class="footer-link" href="post-new.php?post_type=wpi_invoice"><?php _e("Create Invoice", "invoicing"); ?></a> |
|
122 | 122 | </div> |
123 | 123 | </div> |
124 | 124 | |
@@ -126,50 +126,50 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - }else{ |
|
129 | + } else { |
|
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | - if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
|
132 | + if ($addons = $addon_obj->get_section_data($current_tab)) : |
|
133 | 133 | //print_r($addons); |
134 | 134 | ?> |
135 | - <ul class="wpi-products"><?php foreach ( $addons as $addon ) : |
|
136 | - if(965==$addon->info->id){continue;}// don't show quote add on |
|
135 | + <ul class="wpi-products"><?php foreach ($addons as $addon) : |
|
136 | + if (965 == $addon->info->id) {continue; }// don't show quote add on |
|
137 | 137 | ?><li class="wpi-product"> |
138 | 138 | <div class="wpi-product-title"> |
139 | 139 | <h3><?php |
140 | - if ( ! empty( $addon->info->excerpt) ){ |
|
141 | - echo wpi_help_tip( $addon->info->excerpt ); |
|
140 | + if (!empty($addon->info->excerpt)) { |
|
141 | + echo wpi_help_tip($addon->info->excerpt); |
|
142 | 142 | } |
143 | - echo esc_html( $addon->info->title ); ?></h3> |
|
143 | + echo esc_html($addon->info->title); ?></h3> |
|
144 | 144 | </div> |
145 | 145 | |
146 | 146 | <span class="wpi-product-image"> |
147 | - <?php if ( ! empty( $addon->info->thumbnail) ) : ?> |
|
148 | - <img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/> |
|
147 | + <?php if (!empty($addon->info->thumbnail)) : ?> |
|
148 | + <img src="<?php echo esc_attr($addon->info->thumbnail); ?>"/> |
|
149 | 149 | <?php endif; |
150 | 150 | |
151 | - if ( 'stripe-payment-gateway' == $addon->info->slug ) { |
|
151 | + if ('stripe-payment-gateway' == $addon->info->slug) { |
|
152 | 152 | $addon->info->slug = 'getpaid-stripe-payments'; |
153 | 153 | $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/'; |
154 | 154 | } |
155 | 155 | |
156 | - if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){ |
|
157 | - echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
158 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
156 | + if (isset($addon->info->link) && substr($addon->info->link, 0, 21) === "https://wordpress.org") { |
|
157 | + echo '<a href="' . admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug) . '&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
|
158 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
159 | 159 | echo '</a>'; |
160 | - }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){ |
|
161 | - if(defined('WP_EASY_UPDATES_ACTIVE')){ |
|
162 | - $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
163 | - }else{ |
|
160 | + }elseif (isset($addon->info->link) && (substr($addon->info->link, 0, 23) === "https://wpinvoicing.com" || substr($addon->info->link, 0, 21) === "https://wpgetpaid.com")) { |
|
161 | + if (defined('WP_EASY_UPDATES_ACTIVE')) { |
|
162 | + $url = admin_url('/plugin-install.php?tab=plugin-information&plugin=' . $addon->info->slug . '&width=770&height=660&item_id=' . $addon->info->id . '&update_url=https://wpgetpaid.com&TB_iframe=true'); |
|
163 | + } else { |
|
164 | 164 | // if installed show activation link |
165 | - if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
|
165 | + if (isset($installed_plugins['wp-easy-updates/external-updates.php'])) { |
|
166 | 166 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
167 | - }else{ |
|
167 | + } else { |
|
168 | 168 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
169 | 169 | } |
170 | 170 | } |
171 | - echo '<a href="'.$url.'" class="thickbox">'; |
|
172 | - echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
|
171 | + echo '<a href="' . $url . '" class="thickbox">'; |
|
172 | + echo '<span class="wpi-product-info">' . __('More info', 'invoicing') . '</span>'; |
|
173 | 173 | echo '</a>'; |
174 | 174 | } |
175 | 175 | |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | <span class="wpi-product-button"> |
182 | 182 | <?php |
183 | - $addon_obj->output_button( $addon ); |
|
183 | + $addon_obj->output_button($addon); |
|
184 | 184 | ?> |
185 | 185 | </span> |
186 | 186 | |
@@ -194,21 +194,21 @@ discard block |
||
194 | 194 | |
195 | 195 | <div class="clearfix" ></div> |
196 | 196 | |
197 | - <?php if($current_tab =='addons'){ ?> |
|
198 | - <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> |
|
199 | - <?php } if($current_tab =='gateways'){ ?> |
|
200 | - <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> |
|
197 | + <?php if ($current_tab == 'addons') { ?> |
|
198 | + <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> |
|
199 | + <?php } if ($current_tab == 'gateways') { ?> |
|
200 | + <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> |
|
201 | 201 | <?php } ?> |
202 | 202 | |
203 | - <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> |
|
204 | - <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> |
|
203 | + <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> |
|
204 | + <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 | 205 | <div id="wpeu-licence-popup" style="display:none;"> |
206 | 206 | <span class="wpi-notification noti-white"> |
207 | - <h3 class="wpeu-licence-title"><?php _e("Licence key",'invoicing');?></h3> |
|
208 | - <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> |
|
207 | + <h3 class="wpeu-licence-title"><?php _e("Licence key", 'invoicing'); ?></h3> |
|
208 | + <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 | 209 | <br> |
210 | 210 | <?php |
211 | - 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>' ); |
|
211 | + 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>'); |
|
212 | 212 | ?> |
213 | 213 | </span> |
214 | 214 | </div> |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | </div> |
127 | 127 | </div> |
128 | 128 | <?php |
129 | - }else{ |
|
129 | + } else{ |
|
130 | 130 | $installed_plugins = get_plugins(); |
131 | 131 | $addon_obj = new WPInv_Admin_Addons(); |
132 | 132 | if ($addons = $addon_obj->get_section_data( $current_tab ) ) : |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >'; |
158 | 158 | echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>'; |
159 | 159 | echo '</a>'; |
160 | - }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){ |
|
160 | + } elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){ |
|
161 | 161 | if(defined('WP_EASY_UPDATES_ACTIVE')){ |
162 | 162 | $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true'); |
163 | - }else{ |
|
163 | + } else{ |
|
164 | 164 | // if installed show activation link |
165 | 165 | if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){ |
166 | 166 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation'; |
167 | - }else{ |
|
167 | + } else{ |
|
168 | 168 | $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external'; |
169 | 169 | } |
170 | 170 | } |
@@ -13,9 +13,9 @@ discard block |
||
13 | 13 | |
14 | 14 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function wpinv_sanitize_country( $country ) { |
38 | 38 | |
39 | - // Enure the country is specified |
|
39 | + // Enure the country is specified |
|
40 | 40 | if ( empty( $country ) ) { |
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option( 'default_state', '' ); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters( 'wpinv_default_state', $state ); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -305,11 +305,11 @@ discard block |
||
305 | 305 | |
306 | 306 | $country = wpinv_sanitize_country( $country ); |
307 | 307 | |
308 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
309 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
310 | - return $continent_code; |
|
311 | - } |
|
312 | - } |
|
308 | + foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
309 | + if ( false !== array_search( $country, $countries, true ) ) { |
|
310 | + return $continent_code; |
|
311 | + } |
|
312 | + } |
|
313 | 313 | |
314 | 314 | return ''; |
315 | 315 | |
@@ -601,33 +601,33 @@ discard block |
||
601 | 601 | } |
602 | 602 | |
603 | 603 | function wpinv_get_states_field() { |
604 | - if( empty( $_POST['country'] ) ) { |
|
605 | - $_POST['country'] = wpinv_get_default_country(); |
|
606 | - } |
|
607 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
604 | + if( empty( $_POST['country'] ) ) { |
|
605 | + $_POST['country'] = wpinv_get_default_country(); |
|
606 | + } |
|
607 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
608 | 608 | |
609 | - if( !empty( $states ) ) { |
|
610 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
609 | + if( !empty( $states ) ) { |
|
610 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
611 | 611 | |
612 | 612 | $class = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : ''; |
613 | 613 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
614 | 614 | |
615 | 615 | $args = array( |
616 | - 'name' => $sanitized_field_name, |
|
617 | - 'id' => $sanitized_field_name, |
|
618 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
619 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
620 | - 'show_option_all' => false, |
|
621 | - 'show_option_none' => false |
|
622 | - ); |
|
623 | - |
|
624 | - $response = wpinv_html_select( $args ); |
|
625 | - |
|
626 | - } else { |
|
627 | - $response = 'nostates'; |
|
628 | - } |
|
616 | + 'name' => $sanitized_field_name, |
|
617 | + 'id' => $sanitized_field_name, |
|
618 | + 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
619 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
620 | + 'show_option_all' => false, |
|
621 | + 'show_option_none' => false |
|
622 | + ); |
|
623 | + |
|
624 | + $response = wpinv_html_select( $args ); |
|
625 | + |
|
626 | + } else { |
|
627 | + $response = 'nostates'; |
|
628 | + } |
|
629 | 629 | |
630 | - return $response; |
|
630 | + return $response; |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -645,46 +645,46 @@ discard block |
||
645 | 645 | */ |
646 | 646 | function wpinv_get_address_formats() { |
647 | 647 | |
648 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
649 | - array( |
|
650 | - 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
651 | - 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
652 | - 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
653 | - 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
654 | - 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
655 | - 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
656 | - 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | - 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
658 | - 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | - 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | - 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
661 | - 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
662 | - 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
663 | - 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
664 | - 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
665 | - 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
666 | - 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
667 | - 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
668 | - 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
669 | - 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
670 | - 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
671 | - 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
672 | - 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
673 | - 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
674 | - 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
675 | - 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
676 | - 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
677 | - 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
678 | - 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
679 | - 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
680 | - 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
681 | - 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
682 | - 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
683 | - 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
684 | - 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
685 | - 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
686 | - ) |
|
687 | - ); |
|
648 | + return apply_filters( 'wpinv_localisation_address_formats', |
|
649 | + array( |
|
650 | + 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
|
651 | + 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
|
652 | + 'AT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
653 | + 'BE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
654 | + 'CA' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{state_code}} {{zip}}\n{{country}}", |
|
655 | + 'CH' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
656 | + 'CL' => "{{company}}\n{{name}}\n{{address}}\n{{state}}\n{{zip}} {{city}}\n{{country}}", |
|
657 | + 'CN' => "{{country}} {{zip}}\n{{state}}, {{city}}, {{address}}\n{{company}}\n{{name}}", |
|
658 | + 'CZ' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
659 | + 'DE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
660 | + 'EE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
661 | + 'FI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
662 | + 'DK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
663 | + 'FR' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city_upper}}\n{{country}}", |
|
664 | + 'HK' => "{{company}}\n{{first_name}} {{last_name_upper}}\n{{address}}\n{{city_upper}}\n{{state_upper}}\n{{country}}", |
|
665 | + 'HU' => "{{name}}\n{{company}}\n{{city}}\n{{address}}\n{{zip}}\n{{country}}", |
|
666 | + 'IN' => "{{company}}\n{{name}}\n{{address}}\n{{city}} {{zip}}\n{{state}}, {{country}}", |
|
667 | + 'IS' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
668 | + 'IT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}}\n{{city}}\n{{state_upper}}\n{{country}}", |
|
669 | + 'JP' => "{{zip}}\n{{state}} {{city}} {{address}}\n{{company}}\n{{last_name}} {{first_name}}\n{{country}}", |
|
670 | + 'TW' => "{{company}}\n{{last_name}} {{first_name}}\n{{address}}\n{{state}}, {{city}} {{zip}}\n{{country}}", |
|
671 | + 'LI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
672 | + 'NL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
673 | + 'NZ' => "{{name}}\n{{company}}\n{{address}}\n{{city}} {{zip}}\n{{country}}", |
|
674 | + 'NO' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
675 | + 'PL' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
676 | + 'PT' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
677 | + 'SK' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
678 | + 'RS' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
679 | + 'SI' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
680 | + 'ES' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}}\n{{state}}\n{{country}}", |
|
681 | + 'SE' => "{{company}}\n{{name}}\n{{address}}\n{{zip}} {{city}}\n{{country}}", |
|
682 | + 'TR' => "{{name}}\n{{company}}\n{{address}}\n{{zip}} {{city}} {{state}}\n{{country}}", |
|
683 | + 'UG' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}, {{country}}", |
|
684 | + 'US' => "{{name}}\n{{company}}\n{{address}}\n{{city}}, {{state_code}} {{zip}}\n{{country}}", |
|
685 | + 'VN' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{country}}", |
|
686 | + ) |
|
687 | + ); |
|
688 | 688 | } |
689 | 689 | |
690 | 690 | /** |
@@ -701,21 +701,21 @@ discard block |
||
701 | 701 | } |
702 | 702 | |
703 | 703 | // Get all formats. |
704 | - $formats = wpinv_get_address_formats(); |
|
704 | + $formats = wpinv_get_address_formats(); |
|
705 | 705 | |
706 | - // Get format for the specified country. |
|
707 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
706 | + // Get format for the specified country. |
|
707 | + $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
708 | 708 | |
709 | 709 | /** |
710 | - * Filters the address format to use on Invoices. |
|
710 | + * Filters the address format to use on Invoices. |
|
711 | 711 | * |
712 | 712 | * New lines will be replaced by a `br` element. Double new lines will be replaced by a paragraph. HTML tags are allowed. |
713 | - * |
|
714 | - * @since 1.0.13 |
|
715 | - * |
|
716 | - * @param string $format The address format to use. |
|
713 | + * |
|
714 | + * @since 1.0.13 |
|
715 | + * |
|
716 | + * @param string $format The address format to use. |
|
717 | 717 | * @param string $country The country who's address format is being retrieved. |
718 | - */ |
|
718 | + */ |
|
719 | 719 | return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
720 | 720 | } |
721 | 721 | |
@@ -736,8 +736,8 @@ discard block |
||
736 | 736 | 'country' => '', |
737 | 737 | 'zip' => '', |
738 | 738 | 'first_name' => '', |
739 | - 'last_name' => '', |
|
740 | - 'company' => '', |
|
739 | + 'last_name' => '', |
|
740 | + 'company' => '', |
|
741 | 741 | ); |
742 | 742 | |
743 | 743 | $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
@@ -758,14 +758,14 @@ discard block |
||
758 | 758 | $args['country_code']= $country; |
759 | 759 | |
760 | 760 | /** |
761 | - * Filters the address format replacements to use on Invoices. |
|
761 | + * Filters the address format replacements to use on Invoices. |
|
762 | 762 | * |
763 | - * |
|
764 | - * @since 1.0.13 |
|
765 | - * |
|
766 | - * @param array $replacements The address replacements to use. |
|
763 | + * |
|
764 | + * @since 1.0.13 |
|
765 | + * |
|
766 | + * @param array $replacements The address replacements to use. |
|
767 | 767 | * @param array $billing_details The billing details to use. |
768 | - */ |
|
768 | + */ |
|
769 | 769 | $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
770 | 770 | |
771 | 771 | $return = array(); |
@@ -788,5 +788,5 @@ discard block |
||
788 | 788 | * @return string |
789 | 789 | */ |
790 | 790 | function wpinv_trim_formatted_address_line( $line ) { |
791 | - return trim( $line, ', ' ); |
|
791 | + return trim( $line, ', ' ); |
|
792 | 792 | } |
793 | 793 | \ No newline at end of file |
@@ -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 | |
15 | 15 | function wpinv_get_default_country() { |
16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
16 | + $country = wpinv_get_option('default_country', 'UK'); |
|
17 | 17 | |
18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
18 | + return apply_filters('wpinv_default_country', $country); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | /** |
@@ -23,8 +23,8 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @return string |
25 | 25 | */ |
26 | -function getpaid_get_ip_country( $ip_address = '' ) { |
|
27 | - $country = GetPaid_Geolocation::geolocate_ip( $ip_address, true ); |
|
26 | +function getpaid_get_ip_country($ip_address = '') { |
|
27 | + $country = GetPaid_Geolocation::geolocate_ip($ip_address, true); |
|
28 | 28 | return $country['country']; |
29 | 29 | } |
30 | 30 | |
@@ -34,59 +34,59 @@ discard block |
||
34 | 34 | * @param string $country The country code to sanitize |
35 | 35 | * @return array |
36 | 36 | */ |
37 | -function wpinv_sanitize_country( $country ) { |
|
37 | +function wpinv_sanitize_country($country) { |
|
38 | 38 | |
39 | 39 | // Enure the country is specified |
40 | - if ( empty( $country ) ) { |
|
40 | + if (empty($country)) { |
|
41 | 41 | $country = wpinv_get_default_country(); |
42 | 42 | } |
43 | - return trim( wpinv_utf8_strtoupper( $country ) ); |
|
43 | + return trim(wpinv_utf8_strtoupper($country)); |
|
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | -function wpinv_is_base_country( $country ) { |
|
47 | +function wpinv_is_base_country($country) { |
|
48 | 48 | $base_country = wpinv_get_default_country(); |
49 | 49 | |
50 | - if ( $base_country === 'UK' ) { |
|
50 | + if ($base_country === 'UK') { |
|
51 | 51 | $base_country = 'GB'; |
52 | 52 | } |
53 | - if ( $country == 'UK' ) { |
|
53 | + if ($country == 'UK') { |
|
54 | 54 | $country = 'GB'; |
55 | 55 | } |
56 | 56 | |
57 | - return ( $country && $country === $base_country ) ? true : false; |
|
57 | + return ($country && $country === $base_country) ? true : false; |
|
58 | 58 | } |
59 | 59 | |
60 | -function wpinv_country_name( $country_code = '' ) { |
|
60 | +function wpinv_country_name($country_code = '') { |
|
61 | 61 | $countries = wpinv_get_country_list(); |
62 | 62 | $country_code = $country_code == 'UK' ? 'GB' : $country_code; |
63 | - $country = isset( $countries[$country_code] ) ? $countries[$country_code] : $country_code; |
|
63 | + $country = isset($countries[$country_code]) ? $countries[$country_code] : $country_code; |
|
64 | 64 | |
65 | - return apply_filters( 'wpinv_country_name', $country, $country_code ); |
|
65 | + return apply_filters('wpinv_country_name', $country, $country_code); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | function wpinv_get_default_state() { |
69 | - $state = wpinv_get_option( 'default_state', '' ); |
|
69 | + $state = wpinv_get_option('default_state', ''); |
|
70 | 70 | |
71 | - return apply_filters( 'wpinv_default_state', $state ); |
|
71 | + return apply_filters('wpinv_default_state', $state); |
|
72 | 72 | } |
73 | 73 | |
74 | -function wpinv_state_name( $state_code = '', $country_code = '' ) { |
|
74 | +function wpinv_state_name($state_code = '', $country_code = '') { |
|
75 | 75 | $state = $state_code; |
76 | 76 | |
77 | - if ( !empty( $country_code ) ) { |
|
78 | - $states = wpinv_get_country_states( $country_code ); |
|
77 | + if (!empty($country_code)) { |
|
78 | + $states = wpinv_get_country_states($country_code); |
|
79 | 79 | |
80 | - $state = !empty( $states ) && isset( $states[$state_code] ) ? $states[$state_code] : $state; |
|
80 | + $state = !empty($states) && isset($states[$state_code]) ? $states[$state_code] : $state; |
|
81 | 81 | } |
82 | 82 | |
83 | - return apply_filters( 'wpinv_state_name', $state, $state_code, $country_code ); |
|
83 | + return apply_filters('wpinv_state_name', $state, $state_code, $country_code); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | function wpinv_store_address() { |
87 | - $address = wpinv_get_option( 'store_address', '' ); |
|
87 | + $address = wpinv_get_option('store_address', ''); |
|
88 | 88 | |
89 | - return apply_filters( 'wpinv_store_address', $address ); |
|
89 | + return apply_filters('wpinv_store_address', $address); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * |
95 | 95 | * @param WPInv_Invoice $invoice |
96 | 96 | */ |
97 | -function getpaid_maybe_add_default_address( &$invoice ) { |
|
97 | +function getpaid_maybe_add_default_address(&$invoice) { |
|
98 | 98 | |
99 | 99 | $user_id = $invoice->get_user_id(); |
100 | 100 | |
101 | 101 | // Abort if the invoice belongs to no one. |
102 | - if ( empty( $user_id ) ) { |
|
102 | + if (empty($user_id)) { |
|
103 | 103 | return; |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Fill in defaults whenever necessary. |
107 | - foreach ( wpinv_get_user_address( $user_id ) as $key => $value ) { |
|
107 | + foreach (wpinv_get_user_address($user_id) as $key => $value) { |
|
108 | 108 | |
109 | - if ( is_callable( $invoice, "get_$key" ) ) { |
|
110 | - $current = call_user_func( array( $invoice, "get_$key" ) ); |
|
109 | + if (is_callable($invoice, "get_$key")) { |
|
110 | + $current = call_user_func(array($invoice, "get_$key")); |
|
111 | 111 | |
112 | - if ( empty( $current ) ) { |
|
112 | + if (empty($current)) { |
|
113 | 113 | $method = "set_$key"; |
114 | - $invoice->$method( $value ); |
|
114 | + $invoice->$method($value); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | } |
@@ -130,22 +130,22 @@ discard block |
||
130 | 130 | $address_fields = apply_filters( |
131 | 131 | 'getpaid_user_address_fields', |
132 | 132 | array( |
133 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
134 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
135 | - 'address' => __( 'Address', 'invoicing' ), |
|
136 | - 'city' => __( 'City', 'invoicing' ), |
|
137 | - 'country' => __( 'Country', 'invoicing' ), |
|
138 | - 'state' => __( 'State', 'invoicing' ), |
|
139 | - 'zip' => __( 'Zip/Postal Code', 'invoicing' ), |
|
140 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
141 | - 'company' => __( 'Company', 'invoicing' ), |
|
142 | - 'company_id' => __( 'Company ID', 'invoicing' ), |
|
143 | - 'vat_number' => __( 'VAT Number', 'invoicing' ), |
|
133 | + 'first_name' => __('First Name', 'invoicing'), |
|
134 | + 'last_name' => __('Last Name', 'invoicing'), |
|
135 | + 'address' => __('Address', 'invoicing'), |
|
136 | + 'city' => __('City', 'invoicing'), |
|
137 | + 'country' => __('Country', 'invoicing'), |
|
138 | + 'state' => __('State', 'invoicing'), |
|
139 | + 'zip' => __('Zip/Postal Code', 'invoicing'), |
|
140 | + 'phone' => __('Phone Number', 'invoicing'), |
|
141 | + 'company' => __('Company', 'invoicing'), |
|
142 | + 'company_id' => __('Company ID', 'invoicing'), |
|
143 | + 'vat_number' => __('VAT Number', 'invoicing'), |
|
144 | 144 | ) |
145 | 145 | ); |
146 | 146 | |
147 | - if ( ! wpinv_use_taxes() && isset( $address_fields['vat_number'] ) ) { |
|
148 | - unset( $address_fields['vat_number'] ); |
|
147 | + if (!wpinv_use_taxes() && isset($address_fields['vat_number'])) { |
|
148 | + unset($address_fields['vat_number']); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | return $address_fields; |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | * |
157 | 157 | * @return bool |
158 | 158 | */ |
159 | -function getpaid_is_address_field_whitelisted( $key ) { |
|
160 | - return array_key_exists( $key, getpaid_user_address_fields() ); |
|
159 | +function getpaid_is_address_field_whitelisted($key) { |
|
160 | + return array_key_exists($key, getpaid_user_address_fields()); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -167,24 +167,24 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param WPInv_Invoice $invoice |
169 | 169 | */ |
170 | -function getpaid_save_invoice_user_address( $invoice ) { |
|
170 | +function getpaid_save_invoice_user_address($invoice) { |
|
171 | 171 | |
172 | 172 | // Retrieve the invoice. |
173 | - $invoice = wpinv_get_invoice( $invoice ); |
|
173 | + $invoice = wpinv_get_invoice($invoice); |
|
174 | 174 | |
175 | 175 | // Abort if it does not exist. |
176 | - if ( empty( $invoice ) || $invoice->is_renewal() ) { |
|
176 | + if (empty($invoice) || $invoice->is_renewal()) { |
|
177 | 177 | return; |
178 | 178 | } |
179 | 179 | |
180 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
180 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
181 | 181 | |
182 | - if ( is_callable( array( $invoice, "get_$field" ) ) ) { |
|
183 | - $value = call_user_func( array( $invoice, "get_$field" ) ); |
|
182 | + if (is_callable(array($invoice, "get_$field"))) { |
|
183 | + $value = call_user_func(array($invoice, "get_$field")); |
|
184 | 184 | |
185 | 185 | // Only save if it is not empty. |
186 | - if ( ! empty( $value ) ) { |
|
187 | - update_user_meta( $invoice->get_user_id(), '_wpinv_' . $field, $value ); |
|
186 | + if (!empty($value)) { |
|
187 | + update_user_meta($invoice->get_user_id(), '_wpinv_' . $field, $value); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | } |
193 | 193 | |
194 | 194 | } |
195 | -add_action( 'getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address' ); |
|
195 | +add_action('getpaid_checkout_invoice_updated', 'getpaid_save_invoice_user_address'); |
|
196 | 196 | |
197 | 197 | /** |
198 | 198 | * Retrieves a saved user address. |
@@ -201,14 +201,14 @@ discard block |
||
201 | 201 | * @param bool $with_default Whether or not we should use the default country and state. |
202 | 202 | * @return array |
203 | 203 | */ |
204 | -function wpinv_get_user_address( $user_id = 0, $with_default = true ) { |
|
204 | +function wpinv_get_user_address($user_id = 0, $with_default = true) { |
|
205 | 205 | |
206 | 206 | // Prepare the user id. |
207 | - $user_id = empty( $user_id ) ? get_current_user_id() : $user_id; |
|
208 | - $user_info = get_userdata( $user_id ); |
|
207 | + $user_id = empty($user_id) ? get_current_user_id() : $user_id; |
|
208 | + $user_info = get_userdata($user_id); |
|
209 | 209 | |
210 | 210 | // Abort if non exists. |
211 | - if ( empty( $user_info ) ) { |
|
211 | + if (empty($user_info)) { |
|
212 | 212 | return array(); |
213 | 213 | } |
214 | 214 | |
@@ -218,13 +218,13 @@ discard block |
||
218 | 218 | 'email' => $user_info->user_email, |
219 | 219 | ); |
220 | 220 | |
221 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
222 | - $address[$field] = getpaid_get_user_address_field( $user_id, $field ); |
|
221 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
222 | + $address[$field] = getpaid_get_user_address_field($user_id, $field); |
|
223 | 223 | } |
224 | 224 | |
225 | - $address = array_filter( $address ); |
|
225 | + $address = array_filter($address); |
|
226 | 226 | |
227 | - if ( ! $with_default ) { |
|
227 | + if (!$with_default) { |
|
228 | 228 | return $address; |
229 | 229 | } |
230 | 230 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | 'country' => wpinv_get_default_country(), |
236 | 236 | ); |
237 | 237 | |
238 | - return getpaid_array_merge_if_empty( $address, $defaults ); |
|
238 | + return getpaid_array_merge_if_empty($address, $defaults); |
|
239 | 239 | |
240 | 240 | } |
241 | 241 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @param string $field The field to use. |
247 | 247 | * @return string|null |
248 | 248 | */ |
249 | -function getpaid_get_user_address_field( $user_id, $field ) { |
|
249 | +function getpaid_get_user_address_field($user_id, $field) { |
|
250 | 250 | |
251 | 251 | $prefixes = array( |
252 | 252 | '_wpinv_', |
@@ -254,15 +254,15 @@ discard block |
||
254 | 254 | '' |
255 | 255 | ); |
256 | 256 | |
257 | - foreach ( $prefixes as $prefix ) { |
|
257 | + foreach ($prefixes as $prefix) { |
|
258 | 258 | |
259 | 259 | // Meta table. |
260 | - $value = get_user_meta( $user_id, $prefix . $field, true ); |
|
260 | + $value = get_user_meta($user_id, $prefix . $field, true); |
|
261 | 261 | |
262 | 262 | // UWP table. |
263 | - $value = ( empty( $value ) && function_exists( 'uwp_get_usermeta' ) ) ? uwp_get_usermeta( $user_id, $prefix . $field ) : $value; |
|
263 | + $value = (empty($value) && function_exists('uwp_get_usermeta')) ? uwp_get_usermeta($user_id, $prefix . $field) : $value; |
|
264 | 264 | |
265 | - if ( ! empty( $value ) ) { |
|
265 | + if (!empty($value)) { |
|
266 | 266 | return $value; |
267 | 267 | } |
268 | 268 | |
@@ -279,16 +279,16 @@ discard block |
||
279 | 279 | * @param string $return What to return. |
280 | 280 | * @return array |
281 | 281 | */ |
282 | -function wpinv_get_continents( $return = 'all' ) { |
|
282 | +function wpinv_get_continents($return = 'all') { |
|
283 | 283 | |
284 | - $continents = wpinv_get_data( 'continents' ); |
|
284 | + $continents = wpinv_get_data('continents'); |
|
285 | 285 | |
286 | - switch( $return ) { |
|
286 | + switch ($return) { |
|
287 | 287 | case 'name' : |
288 | - return wp_list_pluck( $continents, 'name' ); |
|
288 | + return wp_list_pluck($continents, 'name'); |
|
289 | 289 | break; |
290 | 290 | case 'countries' : |
291 | - return wp_list_pluck( $continents, 'countries' ); |
|
291 | + return wp_list_pluck($continents, 'countries'); |
|
292 | 292 | break; |
293 | 293 | default : |
294 | 294 | return $continents; |
@@ -304,12 +304,12 @@ discard block |
||
304 | 304 | * @param string $country Country code. If no code is specified, defaults to the default country. |
305 | 305 | * @return string |
306 | 306 | */ |
307 | -function wpinv_get_continent_code_for_country( $country = false ) { |
|
307 | +function wpinv_get_continent_code_for_country($country = false) { |
|
308 | 308 | |
309 | - $country = wpinv_sanitize_country( $country ); |
|
309 | + $country = wpinv_sanitize_country($country); |
|
310 | 310 | |
311 | - foreach ( wpinv_get_continents( 'countries' ) as $continent_code => $countries ) { |
|
312 | - if ( false !== array_search( $country, $countries, true ) ) { |
|
311 | + foreach (wpinv_get_continents('countries') as $continent_code => $countries) { |
|
312 | + if (false !== array_search($country, $countries, true)) { |
|
313 | 313 | return $continent_code; |
314 | 314 | } |
315 | 315 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | * @param string $country Country code. If no code is specified, defaults to the default country. |
326 | 326 | * @return array |
327 | 327 | */ |
328 | -function wpinv_get_country_calling_code( $country = null) { |
|
328 | +function wpinv_get_country_calling_code($country = null) { |
|
329 | 329 | |
330 | - $country = wpinv_sanitize_country( $country ); |
|
331 | - $codes = wpinv_get_data( 'phone-codes' ); |
|
332 | - $code = isset( $codes[ $country ] ) ? $codes[ $country ] : ''; |
|
330 | + $country = wpinv_sanitize_country($country); |
|
331 | + $codes = wpinv_get_data('phone-codes'); |
|
332 | + $code = isset($codes[$country]) ? $codes[$country] : ''; |
|
333 | 333 | |
334 | - if ( is_array( $code ) ) { |
|
334 | + if (is_array($code)) { |
|
335 | 335 | return $code[0]; |
336 | 336 | } |
337 | 337 | return $code; |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param bool $first_empty Whether or not the first item in the list should be empty |
345 | 345 | * @return array |
346 | 346 | */ |
347 | -function wpinv_get_country_list( $first_empty = false ) { |
|
348 | - return wpinv_maybe_add_empty_option( apply_filters( 'wpinv_countries', wpinv_get_data( 'countries' ) ), $first_empty ); |
|
347 | +function wpinv_get_country_list($first_empty = false) { |
|
348 | + return wpinv_maybe_add_empty_option(apply_filters('wpinv_countries', wpinv_get_data('countries')), $first_empty); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -355,22 +355,22 @@ discard block |
||
355 | 355 | * @param bool $first_empty Whether or not the first item in the list should be empty |
356 | 356 | * @return array |
357 | 357 | */ |
358 | -function wpinv_get_country_states( $country = null, $first_empty = false ) { |
|
358 | +function wpinv_get_country_states($country = null, $first_empty = false) { |
|
359 | 359 | |
360 | 360 | // Prepare the country. |
361 | - $country = wpinv_sanitize_country( $country ); |
|
361 | + $country = wpinv_sanitize_country($country); |
|
362 | 362 | |
363 | 363 | // Fetch all states. |
364 | - $all_states = wpinv_get_data( 'states' ); |
|
364 | + $all_states = wpinv_get_data('states'); |
|
365 | 365 | |
366 | 366 | // Fetch the specified country's states. |
367 | - $states = isset( $all_states[ $country ] ) ? $all_states[ $country ] : array() ; |
|
368 | - $states = apply_filters( "wpinv_{$country}_states", $states ); |
|
369 | - $states = apply_filters( 'wpinv_country_states', $states, $country ); |
|
367 | + $states = isset($all_states[$country]) ? $all_states[$country] : array(); |
|
368 | + $states = apply_filters("wpinv_{$country}_states", $states); |
|
369 | + $states = apply_filters('wpinv_country_states', $states, $country); |
|
370 | 370 | |
371 | - asort( $states ); |
|
371 | + asort($states); |
|
372 | 372 | |
373 | - return wpinv_maybe_add_empty_option( $states, $first_empty ); |
|
373 | + return wpinv_maybe_add_empty_option($states, $first_empty); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @return array |
381 | 381 | */ |
382 | 382 | function wpinv_get_us_states_list() { |
383 | - return apply_filters( 'wpinv_usa_states', wpinv_get_country_states( 'US' ) ); |
|
383 | + return apply_filters('wpinv_usa_states', wpinv_get_country_states('US')); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | * @return array |
391 | 391 | */ |
392 | 392 | function wpinv_get_canada_states_list() { |
393 | - return apply_filters( 'wpinv_canada_provinces', wpinv_get_country_states( 'CA' ) ); |
|
393 | + return apply_filters('wpinv_canada_provinces', wpinv_get_country_states('CA')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | * @return array |
401 | 401 | */ |
402 | 402 | function wpinv_get_australia_states_list() { |
403 | - return apply_filters( 'wpinv_australia_states', wpinv_get_country_states( 'AU' ) ); |
|
403 | + return apply_filters('wpinv_australia_states', wpinv_get_country_states('AU')); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | * @return array |
411 | 411 | */ |
412 | 412 | function wpinv_get_bangladesh_states_list() { |
413 | - return apply_filters( 'wpinv_bangladesh_states', wpinv_get_country_states( 'BD' ) ); |
|
413 | + return apply_filters('wpinv_bangladesh_states', wpinv_get_country_states('BD')); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | * @return array |
421 | 421 | */ |
422 | 422 | function wpinv_get_brazil_states_list() { |
423 | - return apply_filters( 'wpinv_brazil_states', wpinv_get_country_states( 'BR' ) ); |
|
423 | + return apply_filters('wpinv_brazil_states', wpinv_get_country_states('BR')); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -430,7 +430,7 @@ discard block |
||
430 | 430 | * @return array |
431 | 431 | */ |
432 | 432 | function wpinv_get_bulgaria_states_list() { |
433 | - return apply_filters( 'wpinv_bulgaria_states', wpinv_get_country_states( 'BG' ) ); |
|
433 | + return apply_filters('wpinv_bulgaria_states', wpinv_get_country_states('BG')); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @return array |
441 | 441 | */ |
442 | 442 | function wpinv_get_hong_kong_states_list() { |
443 | - return apply_filters( 'wpinv_hong_kong_states', wpinv_get_country_states( 'HK' ) ); |
|
443 | + return apply_filters('wpinv_hong_kong_states', wpinv_get_country_states('HK')); |
|
444 | 444 | } |
445 | 445 | |
446 | 446 | /** |
@@ -450,7 +450,7 @@ discard block |
||
450 | 450 | * @return array |
451 | 451 | */ |
452 | 452 | function wpinv_get_hungary_states_list() { |
453 | - return apply_filters( 'wpinv_hungary_states', wpinv_get_country_states( 'HU' ) ); |
|
453 | + return apply_filters('wpinv_hungary_states', wpinv_get_country_states('HU')); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -460,7 +460,7 @@ discard block |
||
460 | 460 | * @return array |
461 | 461 | */ |
462 | 462 | function wpinv_get_japan_states_list() { |
463 | - return apply_filters( 'wpinv_japan_states', wpinv_get_country_states( 'JP' ) ); |
|
463 | + return apply_filters('wpinv_japan_states', wpinv_get_country_states('JP')); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -470,7 +470,7 @@ discard block |
||
470 | 470 | * @return array |
471 | 471 | */ |
472 | 472 | function wpinv_get_china_states_list() { |
473 | - return apply_filters( 'wpinv_china_states', wpinv_get_country_states( 'CN' ) ); |
|
473 | + return apply_filters('wpinv_china_states', wpinv_get_country_states('CN')); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | /** |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | * @return array |
481 | 481 | */ |
482 | 482 | function wpinv_get_new_zealand_states_list() { |
483 | - return apply_filters( 'wpinv_new_zealand_states', wpinv_get_country_states( 'NZ' ) ); |
|
483 | + return apply_filters('wpinv_new_zealand_states', wpinv_get_country_states('NZ')); |
|
484 | 484 | } |
485 | 485 | |
486 | 486 | /** |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | * @return array |
491 | 491 | */ |
492 | 492 | function wpinv_get_peru_states_list() { |
493 | - return apply_filters( 'wpinv_peru_states', wpinv_get_country_states( 'PE' ) ); |
|
493 | + return apply_filters('wpinv_peru_states', wpinv_get_country_states('PE')); |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | /** |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @return array |
501 | 501 | */ |
502 | 502 | function wpinv_get_indonesia_states_list() { |
503 | - return apply_filters( 'wpinv_indonesia_states', wpinv_get_country_states( 'ID' ) ); |
|
503 | + return apply_filters('wpinv_indonesia_states', wpinv_get_country_states('ID')); |
|
504 | 504 | } |
505 | 505 | |
506 | 506 | /** |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | * @return array |
511 | 511 | */ |
512 | 512 | function wpinv_get_india_states_list() { |
513 | - return apply_filters( 'wpinv_india_states', wpinv_get_country_states( 'IN' ) ); |
|
513 | + return apply_filters('wpinv_india_states', wpinv_get_country_states('IN')); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -520,7 +520,7 @@ discard block |
||
520 | 520 | * @return array |
521 | 521 | */ |
522 | 522 | function wpinv_get_iran_states_list() { |
523 | - return apply_filters( 'wpinv_iran_states', wpinv_get_country_states( 'IR' ) ); |
|
523 | + return apply_filters('wpinv_iran_states', wpinv_get_country_states('IR')); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | * @return array |
531 | 531 | */ |
532 | 532 | function wpinv_get_italy_states_list() { |
533 | - return apply_filters( 'wpinv_italy_states', wpinv_get_country_states( 'IT' ) ); |
|
533 | + return apply_filters('wpinv_italy_states', wpinv_get_country_states('IT')); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | * @return array |
541 | 541 | */ |
542 | 542 | function wpinv_get_malaysia_states_list() { |
543 | - return apply_filters( 'wpinv_malaysia_states', wpinv_get_country_states( 'MY' ) ); |
|
543 | + return apply_filters('wpinv_malaysia_states', wpinv_get_country_states('MY')); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | * @return array |
551 | 551 | */ |
552 | 552 | function wpinv_get_mexico_states_list() { |
553 | - return apply_filters( 'wpinv_mexico_states', wpinv_get_country_states( 'MX' ) ); |
|
553 | + return apply_filters('wpinv_mexico_states', wpinv_get_country_states('MX')); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | * @return array |
561 | 561 | */ |
562 | 562 | function wpinv_get_nepal_states_list() { |
563 | - return apply_filters( 'wpinv_nepal_states', wpinv_get_country_states( 'NP' ) ); |
|
563 | + return apply_filters('wpinv_nepal_states', wpinv_get_country_states('NP')); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | * @return array |
571 | 571 | */ |
572 | 572 | function wpinv_get_south_africa_states_list() { |
573 | - return apply_filters( 'wpinv_south_africa_states', wpinv_get_country_states( 'ZA' ) ); |
|
573 | + return apply_filters('wpinv_south_africa_states', wpinv_get_country_states('ZA')); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | /** |
@@ -580,7 +580,7 @@ discard block |
||
580 | 580 | * @return array |
581 | 581 | */ |
582 | 582 | function wpinv_get_thailand_states_list() { |
583 | - return apply_filters( 'wpinv_thailand_states', wpinv_get_country_states( 'TH' ) ); |
|
583 | + return apply_filters('wpinv_thailand_states', wpinv_get_country_states('TH')); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
@@ -590,7 +590,7 @@ discard block |
||
590 | 590 | * @return array |
591 | 591 | */ |
592 | 592 | function wpinv_get_turkey_states_list() { |
593 | - return apply_filters( 'wpinv_turkey_states', wpinv_get_country_states( 'TR' ) ); |
|
593 | + return apply_filters('wpinv_turkey_states', wpinv_get_country_states('TR')); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | /** |
@@ -600,31 +600,31 @@ discard block |
||
600 | 600 | * @return array |
601 | 601 | */ |
602 | 602 | function wpinv_get_spain_states_list() { |
603 | - return apply_filters( 'wpinv_spain_states', wpinv_get_country_states( 'ES' ) ); |
|
603 | + return apply_filters('wpinv_spain_states', wpinv_get_country_states('ES')); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | function wpinv_get_states_field() { |
607 | - if( empty( $_POST['country'] ) ) { |
|
607 | + if (empty($_POST['country'])) { |
|
608 | 608 | $_POST['country'] = wpinv_get_default_country(); |
609 | 609 | } |
610 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
610 | + $states = wpinv_get_country_states(sanitize_text_field($_POST['country'])); |
|
611 | 611 | |
612 | - if( !empty( $states ) ) { |
|
613 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
612 | + if (!empty($states)) { |
|
613 | + $sanitized_field_name = sanitize_text_field($_POST['field_name']); |
|
614 | 614 | |
615 | - $class = isset( $_POST['class'] ) ? esc_attr( $_POST['class'] ) : ''; |
|
615 | + $class = isset($_POST['class']) ? esc_attr($_POST['class']) : ''; |
|
616 | 616 | $class .= " $sanitized_field_name getpaid_js_field-state custom-select wpinv-select wpi_select2"; |
617 | 617 | |
618 | - $args = array( |
|
618 | + $args = array( |
|
619 | 619 | 'name' => $sanitized_field_name, |
620 | 620 | 'id' => $sanitized_field_name, |
621 | - 'class' => implode( ' ', array_unique( explode( ' ', $class ) ) ), |
|
622 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
621 | + 'class' => implode(' ', array_unique(explode(' ', $class))), |
|
622 | + 'options' => array_merge(array('' => ''), $states), |
|
623 | 623 | 'show_option_all' => false, |
624 | 624 | 'show_option_none' => false |
625 | 625 | ); |
626 | 626 | |
627 | - $response = wpinv_html_select( $args ); |
|
627 | + $response = wpinv_html_select($args); |
|
628 | 628 | |
629 | 629 | } else { |
630 | 630 | $response = 'nostates'; |
@@ -633,10 +633,10 @@ discard block |
||
633 | 633 | return $response; |
634 | 634 | } |
635 | 635 | |
636 | -function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
|
637 | - $country = !empty( $country ) ? $country : wpinv_get_default_country(); |
|
636 | +function wpinv_default_billing_country($country = '', $user_id = 0) { |
|
637 | + $country = !empty($country) ? $country : wpinv_get_default_country(); |
|
638 | 638 | |
639 | - return apply_filters( 'wpinv_default_billing_country', $country, $user_id ); |
|
639 | + return apply_filters('wpinv_default_billing_country', $country, $user_id); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | /** |
@@ -648,7 +648,7 @@ discard block |
||
648 | 648 | */ |
649 | 649 | function wpinv_get_address_formats() { |
650 | 650 | |
651 | - return apply_filters( 'wpinv_localisation_address_formats', |
|
651 | + return apply_filters('wpinv_localisation_address_formats', |
|
652 | 652 | array( |
653 | 653 | 'default' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}}\n{{zip}}\n{{country}}", |
654 | 654 | 'AU' => "{{name}}\n{{company}}\n{{address}}\n{{city}}\n{{state}} {{zip}}\n{{country}}", |
@@ -697,9 +697,9 @@ discard block |
||
697 | 697 | * @see `wpinv_get_invoice_address_replacements` |
698 | 698 | * @return string |
699 | 699 | */ |
700 | -function wpinv_get_full_address_format( $country = false) { |
|
700 | +function wpinv_get_full_address_format($country = false) { |
|
701 | 701 | |
702 | - if( empty( $country ) ) { |
|
702 | + if (empty($country)) { |
|
703 | 703 | $country = wpinv_get_default_country(); |
704 | 704 | } |
705 | 705 | |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | $formats = wpinv_get_address_formats(); |
708 | 708 | |
709 | 709 | // Get format for the specified country. |
710 | - $format = ( $country && isset( $formats[ $country ] ) ) ? $formats[ $country ] : $formats['default']; |
|
710 | + $format = ($country && isset($formats[$country])) ? $formats[$country] : $formats['default']; |
|
711 | 711 | |
712 | 712 | /** |
713 | 713 | * Filters the address format to use on Invoices. |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | * @param string $format The address format to use. |
720 | 720 | * @param string $country The country who's address format is being retrieved. |
721 | 721 | */ |
722 | - return apply_filters( 'wpinv_get_full_address_format', $format, $country ); |
|
722 | + return apply_filters('wpinv_get_full_address_format', $format, $country); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @param array $billing_details customer's billing details |
731 | 731 | * @return array |
732 | 732 | */ |
733 | -function wpinv_get_invoice_address_replacements( $billing_details ) { |
|
733 | +function wpinv_get_invoice_address_replacements($billing_details) { |
|
734 | 734 | |
735 | 735 | $default_args = array( |
736 | 736 | 'address' => '', |
@@ -743,22 +743,22 @@ discard block |
||
743 | 743 | 'company' => '', |
744 | 744 | ); |
745 | 745 | |
746 | - $args = map_deep( wp_parse_args( $billing_details, $default_args ), 'trim' ); |
|
746 | + $args = map_deep(wp_parse_args($billing_details, $default_args), 'trim'); |
|
747 | 747 | $state = $args['state']; |
748 | 748 | $country = $args['country']; |
749 | 749 | |
750 | 750 | // Handle full country name. |
751 | - $full_country = empty( $country ) ? $country : wpinv_country_name( $country ); |
|
751 | + $full_country = empty($country) ? $country : wpinv_country_name($country); |
|
752 | 752 | |
753 | 753 | // Handle full state name. |
754 | - $full_state = ( $country && $state ) ? wpinv_state_name( $state, $country ) : $state; |
|
754 | + $full_state = ($country && $state) ? wpinv_state_name($state, $country) : $state; |
|
755 | 755 | |
756 | 756 | $args['postcode'] = $args['zip']; |
757 | 757 | $args['name'] = $args['first_name'] . ' ' . $args['last_name']; |
758 | 758 | $args['state'] = $full_state; |
759 | 759 | $args['state_code'] = $state; |
760 | 760 | $args['country'] = $full_country; |
761 | - $args['country_code']= $country; |
|
761 | + $args['country_code'] = $country; |
|
762 | 762 | |
763 | 763 | /** |
764 | 764 | * Filters the address format replacements to use on Invoices. |
@@ -769,14 +769,14 @@ discard block |
||
769 | 769 | * @param array $replacements The address replacements to use. |
770 | 770 | * @param array $billing_details The billing details to use. |
771 | 771 | */ |
772 | - $replacements = apply_filters( 'wpinv_get_invoice_address_replacements', $args, $billing_details ); |
|
772 | + $replacements = apply_filters('wpinv_get_invoice_address_replacements', $args, $billing_details); |
|
773 | 773 | |
774 | 774 | $return = array(); |
775 | 775 | |
776 | - foreach( $replacements as $key => $value ) { |
|
777 | - $value = is_scalar( $value ) ? trim( sanitize_text_field( $value ) ) : ''; |
|
776 | + foreach ($replacements as $key => $value) { |
|
777 | + $value = is_scalar($value) ? trim(sanitize_text_field($value)) : ''; |
|
778 | 778 | $return['{{' . $key . '}}'] = $value; |
779 | - $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper( $value ); |
|
779 | + $return['{{' . $key . '_upper}}'] = wpinv_utf8_strtoupper($value); |
|
780 | 780 | } |
781 | 781 | |
782 | 782 | return $return; |
@@ -790,6 +790,6 @@ discard block |
||
790 | 790 | * @since 1.0.14 |
791 | 791 | * @return string |
792 | 792 | */ |
793 | -function wpinv_trim_formatted_address_line( $line ) { |
|
794 | - return trim( $line, ', ' ); |
|
793 | +function wpinv_trim_formatted_address_line($line) { |
|
794 | + return trim($line, ', '); |
|
795 | 795 | } |
796 | 796 | \ No newline at end of file |
@@ -20,13 +20,13 @@ |
||
20 | 20 | <title><?php esc_html_e( 'GetPaid › Setup Wizard', 'invoicing' ); ?></title> |
21 | 21 | <?php |
22 | 22 | getpaid_admin()->enqeue_scripts(); |
23 | - wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' ); |
|
24 | - wp_print_styles( 'select2' ); |
|
23 | + wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' ); |
|
24 | + wp_print_styles( 'select2' ); |
|
25 | 25 | wp_print_scripts( 'select2' ); |
26 | - wp_print_scripts( 'wpinv-admin-script' ); |
|
26 | + wp_print_scripts( 'wpinv-admin-script' ); |
|
27 | 27 | do_action( 'admin_print_styles' ); |
28 | 28 | do_action( 'admin_head' ); |
29 | - ?> |
|
29 | + ?> |
|
30 | 30 | <style> |
31 | 31 | body, p{ |
32 | 32 | font-size: 16px; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $aui_settings = AyeCode_UI_Settings::instance(); |
10 | 10 | $aui_settings->enqueue_scripts(); |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | <head> |
18 | 18 | <meta name="viewport" content="width=device-width"/> |
19 | 19 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> |
20 | - <title><?php esc_html_e( 'GetPaid › Setup Wizard', 'invoicing' ); ?></title> |
|
20 | + <title><?php esc_html_e('GetPaid › Setup Wizard', 'invoicing'); ?></title> |
|
21 | 21 | <?php |
22 | 22 | getpaid_admin()->enqeue_scripts(); |
23 | - wp_enqueue_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0' ); |
|
24 | - wp_print_styles( 'select2' ); |
|
25 | - wp_print_scripts( 'select2' ); |
|
26 | - wp_print_scripts( 'wpinv-admin-script' ); |
|
27 | - do_action( 'admin_print_styles' ); |
|
28 | - do_action( 'admin_head' ); |
|
23 | + wp_enqueue_style('font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(), 'v5.13.0'); |
|
24 | + wp_print_styles('select2'); |
|
25 | + wp_print_scripts('select2'); |
|
26 | + wp_print_scripts('wpinv-admin-script'); |
|
27 | + do_action('admin_print_styles'); |
|
28 | + do_action('admin_head'); |
|
29 | 29 | ?> |
30 | 30 | <style> |
31 | 31 | body, p{ |
@@ -37,21 +37,21 @@ discard block |
||
37 | 37 | font-weight: 500; |
38 | 38 | margin-bottom: .1rem; |
39 | 39 | } |
40 | - <?php echo $aui_settings::css_primary( '#009874', true ); ?> |
|
40 | + <?php echo $aui_settings::css_primary('#009874', true); ?> |
|
41 | 41 | </style> |
42 | 42 | </head> |
43 | 43 | |
44 | 44 | <body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;"> |
45 | 45 | |
46 | - <?php if ( isset( $_REQUEST['step'] ) ) : ?> |
|
46 | + <?php if (isset($_REQUEST['step'])) : ?> |
|
47 | 47 | <ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center"> |
48 | - <?php foreach ( $steps as $step => $data ) : ?> |
|
48 | + <?php foreach ($steps as $step => $data) : ?> |
|
49 | 49 | <li class="list-group-item flex-fill rounded-0 <?php |
50 | 50 | echo $step == $current ? 'active' : 'd-none d-md-block'; |
51 | - echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? ' done' : ''; |
|
51 | + echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? ' done' : ''; |
|
52 | 52 | ?>"> |
53 | - <i class="far fa-check-circle <?php echo array_search( $current, array_keys( $steps ) ) > array_search( $step, array_keys( $steps ) ) ? 'text-success' : '' ;?>"></i> |
|
54 | - <?php echo esc_html( $data['name'] ); ?> |
|
53 | + <i class="far fa-check-circle <?php echo array_search($current, array_keys($steps)) > array_search($step, array_keys($steps)) ? 'text-success' : ''; ?>"></i> |
|
54 | + <?php echo esc_html($data['name']); ?> |
|
55 | 55 | </li> |
56 | 56 | <?php endforeach; ?> |
57 | 57 | </ol> |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | <div class="text-center pb-3 mt-5"> |
63 | 63 | <a class=" text-decoration-none" href="https://wpgetpaid.com/"> |
64 | 64 | <span class="text-black-50"> |
65 | - <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" /> |
|
65 | + <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'; ?>" /> |
|
66 | 66 | </span> |
67 | 67 | </a> |
68 | 68 | </div> |
69 | 69 | \ No newline at end of file |
@@ -55,9 +55,12 @@ |
||
55 | 55 | </li> |
56 | 56 | <?php endforeach; ?> |
57 | 57 | </ol> |
58 | - <?php else: ?> |
|
58 | + <?php else { |
|
59 | + : ?> |
|
59 | 60 | <div class='mb-3'> </div> |
60 | - <?php endif; ?> |
|
61 | + <?php endif; |
|
62 | +} |
|
63 | +?> |
|
61 | 64 | |
62 | 65 | <div class="text-center pb-3 mt-5"> |
63 | 66 | <a class=" text-decoration-none" href="https://wpgetpaid.com/"> |
@@ -4,30 +4,30 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <div class="card shadow-sm my-5">' |
12 | 12 | |
13 | - <form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>"> |
|
14 | - <?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?> |
|
15 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
16 | - <?php getpaid_hidden_field( 'redirect', $next_url ); ?> |
|
13 | + <form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>"> |
|
14 | + <?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?> |
|
15 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
16 | + <?php getpaid_hidden_field('redirect', $next_url); ?> |
|
17 | 17 | <div class="gd-wizard-recommend"> |
18 | 18 | |
19 | - <h2 class="gd-settings-title h3"><?php _e( 'Recommended Plugins', 'invoicing' ); ?></h2> |
|
20 | - <p><?php _e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p> |
|
19 | + <h2 class="gd-settings-title h3"><?php _e('Recommended Plugins', 'invoicing'); ?></h2> |
|
20 | + <p><?php _e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p> |
|
21 | 21 | |
22 | 22 | <ul class="list-group"> |
23 | - <?php foreach ( $recommended_plugins as $plugin ) : ?> |
|
23 | + <?php foreach ($recommended_plugins as $plugin) : ?> |
|
24 | 24 | <li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left"> |
25 | - <span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span> |
|
25 | + <span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span> |
|
26 | 26 | <div class="custom-control custom-switch getpaid-install-plugin-siwtch-div mr-n2"> |
27 | - <input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="custom-control-input" <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?>> |
|
27 | + <input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="custom-control-input" <?php if (is_plugin_active($plugin['slug'])) {echo "checked"; } ?>> |
|
28 | 28 | <label class="custom-control-label" for="ac-setting-updates"></label> |
29 | 29 | </div> |
30 | - <small class="w-100"><?php echo esc_attr( $plugin['desc'] );?></small> |
|
30 | + <small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small> |
|
31 | 31 | </li> |
32 | 32 | <?php endforeach; ?> |
33 | 33 | </ul> |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | <input |
37 | 37 | type="submit" |
38 | 38 | class="btn btn-primary button-next" |
39 | - value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
|
39 | + value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/> |
|
40 | 40 | </p> |
41 | 41 | |
42 | 42 | </div> |
@@ -4,15 +4,15 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <div class="card shadow-sm my-5"> |
12 | 12 | |
13 | 13 | <form method="post" class="text-left card-body" action="options.php"> |
14 | - <?php settings_fields( 'wpinv_settings' ); ?> |
|
15 | - <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>"> |
|
14 | + <?php settings_fields('wpinv_settings'); ?> |
|
15 | + <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>"> |
|
16 | 16 | |
17 | 17 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
18 | 18 | <tbody> |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | - if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
|
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
23 | + if (isset($wp_settings_fields[$page][$section])) { |
|
24 | + $settings = $wp_settings_fields[$page][$section]; |
|
25 | 25 | |
26 | - foreach ( $settings as $field ) { |
|
26 | + foreach ($settings as $field) { |
|
27 | 27 | |
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
28 | + $name = esc_attr($field['id']); |
|
29 | + $id = sanitize_key($name); |
|
30 | 30 | $class = ''; |
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
31 | + $value = isset($field['args']['std']) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean(wpinv_get_option($field['args']['id'], $value)); |
|
33 | + $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : ''; |
|
34 | + $type = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback'])); |
|
35 | + $label = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : ''; |
|
36 | + $options = isset($field['args']['options']) ? $field['args']['options'] : array(); |
|
37 | 37 | |
38 | - if ( false !== strpos( $name, 'logo') ) { |
|
38 | + if (false !== strpos($name, 'logo')) { |
|
39 | 39 | $type = 'hidden'; |
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ('country_states' == $type) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
44 | + if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) { |
|
45 | 45 | $type = 'text'; |
46 | 46 | } else { |
47 | 47 | $type = 'select'; |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | $class = 'getpaid_js_field-state'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
53 | + if ('wpinv_settings[default_country]' == $name) { |
|
54 | 54 | $class = 'getpaid_js_field-country'; |
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ($type) { |
|
58 | 58 | |
59 | 59 | case 'hidden': |
60 | 60 | echo "<input type='hidden' id='$id' name='$name' value='$value' />"; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'type' => $type, |
67 | 67 | 'id' => $id, |
68 | 68 | 'name' => $name, |
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
69 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
70 | 70 | 'required' => false, |
71 | 71 | 'help_text' => $help_text, |
72 | 72 | 'label' => $label, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | array( |
83 | 83 | 'id' => $id, |
84 | 84 | 'name' => $name, |
85 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | + 'value' => is_scalar($value) ? esc_textarea($value) : '', |
|
86 | 86 | 'required' => false, |
87 | 87 | 'help_text' => $help_text, |
88 | 88 | 'label' => $label, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | ); |
95 | 95 | |
96 | 96 | // Bug fixed in AUI 0.1.51 for name stripping [] |
97 | - echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea ); |
|
97 | + echo str_replace(sanitize_html_class($name), esc_attr($name), $textarea); |
|
98 | 98 | |
99 | 99 | break; |
100 | 100 | case 'select': |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | 'id' => $id, |
104 | 104 | 'name' => $name, |
105 | 105 | 'placeholder' => '', |
106 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
106 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
107 | 107 | 'required' => false, |
108 | 108 | 'help_text' => $help_text, |
109 | 109 | 'label' => $label, |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | <input |
129 | 129 | type="submit" |
130 | 130 | class="btn btn-primary button-next" |
131 | - value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
|
131 | + value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/> |
|
132 | 132 | </p> |
133 | 133 | </table> |
134 | 134 | </form> |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
11 | - exit; // Exit if accessed directly |
|
11 | + exit; // Exit if accessed directly |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | /** |
@@ -319,10 +319,10 @@ discard block |
||
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
322 | - * Output the metabox. |
|
323 | - * |
|
324 | - * @param WP_Post $post |
|
325 | - */ |
|
322 | + * Output the metabox. |
|
323 | + * |
|
324 | + * @param WP_Post $post |
|
325 | + */ |
|
326 | 326 | public static function output2( $post ) { |
327 | 327 | |
328 | 328 | // Prepare the invoice. |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -16,82 +16,82 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class GetPaid_Meta_Box_Invoice_Items { |
18 | 18 | |
19 | - public static function get_columns( $invoice ) { |
|
19 | + public static function get_columns($invoice) { |
|
20 | 20 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
21 | 21 | $columns = array( |
22 | - 'id' => __( 'ID', 'invoicing' ), |
|
23 | - 'title' => __( 'Item', 'invoicing' ), |
|
22 | + 'id' => __('ID', 'invoicing'), |
|
23 | + 'title' => __('Item', 'invoicing'), |
|
24 | 24 | 'price' => sprintf( |
25 | 25 | '<span class="getpaid-hide-if-hours getpaid-hide-if-quantity">%s</span> |
26 | 26 | <span class="getpaid-hide-if-hours hide-if-amount">%s</span> |
27 | 27 | <span class="getpaid-hide-if-quantity hide-if-amount">%s</span>', |
28 | - __( 'Amount', 'invoicing' ), |
|
29 | - __( 'Price', 'invoicing' ), |
|
30 | - __( 'Rate', 'invoicing' ) |
|
28 | + __('Amount', 'invoicing'), |
|
29 | + __('Price', 'invoicing'), |
|
30 | + __('Rate', 'invoicing') |
|
31 | 31 | ), |
32 | 32 | 'qty' => sprintf( |
33 | 33 | '<span class="getpaid-hide-if-hours">%s</span><span class="getpaid-hide-if-quantity">%s</span>', |
34 | - __( 'Quantity', 'invoicing' ), |
|
35 | - __( 'Hours', 'invoicing' ) |
|
34 | + __('Quantity', 'invoicing'), |
|
35 | + __('Hours', 'invoicing') |
|
36 | 36 | ), |
37 | - 'total' => __( 'Total', 'invoicing' ), |
|
38 | - 'tax' => __( 'Tax (%)', 'invoicing' ), |
|
37 | + 'total' => __('Total', 'invoicing'), |
|
38 | + 'tax' => __('Tax (%)', 'invoicing'), |
|
39 | 39 | 'action' => '', |
40 | 40 | ); |
41 | 41 | |
42 | - if ( ! $use_taxes ) { |
|
43 | - unset( $columns['tax'] ); |
|
42 | + if (!$use_taxes) { |
|
43 | + unset($columns['tax']); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | return $columns; |
47 | 47 | } |
48 | 48 | |
49 | - public static function output( $post, $invoice = false ) { |
|
49 | + public static function output($post, $invoice = false) { |
|
50 | 50 | |
51 | - if ( apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) { |
|
52 | - return self::output2( $post ); |
|
51 | + if (apply_filters('getpaid_use_new_invoice_items_metabox', false)) { |
|
52 | + return self::output2($post); |
|
53 | 53 | } |
54 | 54 | |
55 | - $post_id = !empty( $post->ID ) ? $post->ID : 0; |
|
56 | - $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice( $post_id ); |
|
55 | + $post_id = !empty($post->ID) ? $post->ID : 0; |
|
56 | + $invoice = $invoice instanceof WPInv_Invoice ? $invoice : new WPInv_Invoice($post_id); |
|
57 | 57 | $use_taxes = $invoice->is_taxable() && wpinv_use_taxes(); |
58 | - $item_types = apply_filters( 'wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post ); |
|
59 | - $columns = self::get_columns( $invoice ); |
|
60 | - $cols = count( $columns ); |
|
58 | + $item_types = apply_filters('wpinv_item_types_for_quick_add_item', wpinv_get_item_types(), $post); |
|
59 | + $columns = self::get_columns($invoice); |
|
60 | + $cols = count($columns); |
|
61 | 61 | $class = ''; |
62 | 62 | |
63 | - unset( $item_types['adv'] ); |
|
64 | - unset( $item_types['package'] ); |
|
63 | + unset($item_types['adv']); |
|
64 | + unset($item_types['package']); |
|
65 | 65 | |
66 | - if ( $invoice->is_paid() ) { |
|
66 | + if ($invoice->is_paid()) { |
|
67 | 67 | $class .= ' wpinv-paid'; |
68 | 68 | } |
69 | 69 | |
70 | - if ( $invoice->is_refunded() ) { |
|
70 | + if ($invoice->is_refunded()) { |
|
71 | 71 | $class .= ' wpinv-refunded'; |
72 | 72 | } |
73 | 73 | |
74 | - if ( $invoice->is_recurring() ) { |
|
74 | + if ($invoice->is_recurring()) { |
|
75 | 75 | $class .= ' wpi-recurring'; |
76 | 76 | } |
77 | 77 | |
78 | 78 | ?> |
79 | 79 | |
80 | - <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr( $invoice->get_status() ); ?>"> |
|
80 | + <div class="wpinv-items-wrap<?php echo $class; ?>" id="wpinv_items_wrap" data-status="<?php echo esc_attr($invoice->get_status()); ?>"> |
|
81 | 81 | <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0"> |
82 | 82 | |
83 | 83 | <thead> |
84 | 84 | <tr> |
85 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
86 | - <th class="<?php echo esc_attr( $key ); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post( $label ); ?></th> |
|
85 | + <?php foreach ($columns as $key => $label) : ?> |
|
86 | + <th class="<?php echo esc_attr($key); echo 'total' == $key || 'qty' == $key ? ' hide-if-amount' : '' ?>"><?php echo wp_kses_post($label); ?></th> |
|
87 | 87 | <?php endforeach; ?> |
88 | 88 | </tr> |
89 | 89 | </thead> |
90 | 90 | |
91 | 91 | <tbody class="wpinv-line-items"> |
92 | 92 | <?php |
93 | - foreach ( $invoice->get_items() as $int => $item ) { |
|
94 | - self::output_row( $columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd' ); |
|
93 | + foreach ($invoice->get_items() as $int => $item) { |
|
94 | + self::output_row($columns, $item, $invoice, $int % 2 == 0 ? 'even' : 'odd'); |
|
95 | 95 | } |
96 | 96 | ?> |
97 | 97 | </tbody> |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | <div class="wp-clearfix"> |
109 | 109 | <label class="wpi-item-name"> |
110 | 110 | <span class="input-text-wrap"> |
111 | - <input type="text" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' );?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
111 | + <input type="text" style="width: 100%" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="wpinv-quick-item-name" name="_wpinv_quick[name]"> |
|
112 | 112 | </span> |
113 | 113 | </label> |
114 | 114 | </div> |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | <div class="wp-clearfix"> |
117 | 117 | <label class="wpi-item-price"> |
118 | 118 | <span class="input-text-wrap"> |
119 | - <input type="text" style="width: 200px" placeholder="<?php esc_attr_e( 'Item Price', 'invoicing' );?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | - × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e( 'Item Quantity', 'invoicing' );?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
119 | + <input type="text" style="width: 200px" placeholder="<?php esc_attr_e('Item Price', 'invoicing'); ?>" class="wpinv-quick-item-price" name="_wpinv_quick[price]"> |
|
120 | + × <input type="text" style="width: 140px" placeholder="<?php esc_attr_e('Item Quantity', 'invoicing'); ?>" class="wpinv-quick-item-qty" name="_wpinv_quick[qty]"> |
|
121 | 121 | </span> |
122 | 122 | </label> |
123 | 123 | </div> |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | <div class="wp-clearfix"> |
126 | 126 | <label class="wpi-item-name"> |
127 | 127 | <span class="input-text-wrap"> |
128 | - <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e( 'Item Description', 'invoicing' );?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
128 | + <textarea rows="4" style="width: 100%" placeholder="<?php esc_attr_e('Item Description', 'invoicing'); ?>" class="wpinv-quick-item-description" name="_wpinv_quick[description]"></textarea> |
|
129 | 129 | </span> |
130 | 130 | </label> |
131 | 131 | </div> |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | <div class="wp-clearfix"> |
134 | 134 | <label class="wpi-item-type"> |
135 | 135 | <span class="input-text-wrap"> |
136 | - <?php echo wpinv_html_select( array( |
|
136 | + <?php echo wpinv_html_select(array( |
|
137 | 137 | 'options' => $item_types, |
138 | 138 | 'name' => '_wpinv_quick[type]', |
139 | 139 | 'id' => '_wpinv_quick_type', |
@@ -141,19 +141,19 @@ discard block |
||
141 | 141 | 'show_option_all' => false, |
142 | 142 | 'show_option_none' => false, |
143 | 143 | 'class' => 'gdmbx2-text-medium wpinv-quick-type', |
144 | - ) ); ?> |
|
144 | + )); ?> |
|
145 | 145 | </span> |
146 | 146 | </label> |
147 | 147 | </div> |
148 | 148 | |
149 | - <?php if ( $use_taxes ) : ?> |
|
149 | + <?php if ($use_taxes) : ?> |
|
150 | 150 | <div class="wp-clearfix"> |
151 | 151 | <label class="wpi-vat-rule"> |
152 | 152 | <span class="input-text-wrap"> |
153 | 153 | <?php |
154 | - echo wpinv_html_select( array( |
|
154 | + echo wpinv_html_select(array( |
|
155 | 155 | 'options' => array_merge( |
156 | - array( '' => __( 'Select VAT Rule', 'invoicing' ) ), |
|
156 | + array('' => __('Select VAT Rule', 'invoicing')), |
|
157 | 157 | getpaid_get_tax_rules() |
158 | 158 | ), |
159 | 159 | 'name' => '_wpinv_quick[vat_rule]', |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | 'show_option_all' => false, |
162 | 162 | 'show_option_none' => false, |
163 | 163 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-rule', |
164 | - ) ); |
|
164 | + )); |
|
165 | 165 | ?> |
166 | 166 | </span> |
167 | 167 | </label> |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | <label class="wpi-vat-class"> |
171 | 171 | <span class="input-text-wrap"> |
172 | 172 | <?php |
173 | - echo wpinv_html_select( array( |
|
173 | + echo wpinv_html_select(array( |
|
174 | 174 | 'options' => array_merge( |
175 | - array( '' => __( 'Select VAT Class', 'invoicing' ) ), |
|
175 | + array('' => __('Select VAT Class', 'invoicing')), |
|
176 | 176 | getpaid_get_tax_classes() |
177 | 177 | ), |
178 | 178 | 'name' => '_wpinv_quick[vat_class]', |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | 'show_option_all' => false, |
181 | 181 | 'show_option_none' => false, |
182 | 182 | 'class' => 'gdmbx2-text-medium wpinv-quick-vat-class', |
183 | - ) ); |
|
183 | + )); |
|
184 | 184 | ?> |
185 | 185 | </span> |
186 | 186 | </label> |
@@ -201,29 +201,29 @@ discard block |
||
201 | 201 | </td> |
202 | 202 | </tr> |
203 | 203 | <tr class="totals"> |
204 | - <td colspan="<?php echo ( $cols - 4 ); ?>"></td> |
|
204 | + <td colspan="<?php echo ($cols - 4); ?>"></td> |
|
205 | 205 | <td colspan="4"> |
206 | 206 | <table cellspacing="0" cellpadding="0"> |
207 | 207 | <tr class="subtotal"> |
208 | - <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td> |
|
209 | - <td class="total"><?php echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );?></td> |
|
208 | + <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td> |
|
209 | + <td class="total"><?php echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); ?></td> |
|
210 | 210 | <td class="action"></td> |
211 | 211 | </tr> |
212 | 212 | <tr class="discount"> |
213 | - <td class="name"><?php _e( 'Discount:', 'invoicing' ) ; ?></td> |
|
214 | - <td class="total"><?php echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );?></td> |
|
213 | + <td class="name"><?php _e('Discount:', 'invoicing'); ?></td> |
|
214 | + <td class="total"><?php echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); ?></td> |
|
215 | 215 | <td class="action"></td> |
216 | 216 | </tr> |
217 | - <?php if ( $use_taxes ) : ?> |
|
217 | + <?php if ($use_taxes) : ?> |
|
218 | 218 | <tr class="tax"> |
219 | - <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td> |
|
220 | - <td class="total"><?php echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );?></td> |
|
219 | + <td class="name"><?php _e('Tax:', 'invoicing'); ?></td> |
|
220 | + <td class="total"><?php echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); ?></td> |
|
221 | 221 | <td class="action"></td> |
222 | 222 | </tr> |
223 | 223 | <?php endif; ?> |
224 | 224 | <tr class="total"> |
225 | - <td class="name"><?php _e( 'Total:', 'invoicing' );?></td> |
|
226 | - <td class="total"><?php echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );?></td> |
|
225 | + <td class="name"><?php _e('Total:', 'invoicing'); ?></td> |
|
226 | + <td class="total"><?php echo wpinv_price($invoice->get_total(), $invoice->get_currency()); ?></td> |
|
227 | 227 | <td class="action"></td> |
228 | 228 | </tr> |
229 | 229 | </table> |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | </table> |
235 | 235 | <div class="wpinv-actions"> |
236 | 236 | <?php |
237 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
237 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
238 | 238 | echo wpinv_item_dropdown( |
239 | 239 | array( |
240 | 240 | 'name' => 'wpinv_invoice_item', |
@@ -244,61 +244,61 @@ discard block |
||
244 | 244 | ) |
245 | 245 | ); |
246 | 246 | |
247 | - echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf( esc_html__( 'Add item to %s', 'invoicing' ), $invoice->get_label() ) . '</button>'; |
|
248 | - echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__( 'Create new item', 'invoicing' ) . '</button>'; |
|
249 | - echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__( 'Recalculate Totals', 'invoicing' ) . '</button>'; |
|
247 | + echo " " . '<button class="button button-primary" id="wpinv-add-item">' . sprintf(esc_html__('Add item to %s', 'invoicing'), $invoice->get_label()) . '</button>'; |
|
248 | + echo " " . '<button class="button button-primary" id="wpinv-new-item">' . esc_html__('Create new item', 'invoicing') . '</button>'; |
|
249 | + echo " " . '<button class="button button-primary wpinv-flr" id="wpinv-recalc-totals">' . esc_html__('Recalculate Totals', 'invoicing') . '</button>'; |
|
250 | 250 | |
251 | 251 | } |
252 | 252 | ?> |
253 | - <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?> |
|
253 | + <?php do_action('wpinv_invoice_items_actions', $invoice); ?> |
|
254 | 254 | </div> |
255 | 255 | </div> |
256 | 256 | <?php |
257 | 257 | } |
258 | 258 | |
259 | - public static function output_row( $columns, $item, $invoice, $class='even' ) { |
|
259 | + public static function output_row($columns, $item, $invoice, $class = 'even') { |
|
260 | 260 | |
261 | 261 | ?> |
262 | - <tr class="item item-<?php echo esc_attr( $class ); ?>" data-item-id="<?php echo esc_attr( $item->get_id() ); ?>"> |
|
263 | - <?php foreach ( array_keys( $columns ) as $column ) : ?> |
|
264 | - <td class="<?php echo esc_attr( $column ); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
262 | + <tr class="item item-<?php echo esc_attr($class); ?>" data-item-id="<?php echo esc_attr($item->get_id()); ?>"> |
|
263 | + <?php foreach (array_keys($columns) as $column) : ?> |
|
264 | + <td class="<?php echo esc_attr($column); echo 'total' == $column || 'qty' == $column ? ' hide-if-amount' : '' ?>"> |
|
265 | 265 | <?php |
266 | - switch ( $column ) { |
|
266 | + switch ($column) { |
|
267 | 267 | case 'id': |
268 | 268 | echo (int) $item->get_id(); |
269 | 269 | break; |
270 | 270 | case 'title': |
271 | 271 | printf( |
272 | 272 | '<a href="%s" target="_blank">%s</a>', |
273 | - get_edit_post_link( $item->get_id() ), |
|
274 | - esc_html( $item->get_raw_name() ) |
|
273 | + get_edit_post_link($item->get_id()), |
|
274 | + esc_html($item->get_raw_name()) |
|
275 | 275 | ); |
276 | 276 | |
277 | - $summary = apply_filters( 'getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice ); |
|
278 | - if ( $summary !== '' ) { |
|
277 | + $summary = apply_filters('getpaid_admin_invoice_line_item_summary', $item->get_description(), $item, $invoice); |
|
278 | + if ($summary !== '') { |
|
279 | 279 | printf( |
280 | 280 | '<span class="meta">%s</span>', |
281 | - wpautop( wp_kses_post( $summary ) ) |
|
281 | + wpautop(wp_kses_post($summary)) |
|
282 | 282 | ); |
283 | 283 | } |
284 | 284 | |
285 | 285 | printf( |
286 | 286 | '<input type="hidden" value="%s" name="getpaid_items[%s][name]" class="getpaid-recalculate-prices-on-change" />', |
287 | - esc_attr( $item->get_raw_name() ), |
|
287 | + esc_attr($item->get_raw_name()), |
|
288 | 288 | (int) $item->get_id() |
289 | 289 | ); |
290 | 290 | |
291 | 291 | printf( |
292 | 292 | '<textarea style="display: none;" name="getpaid_items[%s][description]" class="getpaid-recalculate-prices-on-change">%s</textarea>', |
293 | 293 | (int) $item->get_id(), |
294 | - esc_attr( $item->get_description() ) |
|
294 | + esc_attr($item->get_description()) |
|
295 | 295 | ); |
296 | 296 | |
297 | 297 | break; |
298 | 298 | case 'price': |
299 | 299 | printf( |
300 | 300 | '<input type="text" value="%s" name="getpaid_items[%s][price]" style="width: 100px;" class="getpaid-admin-invoice-item-price getpaid-recalculate-prices-on-change" />', |
301 | - esc_attr( getpaid_unstandardize_amount( $item->get_price() ) ), |
|
301 | + esc_attr(getpaid_unstandardize_amount($item->get_price())), |
|
302 | 302 | (int) $item->get_id() |
303 | 303 | ); |
304 | 304 | |
@@ -306,26 +306,26 @@ discard block |
||
306 | 306 | case 'qty': |
307 | 307 | printf( |
308 | 308 | '<input type="text" style="width: 100px;" value="%s" name="getpaid_items[%s][quantity]" class="getpaid-admin-invoice-item-quantity getpaid-recalculate-prices-on-change" />', |
309 | - floatval( $item->get_quantity() ), |
|
309 | + floatval($item->get_quantity()), |
|
310 | 310 | (int) $item->get_id() |
311 | 311 | ); |
312 | 312 | |
313 | 313 | break; |
314 | 314 | case 'total': |
315 | - echo wpinv_price( $item->get_sub_total(), $invoice->get_currency() ); |
|
315 | + echo wpinv_price($item->get_sub_total(), $invoice->get_currency()); |
|
316 | 316 | |
317 | 317 | break; |
318 | 318 | case 'tax': |
319 | - echo wpinv_round_amount( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
319 | + echo wpinv_round_amount(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
320 | 320 | |
321 | 321 | break; |
322 | 322 | case 'action': |
323 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
323 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
324 | 324 | echo '<i class="fa fa-trash wpinv-item-remove"></i>'; |
325 | 325 | } |
326 | 326 | break; |
327 | 327 | } |
328 | - do_action( 'getpaid_admin_edit_invoice_item_' . $column, $item, $invoice ); |
|
328 | + do_action('getpaid_admin_edit_invoice_item_' . $column, $item, $invoice); |
|
329 | 329 | ?> |
330 | 330 | </td> |
331 | 331 | <?php endforeach; ?> |
@@ -338,10 +338,10 @@ discard block |
||
338 | 338 | * |
339 | 339 | * @param WP_Post $post |
340 | 340 | */ |
341 | - public static function output2( $post ) { |
|
341 | + public static function output2($post) { |
|
342 | 342 | |
343 | 343 | // Prepare the invoice. |
344 | - $invoice = new WPInv_Invoice( $post ); |
|
344 | + $invoice = new WPInv_Invoice($post); |
|
345 | 345 | |
346 | 346 | // Invoice items. |
347 | 347 | $items = $invoice->get_items(); |
@@ -349,28 +349,28 @@ discard block |
||
349 | 349 | $totals = array( |
350 | 350 | |
351 | 351 | 'subtotal' => array( |
352 | - 'label' => __( 'Items Subtotal', 'invoicing' ), |
|
353 | - 'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ), |
|
352 | + 'label' => __('Items Subtotal', 'invoicing'), |
|
353 | + 'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()), |
|
354 | 354 | ), |
355 | 355 | |
356 | 356 | 'discount' => array( |
357 | - 'label' => __( 'Total Discount', 'invoicing' ), |
|
358 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
357 | + 'label' => __('Total Discount', 'invoicing'), |
|
358 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
359 | 359 | ), |
360 | 360 | |
361 | 361 | 'tax' => array( |
362 | - 'label' => __( 'Total Tax', 'invoicing' ), |
|
363 | - 'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ), |
|
362 | + 'label' => __('Total Tax', 'invoicing'), |
|
363 | + 'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()), |
|
364 | 364 | ), |
365 | 365 | |
366 | 366 | 'total' => array( |
367 | - 'label' => __( 'Invoice Total', 'invoicing' ), |
|
368 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
367 | + 'label' => __('Invoice Total', 'invoicing'), |
|
368 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - if ( ! wpinv_use_taxes() ) { |
|
373 | - unset( $totals['tax'] ); |
|
372 | + if (!wpinv_use_taxes()) { |
|
373 | + unset($totals['tax']); |
|
374 | 374 | } |
375 | 375 | |
376 | 376 | $item_args = array( |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | 'orderby' => 'title', |
379 | 379 | 'order' => 'ASC', |
380 | 380 | 'posts_per_page' => -1, |
381 | - 'post_status' => array( 'publish' ), |
|
381 | + 'post_status' => array('publish'), |
|
382 | 382 | 'meta_query' => array( |
383 | 383 | array( |
384 | 384 | 'key' => '_wpinv_type', |
@@ -402,10 +402,10 @@ discard block |
||
402 | 402 | } |
403 | 403 | </style> |
404 | 404 | |
405 | - <div class="bsui getpaid-invoice-items-inner <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
405 | + <div class="bsui getpaid-invoice-items-inner <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem; padding: 0 12px 12px;"> |
|
406 | 406 | |
407 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
408 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
407 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
408 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
409 | 409 | |
410 | 410 | <div class="row"> |
411 | 411 | <div class="col-12 col-sm-6"> |
@@ -414,15 +414,15 @@ discard block |
||
414 | 414 | array( |
415 | 415 | 'id' => 'wpinv_template', |
416 | 416 | 'name' => 'wpinv_template', |
417 | - 'label' => __( 'Template', 'invoicing' ), |
|
417 | + 'label' => __('Template', 'invoicing'), |
|
418 | 418 | 'label_type' => 'vertical', |
419 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
419 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
420 | 420 | 'class' => 'form-control-sm', |
421 | - 'value' => $invoice->get_template( 'edit' ), |
|
421 | + 'value' => $invoice->get_template('edit'), |
|
422 | 422 | 'options' => array( |
423 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
424 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
425 | - 'amount' => __( 'Amount Only', 'invoicing' ), |
|
423 | + 'quantity' => __('Quantity', 'invoicing'), |
|
424 | + 'hours' => __('Hours', 'invoicing'), |
|
425 | + 'amount' => __('Amount Only', 'invoicing'), |
|
426 | 426 | ), |
427 | 427 | 'data-allow-clear' => 'false', |
428 | 428 | 'select2' => true, |
@@ -438,11 +438,11 @@ discard block |
||
438 | 438 | array( |
439 | 439 | 'id' => 'wpinv_currency', |
440 | 440 | 'name' => 'wpinv_currency', |
441 | - 'label' => __( 'Currency', 'invoicing' ), |
|
441 | + 'label' => __('Currency', 'invoicing'), |
|
442 | 442 | 'label_type' => 'vertical', |
443 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
443 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
444 | 444 | 'class' => 'form-control-sm', |
445 | - 'value' => $invoice->get_currency( 'edit' ), |
|
445 | + 'value' => $invoice->get_currency('edit'), |
|
446 | 446 | 'required' => false, |
447 | 447 | 'data-allow-clear' => 'false', |
448 | 448 | 'select2' => true, |
@@ -454,24 +454,24 @@ discard block |
||
454 | 454 | </div> |
455 | 455 | </div> |
456 | 456 | |
457 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
457 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
458 | 458 | <?php endif; ?> |
459 | 459 | |
460 | 460 | <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items"> |
461 | 461 | <thead> |
462 | 462 | <tr> |
463 | - <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
463 | + <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th> |
|
464 | 464 | <th class="getpaid-quantity hide-if-amount text-right"> |
465 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
466 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
465 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
466 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
467 | 467 | </th> |
468 | 468 | <th class="getpaid-price hide-if-amount text-right"> |
469 | - <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span> |
|
470 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span> |
|
469 | + <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span> |
|
470 | + <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span> |
|
471 | 471 | </th> |
472 | 472 | <th class="getpaid-item-subtotal text-right"> |
473 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span> |
|
474 | - <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span> |
|
473 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span> |
|
474 | + <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span> |
|
475 | 475 | </th> |
476 | 476 | <th class="getpaid-item-actions hide-if-not-editable" width="70px"> </th> |
477 | 477 | </tr> |
@@ -479,8 +479,8 @@ discard block |
||
479 | 479 | <tbody class="getpaid_invoice_line_items"> |
480 | 480 | <tr class="hide-if-has-items hide-if-not-editable"> |
481 | 481 | <td colspan="2" class="pt-4 pb-4"> |
482 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button> |
|
483 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
|
482 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button> |
|
483 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button> |
|
484 | 484 | </td> |
485 | 485 | <td class="hide-if-amount"> </th> |
486 | 486 | <td class="hide-if-amount"> </th> |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | <div class="col-12 col-sm-6 offset-sm-6"> |
513 | 513 | <table class="getpaid-invoice-totals text-right w-100"> |
514 | 514 | <tbody> |
515 | - <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?> |
|
516 | - <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>"> |
|
517 | - <td class="label"><?php echo esc_html( $data['label'] ) ?>:</td> |
|
515 | + <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?> |
|
516 | + <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>"> |
|
517 | + <td class="label"><?php echo esc_html($data['label']) ?>:</td> |
|
518 | 518 | <td width="1%"></td> |
519 | - <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td> |
|
519 | + <td class="value"><?php echo wp_kses_post($data['value']) ?></td> |
|
520 | 520 | </tr> |
521 | 521 | <?php endforeach; ?> |
522 | 522 | </tbody> |
@@ -529,18 +529,18 @@ discard block |
||
529 | 529 | <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable"> |
530 | 530 | <div class="row"> |
531 | 531 | <div class="text-left col-12 col-sm-8"> |
532 | - <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button> |
|
533 | - <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e( 'Create New Item', 'invoicing' ) ?></button> |
|
534 | - <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?> |
|
532 | + <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button> |
|
533 | + <button type="button" class="button button-secondary create-invoice-item" data-toggle="modal" data-target="#getpaid-create-invoice-item"><?php _e('Create New Item', 'invoicing') ?></button> |
|
534 | + <?php do_action('getpaid-invoice-items-actions', $invoice); ?> |
|
535 | 535 | </div> |
536 | 536 | <div class="text-right col-12 col-sm-4"> |
537 | - <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button> |
|
537 | + <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button> |
|
538 | 538 | </div> |
539 | 539 | </div> |
540 | 540 | </div> |
541 | 541 | |
542 | 542 | <div class="getpaid-invoice-item-actions hide-if-editable"> |
543 | - <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p> |
|
543 | + <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p> |
|
544 | 544 | </div> |
545 | 545 | |
546 | 546 | <!-- Add items to an invoice --> |
@@ -548,8 +548,8 @@ discard block |
||
548 | 548 | <div class="modal-dialog modal-dialog-centered" role="document"> |
549 | 549 | <div class="modal-content"> |
550 | 550 | <div class="modal-header"> |
551 | - <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5> |
|
552 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
551 | + <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5> |
|
552 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
553 | 553 | <span aria-hidden="true">×</span> |
554 | 554 | </button> |
555 | 555 | </div> |
@@ -557,10 +557,10 @@ discard block |
||
557 | 557 | <table class="widefat"> |
558 | 558 | <thead> |
559 | 559 | <tr> |
560 | - <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th> |
|
560 | + <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th> |
|
561 | 561 | <th class="pr-0 text-right hide-if-amount"> |
562 | - <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span> |
|
563 | - <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span> |
|
562 | + <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span> |
|
563 | + <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span> |
|
564 | 564 | </th> |
565 | 565 | </tr> |
566 | 566 | </thead> |
@@ -568,9 +568,9 @@ discard block |
||
568 | 568 | <tr> |
569 | 569 | <td class="pl-0 text-left"> |
570 | 570 | <select class="regular-text getpaid-add-invoice-item-select"> |
571 | - <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option> |
|
572 | - <?php foreach ( get_posts( $item_args ) as $item ) : ?> |
|
573 | - <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option> |
|
571 | + <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option> |
|
572 | + <?php foreach (get_posts($item_args) as $item) : ?> |
|
573 | + <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option> |
|
574 | 574 | <?php endforeach; ?> |
575 | 575 | </select> |
576 | 576 | </td> |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | </table> |
583 | 583 | </div> |
584 | 584 | <div class="modal-footer"> |
585 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
586 | - <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button> |
|
585 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
586 | + <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button> |
|
587 | 587 | </div> |
588 | 588 | </div> |
589 | 589 | </div> |
@@ -594,8 +594,8 @@ discard block |
||
594 | 594 | <div class="modal-dialog modal-dialog-centered" role="document"> |
595 | 595 | <div class="modal-content"> |
596 | 596 | <div class="modal-header"> |
597 | - <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e( "Create Item", 'invoicing' ); ?></h5> |
|
598 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
597 | + <h5 class="modal-title" id="getpaid-create-invoice-item-label"><?php _e("Create Item", 'invoicing'); ?></h5> |
|
598 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
599 | 599 | <span aria-hidden="true">×</span> |
600 | 600 | </button> |
601 | 601 | </div> |
@@ -603,27 +603,27 @@ discard block |
||
603 | 603 | <div class="getpaid-create-item-div"> |
604 | 604 | <input type="hidden" name="id" value="new" class="form-control form-control-sm item-id"> |
605 | 605 | <label class="form-group w-100"> |
606 | - <span><?php _e( 'Name', 'invoicing' ); ?></span> |
|
607 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
606 | + <span><?php _e('Name', 'invoicing'); ?></span> |
|
607 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
608 | 608 | </label> |
609 | 609 | <label class="form-group w-100"> |
610 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
|
611 | - <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
|
612 | - <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
610 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span> |
|
611 | + <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span> |
|
612 | + <input type="text" name="price" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
613 | 613 | </label> |
614 | 614 | <label class="form-group w-100 hide-if-amount"> |
615 | - <span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
|
615 | + <span><?php _e('Quantity', 'invoicing'); ?></span> |
|
616 | 616 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
617 | 617 | </label> |
618 | 618 | <label class="form-group w-100"> |
619 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
620 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
619 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
620 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
621 | 621 | </label> |
622 | 622 | </div> |
623 | 623 | </div> |
624 | 624 | <div class="modal-footer"> |
625 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
626 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Create', 'invoicing' ); ?></button> |
|
625 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
626 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Create', 'invoicing'); ?></button> |
|
627 | 627 | </div> |
628 | 628 | </div> |
629 | 629 | </div> |
@@ -634,8 +634,8 @@ discard block |
||
634 | 634 | <div class="modal-dialog modal-dialog-centered" role="document"> |
635 | 635 | <div class="modal-content"> |
636 | 636 | <div class="modal-header"> |
637 | - <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5> |
|
638 | - <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>"> |
|
637 | + <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5> |
|
638 | + <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>"> |
|
639 | 639 | <span aria-hidden="true">×</span> |
640 | 640 | </button> |
641 | 641 | </div> |
@@ -643,27 +643,27 @@ discard block |
||
643 | 643 | <div class="getpaid-edit-item-div"> |
644 | 644 | <input type="hidden" name="id" class="form-control form-control-sm item-id"> |
645 | 645 | <label class="form-group w-100"> |
646 | - <span><?php _e( 'Name', 'invoicing' ); ?></span> |
|
647 | - <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name"> |
|
646 | + <span><?php _e('Name', 'invoicing'); ?></span> |
|
647 | + <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name"> |
|
648 | 648 | </label> |
649 | 649 | <label class="form-group w-100"> |
650 | - <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span> |
|
651 | - <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span> |
|
652 | - <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price"> |
|
650 | + <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span> |
|
651 | + <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span> |
|
652 | + <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price"> |
|
653 | 653 | </label> |
654 | 654 | <label class="form-group w-100 hide-if-amount"> |
655 | - <span><?php _e( 'Quantity', 'invoicing' ); ?></span> |
|
655 | + <span><?php _e('Quantity', 'invoicing'); ?></span> |
|
656 | 656 | <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity"> |
657 | 657 | </label> |
658 | 658 | <label class="form-group w-100"> |
659 | - <span><?php _e( 'Item Description', 'invoicing' ); ?></span> |
|
660 | - <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea> |
|
659 | + <span><?php _e('Item Description', 'invoicing'); ?></span> |
|
660 | + <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea> |
|
661 | 661 | </label> |
662 | 662 | </div> |
663 | 663 | </div> |
664 | 664 | <div class="modal-footer"> |
665 | - <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button> |
|
666 | - <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button> |
|
665 | + <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button> |
|
666 | + <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button> |
|
667 | 667 | </div> |
668 | 668 | </div> |
669 | 669 | </div> |