data = Advanced_Ads_AdSense_Data::get_instance(); // Adsense does not use the default generated settings section id. overwrite it with the old value. $this->settings_section_id = 'advanced_ads_adsense_setting_section'; } /** * Register settings to Advanced Ads > Settings > AdSense * * @param string $hook settings page hook. * @param string $section_id settings section id. */ protected function register_settings( $hook, $section_id ) { // Add setting field to disable ads. add_settings_field( 'adsense-id', __( 'AdSense account', 'advanced-ads' ), array( $this, 'render_settings_adsense_id' ), $hook, $section_id ); // Activate AdSense verification code and Auto ads (previously Page-Level ads). add_settings_field( 'adsense-page-level', __( 'Auto ads', 'advanced-ads' ), array( $this, 'render_settings_adsense_page_level' ), $hook, $section_id ); // AdSense anchor ad on top of pages. // Only show this field if selected, otherwise use new auto ads code. if ( isset( $this->data->get_options()['top-anchor-ad'] ) ) { add_settings_field( 'top_anchor_ad', __( 'Auto ads', 'advanced-ads' ) . ': ' . __( 'Disable top anchor ad', 'advanced-ads' ), array( $this, 'render_settings_adsense_top_anchor_ad' ), $hook, $section_id ); } // Hide AdSense stats in the backend. add_settings_field( 'hide_stats', __( 'Disable stats', 'advanced-ads' ), array( $this, 'render_settings_adsense_hide_stats' ), $hook, $section_id ); // Add setting field for adsense limit. // Deprecated of January, 2019; will be removed one year later. $limit_per_page = $this->data->get_limit_per_page(); if ( $limit_per_page ) { add_settings_field( 'adsense-limit', __( 'Limit to 3 ads', 'advanced-ads' ), array( $this, 'render_settings_adsense_limit' ), $hook, $section_id ); }; // Disable AdSense violation warnings. add_settings_field( 'adsense-warnings-disable', __( 'Disable violation warnings', 'advanced-ads' ), array( $this, 'render_settings_adsense_warnings_disable' ), $hook, $section_id ); add_settings_field( 'adsense-background', __( 'Transparent background', 'advanced-ads' ), array( $this, 'render_settings_adsense_background' ), $hook, $section_id ); add_settings_field( 'adsense-full-width', __( 'Full width responsive ads on mobile', 'advanced-ads' ), array( $this, 'render_settings_adsense_fullwidth' ), $hook, 'advanced_ads_adsense_setting_section' ); } /** * Render AdSense settings section */ public function render_settings_section_callback() { // For whatever purpose there might come. } /** * Render AdSense management api setting */ public function render_settings_management_api() { require_once GADSENSE_BASE_PATH . 'admin/views/mapi-settings.php'; } /** * Render AdSense id setting */ public function render_settings_adsense_id() { require_once GADSENSE_BASE_PATH . 'admin/views/adsense-account.php'; } /** * Render AdSense limit setting * * @since 1.5.1 * @deprecated January, 2019 – let’s give users one year until we remove the whole logic completely */ public function render_settings_adsense_limit() { $limit_per_page = $this->data->get_limit_per_page(); ?>
data->get_options(); $anchor_ad = isset( $options['top-anchor-ad'] ) ? $options['top-anchor-ad'] : ''; ?> data->get_options(); $hide_stats = isset( $options['hide-stats'] ); ?> data->get_options(); $page_level = $options['page-level-enabled']; ?>
get_options(); $auto_ads_enabled = ! empty( $adsense_options['amp']['auto_ads_enabled'] ); $option_name = GADSENSE_OPT_NAME . '[amp]'; include GADSENSE_BASE_PATH . 'admin/views/settings/amp-auto-ads.php'; } /** * Render AdSense violation warnings setting * * @since 1.6.9 */ public function render_settings_adsense_warnings_disable() { $options = $this->data->get_options(); $disable_violation_warnings = isset( $options['violation-warnings-disable'] ) ? 1 : 0; ?>
Ad Health feature monitors if AdSense is implemented correctly on your site. It also considers ads not managed with Advanced Ads. Enable this option to remove these checks', 'advanced-ads' ), array( 'a' => array( 'href' => true, 'target' => true, ), ) ), esc_url( ADVADS_URL ) . 'manual/ad-health/#utm_source=advanced-ads&utm_medium=link&utm_campaign=backend-autoads-ads' ); ?>
data->get_options(); $background = $options['background']; ?> data->get_options(); $fw = ! empty( $options['fullwidth-ads'] ) ? $options['fullwidth-ads'] : 'default'; ?>use the full width of your visitor's mobile device screen", 'advanced-ads' ), esc_url( 'https://support.google.com/adsense/answer/7445870' ) ), array( 'a' => array( 'href' => true, 'target' => true, ), ) ); ?>
get_adsense_id() ); $units = array(); $mapi_options = Advanced_Ads_AdSense_MAPI::get_option(); if ( isset( $mapi_options['ad_codes'] ) && isset( $mapi_options['accounts'] ) && isset( $mapi_options['accounts'][ $adsense_id ] ) && isset( $mapi_options['accounts'][ $adsense_id ]['ad_units'] ) ) { $ad_codes = $mapi_options['ad_codes']; foreach ( $mapi_options['accounts'][ $adsense_id ]['ad_units'] as $id => $raw ) { $ad_unit = new Advanced_Ads_Ad_Network_Ad_Unit( $raw ); $ad_unit->id = $id; $ad_unit->slot_id = isset( $raw['code'] ) ? $raw['code'] : '-'; $ad_unit->name = isset( $raw['name'] ) ? $raw['name'] : '-'; // phpcs:ignore $ad_unit->active = isset( $raw['status'] ) && in_array( $raw['status'], self::$status_codes_active ); if ( isset( $ad_codes[ $id ] ) ) { $ad_unit->code = $ad_codes[ $id ]; } if ( isset( $raw['contentAdsSettings'] ) ) { if ( isset( $raw['contentAdsSettings']['type'] ) ) { $ad_unit->display_type = $raw['contentAdsSettings']['type']; $ad_unit->display_type = Advanced_Ads_AdSense_MAPI::format_ad_data( $ad_unit, 'type' ); } if ( isset( $raw['contentAdsSettings']['size'] ) ) { $ad_unit->display_size = $raw['contentAdsSettings']['size']; $ad_unit->display_size = Advanced_Ads_AdSense_MAPI::format_ad_data( $ad_unit, 'size' ); } } $units[] = $ad_unit; } } return $units; } /** * Render the list of ads loaded through the API. * * @param bool $hide_idle_ads true to hide inactive ads. * @param null $ad_unit_id ID of the ad unit. * * @return mixed|void */ public function print_external_ads_list( $hide_idle_ads = true, $ad_unit_id = null ) { Advanced_Ads_AdSense_Admin::get_mapi_ad_selector( $hide_idle_ads ); } /** * Whether the loaded AdSense ad is supported through the API. * at the time we wrote this, native ad formats like In-article, In-feed and Matched Content are not supported. * * @param object $ad_unit ad unit object. * * @return bool */ public function is_supported( $ad_unit ) { $mapi_options = Advanced_Ads_AdSense_MAPI::get_option(); $supported = ! array_key_exists( $ad_unit->id, $mapi_options['unsupported_units'] ); if ( ! $supported ) { $supported = array_key_exists( $ad_unit->id, $mapi_options['ad_codes'] ); } return $supported; } /** * Update the list of external ad units. */ public function update_external_ad_units() { Advanced_Ads_AdSense_MAPI::get_instance()->ajax_get_adUnits(); } /** * If the AdSense account is connected. * * @return bool */ public function is_account_connected() { return Advanced_Ads_AdSense_Data::get_instance()->is_setup(); } /** * Return path to module-specific JavaScript. * * @return string */ public function get_javascript_base_path() { return GADSENSE_BASE_URL . 'admin/assets/js/adsense.js'; } /** * JavaScript data to print in the source code. * * @inheritDoc * * @param array $data data to be printed. * @return array */ public function append_javascript_data( &$data ) { $pub_id = Advanced_Ads_AdSense_Data::get_instance()->get_adsense_id(); $data['pubId'] = $pub_id; $data['connected'] = $this->is_account_connected(); $data['ad_types'] = array( 'matched_content' => _x( 'Matched Content', 'AdSense ad type', 'advanced-ads' ), 'in_article' => _x( 'In-article', 'AdSense ad type', 'advanced-ads' ), 'in_feed' => _x( 'In-feed', 'AdSense ad type', 'advanced-ads' ), 'display' => _x( 'Display', 'AdSense ad type', 'advanced-ads' ), 'link' => _x( 'Link', 'AdSense ad type', 'advanced-ads' ), ); return $data; } /** * If the ad also has a manual ad setup option. * * @return bool */ public function supports_manual_ad_setup() { return true; } }