' . esc_html__( 'Is aeoora helping your site show up in AI answers?', 'aeoora' ) . ' ' . esc_html__( 'A quick review on WordPress.org helps other site owners find it, and keeps aeoora free.', 'aeoora' ) . '
' . esc_html__( 'A physical robots.txt file exists in your site root, so WordPress cannot apply your aeoora crawler rules. Open AI crawlers → robots.txt to sync them into the file.', 'aeoora' ) . '
aeoora — ' . esc_html(
sprintf(
/* translators: 1: table names, 2: database error message. */
__( 'The database tables could not be created (%1$s), so crawler visits are not being recorded. Ask your host to allow the database user to create tables; aeoora tries again every ten minutes while you use the admin. Database said: %2$s', 'aeoora' ),
implode( ', ', (array) $error['tables'] ),
isset( $error['error'] ) && '' !== $error['error'] ? (string) $error['error'] : '—'
)
) . '
';
}
if ( $ours && ! get_option( 'aeoora_cache_notice_dismissed' ) ) {
$caches = Aeoora_Compat::page_caches();
if ( $caches ) {
self::cache_notice( $caches );
self::dismiss_script();
}
}
}
/**
* Page cache notice with copy-ready rules that let crawlers through the
* cache (so their visits are logged and blocks apply).
*
* @param string[] $caches Detected caches.
*/
private static function cache_notice( array $caches ) {
$ai = array();
$blocked = array();
foreach ( Aeoora_Bots::all() as $id => $bot ) {
if ( ! empty( $bot['regex'] ) || ! empty( $bot['either'] ) || '' === (string) $bot['pattern'] ) {
continue;
}
if ( 'block' === Aeoora_Bots::policy( $id ) ) {
$blocked[ $bot['pattern'] ] = true;
} elseif ( Aeoora_Bots::is_ai_category( $bot['category'] ) && ! empty( $bot['token'] ) ) {
$ai[ $bot['pattern'] ] = true;
}
}
$all = array_keys( $ai + $blocked );
if ( ! $all ) {
return;
}
$re = implode( '|', array_map( static function ( $p ) {
return str_replace( '"', '', preg_quote( $p, '#' ) );
}, $all ) );
$cf = implode( ' or ', array_map( static function ( $p ) {
return '(http.user_agent contains "' . str_replace( array( '\\', '"' ), '', $p ) . '")';
}, array_slice( $all, 0, 60 ) ) );
$htaccess = "# BEGIN aeoora: AI crawlers bypass the page cache\n\nRewriteEngine On\nRewriteCond %{HTTP_USER_AGENT} \"({$re})\" [NC]\nRewriteRule .* - [E=Cache-Control:no-cache]\n\n# END aeoora: AI crawlers bypass the page cache";
$nginx = "# http {} block\nmap \$http_user_agent \$aeoora_bot {\n\tdefault 0;\n\t\"~*({$re})\" 1;\n}\n\n# server {} or location {} block that uses fastcgi_cache\nfastcgi_cache_bypass \$aeoora_bot;\nfastcgi_no_cache \$aeoora_bot;";
echo '
' . esc_html(
sprintf(
/* translators: %s: page cache names. */
__( 'Page cache detected: %s.', 'aeoora' ),
implode( ', ', $caches )
)
) . ' ' . esc_html__( 'Cached pages are served without running WordPress, so aeoora cannot log crawler visits to them, and crawlers you block still get them. Let AI crawlers through the cache with one of these rules:', 'aeoora' ) . '
' . esc_html__( 'Bypassing the cache for these crawlers makes WordPress answer their requests. The rules list the AI crawlers that respect robots.txt plus the crawlers you block.', 'aeoora' ) . '
';
}
/**
* Tiny dismiss script for notices outside our screens.
*/
private static function dismiss_script() {
static $added = false;
if ( $added ) {
return;
}
$added = true;
$js = "document.addEventListener('click',function(e){if(!e.target.closest){return;}var a=e.target.closest('.aeoora-notice [data-aeoora-action]');var n=a||e.target.closest('.aeoora-notice .notice-dismiss');if(!n){return;}var box=n.closest('.aeoora-notice');var fd=new FormData();fd.append('action','aeoora_dismiss');fd.append('what',a?a.getAttribute('data-aeoora-action'):box.getAttribute('data-aeoora-dismiss'));fd.append('_wpnonce'," . wp_json_encode( wp_create_nonce( 'aeoora_dismiss' ) ) . ");fetch(window.ajaxurl,{method:'POST',body:fd,credentials:'same-origin'});if(a){box.remove();}});";
wp_add_inline_script( 'common', $js );
}
/**
* Time to ask for a review? Seven days after install, never during setup,
* and not again once answered ("later" waits 30 days).
*
* @return bool
*/
private static function ask_review() {
$state = get_option( 'aeoora_review', 0 );
if ( 'done' === $state || ( is_numeric( $state ) && time() < (int) $state ) || 'setup' === self::current() ) {
return false;
}
$installed = (int) get_option( 'aeoora_installed_at', time() );
return time() - $installed > 7 * DAY_IN_SECONDS && (bool) apply_filters( 'aeoora_ask_review', true );
}
/**
* Dismiss handler.
*/
public static function dismiss() {
check_ajax_referer( 'aeoora_dismiss' );
$what = isset( $_POST['what'] ) ? sanitize_key( wp_unslash( $_POST['what'] ) ) : '';
if ( current_user_can( 'manage_options' ) ) {
if ( 'welcome' === $what ) {
delete_option( 'aeoora_show_welcome' );
} elseif ( 'cache' === $what ) {
update_option( 'aeoora_cache_notice_dismissed', 1, false );
} elseif ( 'review_done' === $what ) {
update_option( 'aeoora_review', 'done', false );
} elseif ( 'review_later' === $what ) {
update_option( 'aeoora_review', time() + 30 * DAY_IN_SECONDS, false );
}
}
wp_send_json_success();
}
/**
* Footer text on our screens.
*
* @param string $text Text.
* @return string
*/
public static function footer_text( $text ) {
$screen = get_current_screen();
if ( $screen && in_array( $screen->id, self::$hooks, true ) ) {
/* translators: %s: version. */
return sprintf( esc_html__( 'aeoora %s · Free and open source AEO for WordPress · Built by Codefreex', 'aeoora' ), esc_html( AEOORA_VERSION ) ) . ' · aeoora.com · '
/* translators: %s: link to the review form, with five stars as its text. */
. sprintf( esc_html__( 'Enjoying aeoora? Rate it %s on WordPress.org.', 'aeoora' ), '★★★★★' );
}
return $text;
}
}