@@ -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,7 +67,7 @@ discard block |
||
67 | 67 | |
68 | 68 | $products = isset($section_data->products) ? $section_data->products : ''; |
69 | 69 | |
70 | - return apply_filters( 'wpi_addons_section_data', $products, $section_id ); |
|
70 | + return apply_filters('wpi_addons_section_data', $products, $section_id); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param string $theme |
79 | 79 | * @param string $plugin |
80 | 80 | */ |
81 | - public function output_button( $addon ) { |
|
82 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
81 | + public function output_button($addon) { |
|
82 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
83 | 83 | // $button_text = __('Free','invoicing'); |
84 | 84 | // $licensing = false; |
85 | 85 | // $installed = false; |
@@ -91,14 +91,14 @@ discard block |
||
91 | 91 | // $install_status = 'get'; |
92 | 92 | // $onclick = ''; |
93 | 93 | |
94 | - $wp_org_themes = array('supreme-directory','directory-starter'); |
|
94 | + $wp_org_themes = array('supreme-directory', 'directory-starter'); |
|
95 | 95 | |
96 | 96 | $button_args = array( |
97 | 97 | 'type' => $current_tab, |
98 | 98 | 'id' => isset($addon->info->id) ? absint($addon->info->id) : '', |
99 | 99 | 'title' => isset($addon->info->title) ? $addon->info->title : '', |
100 | - 'button_text' => __('Free','invoicing'), |
|
101 | - 'price_text' => __('Free','invoicing'), |
|
100 | + 'button_text' => __('Free', 'invoicing'), |
|
101 | + 'price_text' => __('Free', 'invoicing'), |
|
102 | 102 | 'link' => isset($addon->info->link) ? $addon->info->link : '', // link to product |
103 | 103 | 'url' => isset($addon->info->link) ? $addon->info->link : '', // button url |
104 | 104 | 'class' => 'button-primary', |
@@ -114,83 +114,83 @@ discard block |
||
114 | 114 | 'update_url' => '', |
115 | 115 | ); |
116 | 116 | |
117 | - if( ($current_tab == 'addons' || $current_tab =='gateways') && isset($addon->info->id) && $addon->info->id){ |
|
118 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
119 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
117 | + if (($current_tab == 'addons' || $current_tab == 'gateways') && isset($addon->info->id) && $addon->info->id) { |
|
118 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
119 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
120 | 120 | $status = self::install_plugin_install_status($addon); |
121 | 121 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
122 | - if(isset($status['status'])){$button_args['install_status'] = $status['status'];} |
|
122 | + if (isset($status['status'])) {$button_args['install_status'] = $status['status']; } |
|
123 | 123 | $button_args['update_url'] = "https://wpinvoicing.com"; |
124 | - }elseif($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
125 | - if(!empty($addon->licensing->edd_slug)){$button_args['slug'] = $addon->licensing->edd_slug;} |
|
124 | + }elseif ($current_tab == 'themes' && isset($addon->info->id) && $addon->info->id) { |
|
125 | + if (!empty($addon->licensing->edd_slug)) {$button_args['slug'] = $addon->licensing->edd_slug; } |
|
126 | 126 | $button_args['installed'] = self::is_theme_installed($addon); |
127 | - if(!in_array($button_args['slug'],$wp_org_themes)){ |
|
127 | + if (!in_array($button_args['slug'], $wp_org_themes)) { |
|
128 | 128 | $button_args['update_url'] = "https://wpinvoicing.com"; |
129 | 129 | } |
130 | - }elseif($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug){ |
|
131 | - include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api.. |
|
132 | - $status = install_plugin_install_status(array("slug"=>$button_args['slug'],"version"=>"")); |
|
130 | + }elseif ($current_tab == 'recommended_plugins' && isset($addon->info->slug) && $addon->info->slug) { |
|
131 | + include_once(ABSPATH . 'wp-admin/includes/plugin-install.php'); //for plugins_api.. |
|
132 | + $status = install_plugin_install_status(array("slug"=>$button_args['slug'], "version"=>"")); |
|
133 | 133 | $button_args['install_status'] = isset($status['status']) ? $status['status'] : 'install'; |
134 | 134 | $button_args['file'] = isset($status['file']) ? $status['file'] : ''; |
135 | 135 | } |
136 | 136 | |
137 | 137 | // set price |
138 | - if(isset($addon->pricing) && !empty($addon->pricing)){ |
|
139 | - if(is_object($addon->pricing)){ |
|
138 | + if (isset($addon->pricing) && !empty($addon->pricing)) { |
|
139 | + if (is_object($addon->pricing)) { |
|
140 | 140 | $prices = (Array)$addon->pricing; |
141 | 141 | $button_args['price'] = reset($prices); |
142 | - }elseif(isset($addon->pricing)){ |
|
142 | + }elseif (isset($addon->pricing)) { |
|
143 | 143 | $button_args['price'] = $addon->pricing; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | |
147 | 147 | // set price text |
148 | - if( $button_args['price'] && $button_args['price'] != '0.00' ){ |
|
149 | - $button_args['price_text'] = sprintf( __('From: $%d', 'invoicing'), $button_args['price']); |
|
148 | + if ($button_args['price'] && $button_args['price'] != '0.00') { |
|
149 | + $button_args['price_text'] = sprintf(__('From: $%d', 'invoicing'), $button_args['price']); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | |
153 | 153 | // set if installed |
154 | - if(in_array($button_args['install_status'], array('installed','latest_installed','update_available','newer_installed'))){ |
|
154 | + if (in_array($button_args['install_status'], array('installed', 'latest_installed', 'update_available', 'newer_installed'))) { |
|
155 | 155 | $button_args['installed'] = true; |
156 | 156 | } |
157 | 157 | |
158 | 158 | // print_r($button_args); |
159 | 159 | // set if active |
160 | - if($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')){ |
|
161 | - if($button_args['type'] != 'themes'){ |
|
160 | + if ($button_args['installed'] && ($button_args['file'] || $button_args['type'] == 'themes')) { |
|
161 | + if ($button_args['type'] != 'themes') { |
|
162 | 162 | $button_args['active'] = is_plugin_active($button_args['file']); |
163 | - }else{ |
|
163 | + } else { |
|
164 | 164 | $button_args['active'] = self::is_theme_active($addon); |
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | 168 | // set button text and class |
169 | - if($button_args['active']){ |
|
170 | - $button_args['button_text'] = __('Active','invoicing'); |
|
169 | + if ($button_args['active']) { |
|
170 | + $button_args['button_text'] = __('Active', 'invoicing'); |
|
171 | 171 | $button_args['class'] = ' button-secondary disabled '; |
172 | - }elseif($button_args['installed']){ |
|
173 | - $button_args['button_text'] = __('Activate','invoicing'); |
|
172 | + }elseif ($button_args['installed']) { |
|
173 | + $button_args['button_text'] = __('Activate', 'invoicing'); |
|
174 | 174 | |
175 | - if($button_args['type'] != 'themes'){ |
|
176 | - if ( current_user_can( 'manage_options' ) ) { |
|
177 | - $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin='.$button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
178 | - }else{ |
|
175 | + if ($button_args['type'] != 'themes') { |
|
176 | + if (current_user_can('manage_options')) { |
|
177 | + $button_args['url'] = wp_nonce_url(admin_url('plugins.php?action=activate&plugin=' . $button_args['file']), 'activate-plugin_' . $button_args['file']); |
|
178 | + } else { |
|
179 | 179 | $button_args['url'] = '#'; |
180 | 180 | } |
181 | - }else{ |
|
182 | - if ( current_user_can( 'switch_themes' ) ) { |
|
181 | + } else { |
|
182 | + if (current_user_can('switch_themes')) { |
|
183 | 183 | $button_args['url'] = self::get_theme_activation_url($addon); |
184 | - }else{ |
|
184 | + } else { |
|
185 | 185 | $button_args['url'] = '#'; |
186 | 186 | } |
187 | 187 | } |
188 | 188 | |
189 | - }else{ |
|
190 | - if($button_args['type'] == 'recommended_plugins'){ |
|
191 | - $button_args['button_text'] = __('Install','invoicing'); |
|
192 | - }else{ |
|
193 | - $button_args['button_text'] = __('Get it','invoicing'); |
|
189 | + } else { |
|
190 | + if ($button_args['type'] == 'recommended_plugins') { |
|
191 | + $button_args['button_text'] = __('Install', 'invoicing'); |
|
192 | + } else { |
|
193 | + $button_args['button_text'] = __('Get it', 'invoicing'); |
|
194 | 194 | |
195 | 195 | /*if($button_args['type'] == 'themes' && in_array($button_args['slug'],$wp_org_themes) ){ |
196 | 196 | $button_args['button_text'] = __('Install','invoicing'); |
@@ -203,45 +203,45 @@ discard block |
||
203 | 203 | |
204 | 204 | |
205 | 205 | // filter the button arguments |
206 | - $button_args = apply_filters('edd_api_button_args',$button_args); |
|
206 | + $button_args = apply_filters('edd_api_button_args', $button_args); |
|
207 | 207 | |
208 | 208 | // set price text |
209 | - if(isset($button_args['price_text'])){ |
|
209 | + if (isset($button_args['price_text'])) { |
|
210 | 210 | ?> |
211 | 211 | <a |
212 | 212 | target="_blank" |
213 | 213 | class="addons-price-text" |
214 | - href="<?php echo esc_url( $button_args['link'] ); ?>"> |
|
215 | - <?php echo esc_html( $button_args['price_text'] ); ?> |
|
214 | + href="<?php echo esc_url($button_args['link']); ?>"> |
|
215 | + <?php echo esc_html($button_args['price_text']); ?> |
|
216 | 216 | </a> |
217 | 217 | <?php |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | 221 | $target = ''; |
222 | - if ( ! empty( $button_args['url'] ) ) { |
|
222 | + if (!empty($button_args['url'])) { |
|
223 | 223 | $target = strpos($button_args['url'], get_site_url()) !== false ? '' : ' target="_blank" '; |
224 | 224 | } |
225 | 225 | |
226 | 226 | ?> |
227 | 227 | <a |
228 | - data-licence="<?php echo esc_attr($button_args['license']);?>" |
|
229 | - data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>" |
|
230 | - data-title="<?php echo esc_attr($button_args['title']);?>" |
|
231 | - data-type="<?php echo esc_attr($button_args['type']);?>" |
|
232 | - data-text-error-message="<?php _e('Something went wrong!','invoicing');?>" |
|
233 | - data-text-activate="<?php _e('Activate','invoicing');?>" |
|
234 | - data-text-activating="<?php _e('Activating','invoicing');?>" |
|
235 | - data-text-deactivate="<?php _e('Deactivate','invoicing');?>" |
|
236 | - data-text-installed="<?php _e('Installed','invoicing');?>" |
|
237 | - data-text-install="<?php _e('Install','invoicing');?>" |
|
238 | - data-text-installing="<?php _e('Installing','invoicing');?>" |
|
239 | - data-text-error="<?php _e('Error','invoicing');?>" |
|
240 | - <?php if(!empty($button_args['onclick'])){echo " onclick='".$button_args['onclick']."' ";}?> |
|
241 | - <?php echo $target;?> |
|
242 | - class="addons-button <?php echo esc_attr( $button_args['class'] ); ?>" |
|
243 | - href="<?php echo esc_url( $button_args['url'] ); ?>"> |
|
244 | - <?php echo esc_html( $button_args['button_text'] ); ?> |
|
228 | + data-licence="<?php echo esc_attr($button_args['license']); ?>" |
|
229 | + data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>" |
|
230 | + data-title="<?php echo esc_attr($button_args['title']); ?>" |
|
231 | + data-type="<?php echo esc_attr($button_args['type']); ?>" |
|
232 | + data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>" |
|
233 | + data-text-activate="<?php _e('Activate', 'invoicing'); ?>" |
|
234 | + data-text-activating="<?php _e('Activating', 'invoicing'); ?>" |
|
235 | + data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>" |
|
236 | + data-text-installed="<?php _e('Installed', 'invoicing'); ?>" |
|
237 | + data-text-install="<?php _e('Install', 'invoicing'); ?>" |
|
238 | + data-text-installing="<?php _e('Installing', 'invoicing'); ?>" |
|
239 | + data-text-error="<?php _e('Error', 'invoicing'); ?>" |
|
240 | + <?php if (!empty($button_args['onclick'])) {echo " onclick='" . $button_args['onclick'] . "' "; }?> |
|
241 | + <?php echo $target; ?> |
|
242 | + class="addons-button <?php echo esc_attr($button_args['class']); ?>" |
|
243 | + href="<?php echo esc_url($button_args['url']); ?>"> |
|
244 | + <?php echo esc_html($button_args['button_text']); ?> |
|
245 | 245 | </a> |
246 | 246 | <?php |
247 | 247 | |
@@ -256,35 +256,35 @@ discard block |
||
256 | 256 | $tabs = self::get_tabs(); |
257 | 257 | $sections = self::get_sections(); |
258 | 258 | $theme = wp_get_theme(); |
259 | - $section_keys = array_keys( $sections ); |
|
260 | - $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys ); |
|
261 | - $current_tab = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] ); |
|
262 | - include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' ); |
|
259 | + $section_keys = array_keys($sections); |
|
260 | + $current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys); |
|
261 | + $current_tab = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']); |
|
262 | + include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php'); |
|
263 | 263 | } |
264 | 264 | |
265 | 265 | /** |
266 | 266 | * A list of recommended wp.org plugins. |
267 | 267 | * @return array |
268 | 268 | */ |
269 | - public function get_recommend_wp_plugins(){ |
|
269 | + public function get_recommend_wp_plugins() { |
|
270 | 270 | $plugins = array( |
271 | 271 | 'invoicing-quotes' => array( |
272 | 272 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
273 | 273 | 'slug' => 'invoicing-quotes', |
274 | 274 | 'name' => 'Quotes', |
275 | - 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'), |
|
275 | + 'desc' => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'), |
|
276 | 276 | ), |
277 | 277 | 'geodirectory' => array( |
278 | 278 | 'url' => 'https://wordpress.org/plugins/geodirectory/', |
279 | 279 | 'slug' => 'geodirectory', |
280 | 280 | 'name' => 'GeoDirectory', |
281 | - 'desc' => __('Turn any WordPress theme into a global business directory portal.','invoicing'), |
|
281 | + 'desc' => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'), |
|
282 | 282 | ), |
283 | 283 | 'userswp' => array( |
284 | 284 | 'url' => 'https://wordpress.org/plugins/userswp/', |
285 | 285 | 'slug' => 'userswp', |
286 | 286 | 'name' => 'UsersWP', |
287 | - 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'), |
|
287 | + 'desc' => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'), |
|
288 | 288 | ), |
289 | 289 | ); |
290 | 290 |