'; ?>

%2$s

', esc_attr( (string) ( $notice['type'] ?? 'info' ) ), esc_html( (string) ( $notice['message'] ?? '' ) ) ); } ?>
>
%5$s', esc_attr( $id ), $active ? ' is-active' : '', $active ? 'true' : 'false', $active ? 0 : -1, esc_html( $label ) ); } /** * @param list> $rows */ private static function render_queries_panel( array $rows, bool $configured ): void { $paa_by_query = Ideas::phrases_by_query( Ideas::KIND_PAA ); $related_by_query = Ideas::phrases_by_query( Ideas::KIND_RELATED ); ?>
0 ? esc_html( (string) (int) $pos ) : '—'; ?>
$rows * @return list */ private static function idea_questions( array $rows ): array { $out = []; foreach ( $rows as $row ) { $phrase = is_array( $row ) ? trim( (string) ( $row['question'] ?? '' ) ) : trim( (string) $row ); if ( '' !== $phrase ) { $out[] = $phrase; } } return $out; } /** * @param list $paa * @param list $suggest */ private static function render_query_ideas( int $id, array $paa, array $suggest ): void { if ( [] === $paa && [] === $suggest ) { echo '—'; return; } $panel_id = 'forwp-positions-ideas-' . $id; $icon = ''; ?> > $rows */ private static function render_related_panel( array $rows ): void { $labels = []; foreach ( $rows as $row ) { $labels[ (int) $row['id'] ] = (string) $row['query_text']; } $paa = Ideas::list_kind( Ideas::KIND_PAA ); $related = Ideas::list_kind( Ideas::KIND_RELATED ); ?>

> $items * @param array $labels */ private static function render_ideas_group( string $title, array $items, array $labels ): void { ?>

  • #

$organic */ private static function render_preview( int $id, array $organic, string $query ): void { if ( [] === $organic ) { return; } $panel_id = 'forwp-positions-preview-' . $id; $icon = ''; ?> get_error_message() ); } else { self::set_notice( 'success', __( 'Query added.', '4wp-seo-helper' ) ); } wp_safe_redirect( admin_url( 'admin.php?page=' . Menu::POSITIONS_PAGE_SLUG ) ); exit; } if ( 'check' === $action ) { check_admin_referer( 'forwp_positions_check', 'forwp_positions_check_nonce' ); $query_id = isset( $_POST['query_id'] ) ? (int) $_POST['query_id'] : 0; $row = Repository::get( $query_id ); if ( ! $row ) { self::set_notice( 'error', __( 'Query not found.', '4wp-seo-helper' ) ); wp_safe_redirect( admin_url( 'admin.php?page=' . Menu::POSITIONS_PAGE_SLUG ) ); exit; } $result = Client::check_query( (string) $row['query_text'], (string) $row['gl'], (string) $row['hl'], (int) ( $_POST['forwp_positions_depth'] ?? Client::DEFAULT_PAGES ) ); Repository::save_check( $query_id, $result ); $when = mysql2date( 'Y-m-d H:i', (string) $result['checked_at'] ) ?: (string) $result['checked_at']; $target = (string) ( $result['target_property'] ?? Target::property() ); if ( ! empty( $result['ok'] ) ) { self::set_notice( 'success', '' !== $target ? sprintf( /* translators: 1: datetime, 2: GSC property, 3: max rank searched */ __( 'Checked %1$s for %2$s (top %3$d).', '4wp-seo-helper' ), $when, $target, (int) ( $result['depth'] ?? Client::PAGE_SIZE ) ) : sprintf( /* translators: %s: datetime */ __( 'Checked %s.', '4wp-seo-helper' ), $when ) ); } else { self::set_notice( 'error', sprintf( /* translators: 1: datetime, 2: error */ __( 'Check at %1$s failed: %2$s', '4wp-seo-helper' ), $when, (string) ( $result['error'] ?? '' ) ) ); } wp_safe_redirect( admin_url( 'admin.php?page=' . Menu::POSITIONS_PAGE_SLUG ) ); exit; } if ( 'delete' === $action ) { check_admin_referer( 'forwp_positions_delete', 'forwp_positions_delete_nonce' ); $query_id = isset( $_POST['query_id'] ) ? (int) $_POST['query_id'] : 0; if ( Repository::delete_query( $query_id ) ) { self::set_notice( 'success', __( 'Query deleted.', '4wp-seo-helper' ) ); } else { self::set_notice( 'error', __( 'Could not delete the query.', '4wp-seo-helper' ) ); } wp_safe_redirect( admin_url( 'admin.php?page=' . Menu::POSITIONS_PAGE_SLUG ) ); exit; } } private static function set_notice( string $type, string $message ): void { set_transient( 'forwp_positions_notice_' . get_current_user_id(), [ 'type' => $type, 'message' => $message, ], MINUTE_IN_SECONDS ); } }