Passed
Push — master ( 330418...c4952f )
by Brian
05:45 queued 27s
created
includes/class-wpinv-addons.php 2 patches
Indentation   +212 added lines, -212 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 = WPINV_PLUGIN_URL . 'assets/images/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 = WPINV_PLUGIN_URL . 'assets/images/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
 block discarded – undo
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,9 +229,9 @@  discard block
 block discarded – undo
229 229
 				<?php echo esc_html( $button_args['price_text'] ); ?>
230 230
 			</a>
231 231
 			<?php
232
-		}
232
+        }
233 233
 
234
-		?>
234
+        ?>
235 235
 		<a
236 236
 			data-licence="<?php echo esc_attr($button_args['license']);?>"
237 237
 			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
@@ -253,33 +253,33 @@  discard block
 block discarded – undo
253 253
 		<?php
254 254
 
255 255
 
256
-	}
257
-
258
-
259
-	/**
260
-	 * Handles output of the addons page in admin.
261
-	 */
262
-	public function output() {
263
-		$tabs            = self::get_tabs();
264
-		$sections        = self::get_sections();
265
-		$theme           = wp_get_theme();
266
-		$section_keys    = array_keys( $sections );
267
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
268
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
269
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
270
-	}
271
-
272
-	/**
273
-	 * A list of recommended wp.org plugins.
274
-	 * @return array
275
-	 */
276
-	public function get_recommend_wp_plugins(){
277
-		$plugins = array(
256
+    }
257
+
258
+
259
+    /**
260
+     * Handles output of the addons page in admin.
261
+     */
262
+    public function output() {
263
+        $tabs            = self::get_tabs();
264
+        $sections        = self::get_sections();
265
+        $theme           = wp_get_theme();
266
+        $section_keys    = array_keys( $sections );
267
+        $current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
268
+        $current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
269
+        include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
270
+    }
271
+
272
+    /**
273
+     * A list of recommended wp.org plugins.
274
+     * @return array
275
+     */
276
+    public function get_recommend_wp_plugins(){
277
+        $plugins = array(
278 278
             'invoicing-quotes' => array(
279 279
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
280 280
                 'slug'   => 'invoicing-quotes',
281
-				'name'   => 'Quotes',
282
-				'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png',
281
+                'name'   => 'Quotes',
282
+                'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png',
283 283
                 'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
284 284
             ),
285 285
             'geodirectory' => array(
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
                 'name'   => 'UsersWP',
295 295
                 'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
296 296
             ),
297
-		);
297
+        );
298 298
 
299
-		return $plugins;
300
-	}
299
+        return $plugins;
300
+    }
301 301
 }
Please login to merge, or discard this patch.
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 = WPINV_PLUGIN_URL . 'assets/images/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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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,38 +217,38 @@  discard block
 block discarded – undo
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
 		<a
236
-			data-licence="<?php echo esc_attr($button_args['license']);?>"
237
-			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0;?>"
238
-			data-title="<?php echo esc_attr($button_args['title']);?>"
239
-			data-type="<?php echo esc_attr($button_args['type']);?>"
240
-			data-text-error-message="<?php _e('Something went wrong!','invoicing');?>"
241
-			data-text-activate="<?php _e('Activate','invoicing');?>"
242
-			data-text-activating="<?php _e('Activating','invoicing');?>"
243
-			data-text-deactivate="<?php _e('Deactivate','invoicing');?>"
244
-			data-text-installed="<?php _e('Installed','invoicing');?>"
245
-			data-text-install="<?php _e('Install','invoicing');?>"
246
-			data-text-installing="<?php _e('Installing','invoicing');?>"
247
-			data-text-error="<?php _e('Error','invoicing');?>"
248
-			<?php if(!empty($button_args['onclick'])){echo " onclick='".esc_attr( $button_args['onclick'] )."' ";}?>
249
-			class="addons-button  <?php echo esc_attr( $button_args['class'] ); ?>"
250
-			href="<?php echo esc_url( $button_args['url'] ); ?>">
251
-			<?php echo esc_html( $button_args['button_text'] ); ?>
236
+			data-licence="<?php echo esc_attr($button_args['license']); ?>"
237
+			data-licensing="<?php echo $button_args['licensing'] ? 1 : 0; ?>"
238
+			data-title="<?php echo esc_attr($button_args['title']); ?>"
239
+			data-type="<?php echo esc_attr($button_args['type']); ?>"
240
+			data-text-error-message="<?php _e('Something went wrong!', 'invoicing'); ?>"
241
+			data-text-activate="<?php _e('Activate', 'invoicing'); ?>"
242
+			data-text-activating="<?php _e('Activating', 'invoicing'); ?>"
243
+			data-text-deactivate="<?php _e('Deactivate', 'invoicing'); ?>"
244
+			data-text-installed="<?php _e('Installed', 'invoicing'); ?>"
245
+			data-text-install="<?php _e('Install', 'invoicing'); ?>"
246
+			data-text-installing="<?php _e('Installing', 'invoicing'); ?>"
247
+			data-text-error="<?php _e('Error', 'invoicing'); ?>"
248
+			<?php if (!empty($button_args['onclick'])) {echo " onclick='" . esc_attr($button_args['onclick']) . "' "; }?>
249
+			class="addons-button  <?php echo esc_attr($button_args['class']); ?>"
250
+			href="<?php echo esc_url($button_args['url']); ?>">
251
+			<?php echo esc_html($button_args['button_text']); ?>
252 252
 		</a>
253 253
 		<?php
254 254
 
@@ -263,36 +263,36 @@  discard block
 block discarded – undo
263 263
 		$tabs            = self::get_tabs();
264 264
 		$sections        = self::get_sections();
265 265
 		$theme           = wp_get_theme();
266
-		$section_keys    = array_keys( $sections );
267
-		$current_section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : current( $section_keys );
268
-		$current_tab     = empty( $_GET['tab'] ) ? 'addons' : sanitize_title( $_GET['tab'] );
269
-		include_once( WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php' );
266
+		$section_keys    = array_keys($sections);
267
+		$current_section = isset($_GET['section']) ? sanitize_text_field($_GET['section']) : current($section_keys);
268
+		$current_tab     = empty($_GET['tab']) ? 'addons' : sanitize_title($_GET['tab']);
269
+		include_once(WPINV_PLUGIN_DIR . '/includes/admin/html-admin-page-addons.php');
270 270
 	}
271 271
 
272 272
 	/**
273 273
 	 * A list of recommended wp.org plugins.
274 274
 	 * @return array
275 275
 	 */
276
-	public function get_recommend_wp_plugins(){
276
+	public function get_recommend_wp_plugins() {
277 277
 		$plugins = array(
278 278
             'invoicing-quotes' => array(
279 279
                 'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
280 280
                 'slug'   => 'invoicing-quotes',
281 281
 				'name'   => 'Quotes',
282 282
 				'thumbnail'  => 'https://ps.w.org/invoicing-quotes/assets/banner-772x250.png',
283
-                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.','invoicing'),
283
+                'desc'   => __('Allows you to create quotes, send them to clients and convert them to Invoices when accepted by the customer.', 'invoicing'),
284 284
             ),
285 285
             'geodirectory' => array(
286 286
                 'url'   => 'https://wordpress.org/plugins/geodirectory/',
287 287
                 'slug'   => 'geodirectory',
288 288
                 'name'   => 'GeoDirectory',
289
-                'desc'   => __('Turn any WordPress theme into a global business directory portal.','invoicing'),
289
+                'desc'   => __('Turn any WordPress theme into a global business directory portal.', 'invoicing'),
290 290
             ),
291 291
             'userswp' => array(
292 292
                 'url'   => 'https://wordpress.org/plugins/userswp/',
293 293
                 'slug'   => 'userswp',
294 294
                 'name'   => 'UsersWP',
295
-                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.','invoicing'),
295
+                'desc'   => __('Allow frontend user login and registration as well as have slick profile pages.', 'invoicing'),
296 296
             ),
297 297
 		);
298 298
 
Please login to merge, or discard this patch.