__( 'What helps people find you on Google and in AI answers, and what keeps them coming back. Node looks at your site every day, the way a visitor would.', 'nodebook' ) ) ); $pct = $total ? (int) round( $done / $total * 100 ) : 0; echo '
'; $calm = 'calm' === Nodebook_Node::personality(); if ( $todo ) { $line = sprintf( /* translators: 1: checks done, 2: total, 3: next thing to do */ $calm ? __( '%1$s of %2$s done. Next: %3$s.', 'nodebook' ) : __( '%1$s of %2$s done! Next up: %3$s 💪', 'nodebook' ), number_format_i18n( $done ), number_format_i18n( $total ), lcfirst( $todo[0]['title'] ) ); } else { $line = $calm ? __( 'Everything checked is in order.', 'nodebook' ) : __( 'All done. Your site is in great shape 🎉', 'nodebook' ); } if ( ! Nodebook_Admin_Node::says( $line, $todo ? 'calm' : 'happy' ) ) { echo '

' . esc_html( $line ) . '

'; } $tones = array( 'found' => '#0071E3', 'ai' => '#AF52DE', 'content' => '#FF9500', 'sell' => '#34C759', 'reach' => '#FF2D55', 'site' => '#30B0C7', ); echo '
' . esc_html( $pct . '%' ) . '' . esc_html( /* translators: 1: done, 2: total */ sprintf( __( '%1$s of %2$s', 'nodebook' ), number_format_i18n( $done ), number_format_i18n( $total ) ) ) . '
'; echo '

'; if ( empty( $probe['time'] ) ) { esc_html_e( 'Not looked at your site yet.', 'nodebook' ); } elseif ( empty( $probe['ok'] ) ) { esc_html_e( 'Could not open your own site from here (your host may block it). Checks that need it show a question mark.', 'nodebook' ); } else { echo esc_html( /* translators: %s: time ago */ sprintf( __( 'Looked at your site %s ago.', 'nodebook' ), human_time_diff( (int) $probe['time'], time() ) ) ); } echo '

'; echo '
'; echo '
'; $marks_url = admin_url( 'admin-post.php' ); foreach ( Nodebook_Growth::groups() as $g => $label ) { $rows = array_values( array_filter( $checks, static function ( $x ) use ( $g ) { return $x['group'] === $g; } ) ); if ( ! $rows ) { continue; } $open = array_filter( $rows, static function ( $x ) { return 'ok' !== $x['state'] && 'skip' !== $x['mark']; } ); $rest = array_filter( $rows, static function ( $x ) { return 'ok' === $x['state'] || 'skip' === $x['mark']; } ); echo '

' . wp_kses( Nodebook_Icons::svg( $label[1], 18 ), Nodebook_Icons::kses() ) . esc_html( $label[0] ) . '

' . esc_html( /* translators: 1: done, 2: total */ sprintf( __( '%1$s of %2$s', 'nodebook' ), number_format_i18n( count( $rows ) - count( $open ) ), number_format_i18n( count( $rows ) ) ) ) . '
    '; foreach ( $open as $x ) { self::row( $x, $marks_url ); } echo '
'; if ( $rest ) { echo '
' . esc_html( /* translators: %s: number */ sprintf( _n( '%s done or not for you', '%s done or not for you', count( $rest ), 'nodebook' ), number_format_i18n( count( $rest ) ) ) ) . '
    '; foreach ( $rest as $x ) { self::row( $x, $marks_url ); } echo '
'; } echo '
'; } echo '
'; Nodebook_Admin::footer(); } private static function row( array $x, $post_url ) { $state = 'skip' === $x['mark'] ? 'skip' : $x['state']; $icon = array( 'ok' => 'check', 'todo' => 'target', 'unknown' => 'clock', 'skip' => 'eye', ); echo '
  • ' . esc_html( $x['title'] ) . ''; if ( 'ok' !== $state ) { echo '

    ' . esc_html( $x['why'] ) . '

    '; } if ( '' !== (string) $x['detail'] ) { echo '

    ' . esc_html( $x['detail'] ) . '

    '; } echo '
    '; if ( 'todo' === $state && $x['fix'] ) { $ext = 0 !== strpos( $x['fix'][1], admin_url() ); echo '' . esc_html( $x['fix'][0] ) . ( $ext ? ' ↗' : '' ) . ''; } $form = static function ( $how, $label, $cls = 'button-link' ) use ( $x, $post_url ) { echo '
    '; wp_nonce_field( 'nodebook_growth' ); echo '
    '; }; if ( 'todo' === $state || 'unknown' === $state ) { if ( $x['manual'] ) { $form( 'done', __( 'Done', 'nodebook' ), 'nb-btn' ); } $form( 'skip', __( 'Not for me', 'nodebook' ), 'button-link nb-grow__skip' ); } elseif ( $x['mark'] ) { $form( 'undo', __( 'Undo', 'nodebook' ), 'button-link nb-grow__skip' ); } echo '
  • '; } private static function ai_card() { $ai = Nodebook_Growth::ai_visits( 30 ); echo '

    ' . esc_html__( 'AI visitors', 'nodebook' ) . '

    ' . esc_html__( '30 days', 'nodebook' ) . '
    '; if ( ! $ai['total'] ) { echo '

    ' . esc_html__( 'No visits from ChatGPT, Claude, Perplexity or other AI crawlers seen yet. They show up here as soon as they read your pages.', 'nodebook' ) . '

    '; return; } echo '

    ' . esc_html( number_format_i18n( $ai['total'] ) ) . ' ' . esc_html( _n( 'page read', 'pages read', $ai['total'], 'nodebook' ) ) . '

    ' . esc_html__( 'What they read most', 'nodebook' ) . '

      '; foreach ( $ai['pages'] as $path => $n ) { echo '
    1. ' . esc_html( '/' === $path ? __( 'Home page', 'nodebook' ) : $path ) . '' . esc_html( number_format_i18n( $n ) ) . '
    2. '; } echo '
    '; } private static function missing_card() { $m = Nodebook_Growth::missing( 30 ); if ( ! $m ) { return; } echo '

    ' . esc_html__( 'Pages people could not find', 'nodebook' ) . '

    ' . esc_html__( '30 days', 'nodebook' ) . '
      '; foreach ( $m as $path => $n ) { echo '
    1. ' . esc_html( $path ) . '' . esc_html( number_format_i18n( $n ) ) . '×
    2. '; } echo '
    '; } /** Done, not for me, or undo. */ public static function mark_post() { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Sorry, you are not allowed to do that.', 'nodebook' ), 403 ); } check_admin_referer( 'nodebook_growth' ); $key = isset( $_POST['key'] ) ? sanitize_key( wp_unslash( $_POST['key'] ) ) : ''; $how = isset( $_POST['how'] ) ? sanitize_key( wp_unslash( $_POST['how'] ) ) : ''; if ( '' !== $key ) { Nodebook_Growth::mark( $key, $how ); } Nodebook_Admin::redirect( Nodebook_Admin::url( 'nodebook-growth' ) . '#g-' . $key ); } /** AJAX: look at the site again. */ public static function probe_ajax() { check_ajax_referer( 'nodebook_growth', 'nonce' ); if ( ! current_user_can( 'manage_options' ) ) { wp_send_json_error( null, 403 ); } $p = Nodebook_Growth::probe(); wp_send_json_success( array( 'ok' => ! empty( $p['ok'] ) ) ); } }