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