PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.25
Advanced Ads – Ad Manager & AdSense v2.0.25
2.0.25 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 1 day ago placements 1 day ago class-action-links.php 1 week ago class-addon-box.php 1 day ago class-addon-updater.php 1 day ago class-admin-menu.php 1 day ago class-admin-notices.php 1 year ago class-ajax.php 1 day ago class-app.php 1 day ago class-assets.php 1 day ago class-authors.php 1 year ago class-edd-updater.php 1 day ago class-license-admin-post.php 1 day 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 day ago class-plugin-auto-update.php 1 day ago class-plugin-installer.php 1 day 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 day 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
752 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\Addons;
13 use AdvancedAds\Utilities\Conditional;
14 use AdvancedAds\Framework\Utilities\Arr;
15
16 defined( 'ABSPATH' ) || exit;
17
18 /**
19 * Admin Addon Box.
20 */
21 class Addon_Box {
22 /**
23 * Hide active plugins
24 *
25 * @var bool
26 */
27 private $hide_activated;
28
29 /**
30 * Internal plugins data
31 *
32 * @var array
33 */
34 public $plugins;
35
36 /**
37 * Constructor
38 *
39 * @param bool $hide_activated whether to hide active plugins.
40 * @param bool $rest_request its rest request or not.
41 */
42 public function __construct( $hide_activated = false, $rest_request = false ) {
43 if ( ! is_admin() && ! $rest_request ) {
44 return;
45 }
46 $this->hide_activated = (bool) $hide_activated;
47 $this->build_plugins_data();
48 }
49
50 /**
51 * Build the internal plugin data
52 *
53 * @return void
54 */
55 private function build_plugins_data() {
56 // phpcs:disable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned,WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow
57 $aa_plugins = [
58 'advanced-ads-pro/advanced-ads-pro.php' => [
59 'id' => 'pro',
60 'constant' => 'AAP_VERSION',
61 'title' => 'Advanced Ads Pro',
62 'description' => __( 'Take the monetization of your website to the next level.', 'advanced-ads' ),
63 'download_link' => 'https://wpadvancedads.com/add-ons/advanced-ads-pro/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
64 'manual' => 'https://wpadvancedads.com/manual/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
65 ],
66 'advanced-ads-responsive/responsive-ads.php' => [
67 'id' => 'ampads',
68 'constant' => 'AAR_VERSION',
69 'title' => 'AMP Ads',
70 'description' => __( 'Integrate your ads on AMP (Accelerated Mobile Pages) and auto-convert your Google AdSense ad units for enhanced mobile performance.', 'advanced-ads' ),
71 'download_link' => 'https://wpadvancedads.com/add-ons/responsive-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
72 'manual' => 'https://wpadvancedads.com/manual/ads-on-amp-pages/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
73 ],
74 'advanced-ads-gam/advanced-ads-gam.php' => [
75 'id' => 'gam',
76 'constant' => 'AAGAM_VERSION',
77 'title' => 'Google Ad Manager Integration',
78 'description' => __( 'Simplify the process of implementing ad units from Google Ad Manager swiftly and without errors.', 'advanced-ads' ),
79 'download_link' => 'https://wpadvancedads.com/add-ons/google-ad-manager/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
80 'manual' => 'https://wpadvancedads.com/manual/google-ad-manager-integration-manual/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
81 ],
82 'advanced-ads-layer/layer-ads.php' => [
83 'id' => 'popuplayer',
84 'constant' => 'AAPLDS_VERSION',
85 'title' => 'PopUp and Layer Ads',
86 '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' ),
87 'download_link' => 'https://wpadvancedads.com/add-ons/popup-and-layer-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
88 'manual' => 'https://wpadvancedads.com/manual/popup-and-layer-ads-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
89 ],
90 'advanced-ads-selling/advanced-ads-selling.php' => [
91 'id' => 'sellingads',
92 'constant' => 'AASA_VERSION',
93 'title' => 'Selling Ads',
94 'description' => __( 'Earn more money by enabling advertisers to buy ad space directly on your site’s frontend.', 'advanced-ads' ),
95 'download_link' => 'https://wpadvancedads.com/add-ons/selling-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
96 'manual' => 'https://wpadvancedads.com/manual/selling-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
97 ],
98 'advanced-ads-sticky-ads/sticky-ads.php' => [
99 'id' => 'stickyads',
100 'constant' => 'AASADS_SLUG',
101 'title' => 'Sticky Ads',
102 'description' => __( 'Increase click rates by anchoring ads in sticky positions above, alongside, or below your website.', 'advanced-ads' ),
103 'download_link' => 'https://wpadvancedads.com/add-ons/sticky-ads/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
104 'manual' => 'https://wpadvancedads.com/manual/sticky-ads-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
105 ],
106 'advanced-ads-tracking/tracking.php' => [
107 'id' => 'tracking',
108 'constant' => 'AAT_VERSION',
109 'title' => 'Tracking',
110 'description' => __( 'Monitor your ad performance to maximize your revenue.', 'advanced-ads' ),
111 'download_link' => 'https://wpadvancedads.com/add-ons/tracking/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
112 'manual' => 'https://wpadvancedads.com/manual/tracking-documentation/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
113 ],
114 'advanced-ads-slider/slider.php' => [
115 'id' => 'adslider',
116 'constant' => 'AAS_VERSION',
117 'title' => 'Ad Slider',
118 'description' => __( 'Create a beautiful ad slider and increase the ad impressions per page view. Free add-on for subscribers to our newsletter.', 'advanced-ads' ),
119 'download_link' => 'https://wpadvancedads.com/add-ons/slider/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons',
120 'manual' => 'https://wpadvancedads.com/manual/ad-slider/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual',
121 ],
122 'advanced-ads-adsense-in-feed/advanced-ads-in-feed.php' => [
123 'id' => 'adsenseinfeed',
124 'constant' => 'AAINF_VERSION',
125 'title' => 'AdSense In-Feed',
126 'description' => __( 'Place AdSense In-feed ads between posts on homepage, category, and archive pages for optimal engagement.', 'advanced-ads' ),
127 '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' ),
128 'manual' => 'https://wpadvancedads.com/add-adsense-in-feed-to-wordpress/#Adding_the_In-feed_ad_to_your_WordPress_site',
129 ],
130 ];
131 // phpcs:enable WordPress.Arrays.MultipleStatementAlignment.DoubleArrowNotAligned,WordPress.Arrays.MultipleStatementAlignment.LongIndexSpaceBeforeDoubleArrow
132
133 $plugins = Addons::get_plugins();
134 $this->plugins = [
135 'plugins' => [],
136 'premium_level' => 'free',
137 ];
138
139 $pro = false;
140 $tracking = false;
141 $bundle_indicators = [
142 'ampads',
143 'stickyads',
144 'gam',
145 'sellingads',
146 'popuplayer',
147 ];
148
149 foreach ( $aa_plugins as $file => $data ) {
150 if ( array_key_exists( $file, $plugins ) ) {
151 $this->plugins['plugins'][ $data['id'] ] = [ 'status' => defined( $data['constant'] ) ? 'active' : 'installed' ];
152 if ( in_array( $data['id'], $bundle_indicators, true ) ) {
153 $this->plugins['premium_level'] = 'bundle';
154 }
155 if ( in_array( $data['id'], [ 'pro', 'tracking' ], true ) ) {
156 ${$data['id']} = true;
157 }
158 } else {
159 $this->plugins['plugins'][ $data['id'] ] = [ 'status' => 'missing' ];
160 }
161 $this->plugins['plugins'][ $data['id'] ]['file'] = $file;
162 if ( isset( $plugins[ $file ] ) ) {
163 $this->plugins['plugins'][ $data['id'] ]['name'] = $plugins[ $file ]['Name'];
164 }
165 $this->plugins['plugins'][ $data['id'] ] += $data;
166 }
167
168 if ( 'bundle' === $this->plugins['premium_level'] ) {
169 return;
170 }
171
172 if ( $pro || $tracking ) {
173 $this->plugins['premium_level'] = 'premium';
174 }
175
176 if ( $pro && $tracking ) {
177 $this->plugins['premium_level'] = 'bundle';
178 }
179 }
180
181 /**
182 * Get feature grid data for an addon
183 *
184 * @param string $id add-on internal ID.
185 *
186 * @return array
187 */
188 private function get_grid_data( $id ) {
189 if ( 'pro' === $id ) {
190 return [
191 __( 'Cache Busting', 'advanced-ads' ),
192 __( 'Click Fraud Protection', 'advanced-ads' ),
193 __( 'Lazy Loading', 'advanced-ads' ),
194 __( 'Anti Ad Blocker', 'advanced-ads' ),
195 __( 'Geo Targeting', 'advanced-ads' ),
196 __( '+23 Conditions', 'advanced-ads' ),
197 __( '+11 Placements', 'advanced-ads' ),
198 __( 'Parallax Ads', 'advanced-ads' ),
199 __( 'Ad Grids', 'advanced-ads' ),
200 __( 'Ad Refresh', 'advanced-ads' ),
201 __( 'A/B Tests', 'advanced-ads' ),
202 ];
203 }
204
205 if ( 'tracking' === $id ) {
206 return [
207 __( 'Impressions & Clicks', 'advanced-ads' ),
208 __( 'Click-Through Rate', 'advanced-ads' ),
209 __( 'Statistics', 'advanced-ads' ),
210 __( 'Google Analytics', 'advanced-ads' ),
211 __( 'Local Data Processing', 'advanced-ads' ),
212 __( 'Email Reports', 'advanced-ads' ),
213 __( 'Link Cloaking', 'advanced-ads' ),
214 ];
215 }
216
217 return [];
218 }
219
220 /**
221 * Sort plugins by status (missing|installed|enabled)
222 *
223 * @param array $a plugin data.
224 * @param array $b plugin data.
225 *
226 * @return int
227 */
228 private function sort_by_status( $a, $b ) {
229 static $order;
230 if ( null === $order ) {
231 $order = [
232 'missing' => 0,
233 'installed' => 1,
234 'active' => 2,
235 ];
236 }
237
238 return $order[ $a['status'] ] < $order[ $b['status'] ] ? 1 : -1;
239 }
240
241 /**
242 * Sort extra add-ons by the order field
243 *
244 * @param int $a order to compare.
245 * @param int $b order to compare.
246 *
247 * @return mixed
248 */
249 private function sort_by_order( $a, $b ) {
250 return (int) $a['order'] - (int) $b['order'];
251 }
252
253 /**
254 * Get plugin list to display into a given section
255 *
256 * @param string $section section slug (installed|available|special).
257 *
258 * @return array[]
259 */
260 private function get_displayable_items( $section ) {
261 switch ( $section ) {
262 case 'special':
263 $items = [];
264 if ( 'missing' === $this->plugins['plugins']['adslider']['status'] ) {
265 $items['adslider'] = $this->plugins['plugins']['adslider'];
266 }
267 if ( 'missing' === $this->plugins['plugins']['adsenseinfeed']['status'] ) {
268 $items['adsenseinfeed'] = $this->plugins['plugins']['adsenseinfeed'];
269 }
270
271 return $items;
272 case 'available':
273 if ( 'free' === $this->plugins['premium_level'] ) {
274 return [
275 'aa' => [
276 'id' => 'aa',
277 'upsell' => true,
278 ],
279 'aalt' => [ 'id' => 'aalt' ],
280 'pro' => array_merge( $this->plugins['plugins']['pro'], [ 'grid' => true ] ),
281 'tracking' => array_merge( $this->plugins['plugins']['tracking'], [ 'grid' => true ] ),
282 ];
283 }
284
285 if ( 'premium' === $this->plugins['premium_level'] ) {
286 $items = [
287 'aa' => [
288 'id' => 'aa',
289 'upsell' => true,
290 ],
291 'aalt' => [ 'id' => 'aalt' ],
292 ];
293
294 if ( 'missing' === $this->plugins['plugins']['pro']['status'] ) {
295 $items['pro'] = $this->plugins['plugins']['pro'];
296 $items['pro']['grid'] = true;
297 }
298
299 if ( 'missing' === $this->plugins['plugins']['tracking']['status'] ) {
300 $items['tracking'] = $this->plugins['plugins']['tracking'];
301 $items['tracking']['grid'] = true;
302 }
303
304 return $items;
305 }
306
307 if ( 'bundle' === $this->plugins['premium_level'] ) {
308 return [ 'aalt' => [ 'id' => 'aalt' ] ];
309 }
310
311 return [];
312 default: // Installed add-ons.
313 if ( 'free' === $this->plugins['premium_level'] && 'missing' === $this->plugins['plugins']['adslider']['status'] && 'missing' === $this->plugins['plugins']['adsenseinfeed']['status'] ) {
314 return [
315 'none' =>
316 [
317 'id' => 'none',
318 ],
319 ];
320 }
321
322 if ( 'bundle' === $this->plugins['premium_level'] ) {
323 $items = [
324 'aa' => [ 'id' => 'aa' ],
325 ]
326 + Arr::where(
327 $this->get_special_add_ons(),
328 function ( $item ) {
329 return in_array( $item['status'], [ 'installed', 'active' ], true );
330 }
331 );
332
333 return $items;
334 }
335
336 $displayable_items = Arr::where(
337 $this->plugins['plugins'],
338 function ( $item ) {
339 return 'missing' !== $item['status'];
340 }
341 );
342
343 usort( $displayable_items, [ $this, 'sort_by_status' ] );
344
345 return $displayable_items;
346 }
347 }
348
349 /**
350 * Get list of plugins of the "special" section
351 *
352 * @return array
353 */
354 private function get_special_add_ons() {
355 return Arr::where(
356 $this->plugins['plugins'],
357 function ( $item ) {
358 return in_array( $item['id'], [ 'adslider', 'adsenseinfeed' ], true );
359 }
360 );
361 }
362
363 /**
364 * Print output for a single add-on (not in bundle)
365 *
366 * @param array $item plugin data.
367 * @param string $section section slug.
368 *
369 * @return void
370 */
371 private function do_single_item( $item, $section ) {
372 if ( 'aa' === $item['id'] ) {
373 $this->all_access( $item['upsell'] ?? false );
374
375 return;
376 }
377
378 if ( 'aalt' === $item['id'] ) {
379 $this->all_access_long_term();
380
381 return;
382 }
383
384 if ( 'none' === $item['id'] ) {
385 ?>
386 <div class="single-item none">
387 <div class="item-details">
388 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-empty.svg' ); ?>" alt=""/></div>
389 <span></span>
390 <div class="name"><?php esc_html_e( 'No add-ons installed', 'advanced-ads' ); ?></div>
391 <span></span>
392 <div class="description">
393 <?php esc_html_e( 'Please select from the list below.', 'advanced-ads' ); ?>
394 <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">
395 <?php esc_html_e( 'Learn how to download, install, and activate an add-on', 'advanced-ads' ); ?>
396 </a>
397 </div>
398 <span></span>
399 <div class="cta"></div>
400 </div>
401 </div>
402 <?php
403 return;
404 }
405
406 $button_class = $item['status'];
407
408 if ( $this->hide_activated && 'active' === $button_class ) {
409 return;
410 }
411
412 if ( 'active' === $item['status'] ) {
413 $button_class .= ' disabled';
414 }
415
416 if ( 'special' === $section && 'adslider' === $item['id'] ) {
417 $button_class = Conditional::user_can_subscribe( 'nl_free_addons' ) ? 'subscribe' : 'subscribed';
418 }
419
420 $grid_data = ! empty( $item['grid'] ) ? $this->get_grid_data( $item['id'] ) : false;
421 $button_target = 'available' === $section ? '_blank' : '_self';
422
423 ?>
424 <div class="single-item">
425 <div class="item-details <?php echo esc_attr( $item['status'] ); ?>">
426 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-' . $item['id'] . '.svg' ); ?>" alt=""/></div>
427 <span></span>
428 <div class="name"><?php echo esc_html( $item['title'] ); ?></div>
429 <span></span>
430 <div class="description"><?php echo esc_html( $item['description'] ); ?></div>
431 <span></span>
432 <div class="cta">
433 <a href="<?php echo esc_url( $this->get_button_target( $item['id'], $section ) ); ?>"
434 <?php if ( 'subscribe' === $button_class ) : ?>
435 data-nonce="<?php echo esc_attr( wp_create_nonce( 'advads-newsletter-subscribe' ) ); ?>"
436 <?php endif; ?>
437 class="<?php echo esc_attr( "button $button_class" ); ?>" target="<?php echo esc_attr( $button_target ); ?>">
438 <i class="dashicons"></i>
439 <?php
440 switch ( $button_class ) {
441 case 'subscribe':
442 esc_html_e( 'Subscribe now', 'advanced-ads' );
443 break;
444 case 'subscribed':
445 esc_html_e( 'Download', 'advanced-ads' );
446 break;
447 case 'missing':
448 echo 'adsenseinfeed' === $item['id'] ? esc_html__( 'Install now', 'advanced-ads' ) : esc_html__( 'Upgrade', 'advanced-ads' );
449 break;
450 case 'installed':
451 esc_html_e( 'Activate now', 'advanced-ads' );
452 break;
453 default: // active disabled.
454 esc_html_e( 'Active', 'advanced-ads' );
455 }
456 ?>
457 </a>
458 <?php if ( in_array( $section, [ 'installed', 'special' ], true ) ) : ?>
459 <div class="external-link">
460 <a href="<?php echo esc_url( $item['manual'] ); ?>" target="_blank">
461 <i class="dashicons dashicons-welcome-learn-more"></i>
462 <span><?php esc_html_e( 'See the manual', 'advanced-ads' ); ?></span>
463 </a>
464 </div>
465 <?php elseif ( 'available' === $section ) : ?>
466 <div class="external-link">
467 <a href="<?php echo esc_url( $item['download_link'] ); ?>" target="_blank">
468 <span><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></span>
469 </a>
470 </div>
471 <?php endif; ?>
472 </div>
473 </div>
474 <?php if ( $grid_data ) : ?>
475 <div class="item-grid">
476 <?php foreach ( $grid_data as $elem ) : ?>
477 <div class="feature">
478 <i class="dashicons"></i>
479 <span><?php echo esc_html( $elem ); ?></span>
480 </div>
481 <?php endforeach; ?>
482 <div class="feature more">
483 <i class="dashicons"></i>
484 <span><?php esc_html_e( 'many more features', 'advanced-ads' ); ?></span>
485 </div>
486 </div>
487 <?php endif; ?>
488 </div>
489 <?php
490 }
491
492 /**
493 * Get the href attribute of a call-to-action link
494 *
495 * @param string $id internal plugin ID.
496 * @param string $section section slug.
497 *
498 * @return mixed|string
499 */
500 private function get_button_target( $id, $section = 'installed' ) {
501 if ( 'available' === $section ) {
502 $link = $this->plugins['plugins'][ $id ]['download_link'];
503 if ( 'tracking' !== $id ) {
504 $link = 'https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons';
505 }
506
507 return $link;
508 }
509
510 if ( 'special' === $section && 'adslider' === $id ) {
511 return 'https://wpadvancedads.com/subscriber-resources/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons-manual';
512 }
513
514 if ( 'installed' === $section ) {
515 if ( 'installed' === $this->plugins['plugins'][ $id ]['status'] ) {
516 if ( version_compare( '6.5.0', get_bloginfo( 'version' ), '<=' ) ) {
517 return '#activate-aaplugin_' . wp_create_nonce( 'updates' ) . '_' . $this->plugins['plugins'][ $id ]['file'] . '_' . $this->plugins['plugins'][ $id ]['name'];
518 }
519
520 return wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $this->plugins['plugins'][ $id ]['file'] . '&amp', 'activate-plugin_' . $this->plugins['plugins'][ $id ]['file'] );
521 }
522
523 return 'https://wpadvancedads.com/account/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons';
524 }
525
526 if ( 'special' === $section && 'adsenseinfeed' === $id && 'missing' === $this->plugins['plugins'][ $id ]['status'] ) {
527 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' );
528 }
529
530 return '#';
531 }
532
533 /**
534 * Print All Access Long Term output
535 *
536 * @return void
537 */
538 private function all_access_long_term() {
539 ?>
540 <div class="single-item">
541 <div class="item-details">
542 <div class="icon">
543 <img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-allaccesslt.svg' ); ?>" alt=""/>
544 </div>
545 <span></span>
546 <div class="name">
547 <?php esc_html_e( 'Advanced Ads All Access long-term', 'advanced-ads' ); ?>
548 </div>
549 <span></span>
550 <div class="description">
551 <?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' ); ?>
552 </div>
553 <span></span>
554 <div class="cta">
555 <div>
556 <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">
557 <i class="dashicons"></i>
558 <?php esc_html_e( 'Upgrade', 'advanced-ads' ); ?>
559 </a>
560 </div>
561 <div class="external-link">
562 <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>
563 </div>
564 </div>
565 </div>
566 </div>
567 <?php
568 }
569
570 /**
571 * Print All Access output
572 *
573 * @param bool $is_upsell whether it's an upsell or an installed (assumed) bundle.
574 *
575 * @return void
576 */
577 private function all_access( $is_upsell = false ) {
578 $all_access_items = [
579 'pro',
580 'tracking',
581 'stickyads',
582 'popuplayer',
583 'ampads',
584 'gam',
585 'sellingads',
586 ];
587
588 ?>
589 <div class="bundle">
590 <div class="bundle-details">
591 <div class="icon">
592 <img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-allaccess.svg' ); ?>" alt=""/>
593 </div>
594 <span></span>
595 <div class="name">
596 <?php esc_html_e( 'Advanced Ads All Access', 'advanced-ads' ); ?>
597 </div>
598 <span></span>
599 <div class="description">
600 <?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' ); ?>
601 </div>
602 <span></span>
603 <div class="cta">
604 <?php if ( $is_upsell ) : ?>
605 <div>
606 <a href="https://wpadvancedads.com/pricing/?utm_source=advanced-ads&utm_medium=link&utm_campaign=overview-add-ons" class="button upsell" target="_blank">
607 <i class="dashicons"></i><?php esc_html_e( 'Upgrade', 'advanced-ads' ); ?>
608 </a>
609 </div>
610 <div class="external-link">
611 <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>
612 </div>
613 <?php endif; ?>
614 </div>
615 </div>
616 <div class="bundle-items">
617 <?php
618 foreach ( $all_access_items as $item ) {
619 $this->do_bundle_item( $item, $is_upsell );
620 }
621 ?>
622 </div>
623 </div>
624 <?php
625 }
626
627 /**
628 * Print output of a bundle's item
629 *
630 * @param string $id internal plugin ID.
631 * @param bool $is_upsell whether it's for an upsell. False if a bundle is assumed existing.
632 *
633 * @return void
634 */
635 private function do_bundle_item( $id, $is_upsell = false ) {
636 $button_class = $this->plugins['plugins'][ $id ]['status'];
637
638 if ( 'active' === $this->plugins['plugins'][ $id ]['status'] ) {
639 $button_class .= ' disabled';
640 }
641
642 if ( $is_upsell ) {
643 $button_class = 'disabled';
644 }
645
646 $plugin = $this->plugins['plugins'][ $id ];
647
648 ?>
649 <div class="bundle-item">
650 <div class="icon"><img src="<?php echo esc_url( ADVADS_BASE_URL . 'assets/img/add-ons/aa-addons-icons-' . $id . '.svg' ); ?>" alt=""/></div>
651 <span></span>
652 <div class="name"><?php echo esc_html( $plugin['title'] ); ?></div>
653 <span></span>
654 <div class="description">
655 <?php echo esc_html( $plugin['description'] ); ?>
656 <a href="<?php echo esc_url( $plugin['download_link'] ); ?>" target="_blank"><?php esc_html_e( 'Learn more', 'advanced-ads' ); ?></a>
657 </div>
658 <span></span>
659 <div class="cta">
660 <div>
661 <a href="<?php echo $is_upsell ? '#' : esc_url( $this->get_button_target( $id ) ); ?>"
662 class="<?php echo esc_attr( "button $button_class" ); ?>"
663 target="<?php echo 'installed' === $plugin['status'] ? '_self' : '_blank'; ?>">
664 <?php if ( ! $is_upsell ) : ?>
665 <i class="dashicons"></i>
666 <?php endif; ?>
667 <?php
668 if ( $is_upsell ) {
669 esc_html_e( 'Included', 'advanced-ads' );
670 } elseif ( 'active' === $plugin['status'] ) {
671 esc_html_e( 'Active', 'advanced-ads' );
672 } elseif ( 'installed' === $plugin['status'] ) {
673 esc_html_e( 'Activate now', 'advanced-ads' );
674 } else {
675 esc_html_e( 'Download', 'advanced-ads' );
676 }
677 ?>
678 </a>
679 </div>
680 </div>
681 </div>
682 <div class="separator"></div>
683 <?php
684 }
685
686 /**
687 * Displays the add-on box content
688 *
689 * @param bool $is_dashboard whether it's displayed on the dashboard screen.
690 *
691 * @return void
692 */
693 public function display( $is_dashboard = true ) {
694 ?>
695 <div id="advanced-ads-addon-box">
696 <span class="subheader"><?php esc_html_e( 'Installed Add-ons', 'advanced-ads' ); ?></span>
697 <?php foreach ( $this->get_displayable_items( 'installed' ) as $item ) : ?>
698 <?php $this->do_single_item( $item, 'installed' ); ?>
699 <?php endforeach; ?>
700 <span class="subheader"><?php esc_html_e( 'Available Add-ons', 'advanced-ads' ); ?></span>
701 <?php foreach ( $this->get_displayable_items( 'available' ) as $item ) : ?>
702 <?php $this->do_single_item( $item, 'available' ); ?>
703 <?php endforeach; ?>
704 <span class="subheader"><?php esc_html_e( 'Free Add-ons & Special Purpose', 'advanced-ads' ); ?></span>
705 <?php foreach ( $this->get_displayable_items( 'special' ) as $item ) : ?>
706 <?php $this->do_single_item( $item, 'special' ); ?>
707 <?php endforeach; ?>
708 <?php
709 $add_ons = apply_filters( 'advanced-ads-overview-add-ons', [] );
710 uasort( $add_ons, [ $this, 'sort_by_order' ] );
711 ?>
712 <?php foreach ( $add_ons as $add_on ) : ?>
713 <?php
714 if ( ! $is_dashboard && empty( $add_on['outside_dashboard'] ) ) {
715 continue;
716 }
717 ?>
718 <div class="single-item add-on <?php echo ! empty( $add_on['class'] ) ? esc_attr( $add_on['class'] ) : ''; ?>">
719 <div class="item-details">
720 <div class="icon">
721 <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=""/>
722 </div>
723 <span></span>
724 <div class="name"><?php echo esc_html( $add_on['title'] ); ?></div>
725 <span></span>
726 <div class="description"><?php echo esc_html( $add_on['desc'] ); ?></div>
727 <span></span>
728 <div class="cta <?php echo ! empty( $add_on['link'] ) && ! empty( $add_on['link_primary'] ) && $add_on['link_primary'] ? 'primary' : 'secondary'; ?>">
729 <?php if ( ! empty( $add_on['link'] ) ) : ?>
730 <a href="<?php echo esc_url( $add_on['link'] ); ?>" class="button">
731 <?php if ( ! empty( $add_on['link_icon'] ) ) : ?>
732 <i class="dashicons <?php echo esc_attr( $add_on['link_icon'] ); ?>"></i>
733 <?php endif; ?>
734 <?php echo ! empty( $add_on['link_title'] ) ? esc_html( $add_on['link_title'] ) : esc_html__( 'Get this add-on', 'advanced-ads' ); ?>
735 </a>
736 <?php endif; ?>
737 </div>
738 </div>
739 </div>
740 <?php endforeach; ?>
741 </div>
742 <footer>
743 <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">
744 <?php esc_html_e( 'How to download, install, and activate an add-on', 'advanced-ads' ); ?>
745 <span class="screen-reader-text"> (opens in a new tab)</span>
746 <span aria-hidden="true" class="dashicons dashicons-external"></span>
747 </a>
748 </footer>
749 <?php
750 }
751 }
752