get_options(); if ( isset( $options['pro']['general']['disable-by-post-types'] ) && is_array( $options['pro']['general']['disable-by-post-types'] ) ) { $pro['general']['disable-by-post-types'] = $options['pro']['general']['disable-by-post-types']; } else { $pro['general']['disable-by-post-types'] = array(); } Advanced_Ads_Pro::get_instance()->update_options( $pro ); return $options; } /** * Render content of module enable option */ public function render_modules_enable() { } /** * Render additional pro settings * * @since 1.1 */ public function render_other_settings() { // Save options when the user is on the "Pro" tab. $selected = $this->get_disable_by_post_type_options(); foreach ( $selected as $item ) { ?> get_options(); $autoptimize_support_disabled = isset( $options['autoptimize-support-disabled'] ) ? $options['autoptimize-support-disabled'] : false; require AAP_BASE_PATH . '/views/setting_autoptimize.php'; } /** * Render settings to disable ads by post types. */ public function render_settings_disable_post_types() { $selected = $this->get_disable_by_post_type_options(); $post_types = get_post_types( array( 'public' => true, 'publicly_queryable' => true, ), 'objects', 'or' ); $type_label_counts = array_count_values( wp_list_pluck( $post_types, 'label' ) ); require AAP_BASE_PATH . '/views/setting_disable_post_types.php'; } /** * Get "Disabled by post type" Pro options. */ private function get_disable_by_post_type_options() { $options = Advanced_Ads_Pro::get_instance()->get_options(); if ( isset( $options['general']['disable-by-post-types'] ) && is_array( $options['general']['disable-by-post-types'] ) ) { $selected = $options['general']['disable-by-post-types']; } else { $selected = array(); } return $selected; } /** * Register license */ public function render_settings_license_callback() { $licenses = get_option( ADVADS_SLUG . '-licenses', array() ); $license_key = isset( $licenses['pro'] ) ? $licenses['pro'] : ''; $license_status = get_option( Advanced_Ads_Pro::OPTION_KEY . '-license-status', false ); // Get license status for old key. if ( ! $license_status ) { $old_license_status = get_option( Advanced_Ads_Pro::OPTION_KEY . '-modules-license-status', false ); if ( $old_license_status ) { update_option( Advanced_Ads_Pro::OPTION_KEY . '-license-status', $old_license_status ); delete_option( Advanced_Ads_Pro::OPTION_KEY . '-modules-license-status', $old_license_status ); } } $index = 'pro'; $plugin_name = AAP_PLUGIN_NAME; $options_slug = Advanced_Ads_Pro::OPTION_KEY; $plugin_url = self::PLUGIN_LINK; // Template in main plugin. include ADVADS_BASE_PATH . 'admin/views/setting-license.php'; } /** * Add tracking settings tab * * @since 1.2.0 * @param array $tabs existing setting tabs. * @return array $tabs setting tabs with AdSense tab attached. */ public function setting_tabs( array $tabs ) { $tabs['pro'] = array( // TODO abstract string. 'page' => Advanced_Ads_Pro::OPTION_KEY . '-settings', 'group' => Advanced_Ads_Pro::OPTION_KEY, 'tabid' => 'pro', 'title' => 'Pro', ); return $tabs; } /** * Form field for user role selection * * @param array $user user data. */ public function add_user_role_fields( $user ) { if ( ! current_user_can( 'edit_users' ) ) { return; } $roles = array( 'advanced_ads_admin' => __( 'Ad Admin', 'advanced-ads-pro' ), 'advanced_ads_manager' => __( 'Ad Manager', 'advanced-ads-pro' ), 'advanced_ads_user' => __( 'Ad User', 'advanced-ads-pro' ), '' => __( '--no role--', 'advanced-ads-pro' ), ); $role = get_user_meta( $user->ID, self::ROLE_FIELD_NAME, true ); ?>

remove_role( $prev_role ); // Save new role as user meta. update_user_meta( $user_id, self::ROLE_FIELD_NAME, $_POST[ self::ROLE_FIELD_NAME ] ); if ( $_POST[ self::ROLE_FIELD_NAME ] ) { // Add role. $user->add_role( $_POST[ self::ROLE_FIELD_NAME ] ); } } // phpcs:enable } /** * Show a notice if advanced visitor conditions are disabled. Maybe some users are looking for it * * @param Advanced_Ads_Ad $ad Advanced_Ads_Ad object. */ public function show_condition_notice( $ad ) { $options = Advanced_Ads_Pro::get_instance()->get_options(); if ( ! isset( $options['advanced-visitor-conditions']['enabled'] ) ) { echo '

' . sprintf( wp_kses( // Translators: %s is a URL. __( 'Enable the Advanced Visitor Conditions in the settings.', 'advanced-ads-pro' ), array( 'a' => array( 'href' => array(), 'target' => array(), ), ) ), esc_url( admin_url( 'admin.php?page=advanced-ads-settings#top#pro' ) ) ) . '

'; } } /** * Add output options to ad edit page * * @param Advanced_Ads_Ad $ad Advanced_Ads_Ad ad object. */ public function render_ad_output_options( Advanced_Ads_Ad $ad ) { $output_options = $ad->options( 'output' ); $once_per_page = ! empty( $output_options['once_per_page'] ) ? 1 : 0; require AAP_BASE_PATH . '/views/setting_output_once.php'; // Get CodeMirror setting for Custom code textarea. $settings = $this->get_code_editor_settings(); $custom_code = ! empty( $output_options['custom-code'] ) ? esc_textarea( $output_options['custom-code'] ) : ''; require AAP_BASE_PATH . '/views/setting_custom_code.php'; } /** * Render repeat option for Content placement. * * @param string $_placement_slug id of the placement. * @param array $_placement placement options. */ public function render_placement_repeat_option( $_placement_slug, $_placement ) { $words_between_repeats = ! empty( $_placement['options']['words_between_repeats'] ) ? absint( $_placement['options']['words_between_repeats'] ) : 0; require AAP_BASE_PATH . '/views/setting_repeat.php'; } /** * Get CodeMirror settings. */ public function get_code_editor_settings() { global $wp_version; if ( 'advanced_ads' !== get_current_screen()->id || defined( 'ADVANCED_ADS_DISABLE_CODE_HIGHLIGHTING' ) || -1 === version_compare( $wp_version, '4.9' ) ) { return false; } // Enqueue code editor and settings for manipulating HTML. $settings = wp_enqueue_code_editor( array( 'type' => 'text/html' ) ); if ( ! $settings ) { $settings = false; } return $settings; } /** * Register and enqueue admin-specific style sheet. */ public function enqueue_admin_styles() { wp_enqueue_style( AAP_SLUG . '-admin-styles', AAP_BASE_URL . 'assets/admin.css', array(), AAP_VERSION ); } /** * Show a note about a deprecated feature and link to the appropriate page in our manual * * @param string $feature simple string to indicate the deprecated feature. Will be added to the UTM campaign attribute. */ public static function show_deprecated_notice( $feature = '' ) { $url = esc_url( ADVADS_URL ) . 'manual/deprecated-features/'; if ( '' !== $feature ) { $url .= '#utm_source=advanced-ads&utm_medium=link&utm_campaign=deprecated-' . sanitize_title_for_query( $feature ); } echo ''; printf( // Translators: %1$s is the opening link tag, %2$s is closing link tag. esc_html__( 'This feature is deprecated. Please find the removal schedule %1$shere%2$s', 'advanced-ads-pro' ), '', '' ); echo ''; } /** * Only show privacy warning if cache-busting module not enabled. * * @param bool $show Whether to show warning. * * @return bool */ public function show_custom_privacy_warning( $show ) { if ( ! $show ) { return $show; } $options = Advanced_Ads_Pro::get_instance()->get_options(); return ! isset( $options['cache-busting']['enabled'] ); } /** * Update Link in Privacy settings ot settings page instead of external plugin page. * * @return array */ public function privacy_link_attributes() { return array( 'href' => esc_url( admin_url( 'admin.php?page=advanced-ads-settings#top#pro' ) ), ); } /** * Show the ignore-consent checkbox if this ad has custom code and type is image or dummy. * The filter is called `advanced-ads-ad-privacy-hide-ignore-consent`, so the return needs to be !$hide to show. * * @param bool $hide Whether to show ignore-consent checkbox. * @param Advanced_Ads_Ad $ad The ad object * * @return bool */ public function hide_ignore_consent_checkbox( $hide, Advanced_Ads_Ad $ad ) { if ( ! $hide || ! in_array( $ad->type, array( 'image', 'dummy' ), true ) ) { return $hide; } return empty( Advanced_Ads_Pro::get_instance()->get_custom_code( $ad ) ); } /** * Show a warning below the form of Advanced Ads widgets if cache-busting is enabled * but the widget does not use a placement or "Force passive cache-busting" is enabled * * Uses the in_widget_form action hook * * @param WP_Widget $widget The widget instance (passed by reference). * @param null $return Return null if new fields are added. * @param array $instance An array of the widget's settings. */ public function show_no_placement_in_widget_warning( $widget, $return, $instance ) { // bail if this is not the Advanced Ads widget if ( ! is_a( $widget, 'Advanced_Ads_Widget' ) ) { return; } // bail if cache-busting is not enabled or if Force passive cache-busting is enabled $options = Advanced_Ads_Pro::get_instance()->get_options(); if ( empty( $options['cache-busting']['enabled'] ) || isset( $options['cache-busting']['passive_all'] ) ) { return; } // check item ID and show warning if it is given but does not contain a placement if ( ! empty( $instance['item_id'] ) && 0 !== strpos( $instance['item_id'], 'placement_' ) ) { ?>

Privacy > Policy Guide * which customers can use as a basic templace. */ public function add_privacy_policy_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } ob_start(); include AAP_BASE_PATH . 'views/privacy-policy-content.php'; wp_add_privacy_policy_content( AAP_PLUGIN_NAME, wp_kses_post( wpautop( ob_get_clean(), false ) ) ); } }