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-settings.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-settings.php
652 lines
1 <?php
2 /**
3 * Setting class
4 *
5 * @package AdvancedAds
6 * @author Advanced Ads <info@wpadvancedads.com>
7 * @since 1.48.0
8 */
9
10 namespace AdvancedAds\Admin;
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Advanced_Ads;
15 use Advanced_Ads_Utils;
16 use AdvancedAds\Constants;
17 use AdvancedAds\Utilities\Data;
18 use AdvancedAds\Utilities\Sanitize;
19 use AdvancedAds\Utilities\WordPress;
20 use AdvancedAds\Utilities\Conditional;
21 use AdvancedAds\Framework\Interfaces\Integration_Interface;
22
23 /**
24 * Class Settings
25 */
26 class Settings implements Integration_Interface {
27
28 /**
29 * Setting options
30 *
31 * @var array with plugin options
32 */
33 private $options;
34
35 /**
36 * Hook name
37 *
38 * @var string
39 */
40 private $hook;
41
42 /**
43 * Hook into WordPress.
44 *
45 * @return void
46 */
47 public function hooks(): void {
48 add_action( 'admin_init', [ $this, 'settings_init' ] );
49 add_action( 'admin_init', [ $this, 'settings_capabilities' ], 20 );
50 add_filter( 'advanced-ads-setting-tabs', [ $this, 'add_tabs' ], 50 );
51 add_filter( 'advanced-ads-ad-admin-options', [ $this, 'allow_save_settings' ] );
52
53 $this->options = Advanced_Ads::get_instance()->options();
54 }
55
56 /**
57 * Add tabs to the settings page.
58 *
59 * @param array $tabs setting tabs.
60 *
61 * @return array
62 */
63 public function add_tabs( array $tabs ): array {
64 if ( ! defined( 'AAP_VERSION' ) ) {
65 $tabs['pro_pitch'] = [
66 'page' => 'advanced-ads-settings-pro-pitch-page',
67 'tabid' => 'pro-pitch',
68 'title' => __( 'Pro', 'advanced-ads' ),
69 ];
70 }
71
72 if ( ! defined( 'AAT_VERSION' ) ) {
73 $tabs['tracking_pitch'] = [
74 'page' => 'advanced-ads-settings-tracking-pitch-page',
75 'tabid' => 'tracking-pitch',
76 'title' => __( 'Tracking', 'advanced-ads' ),
77 ];
78 }
79
80 return $tabs;
81 }
82
83 /**
84 * Initialize settings
85 *
86 * @since 1.0.1
87 *
88 * @return void
89 */
90 public function settings_init(): void {
91 $this->hook = wp_advads()->screens->get_hook( 'settings' );
92 register_setting( ADVADS_SLUG, ADVADS_SLUG, [ $this, 'sanitize_settings' ] );
93
94 $this->section_management();
95 $this->section_disable_ads();
96 $this->section_layout();
97 $this->section_content_injection();
98 $this->section_pro_pitches();
99
100 // hook for additional settings from add-ons.
101 do_action( 'advanced-ads-settings-init', $this->hook );
102 }
103
104 /**
105 * Make sure ad admin can save options.
106 * Add a filter on `admin_init` priority 20 to allow other modules/add-ons to add their options.
107 * Filter option_page_capability_ with the appropriate slug in return to allow the Ad Admin user role to save these settings/options.
108 */
109 public function settings_capabilities() {
110 $ad_admin_options = [ ADVADS_SLUG ];
111 /**
112 * Filters all options that the Ad Admin Role should have access to.
113 *
114 * @param array $ad_admin_options Array with option names.
115 */
116 $ad_admin_options = apply_filters( 'advanced-ads-ad-admin-options', $ad_admin_options );
117 foreach ( $ad_admin_options as $ad_admin_option ) {
118 add_filter(
119 'option_page_capability_' . $ad_admin_option,
120 function () {
121 return Conditional::user_cap( 'advanced_ads_manage_options' );
122 }
123 );
124 }
125 }
126
127 /**
128 * Allow Ad Admin to save settings.
129 *
130 * @param string[] $options Array with allowed options.
131 *
132 * @return string[]
133 */
134 public function allow_save_settings( $options ) {
135 $options[] = ADVADS_SETTINGS_ADBLOCKER;
136 return $options;
137 }
138
139 /**
140 * Options to disable ads
141 */
142 public function render_settings_disable_ads() {
143 $options = Advanced_Ads::get_instance()->options();
144
145 // set the variables.
146 $disable_all = isset( $options['disabled-ads']['all'] ) ? 1 : 0;
147 $disable_404 = isset( $options['disabled-ads']['404'] ) ? 1 : 0;
148 $disable_archives = isset( $options['disabled-ads']['archives'] ) ? 1 : 0;
149 $disable_secondary = isset( $options['disabled-ads']['secondary'] ) ? 1 : 0;
150 $disable_feed = ( ! isset( $options['disabled-ads']['feed'] ) || $options['disabled-ads']['feed'] ) ? 1 : 0;
151 $disable_rest_api = isset( $options['disabled-ads']['rest-api'] ) ? 1 : 0;
152
153 // load the template.
154 include_once ADVADS_ABSPATH . 'views/admin/settings/general/disable-ads.php';
155 }
156
157 /**
158 * Render setting to hide ads from logged in users
159 */
160 public function render_settings_hide_for_users() {
161 global $wp_roles;
162
163 $hide_for_roles = [];
164 $options = Advanced_Ads::get_instance()->options();
165 $roles = $wp_roles->get_names();
166
167 if ( isset( $options['hide-for-user-role'] ) ) {
168 $hide_for_roles = Advanced_Ads_Utils::maybe_translate_cap_to_role( $options['hide-for-user-role'] );
169 }
170
171 include_once ADVADS_ABSPATH . 'views/admin/settings/general/hide-for-user-role.php';
172 }
173
174 /**
175 * Render setting to hide ads from logged in users
176 */
177 public function render_settings_hide_for_ip_address() {
178 $disable_ip_addr = $this->options['hide-for-ip-address']['enabled'] ?? 0;
179 $ip_address = $this->options['hide-for-ip-address']['ips'] ?? '';
180
181 include_once ADVADS_ABSPATH . 'views/admin/settings/general/hide-for-ip-address.php';
182 }
183
184 /**
185 * Render setting to display advanced js file
186 */
187 public function render_settings_advanced_js() {
188 $options = Advanced_Ads::get_instance()->options();
189 $checked = ( ! empty( $options['advanced-js'] ) ) ? 1 : 0;
190
191 include_once ADVADS_ABSPATH . 'views/admin/settings/general/advanced-js.php';
192 }
193
194 /**
195 * Render setting for content injection protection
196 */
197 public function render_settings_content_injection_everywhere() {
198 $options = Advanced_Ads::get_instance()->options();
199 $enabled = $options['content-injection-enabled'] ?? '';
200 if ( ! isset( $options['content-injection-everywhere'] ) ) {
201 $everywhere = 0;
202 } elseif ( 'true' === $options['content-injection-everywhere'] ) {
203 $everywhere = - 1;
204 } else {
205 $everywhere = absint( $options['content-injection-everywhere'] );
206 }
207 include_once ADVADS_ABSPATH . 'views/admin/settings/general/content-injection-everywhere.php';
208 }
209
210 /**
211 * Render setting for content injection priority
212 */
213 public function render_settings_content_injection_priority() {
214 $options = Advanced_Ads::get_instance()->options();
215 $priority = ( isset( $options['content-injection-priority'] ) ) ? (int) $options['content-injection-priority'] : 100;
216
217 include_once ADVADS_ABSPATH . 'views/admin/settings/general/content-injection-priority.php';
218 }
219
220 /**
221 * Render setting to disable content injection level limitation
222 */
223 public function render_settings_content_injection_level_limitation() {
224 $options = Advanced_Ads::get_instance()->options();
225 $checked = ( ! empty( $options['content-injection-level-disabled'] ) ) ? 1 : 0;
226
227 include_once ADVADS_ABSPATH . 'views/admin/settings/general/content-injection-level-limitation.php';
228 }
229
230 /**
231 * Render setting for blocking bots
232 */
233 public function render_settings_block_bots() {
234 $options = Advanced_Ads::get_instance()->options();
235 $checked = ( ! empty( $options['block-bots'] ) ) ? 1 : 0;
236
237 include_once ADVADS_ABSPATH . 'views/admin/settings/general/block-bots.php';
238 }
239
240 /**
241 * Render setting to disable ads by post types
242 */
243 public function render_settings_disable_post_types() {
244 $post_types = get_post_types(
245 [
246 'public' => true,
247 'publicly_queryable' => true,
248 ],
249 'objects',
250 'or'
251 );
252 $type_label_counts = array_count_values( wp_list_pluck( $post_types, 'label' ) );
253
254 include_once ADVADS_ABSPATH . '/views/admin/settings/general/disable-post-types.php';
255 }
256
257 /**
258 * Render setting to disable notices and Ad Health
259 */
260 public function render_settings_disabled_notices() {
261 $options = Advanced_Ads::get_instance()->options();
262 $checked = ( ! empty( $options['disable-notices'] ) ) ? 1 : 0;
263
264 include_once ADVADS_ABSPATH . '/views/admin/settings/general/disable-notices.php';
265 }
266
267 /**
268 * Render setting for frontend prefix
269 */
270 public function render_settings_front_prefix() {
271 $options = Advanced_Ads::get_instance()->options();
272
273 $prefix = wp_advads()->get_frontend_prefix();
274 $old_prefix = ( isset( $options['id-prefix'] ) ) ? esc_attr( $options['id-prefix'] ) : '';
275
276 include_once ADVADS_ABSPATH . '/views/admin/settings/general/frontend-prefix.php';
277 }
278
279 /**
280 * Render setting to allow editors to manage ads
281 */
282 public function render_settings_editors_manage_ads() {
283 $allow = false;
284 $options = Advanced_Ads::get_instance()->options();
285
286 // is false by default if no options where previously set.
287 if ( isset( $options['editors-manage-ads'] ) && $options['editors-manage-ads'] ) {
288 $allow = true;
289 }
290
291 include_once ADVADS_ABSPATH . '/views/admin/settings/general/editors-manage-ads.php';
292 }
293
294 /**
295 * Prepare the template for multisite allow unfiltered_html settings.
296 *
297 * @return void
298 */
299 public function renders_settings_allow_unfiltered_html() {
300 $options = Advanced_Ads::get_instance()->options();
301 $user_roles_to_display = Data::get_filtered_roles_by_cap();
302
303 if ( empty( $user_roles_to_display ) ) {
304 return;
305 }
306
307 if ( ! isset( $options['allow-unfiltered-html'] ) ) {
308 $options['allow-unfiltered-html'] = [];
309 }
310
311 $allowed_roles = $options['allow-unfiltered-html'];
312
313 include_once ADVADS_ABSPATH . '/views/admin/settings/general/allow-unfiltered-html.php';
314 }
315
316 /**
317 * Render setting to add an "Advertisement" label before ads
318 */
319 public function render_settings_add_custom_label() {
320 $options = Advanced_Ads::get_instance()->options();
321
322 $enabled = isset( $options['custom-label']['enabled'] );
323 $label = ! empty( $options['custom-label']['text'] ) ? esc_html( $options['custom-label']['text'] ) : _x( 'Advertisements', 'label before ads', 'advanced-ads' );
324 $html_enabled = $options['custom-label']['html_enabled'] ?? false;
325
326 include_once ADVADS_ABSPATH . '/views/admin/settings/general/custom-label.php';
327 }
328
329 /**
330 * Render link target="_blank" setting
331 *
332 * @since 1.8.4 – moved here from Tracking add-on
333 */
334 public function render_settings_link_target_callback() {
335
336 // get option if saved for tracking.
337 $options = Advanced_Ads::get_instance()->options();
338 if ( ! isset( $options['target-blank'] ) && function_exists( 'wp_advads_tracking' ) ) {
339 $tracking_target = wp_advads_tracking()->options->get( 'target' );
340 if ( $tracking_target ) {
341 $options['target-blank'] = $tracking_target;
342 }
343 }
344
345 $target = isset( $options['target-blank'] ) ? $options['target-blank'] : 0;
346 include_once ADVADS_ABSPATH . 'views/admin/settings/general/link-target.php';
347 }
348
349 /**
350 * Render setting 'Delete data on uninstall"
351 */
352 public function render_settings_uninstall_delete_data() {
353 $options = Advanced_Ads::get_instance()->options();
354 $enabled = ! empty( $options['uninstall-delete-data'] );
355
356 include_once ADVADS_ABSPATH . 'views/admin/settings/general/uninstall-delete-data.php';
357 }
358
359 /**
360 * Sanitize plugin settings
361 *
362 * @param array $options all the options.
363 *
364 * @return array sanitized options.
365 */
366 public function sanitize_settings( $options ) {
367 if ( isset( $options['front-prefix'] ) ) {
368 $options['front-prefix'] = Sanitize::frontend_prefix(
369 $options['front-prefix'],
370 Constants::DEFAULT_FRONTEND_PREFIX
371 );
372 }
373
374 $options = apply_filters( 'advanced-ads-sanitize-settings', $options );
375
376 // check if editors can edit ads now and set the rights
377 // else, remove that right.
378 $editor_role = get_role( 'editor' );
379 if ( null === $editor_role ) {
380 return $options;
381 }
382
383 $action = isset( $options['editors-manage-ads'] ) && $options['editors-manage-ads']
384 ? 'add_cap' : 'remove_cap';
385
386 $editor_role->$action( 'advanced_ads_see_interface' );
387 $editor_role->$action( 'advanced_ads_edit_ads' );
388 $editor_role->$action( 'advanced_ads_manage_placements' );
389 $editor_role->$action( 'advanced_ads_place_ads' );
390
391 // we need 3 states: ! empty, 1, 0.
392 $options['disabled-ads']['feed'] = ! empty( $options['disabled-ads']['feed'] ) ? 1 : 0;
393
394 if ( isset( $options['content-injection-everywhere'] ) ) {
395 if ( '0' === $options['content-injection-everywhere'] ) {
396 unset( $options['content-injection-everywhere'] );
397 } elseif ( 'true' === $options['content-injection-everywhere'] || $options['content-injection-everywhere'] <= - 1 ) {
398 // Note: the option may be already set 'true' during import.
399 $options['content-injection-everywhere'] = 'true';
400 } else {
401 $options['content-injection-everywhere'] = absint( $options['content-injection-everywhere'] );
402 }
403 }
404
405 return $options;
406 }
407
408 /**
409 * Add management section
410 *
411 * @return void
412 */
413 private function section_management(): void {
414 $section_id = 'advanced_ads_setting_section';
415 add_settings_section(
416 $section_id,
417 __( 'Admin', 'advanced-ads' ),
418 '__return_empty_string',
419 $this->hook
420 );
421
422 add_settings_field(
423 'disable-notices',
424 __( 'Disable Ad Health and other notices', 'advanced-ads' ),
425 [ $this, 'render_settings_disabled_notices' ],
426 $this->hook,
427 $section_id
428 );
429
430 add_settings_field(
431 'editors-manage-ads',
432 __( 'Allow editors to manage ads', 'advanced-ads' ),
433 [ $this, 'render_settings_editors_manage_ads' ],
434 $this->hook,
435 $section_id
436 );
437
438 if (
439 is_multisite()
440 // Allow superadmins to edit the setting when DISALLOW_UNFILTERED_HTML is defined.
441 && ( current_user_can( 'unfiltered_html' ) || is_super_admin() )
442 ) {
443 add_settings_field(
444 'allow-unfiltered-html',
445 /* translators: unfiltered_html */
446 sprintf( __( 'Add the %s capability to user roles on multisite', 'advanced-ads' ), '<code>unfiltered_html</code>' ),
447 [ $this, 'renders_settings_allow_unfiltered_html' ],
448 $this->hook,
449 $section_id
450 );
451 }
452
453 if ( is_main_site() ) {
454 add_settings_field(
455 'uninstall-delete-data',
456 __( 'Delete data on uninstall', 'advanced-ads' ),
457 [ $this, 'render_settings_uninstall_delete_data' ],
458 $this->hook,
459 $section_id
460 );
461 }
462 }
463
464 /**
465 * Disable ads section
466 *
467 * @return void
468 */
469 private function section_disable_ads(): void {
470 $section_id = 'advanced_ads_setting_section_disable_ads';
471 add_settings_section(
472 $section_id,
473 __( 'Disable ads', 'advanced-ads' ),
474 '__return_empty_string',
475 $this->hook
476 );
477
478 add_settings_field(
479 'disable-ads',
480 __( 'Disable ads', 'advanced-ads' ),
481 [ $this, 'render_settings_disable_ads' ],
482 $this->hook,
483 $section_id
484 );
485
486 add_settings_field(
487 'hide-for-user-role',
488 __( 'Hide ads for user roles', 'advanced-ads' ),
489 [ $this, 'render_settings_hide_for_users' ],
490 $this->hook,
491 $section_id
492 );
493
494 add_settings_field(
495 'hide-for-ip-address',
496 __( 'Hide ads for IP addresses', 'advanced-ads' ),
497 [ $this, 'render_settings_hide_for_ip_address' ],
498 $this->hook,
499 $section_id
500 );
501
502 add_settings_field(
503 'block-bots',
504 __( 'Hide ads from bots', 'advanced-ads' ),
505 [ $this, 'render_settings_block_bots' ],
506 $this->hook,
507 $section_id
508 );
509
510 if ( ! defined( 'AAP_VERSION' ) ) {
511 add_settings_field(
512 'disable-by-post-types-pro',
513 __( 'Disable ads for post types', 'advanced-ads' ),
514 [ $this, 'render_settings_disable_post_types' ],
515 $this->hook,
516 $section_id
517 );
518 }
519 }
520
521 /**
522 * Layout section
523 *
524 * @return void
525 */
526 private function section_layout(): void {
527 $section_id = 'advanced_ads_setting_section_output';
528 add_settings_section(
529 $section_id,
530 __( 'Layout / Output', 'advanced-ads' ),
531 '__return_empty_string',
532 $this->hook
533 );
534
535 add_settings_field(
536 'front-prefix',
537 __( 'ID prefix', 'advanced-ads' ),
538 [ $this, 'render_settings_front_prefix' ],
539 $this->hook,
540 $section_id
541 );
542
543 add_settings_field(
544 'add-custom-label',
545 __( 'Ad label', 'advanced-ads' ),
546 [ $this, 'render_settings_add_custom_label' ],
547 $this->hook,
548 $section_id
549 );
550
551 add_settings_field(
552 'link-target',
553 __( 'Open links in a new window', 'advanced-ads' ),
554 [ $this, 'render_settings_link_target_callback' ],
555 $this->hook,
556 $section_id
557 );
558
559 add_settings_field(
560 'activate-advanced-js',
561 __( 'Use advanced JavaScript', 'advanced-ads' ),
562 [ $this, 'render_settings_advanced_js' ],
563 $this->hook,
564 $section_id
565 );
566 }
567
568 /**
569 * Content injection section
570 *
571 * @return void
572 */
573 private function section_content_injection(): void {
574 $section_id = 'advanced_ads_setting_section_injection';
575 add_settings_section(
576 $section_id,
577 __( 'Content injection', 'advanced-ads' ),
578 '__return_empty_string',
579 $this->hook
580 );
581
582 add_settings_field(
583 'content-injection-everywhere',
584 __( 'Content placement in post lists', 'advanced-ads' ),
585 [ $this, 'render_settings_content_injection_everywhere' ],
586 $this->hook,
587 $section_id
588 );
589
590 add_settings_field(
591 'content-injection-priority',
592 __( 'Priority of content injection filter', 'advanced-ads' ),
593 [ $this, 'render_settings_content_injection_priority' ],
594 $this->hook,
595 $section_id
596 );
597
598 add_settings_field(
599 'content-injection-level-limitation',
600 __( 'Disable level limitation', 'advanced-ads' ),
601 [ $this, 'render_settings_content_injection_level_limitation' ],
602 $this->hook,
603 $section_id
604 );
605 }
606
607 /**
608 * Pro pitches section
609 *
610 * @return void
611 */
612 private function section_pro_pitches(): void {
613 // Pro pitch section.
614 if ( ! defined( 'AAP_VERSION' ) ) {
615 add_settings_section(
616 'advanced_ads_settings_pro_pitch_section',
617 '',
618 [ $this, 'render_settings_pro_pitch_section_callback' ],
619 'advanced-ads-settings-pro-pitch-page'
620 );
621 }
622
623 // Tracking pitch section.
624 if ( ! defined( 'AAT_VERSION' ) ) {
625 add_settings_section(
626 'advanced_ads_settings_tracking_pitch_section',
627 '',
628 [ $this, 'render_settings_tracking_pitch_section_callback' ],
629 'advanced-ads-settings-tracking-pitch-page'
630 );
631 }
632 }
633
634 /**
635 * Render pitch for Pro
636 *
637 * @return void
638 */
639 public function render_settings_pro_pitch_section_callback() {
640 echo '<br/>';
641 include ADVADS_ABSPATH . 'views/admin/upgrades/pro-tab.php';
642 }
643
644 /**
645 * Render tracking pitch settings section
646 */
647 public function render_settings_tracking_pitch_section_callback() {
648 echo '<br/>';
649 include ADVADS_ABSPATH . 'views/marketing/ad-metabox-tracking.php';
650 }
651 }
652