PluginProbe ʕ •ᴥ•ʔ
Advanced Ads – Ad Manager & AdSense / 2.0.21
Advanced Ads – Ad Manager & AdSense v2.0.21
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-upgrades.php
advanced-ads / includes / admin Last commit date
ads 3 months ago groups 3 months ago metaboxes 1 year ago pages 3 months ago placements 2 months ago class-action-links.php 1 year ago class-addon-box.php 1 year ago class-addon-updater.php 3 months ago class-admin-menu.php 3 months ago class-admin-notices.php 1 year ago class-ajax.php 3 months ago class-assets.php 3 months ago class-authors.php 1 year ago class-compatibility.php 1 year ago class-edd-updater.php 3 months ago class-list-filters.php 2 months 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 year 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 3 months 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-upgrades.php
203 lines
1 <?php
2 /**
3 * The class is responsible for holding promoting upgrade related functionality.
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 2.0.0
8 */
9
10 namespace AdvancedAds\Admin;
11
12 defined( 'ABSPATH' ) || exit;
13
14 use AdvancedAds\Constants;
15 use AdvancedAds\Abstracts\Ad;
16 use AdvancedAds\Utilities\Conditional;
17 use AdvancedAds\Framework\Interfaces\Integration_Interface;
18
19 /**
20 * Class upgrades
21 */
22 class Upgrades implements Integration_Interface {
23
24 /**
25 * Hook into WordPress.
26 *
27 * @return void
28 */
29 public function hooks(): void {
30 // Show notice in Ad Parameters when someone uses an Ad Manager ad in the plain text code field.
31 add_filter( 'advanced-ads-ad-notices', [ $this, 'ad_notices' ], 10, 3 );
32
33 // Show AMP options on ad edit page of AdSense ads.
34 add_action( 'advanced-ads-gadsense-extra-ad-param', [ $this, 'adsense_type_amp_options' ] );
35
36 // Add Duplicate.
37 add_filter( 'post_row_actions', [ $this, 'render_duplicate_link' ], 10, 2 );
38 add_filter( 'post_row_actions', [ $this, 'render_placement_duplicate_link' ], 10, 2 );
39 add_action( 'post_submitbox_start', [ $this, 'render_duplicate_link_in_submit_box' ] );
40 }
41
42 /**
43 * Show an upgrade link
44 *
45 * @param string $title link text.
46 * @param string $url target URL.
47 * @param string $utm_campaign utm_campaign value to attach to the URL.
48 *
49 * @return void
50 */
51 public static function upgrade_link( $title = '', $url = '', $utm_campaign = 'upgrade' ): void {
52 $title = ! empty( $title ) ? $title : __( 'Upgrade', 'advanced-ads' );
53 $url = ! empty( $url ) ? $url : 'https://wpadvancedads.com/add-ons/';
54
55 $url = add_query_arg(
56 [
57 'utm_source' => 'advanced-ads',
58 'utm_medium' => 'link',
59 'utm_campaign' => $utm_campaign,
60 ],
61 $url
62 );
63
64 include ADVADS_ABSPATH . 'admin/views/upgrades/upgrade-link.php';
65 }
66
67 /**
68 * Show an Advanced Ads Pro upsell pitch
69 *
70 * @param string $utm_campaign utm_campaign value to attach to the URL.
71 *
72 * @return void
73 */
74 public static function pro_feature_link( $utm_campaign = '' ): void {
75 self::upgrade_link(
76 __( 'Pro Feature', 'advanced-ads' ),
77 'https://wpadvancedads.com/advanced-ads-pro/',
78 $utm_campaign
79 );
80 }
81
82 /**
83 * Show notices in the Ad Parameters meta box
84 *
85 * @param array $notices Notices.
86 * @param array $box current meta box.
87 * @param Ad $ad post object.
88 *
89 * @return array
90 */
91 public function ad_notices( $notices, $box, $ad ) {
92 // Show notice when someone uses an Ad Manager ad in the plain text code field.
93 if ( ! defined( 'AAGAM_VERSION' ) && 'ad-parameters-box' === $box['id'] ) {
94 if ( $ad->is_type( 'plain' ) && strpos( $ad->get_content(), 'div-gpt-ad-' ) ) {
95 $notices[] = [
96 'text' => sprintf(
97 /* translators: %1$s and %2$s are opening and closing <a> tags */
98 esc_html__( 'This looks like a Google Ad Manager ad. Use the %1$sGAM Integration%2$s.', 'advanced-ads' ),
99 '<a href="https://wpadvancedads.com/add-ons/google-ad-manager/?utm_source=advanced-ads&utm_medium=link&utm_campaign=upgrade-ad-parameters-gam" target="_blank">',
100 '</a>'
101 ) . ' ' . __( 'A quick and error-free way of implementing ad units from your Google Ad Manager account.', 'advanced-ads' ),
102 ];
103 }
104 }
105
106 return $notices;
107 }
108
109 /**
110 * AMP options for AdSense ads in the Ad Parameters on the ad edit page.
111 */
112 public function adsense_type_amp_options() {
113 if ( ! defined( 'AAR_VERSION' ) && \Advanced_Ads_Checks::active_amp_plugin() ) {
114 include_once ADVADS_ABSPATH . 'admin/views/upgrades/adsense-amp.php';
115 }
116 }
117
118 /**
119 * Add the link to action list for post_row_actions
120 *
121 * @param array $actions list of existing actions.
122 * @param WP_Post $post Post object.
123 *
124 * @return array with actions.
125 */
126 public function render_duplicate_link( $actions, $post ) {
127 if (
128 ! defined( 'AAP_VERSION' )
129 && Constants::POST_TYPE_AD === $post->post_type
130 && Conditional::user_can( 'advanced_ads_edit_ads' )
131 ) {
132 $actions['copy-ad'] = $this->create_duplicate_link();
133 }
134
135 return $actions;
136 }
137
138 /**
139 * Add the link to action list for placements.
140 *
141 * @param array $actions list of existing actions.
142 * @param WP_Post $post Post object.
143 *
144 * @return array with actions.
145 */
146 public function render_placement_duplicate_link( $actions, $post ) {
147 if (
148 ! defined( 'AAP_VERSION' )
149 && Constants::POST_TYPE_PLACEMENT === $post->post_type
150 && Conditional::user_can( 'advanced_ads_edit_ads' )
151 ) {
152 $actions['copy-ad'] = $this->create_duplicate_link( Constants::POST_TYPE_PLACEMENT );
153 }
154
155 return $actions;
156 }
157
158 /**
159 * Add the link to the submit box on the ad edit screen.
160 */
161 public function render_duplicate_link_in_submit_box() {
162 global $post;
163 if (
164 ! defined( 'AAP_VERSION' )
165 && 'edit' === $post->filter // only for already saved ads.
166 && Constants::POST_TYPE_AD === $post->post_type
167 && Conditional::user_can( 'advanced_ads_edit_ads' )
168 ) {
169 ?>
170 <div>
171 <?php echo wp_kses_post( $this->create_duplicate_link() ); ?>
172 </div>
173 <?php
174 }
175 }
176
177 /**
178 * Generate text and upgrade link for the Duplicate function
179 *
180 * @param string $post_type post type.
181 */
182 public function create_duplicate_link( $post_type = Constants::POST_TYPE_AD ) {
183 ob_start();
184
185 $utm_campaign = ( Constants::POST_TYPE_PLACEMENT === $post_type ) ? 'duplicate-placement' : 'duplicate-ad';
186
187 self::upgrade_link(
188 null,
189 sprintf(
190 'https://wpadvancedads.com/advanced-ads-pro/?utm_source=advanced-ads&utm_medium=link&utm_campaign=%s',
191 $utm_campaign
192 ),
193 $utm_campaign
194 );
195
196 return sprintf(
197 '%1$s (%2$s)',
198 esc_html__( 'Duplicate', 'advanced-ads' ),
199 trim( ob_get_clean() )
200 );
201 }
202 }
203