';
}
$content = $visible_content . $hidden_content;
/* translators: %1$s: anchor tag with URL, %2$s: close anchor tag */
$content .= '
' . sprintf( esc_html__( 'If you feel any of these notifications were received in error, please ignore or %1$scontact support%2$s.', 'ad-commander' ), '', '' ) . '
';
return $content;
}
/**
* Create an individual notification.
*
* @param string $text The text to display inside a notification.
* @param string $key The key of the notification.
* @param string $title The notification title text.
* @param string $button The button text.
*
* @return string
*/
private function notification( $text, $key, $title = '', $button = '' ) {
$classes = 'adcmdr-notification adcmdr-notice-error';
$icon = 'visibility';
if ( in_array( $key, $this->hidden_notifications ) ) {
$classes .= ' adcmdr-ignored';
$icon = 'hidden';
}
if ( $title ) {
$title = '' . esc_html( $title ) . ' ';
}
return '
' .
wpautop( $title . $text ) .
$button .
'
';
}
/**
* Test if caching is enabled and settings aren't optimized.
*
* @return bool
*/
private function test_caching() {
if ( Util::cache_detected() && Util::render_method() === 'serverside' ) {
return array(
/* translators: %1$s: anchor tag with URL, %2$s: close anchor tag */
'text' => sprintf( esc_html__( 'Your site appears to use page caching and server-side rendering. This can lead to unexpected behavior. %1$sEdit your rendering settings here.%2$s', 'ad-commander' ), '', '' ),
'title' => __( 'Page caching', 'ad-commander' ),
'button' => Doc::doc_link( 'rendering', false, __( 'Learn more', 'ad-commander' ) ),
);
}
return false;
}
/**
* Block bots + caching + server-side rendering = danger
*
* @return bool
*/
private function test_bots() {
if ( Util::render_method() === 'serverside' && ( Options::instance()->get( 'bots_disable_ads', 'general', true ) || Options::instance()->get( 'bots_disable_tracking', 'tracking', true ) ) ) {
return array(
/* translators: %1$s: anchor tag with URL, %2$s: close anchor tag */
'text' => sprintf( esc_html__( 'You are limiting ad display or tracking for bots, while also using server-side rendering. This can potentially cause problems. %1$sEdit your rendering settings here.%2$s', 'ad-commander' ), '', '' ),
'title' => __( 'Bot blocking', 'ad-commander' ),
'button' => Doc::doc_link( 'bots', false, __( 'Learn more', 'ad-commander' ) ),
);
}
return false;
}
/**
* Test if consent is enabled and has server-side rendermethod
*
* @return bool
*/
private function test_consent() {
if ( Consent::instance()->requires_consent() !== false && Util::render_method() === 'serverside' ) {
return array(
/* translators: %1$s: anchor tag with URL, %2$s: close anchor tag */
'text' => sprintf( esc_html__( 'Consent management only partially works with server-side rendering. %1$sEdit your rendering settings here.%2$s', 'ad-commander' ), '', '' ),
'title' => __( 'Consent required', 'ad-commander' ),
'button' => Doc::doc_link( 'requiring_consent', false, __( 'Learn more', 'ad-commander' ) ),
);
}
return false;
}
/**
* Test if generating custom CSS has failed.
*
* @return bool
*/
private function test_custom_css_failure() {
if ( Options::instance()->get( 'custom_css_failure', null, true, false ) ) {
return array(
/* translators: %1$s: opening anchor tag linking to the General settings tab, %2$s: closing anchor tag */
'text' => sprintf( esc_html__( 'Your site failed to generate CSS for your custom prefix. This is likely due to permissions in your hosting environment. Your CSS prefix was reset to the default. %1$sReview your general settings.%2$s', 'ad-commander' ), '', '' ),
'title' => __( 'Custom CSS Prefix', 'ad-commander' ),
);
}
return false;
}
/**
* Test if visitor cookies are disabled while Pro is active.
*
* Pro visitor targeting conditions and click fraud protection depend on the
* visitor cookies; with them disabled those features silently do nothing.
*/
private function test_visitor_cookies() {
if ( ProBridge::instance()->is_pro_loaded() && Visitor::cookies_disabled() ) {
return array(
'title' => __( 'Visitor Cookies Disabled', 'ad-commander' ),
/* translators: %1$s: opening anchor tag linking to the Consent settings tab, %2$s: closing anchor tag */
'text' => sprintf( esc_html__( 'Visitor cookies are disabled in your %1$sConsent settings%2$s. The Pro visitor conditions Site Impressions, New Visitor, Max Ad Impressions, Max Ad Clicks, Referrer URL (Initial), Browser Width, and Browser Language, as well as click fraud protection, will not function while this setting is enabled. If you do not use these features, you can hide this notification.', 'ad-commander' ), '', '' ),
'button' => Doc::doc_link( 'visitor_targeting', false, __( 'Learn more', 'ad-commander' ) ),
);
}
return false;
}
/**
* Test if lazy loading is enabled with incorrect render methods.
*/
private function test_lazy() {
if ( ProBridge::instance()->pro_feature_check( 'lazyload' ) && LazyPro::instance()->is_lazy_load_enabled() && Util::render_method() === 'serverside' ) {
return array(
/* translators: %1$s: opening anchor tag linking to the General settings tab, %2$s: closing anchor tag */
'text' => sprintf( esc_html__( 'You are using lazy loading with server-side rendering. Your ads will not display. %1$sSwitch to client-side or smart rendering%2$s, or disable lazy loading.', 'ad-commander' ), '', '' ),
'title' => __( 'Lazy Loading Rendering Method', 'ad-commander' ),
);
}
return false;
}
/**
* Test if adsense alerts are available to read.
*/
public function test_adsense_alerts() {
if ( Options::instance()->get( 'disable_adsense_account_alerts', 'adsense', true ) ) {
return false;
}
$admin_instance = AdminAdSense::instance();
$accounts = $admin_instance->get_adsense_api_account();
$pub_id = AdSense::instance()->current_adsense_publisher_id();
if ( $pub_id && $accounts && isset( $accounts['accounts'] ) && ! empty( $accounts['accounts'] ) && isset( $accounts['accounts'][ $pub_id ] ) && isset( $accounts['accounts'][ $pub_id ]['alerts'] ) && ! empty( $accounts['accounts'][ $pub_id ]['alerts'] ) ) {
$alerts = array();
if ( ! empty( $accounts['accounts'][ $pub_id ]['alerts']['items'] ) ) {
foreach ( $accounts['accounts'][ $pub_id ]['alerts']['items'] as $alert ) {
$alerts[] = array(
'id' => esc_html( $alert['name'] ),
/* translators: %1$s AdSense publisher ID. */
'title' => sprintf( esc_html__( 'AdSense Account (%1$s)', 'ad-commander' ), $pub_id ) . ' – ' . esc_html( $alert['severity'] ),
'text' => esc_html( $alert['message'] ),
);
}
}
if ( isset( $accounts['accounts'][ $pub_id ]['alerts']['last_refresh'] ) ) {
if ( $admin_instance->should_resync_adsense_alerts( $accounts['accounts'][ $pub_id ]['alerts']['last_refresh'] ) ) {
$admin_instance->update_account_alerts();
}
}
return $alerts;
}
return false;
}
}