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 |