options();
$display_fine = true;
$wp_admin_bar->add_node( array(
'id' => 'advanced_ads_ad_health',
'title' => __( 'Ad Health', 'advanced-ads' ),
) );
// check if jQuery is loaded in the header
// Hidden, will be shown using js.
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_jquery',
'title' => __( 'jQuery not in header', 'advanced-ads' ),
'href' => ADVADS_URL . 'manual/common-issues#frontend-issues-javascript',
'meta' => array(
'class' => 'hidden advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
// check if AdSense loads QuickStart ads
// Hidden, will be shown using js.
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_quickstart_displayed',
'title' => __( 'Random AdSense ads', 'advanced-ads' ),
'href' => ADVADS_URL . 'adsense-in-random-positions/#utm_source=advanced-ads&utm_medium=link&utm_campaign=frontend-quickstart-ads',
'meta' => array(
'class' => 'hidden advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
// check if an ad blocker is enabled
// Hidden, will be shown using js.
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_adblocker_enabled',
'title' => __( 'Ad blocker enabled', 'advanced-ads' ),
// 'href' => 'https://wpadvancedads.com/support',
'meta' => array(
'class' => 'hidden advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
if ( $wp_the_query->is_singular() ) {
if ( ! $this->did_the_content ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_the_content_not_invoked',
'title' => sprintf( __( '%s filter does not exist', 'advanced-ads' ), 'the_content' ),
'href' => 'https://wpadvancedads.com/manual/ads-not-showing-up/#frontend-issues-the-content-filter',
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
if ( ! empty( $post->ID ) ) {
$ad_settings = get_post_meta( $post->ID, '_advads_ad_settings', true );
if ( ! empty( $ad_settings['disable_ads'] ) ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_disabled_on_page',
'title' => __( 'Ads are disabled on this page', 'advanced-ads' ),
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
if ( ! empty( $ad_settings['disable_the_content'] ) ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_disabled_in_content',
'title' => __( 'Ads are disabled in the content of this page', 'advanced-ads' ),
'href' => get_edit_post_link( $post->ID ) . '#advads-ad-settings',
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
} else {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_post_zero',
'title' => __( 'the current post ID is 0 ', 'advanced-ads' ),
'href' => 'https://wpadvancedads.com/manual/known-plugin-conflicts/#frontend-issue-post-id-empty',
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
}
if ( $wp_the_query->is_404() && ! empty( $options['disabled-ads']['404'] ) ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_no_404',
'title' => __( 'Ads are disabled on 404 pages', 'advanced-ads' ),
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
if ( ! $wp_the_query->is_singular() && ! empty( $options['disabled-ads']['archives'] ) ){
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_no_archive',
'title' => __( 'Ads are disabled on non singular pages', 'advanced-ads' ),
'href' => admin_url( 'admin.php?page=advanced-ads-settings' ),
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
if ( ! extension_loaded( 'dom' ) ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_no_dom_document',
'title' => sprintf( __( 'The %s extension(s) is not loaded', 'advanced-ads' ), 'dom' ),
'href' => 'http://php.net/manual/en/book.dom.php',
'meta' => array(
'class' => 'advanced_ads_ad_health_warning',
'target' => '_blank'
)
) );
$display_fine = false;
}
$display_fine = apply_filters( 'advanced-ads-ad-health-display-fine', $display_fine );
if ( $display_fine ) {
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_fine',
'title' => __( 'Everything is fine', 'advanced-ads' ),
'href' => false,
'meta' => array(
'target' => '_blank',
)
) );
}
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_debug_dfp',
'title' => __( 'debug DFP ads', 'advanced-ads' ),
'href' => esc_url( add_query_arg( 'googfc', '' ) ),
'meta' => array(
'class' => 'hidden advanced_ads_ad_health_debug_dfp_link',
'target' => '_blank',
)
) );
$wp_admin_bar->add_node( array(
'parent' => 'advanced_ads_ad_health',
'id' => 'advanced_ads_ad_health_highlight_ads',
'title' => sprintf( '', __( 'highlight ads', 'advanced-ads' ) )
) );
}
/**
* Set variable to 'true' when 'the_content' filter is invoked.
*
* @param string $content
* @return string $content
*/
public function set_did_the_content( $content ) {
if ( ! $this->did_the_content ) {
$this->did_the_content = true;
}
return $content;
}
/**
* Check conditions and display warning.
* Conditions:
* AdBlocker enabled,
* jQuery is included in header
* AdSense Quick Start ads are running
*/
public function footer_checks() { ?>
type === 'plain' && preg_match( '/gpt\.js/', $content ) ) {
ob_start(); ?>