PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.24
Advanced Ads – Ad Manager & AdSense v2.0.24
2.0.24 2.0.23 2.0.22 2.0.21 1.38.0 1.39.0 1.39.1 1.39.2 1.39.3 1.39.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.40.0 1.40.1 1.40.2 1.41.0 1.42.0 1.42.1 1.42.2 1.43.0 1.44.0 1.44.1 1.45.0 1.45.1 1.46.0 1.47.0 1.47.1 1.47.2 1.47.3 1.47.4 1.47.5 1.48.0 1.48.1 1.49.0 1.5.0 1.5.0.1 1.5.1 1.5.2 1.5.2.1 1.5.4 1.5.4.1 1.5.5 1.50.0 1.51.0 1.51.1 1.51.2 1.51.3 1.52.0 1.52.1 1.52.2 1.52.3 1.52.4 1.53.0 1.53.1 1.53.2 1.54.0 1.54.1 1.55.0 1.56.0 1.56.1 1.56.2 1.56.3 1.56.4 1.6 1.6.1 1.6.10 1.6.10.1 1.6.10.2 1.6.11 1.6.11.1 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.17.1 1.6.17.2 1.6.2 1.6.2.1 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.6 1.6.6.1 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.6.8.3 1.6.9 1.6.9.1 1.6.9.2 1.6.9.3 1.6.9.4 1.7 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.1.1 1.7.1.2 1.7.1.3 1.7.1.4 1.7.1.5 1.7.10 trunk 1.7.11 1.0.1 1.7.12 1.0.2 1.7.13 1.0.3 1.7.14 1.1.0 1.7.15 1.1.1 1.7.16 1.1.2 1.7.17 1.1.3 1.7.18 1.10 1.7.19 1.10.1 1.7.2 1.10.10 1.7.2.1 1.10.11 1.7.20 1.10.12 1.7.21 1.10.2 1.7.22 1.10.3 1.7.23 1.10.4 1.7.24 1.10.5 1.7.25 1.10.6 1.7.3 1.10.7 1.7.4 1.10.8 1.7.4.1 1.10.9 1.7.4.2 1.11 1.7.4.3 1.11.1 1.7.4.4 1.11.2 1.7.4.5 1.12 1.7.5 1.13 1.7.5.1 1.13.1 1.7.6 1.13.2 1.7.7 1.13.3 1.7.8 1.13.4 1.7.9 1.13.5 1.7.9.1 1.13.6 1.7.9.2 1.13.7 1.7.9.3 1.13.8 1.8 1.14 1.8.1 1.14.1 1.8.10 1.14.10 1.8.11 1.14.11 1.8.12 1.14.2 1.8.13 1.14.3 1.8.14 1.14.4 1.8.15 1.14.5 1.8.16 1.14.6 1.8.17 1.14.7 1.8.18 1.14.8 1.8.19 1.14.9 1.8.2 1.15 1.8.20 1.16 1.8.21 1.16.1 1.8.22 1.17 1.8.23 1.17.1 1.8.24 1.17.10 1.8.25 1.17.10-rc.1 1.8.26 1.17.11 1.8.27 1.17.12 1.8.28 1.17.12-rc.1 1.8.29 1.17.2 1.8.3 1.17.3 1.8.30 1.17.4 1.8.4 1.17.5 1.8.5 1.17.6 1.8.6 1.17.7 1.8.7 1.17.8 1.8.8 1.17.9 1.8.9 1.17.9-beta.1 1.9 1.18.0 2.0.0 1.19.0 2.0.1 1.19.1 2.0.10 1.2 2.0.11 1.2.1 2.0.12 1.2.2 2.0.13 1.2.3 2.0.14 1.2.4 2.0.15 1.2.5 2.0.16 1.2.6 2.0.17 1.2.7 2.0.18 1.20.0 2.0.19 1.20.0-rc.1 2.0.2 1.20.0-rc.2 2.0.20 1.20.1 2.0.3 1.20.2 2.0.4 1.20.3 2.0.5 1.21.0 2.0.6 1.21.1 2.0.7 1.22.0 2.0.8 1.22.1 2.0.9 1.22.2 1.23.0 1.23.1 1.23.2 1.24.0 1.24.1 1.24.2 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.29.0 1.29.1 1.3 1.3.1 1.3.10 1.3.11 1.3.12 1.3.13 1.3.14 1.3.15 1.3.16 1.3.17 1.3.18 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.30.0 1.30.1 1.30.2 1.30.2-rc.1 1.30.3 1.30.4 1.30.4-rc.1 1.30.5 1.31.0 1.31.1 1.32.0 1.32.0-rc.1 1.33.0 1.33.1 1.33.2 1.34.0 1.35.0 1.35.1 1.36.0 1.36.1 1.36.2 1.36.3 1.37.0 1.37.1 1.37.2
advanced-ads / includes / admin / class-addon-box.php
advanced-ads / includes / admin Last commit date
ads 1 week ago groups 1 week ago metaboxes 1 year ago pages 3 months ago placements 1 week ago class-action-links.php 1 week ago class-addon-box.php 1 year ago class-addon-updater.php 3 months ago class-admin-menu.php 1 week ago class-admin-notices.php 1 year ago class-ajax.php 3 months ago class-assets.php 1 week ago class-authors.php 1 year ago class-edd-updater.php 1 month ago class-list-filters.php 1 week ago class-marketing.php 1 year ago class-metabox-ad-settings.php 1 year ago class-metabox-ad.php 1 year ago class-misc.php 1 week ago class-page-quick-edit.php 1 year ago class-plugin-installer.php 1 year ago class-post-list.php 1 year ago class-post-types.php 1 week ago class-screen-options.php 3 months ago class-settings.php 1 year ago class-shortcode-creator.php 1 year ago class-system-info.php 1 year ago class-tinymce.php 2 years ago class-translation-promo.php 1 year ago class-upgrades.php 1 year ago class-version-control.php 3 months ago class-welcome.php 1 year ago class-wordpress-dashboard.php 1 year ago index.php 2 years ago
class-addon-box.php
750 lines
1 <?php
2 /**
3 * Admin Addon Box.
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 1.50.0
8 */
9
10 namespace AdvancedAds\Admin;
11
12 use AdvancedAds\Utilities\Conditional;
13 use AdvancedAds\Framework\Utilities\Arr;
14
15 defined( 'ABSPATH' ) || exit;
16
17 /**
18 * Admin Addon Box.
19 */
20 class Addon_Box {
21 /**
22 * Hide active plugins
23 *
24 * @var bool
25 */
26 private $hide_activated;
27
28 /**
29 * Internal plugins data
30 *
31 * @var array
32 */
33 private $plugins;
34
35 /**
36 * Constructor
37 *
38 * @param bool $hide_activated whether to hide active plugins.
39 */
40 public function __construct( $hide_activated = false ) {
41 if ( ! is_admin() ) {
42 return;
43 }
44 $this->hide_activated = (bool) $hide_activated;
45 $this->build_plugins_data();
46 }
47
48 /**
49 * Build the internal plugin data
50 *
51 * @return void
52 */
53 private function build_plugins_data() {
54 // phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned,WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow
55 $aa_plugins = [
56 'advanced-ads-pro/advanced-ads-pro.php' => [
57 'id' => 'pro',
58 'constant' => 'AAP_VERSION',
59 'title' => 'Advanced Ads Pro',
60 'description' => __( 'Take the monetization of your website to the next level.', 'advanced-ads' ),
61 'download_link' => 'https://wpadvancedads.com/add-ons/advanced-ads-pro/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
62 'manual' => 'https://wpadvancedads.com/manual/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
63 ],
64 'advanced-ads-responsive/responsive-ads.php' => [
65 'id' => 'ampads',
66 'constant' => 'AAR_VERSION',
67 'title' => 'AMP Ads',
68 'description' => __( 'Integrate your ads on AMP (Accelerated Mobile Pages) and auto-convert your Google AdSense ad units for enhanced mobile performance.', 'advanced-ads' ),
69 'download_link' => 'https://wpadvancedads.com/add-ons/responsive-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
70 'manual' => 'https://wpadvancedads.com/manual/ads-on-amp-pages/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
71 ],
72 'advanced-ads-gam/advanced-ads-gam.php' => [
73 'id' => 'gam',
74 'constant' => 'AAGAM_VERSION',
75 'title' => 'Google Ad Manager Integration',
76 'description' => __( 'Simplify the process of implementing ad units from Google Ad Manager swiftly and without errors.', 'advanced-ads' ),
77 'download_link' => 'https://wpadvancedads.com/add-ons/google-ad-manager/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
78 'manual' => 'https://wpadvancedads.com/manual/google-ad-manager-integration-manual/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
79 ],
80 'advanced-ads-layer/layer-ads.php' => [
81 'id' => 'popuplayer',
82 'constant' => 'AAPLDS_VERSION',
83 'title' => 'PopUp and Layer Ads',
84 'description' => __( 'Capture attention with customizable pop-ups that ensure your ads and messages get noticed. Set timing and closing options for optimal user engagement.', 'advanced-ads' ),
85 'download_link' => 'https://wpadvancedads.com/add-ons/popup-and-layer-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
86 'manual' => 'https://wpadvancedads.com/manual/popup-and-layer-ads-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
87 ],
88 'advanced-ads-selling/advanced-ads-selling.php' => [
89 'id' => 'sellingads',
90 'constant' => 'AASA_VERSION',
91 'title' => 'Selling Ads',
92 'description' => __( 'Earn more money by enabling advertisers to buy ad space directly on your site’s frontend.', 'advanced-ads' ),
93 'download_link' => 'https://wpadvancedads.com/add-ons/selling-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
94 'manual' => 'https://wpadvancedads.com/manual/selling-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
95 ],
96 'advanced-ads-sticky-ads/sticky-ads.php' => [
97 'id' => 'stickyads',
98 'constant' => 'AASADS_SLUG',
99 'title' => 'Sticky Ads',
100 'description' => __( 'Increase click rates by anchoring ads in sticky positions above, alongside, or below your website.', 'advanced-ads' ),
101 'download_link' => 'https://wpadvancedads.com/add-ons/sticky-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
102 'manual' => 'https://wpadvancedads.com/manual/sticky-ads-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
103 ],
104 'advanced-ads-tracking/tracking.php' => [
105 'id' => 'tracking',
106 'constant' => 'AAT_VERSION',
107 'title' => 'Tracking',
108 'description' => __( 'Monitor your ad performance to maximize your revenue.', 'advanced-ads' ),
109 'download_link' => 'https://wpadvancedads.com/add-ons/tracking/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
110 'manual' => 'https://wpadvancedads.com/manual/tracking-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
111 ],
112 'advanced-ads-slider/slider.php' => [
113 'id' => 'adslider',
114 'constant' => 'AAS_VERSION',
115 'title' => 'Ad Slider',
116 'description' => __( 'Create a beautiful ad slider and increase the ad impressions per page view. Free add-on for subscribers to our newsletter.', 'advanced-ads' ),
117 'download_link' => 'https://wpadvancedads.com/add-ons/slider/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
118 'manual' => 'https://wpadvancedads.com/manual/ad-slider/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
119 ],
120 'advanced-ads-adsense-in-feed/advanced-ads-in-feed.php' => [
121 'id' => 'adsenseinfeed',
122 'constant' => 'AAINF_VERSION',
123 'title' => 'AdSense In-Feed',
124 'description' => __( 'Place AdSense In-feed ads between posts on homepage, category, and archive pages for optimal engagement.', 'advanced-ads' ),
125 'download_link' => wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=advanced-ads-adsense-in-feed' ), 'install-plugin_advanced-ads-adsense-in-feed' ),
126 'manual' => 'https://wpadvancedads.com/add-adsense-in-feed-to-wordpress/#Adding_the_In-feed_ad_to_your_WordPress_site',
127 ],
128 ];
129 // phpcs:enable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned,WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow
130
131 $plugins = get_plugins();
132 $this->plugins = [
133 'plugins' => [],
134 'premium_level' => 'free',
135 ];
136
137 $pro = false;
138 $tracking = false;
139 $bundle_indicators = [
140 'ampads',
141 'stickyads',
142 'gam',
143 'sellingads',
144 'popuplayer',
145 ];
146
147 foreach ( $aa_plugins as $file => $data ) {
148 if ( array_key_exists( $file, $plugins ) ) {
149 $this->plugins['plugins'][ $data['id'] ] = [ 'status' => defined( $data['constant'] ) ? 'active' : 'installed' ];
150 if ( in_array( $data['id'], $bundle_indicators, true ) ) {
151 $this->plugins['premium_level'] = 'bundle';
152 }
153 if ( in_array( $data['id'], [ 'pro', 'tracking' ], true ) ) {
154 ${$data['id']} = true;
155 }
156 } else {
157 $this->plugins['plugins'][ $data['id'] ] = [ 'status' => 'missing' ];
158 }
159 $this->plugins['plugins'][ $data['id'] ]['file'] = $file;
160 if ( isset( $plugins[ $file ] ) ) {
161 $this->plugins['plugins'][ $data['id'] ]['name'] = $plugins[ $file ]['Name'];
162 }
163 $this->plugins['plugins'][ $data['id'] ] += $data;
164 }
165
166 if ( 'bundle' === $this->plugins['premium_level'] ) {
167 return;
168 }
169
170 if ( $pro || $tracking ) {
171 $this->plugins['premium_level'] = 'premium';
172 }
173
174 if ( $pro && $tracking ) {
175 $this->plugins['premium_level'] = 'bundle';
176 }
177 }
178
179 /**
180 * Get feature grid data for an addon
181 *
182 * @param string $id add-on internal ID.
183 *
184 * @return array
185 */
186 private function get_grid_data( $id ) {
187 if ( 'pro' === $id ) {
188 return [
189 __( 'Cache Busting', 'advanced-ads' ),
190 __( 'Click Fraud Protection', 'advanced-ads' ),
191 __( 'Lazy Loading', 'advanced-ads' ),
192 __( 'Anti Ad Blocker', 'advanced-ads' ),
193 __( 'Geo Targeting', 'advanced-ads' ),
194 __( '+23 Conditions', 'advanced-ads' ),
195 __( '+11 Placements', 'advanced-ads' ),
196 __( 'Parallax Ads', 'advanced-ads' ),
197 __( 'Ad Grids', 'advanced-ads' ),
198 __( 'Ad Refresh', 'advanced-ads' ),
199 __( 'A/B Tests', 'advanced-ads' ),
200 ];
201 }
202
203 if ( 'tracking' === $id ) {
204 return [
205 __( 'Impressions & Clicks', 'advanced-ads' ),
206 __( 'Click-Through Rate', 'advanced-ads' ),
207 __( 'Statistics', 'advanced-ads' ),
208 __( 'Google Analytics', 'advanced-ads' ),
209 __( 'Local Data Processing', 'advanced-ads' ),
210 __( 'Email Reports', 'advanced-ads' ),
211 __( 'Link Cloaking', 'advanced-ads' ),
212 ];
213 }
214
215 return [];
216 }
217
218 /**
219 * Sort plugins by status (missing|installed|enabled)
220 *
221 * @param array $a plugin data.
222 * @param array $b plugin data.
223 *
224 * @return int
225 */
226 private function sort_by_status( $a, $b ) {
227 static $order;
228 if ( null === $order ) {
229 $order = [
230 'missing' => 0,
231 'installed' => 1,
232 'active' => 2,
233 ];
234 }
235
236 return $order[ $a['status'] ] < $order[ $b['status'] ] ? 1 : -1;
237 }
238
239 /**
240 * Sort extra add-ons by the order field
241 *
242 * @param int $a order to compare.
243 * @param int $b order to compare.
244 *
245 * @return mixed
246 */
247 private function sort_by_order( $a, $b ) {
248 return (int) $a['order'] - (int) $b['order'];
249 }
250
251 /**
252 * Get plugin list to display into a given section
253 *
254 * @param string $section section slug (installed|available|special).
255 *
256 * @return array[]
257 */
258 private function get_displayable_items( $section ) {
259 switch ( $section ) {
260 case 'special':
261 $items = [];
262 if ( 'missing' === $this->plugins['plugins']['adslider']['status'] ) {
263 $items['adslider'] = $this->plugins['plugins']['adslider'];
264 }
265 if ( 'missing' === $this->plugins['plugins']['adsenseinfeed']['status'] ) {
266 $items['adsenseinfeed'] = $this->plugins['plugins']['adsenseinfeed'];
267 }
268
269 return $items;
270 case 'available':
271 if ( 'free' === $this->plugins['premium_level'] ) {
272 return [
273 'aa' => [
274 'id' => 'aa',
275 'upsell' => true,
276 ],
277 'aalt' => [ 'id' => 'aalt' ],
278 'pro' => array_merge( $this->plugins['plugins']['pro'], [ 'grid' => true ] ),
279 'tracking' => array_merge( $this->plugins['plugins']['tracking'], [ 'grid' => true ] ),
280 ];
281 }
282
283 if ( 'premium' === $this->plugins['premium_level'] ) {
284 $items = [
285 'aa' => [
286 'id' => 'aa',
287 'upsell' => true,
288 ],
289 'aalt' => [ 'id' => 'aalt' ],
290 ];
291
292 if ( 'missing' === $this->plugins['plugins']['pro']['status'] ) {
293 $items['pro'] = $this->plugins['plugins']['pro'];
294 $items['pro']['grid'] = true;
295 }
296
297 if ( 'missing' === $this->plugins['plugins']['tracking']['status'] ) {
298 $items['tracking'] = $this->plugins['plugins']['tracking'];
299 $items['tracking']['grid'] = true;
300 }
301
302 return $items;
303 }
304
305 if ( 'bundle' === $this->plugins['premium_level'] ) {
306 return [ 'aalt' => [ 'id' => 'aalt' ] ];
307 }
308
309 return [];
310 default: // Installed add-ons.
311 if ( 'free' === $this->plugins['premium_level'] && 'missing' === $this->plugins['plugins']['adslider']['status'] && 'missing' === $this->plugins['plugins']['adsenseinfeed']['status'] ) {
312 return [
313 'none' =>
314 [
315 'id' => 'none',
316 ],
317 ];
318 }
319
320 if ( 'bundle' === $this->plugins['premium_level'] ) {
321 $items = [
322 'aa' => [ 'id' => 'aa' ],
323 ]
324 + Arr::where(
325 $this->get_special_add_ons(),
326 function ( $item ) {
327 return in_array( $item['status'], [ 'installed', 'active' ], true );
328 }
329 );
330
331 return $items;
332 }
333
334 $displayable_items = Arr::where(
335 $this->plugins['plugins'],
336 function ( $item ) {
337 return 'missing' !== $item['status'];
338 }
339 );
340
341 usort( $displayable_items, [ $this, 'sort_by_status' ] );
342
343 return $displayable_items;
344 }
345 }
346
347 /**
348 * Get list of plugins of the "special" section
349 *
350 * @return array
351 */
352 private function get_special_add_ons() {
353 return Arr::where(
354 $this->plugins['plugins'],
355 function ( $item ) {
356 return in_array( $item['id'], [ 'adslider', 'adsenseinfeed' ], true );
357 }
358 );
359 }
360
361 /**
362 * Print output for a single add-on (not in bundle)
363 *
364 * @param array $item plugin data.
365 * @param string $section section slug.
366 *
367 * @return void
368 */
369 private function do_single_item( $item, $section ) {
370 if ( 'aa' === $item['id'] ) {
371 $this->all_access( $item['upsell'] ?? false );
372
373 return;
374 }
375
376 if ( 'aalt' === $item['id'] ) {
377 $this->all_access_long_term();
378
379 return;
380 }
381
382 if ( 'none' === $item['id'] ) {
383 ?>
384 <div class="single-item none">
385 <div class="item-details">
386 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-empty.svg' ); ?>" alt=""/></div>
387 <span></span>
388 <div class="name"><?php esc_html_e( 'No add-ons installed', 'advanced-ads' ); ?></div>
389 <span></span>
390 <div class="description">
391 <?php esc_html_e( 'Please select from the list below.', 'advanced-ads' ); ?>
392 <a href="https://wpadvancedads.com/manual/how-to-install-an-add-on/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-install-add-ons" target="_blank">
393 <?php esc_html_e( 'Learn how to download, install, and activate an add-on', 'advanced-ads' ); ?>
394 </a>
395 </div>
396 <span></span>
397 <div class="cta"></div>
398 </div>
399 </div>
400 <?php
401 return;
402 }
403
404 $button_class = $item['status'];
405
406 if ( $this->hide_activated && 'active' === $button_class ) {
407 return;
408 }
409
410 if ( 'active' === $item['status'] ) {
411 $button_class .= ' disabled';
412 }
413
414 if ( 'special' === $section && 'adslider' === $item['id'] ) {
415 $button_class = Conditional::user_can_subscribe( 'nl_free_addons' ) ? 'subscribe' : 'subscribed';
416 }
417
418 $grid_data = ! empty( $item['grid'] ) ? $this->get_grid_data( $item['id'] ) : false;
419 $button_target = 'available' === $section ? '_blank' : '_self';
420
421 ?>
422 <div class="single-item">
423 <div class="item-details <?php echo esc_attr( $item['status'] ); ?>">
424 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-' . $item['id'] . '.svg' ); ?>" alt=""/></div>
425 <span></span>
426 <div class="name"><?php echo esc_html( $item['title'] ); ?></div>
427 <span></span>
428 <div class="description"><?php echo esc_html( $item['description'] ); ?></div>
429 <span></span>
430 <div class="cta">
431 <a href="<?php echo esc_url( $this->get_button_target( $item['id'], $section ) ); ?>"
432 <?php if ( 'subscribe' === $button_class ) : ?>
433 data-nonce="<?php echo esc_attr( wp_create_nonce( 'advads-newsletter-subscribe' ) ); ?>"
434 <?php endif; ?>
435 class="<?php echo esc_attr( "button $button_class" ); ?>" target="<?php echo esc_attr( $button_target ); ?>">
436 <i class="dashicons"></i>
437 <?php
438 switch ( $button_class ) {
439 case 'subscribe':
440 esc_html_e( 'Subscribe now', 'advanced-ads' );
441 break;
442 case 'subscribed':
443 esc_html_e( 'Download', 'advanced-ads' );
444 break;
445 case 'missing':
446 echo 'adsenseinfeed' === $item['id'] ? esc_html__( 'Install now', 'advanced-ads' ) : esc_html__( 'Upgrade', 'advanced-ads' );
447 break;
448 case 'installed':
449 esc_html_e( 'Activate now', 'advanced-ads' );
450 break;
451 default: // active disabled.
452 esc_html_e( 'Active', 'advanced-ads' );
453 }
454 ?>
455 </a>
456 <?php if ( in_array( $section, [ 'installed', 'special' ], true ) ) : ?>
457 <div class="external-link">
458 <a href="<?php echo esc_url( $item['manual'] ); ?>" target="_blank">
459 <i class="dashicons dashicons-welcome-learn-more"></i>
460 <span><?php esc_html_e( 'See the manual', 'advanced-ads' ); ?></span>
461 </a>
462 </div>
463 <?php elseif ( 'available' === $section ) : ?>
464 <div class="external-link">
465 <a href="<?php echo esc_url( $item['download_link'] ); ?>" target="_blank">
466 <span><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></span>
467 </a>
468 </div>
469 <?php endif; ?>
470 </div>
471 </div>
472 <?php if ( $grid_data ) : ?>
473 <div class="item-grid">
474 <?php foreach ( $grid_data as $elem ) : ?>
475 <div class="feature">
476 <i class="dashicons"></i>
477 <span><?php echo esc_html( $elem ); ?></span>
478 </div>
479 <?php endforeach; ?>
480 <div class="feature more">
481 <i class="dashicons"></i>
482 <span><?php esc_html_e( 'many more features', 'advanced-ads' ); ?></span>
483 </div>
484 </div>
485 <?php endif; ?>
486 </div>
487 <?php
488 }
489
490 /**
491 * Get the href attribute of a call-to-action link
492 *
493 * @param string $id internal plugin ID.
494 * @param string $section section slug.
495 *
496 * @return mixed|string
497 */
498 private function get_button_target( $id, $section = 'installed' ) {
499 if ( 'available' === $section ) {
500 $link = $this->plugins['plugins'][ $id ]['download_link'];
501 if ( 'tracking' !== $id ) {
502 $link = 'https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons';
503 }
504
505 return $link;
506 }
507
508 if ( 'special' === $section && 'adslider' === $id ) {
509 return 'https://wpadvancedads.com/subscriber-resources/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual';
510 }
511
512 if ( 'installed' === $section ) {
513 if ( 'installed' === $this->plugins['plugins'][ $id ]['status'] ) {
514 if ( version_compare( '6.5.0', get_bloginfo( 'version' ), '<=' ) ) {
515 return '#activate-aaplugin_' . wp_create_nonce( 'updates' ) . '_' . $this->plugins['plugins'][ $id ]['file'] . '_' . $this->plugins['plugins'][ $id ]['name'];
516 }
517
518 return wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $this->plugins['plugins'][ $id ]['file'] . '&amp', 'activate-plugin_' . $this->plugins['plugins'][ $id ]['file'] );
519 }
520
521 return 'https://wpadvancedads.com/account/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons';
522 }
523
524 if ( 'special' === $section && 'adsenseinfeed' === $id && 'missing' === $this->plugins['plugins'][ $id ]['status'] ) {
525 return wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=advanced-ads-adsense-in-feed' ), 'install-plugin_advanced-ads-adsense-in-feed' );
526 }
527
528 return '#';
529 }
530
531 /**
532 * Print All Access Long Term output
533 *
534 * @return void
535 */
536 private function all_access_long_term() {
537 ?>
538 <div class="single-item">
539 <div class="item-details">
540 <div class="icon">
541 <img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-allaccesslt.svg' ); ?>" alt=""/>
542 </div>
543 <span></span>
544 <div class="name">
545 <?php esc_html_e( 'Advanced Ads All Access long-term', 'advanced-ads' ); ?>
546 </div>
547 <span></span>
548 <div class="description">
549 <?php esc_html_e( 'Secure 4 years of ongoing support and updates with just one payment. Enjoy savings of up to 70% compared to individual add-on purchases.', 'advanced-ads' ); ?>
550 </div>
551 <span></span>
552 <div class="cta">
553 <div>
554 <a href="https://wpadvancedads.com/add-ons/all-access-long-term/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" class="button upsell" target="_blank">
555 <i class="dashicons"></i>
556 <?php esc_html_e( 'Upgrade', 'advanced-ads' ); ?>
557 </a>
558 </div>
559 <div class="external-link">
560 <a href="https://wpadvancedads.com/add-ons/all-access-long-term/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons"><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></a>
561 </div>
562 </div>
563 </div>
564 </div>
565 <?php
566 }
567
568 /**
569 * Print All Access output
570 *
571 * @param bool $is_upsell whether it's an upsell or an installed (assumed) bundle.
572 *
573 * @return void
574 */
575 private function all_access( $is_upsell = false ) {
576 $all_access_items = [
577 'pro',
578 'tracking',
579 'stickyads',
580 'popuplayer',
581 'ampads',
582 'gam',
583 'sellingads',
584 ];
585
586 ?>
587 <div class="bundle">
588 <div class="bundle-details">
589 <div class="icon">
590 <img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-allaccess.svg' ); ?>" alt=""/>
591 </div>
592 <span></span>
593 <div class="name">
594 <?php esc_html_e( 'Advanced Ads All Access', 'advanced-ads' ); ?>
595 </div>
596 <span></span>
597 <div class="description">
598 <?php esc_html_e( 'Every tool you need for website success in one package. Enjoy our complete suite of add-ons for limitless possibilities.', 'advanced-ads' ); ?>
599 </div>
600 <span></span>
601 <div class="cta">
602 <?php if ( $is_upsell ) : ?>
603 <div>
604 <a href="https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" class="button upsell" target="_blank">
605 <i class="dashicons"></i><?php esc_html_e( 'Upgrade', 'advanced-ads' ); ?>
606 </a>
607 </div>
608 <div class="external-link">
609 <a href="https://wpadvancedads.com/add-ons/all-access/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons"><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></a>
610 </div>
611 <?php endif; ?>
612 </div>
613 </div>
614 <div class="bundle-items">
615 <?php
616 foreach ( $all_access_items as $item ) {
617 $this->do_bundle_item( $item, $is_upsell );
618 }
619 ?>
620 </div>
621 </div>
622 <?php
623 }
624
625 /**
626 * Print output of a bundle's item
627 *
628 * @param string $id internal plugin ID.
629 * @param bool $is_upsell whether it's for an upsell. False if a bundle is assumed existing.
630 *
631 * @return void
632 */
633 private function do_bundle_item( $id, $is_upsell = false ) {
634 $button_class = $this->plugins['plugins'][ $id ]['status'];
635
636 if ( 'active' === $this->plugins['plugins'][ $id ]['status'] ) {
637 $button_class .= ' disabled';
638 }
639
640 if ( $is_upsell ) {
641 $button_class = 'disabled';
642 }
643
644 $plugin = $this->plugins['plugins'][ $id ];
645
646 ?>
647 <div class="bundle-item">
648 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-' . $id . '.svg' ); ?>" alt=""/></div>
649 <span></span>
650 <div class="name"><?php echo esc_html( $plugin['title'] ); ?></div>
651 <span></span>
652 <div class="description">
653 <?php echo esc_html( $plugin['description'] ); ?>
654 <a href="<?php echo esc_url( $plugin['download_link'] ); ?>" target="_blank"><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></a>
655 </div>
656 <span></span>
657 <div class="cta">
658 <div>
659 <a href="<?php echo $is_upsell ? '#' : esc_url( $this->get_button_target( $id ) ); ?>"
660 class="<?php echo esc_attr( "button $button_class" ); ?>"
661 target="<?php echo 'installed' === $plugin['status'] ? '_self' : '_blank'; ?>">
662 <?php if ( ! $is_upsell ) : ?>
663 <i class="dashicons"></i>
664 <?php endif; ?>
665 <?php
666 if ( $is_upsell ) {
667 esc_html_e( 'Included', 'advanced-ads' );
668 } elseif ( 'active' === $plugin['status'] ) {
669 esc_html_e( 'Active', 'advanced-ads' );
670 } elseif ( 'installed' === $plugin['status'] ) {
671 esc_html_e( 'Activate now', 'advanced-ads' );
672 } else {
673 esc_html_e( 'Download', 'advanced-ads' );
674 }
675 ?>
676 </a>
677 </div>
678 </div>
679 </div>
680 <div class="separator"></div>
681 <?php
682 }
683
684 /**
685 * Displays the add-on box content
686 *
687 * @param bool $is_dashboard whether it's displayed on the dashboard screen.
688 *
689 * @return void
690 */
691 public function display( $is_dashboard = true ) {
692 ?>
693 <div id="advanced-ads-addon-box">
694 <span class="subheader"><?php esc_html_e( 'Installed Add-ons', 'advanced-ads' ); ?></span>
695 <?php foreach ( $this->get_displayable_items( 'installed' ) as $item ) : ?>
696 <?php $this->do_single_item( $item, 'installed' ); ?>
697 <?php endforeach; ?>
698 <span class="subheader"><?php esc_html_e( 'Available Add-ons', 'advanced-ads' ); ?></span>
699 <?php foreach ( $this->get_displayable_items( 'available' ) as $item ) : ?>
700 <?php $this->do_single_item( $item, 'available' ); ?>
701 <?php endforeach; ?>
702 <span class="subheader"><?php esc_html_e( 'Free Add-ons & Special Purpose', 'advanced-ads' ); ?></span>
703 <?php foreach ( $this->get_displayable_items( 'special' ) as $item ) : ?>
704 <?php $this->do_single_item( $item, 'special' ); ?>
705 <?php endforeach; ?>
706 <?php
707 $add_ons = apply_filters( 'advanced-ads-overview-add-ons', [] );
708 uasort( $add_ons, [ $this, 'sort_by_order' ] );
709 ?>
710 <?php foreach ( $add_ons as $add_on ) : ?>
711 <?php
712 if ( ! $is_dashboard && empty( $add_on['outside_dashboard'] ) ) {
713 continue;
714 }
715 ?>
716 <div class="single-item add-on <?php echo ! empty( $add_on['class'] ) ? esc_attr( $add_on['class'] ) : ''; ?>">
717 <div class="item-details">
718 <div class="icon">
719 <img src="<?php echo esc_url( ! empty( $add_on['icon'] ) ? $add_on['icon'] : ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-empty.svg' ); ?>" alt=""/>
720 </div>
721 <span></span>
722 <div class="name"><?php echo esc_html( $add_on['title'] ); ?></div>
723 <span></span>
724 <div class="description"><?php echo esc_html( $add_on['desc'] ); ?></div>
725 <span></span>
726 <div class="cta <?php echo ! empty( $add_on['link'] ) && ! empty( $add_on['link_primary'] ) && $add_on['link_primary'] ? 'primary' : 'secondary'; ?>">
727 <?php if ( ! empty( $add_on['link'] ) ) : ?>
728 <a href="<?php echo esc_url( $add_on['link'] ); ?>" class="button">
729 <?php if ( ! empty( $add_on['link_icon'] ) ) : ?>
730 <i class="dashicons <?php echo esc_attr( $add_on['link_icon'] ); ?>"></i>
731 <?php endif; ?>
732 <?php echo ! empty( $add_on['link_title'] ) ? esc_html( $add_on['link_title'] ) : esc_html__( 'Get this add-on', 'advanced-ads' ); ?>
733 </a>
734 <?php endif; ?>
735 </div>
736 </div>
737 </div>
738 <?php endforeach; ?>
739 </div>
740 <footer>
741 <a href="https://wpadvancedads.com/manual/how-to-install-an-add-on/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-install-add-ons" target="_blank">
742 <?php esc_html_e( 'How to download, install, and activate an add-on', 'advanced-ads' ); ?>
743 <span class="screen-reader-text"> (opens in a new tab)</span>
744 <span aria-hidden="true" class="dashicons dashicons-external"></span>
745 </a>
746 </footer>
747 <?php
748 }
749 }
750