settings = $settings; } /** * Render the settings page with form, buttons, and log viewer. * * @return void */ public function render_settings_page(): void { if ( ! current_user_can( 'manage_options' ) ) { return; } // Handle manual fetch trigger. if ( isset( $_POST['peptide_news_fetch_now'] ) ) { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'Unauthorized', 'peptide-news' ), 403 ); } check_admin_referer( 'peptide_news_fetch_now_action' ); $fetcher = new Peptide_News_Fetcher(); $fetcher->fetch_all_sources(); echo '

' . esc_html__( 'Fetch completed!', 'peptide-news' ) . '

'; } echo '
'; echo '

' . esc_html( get_admin_page_title() ) . '

'; // Fetch Now button. echo '
'; wp_nonce_field( 'peptide_news_fetch_now_action' ); submit_button( __( 'Fetch Articles Now', 'peptide-news' ), 'secondary', 'peptide_news_fetch_now', false ); echo '
'; // Backfill Sources button (fixes "news.google.com" source labels). echo ''; echo ''; // Generate AI Summaries button. echo '
'; echo ''; echo ''; ?> 0 ) { $extra_info .= sprintf( ' | %s: %d', esc_html__( 'Filtered out', 'peptide-news' ), $last_fetch['filtered_out'] ); } if ( isset( $last_fetch['ai_processed'] ) ) { $extra_info .= sprintf( ' | %s: %d', esc_html__( 'AI analyzed', 'peptide-news' ), $last_fetch['ai_processed'] ); } printf( '

%s: %s | %s: %d | %s: %d%s

', esc_html__( 'Last fetch', 'peptide-news' ), esc_html( $last_fetch['time'] ), esc_html__( 'Found', 'peptide-news' ), intval( $last_fetch['found'] ), esc_html__( 'New stored', 'peptide-news' ), intval( $last_fetch['new_stored'] ), esc_html( $extra_info ) ); } // Settings form. echo '
'; settings_fields( 'peptide_news_settings_group' ); do_settings_sections( 'peptide-news-settings' ); submit_button(); echo '
'; // Shortcode usage info. echo '

' . esc_html__( 'Usage', 'peptide-news' ) . '

'; echo '

' . esc_html__( 'Shortcode:', 'peptide-news' ) . ' [peptide_news] ' . esc_html__( 'or', 'peptide-news' ) . ' [peptide_news count="5"]

'; echo '

' . esc_html__( 'Widget:', 'peptide-news' ) . ' ' . esc_html__( 'Add "Peptide News" from Appearance > Widgets.', 'peptide-news' ) . '

'; // ── Plugin Log Viewer ────────────────────────────────────────── Peptide_News_Admin_Log_Viewer::render_log_viewer(); echo '
'; } }