Changeset 3748372 for archivist-ai/trunk/admin/class-arcai-admin.php
- Timestamp:
- 10/15/2026 11:59:49 AM (40 hours ago)
- File:
-
- 1 edited
-
archivist-ai/trunk/admin/class-arcai-admin.php (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
archivist-ai/trunk/admin/class-arcai-admin.php
r3748265 r3748372 16 16 add_action( 'admin_init', array( $this, 'register_settings' ) ); 17 17 add_action( 'admin_init', array( $this, 'add_privacy_policy_content' ) ); 18 add_action( 'admin_post_arcai_review_prompt', array( $this, 'handle_review_prompt' ) ); 18 19 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) ); 19 20 add_action( 'wp_ajax_arcai_estimate_index', array( $this, 'ajax_estimate' ) ); … … 191 192 'tone' => $state['indexed_posts'] ? 'ok' : 'off', 192 193 ); 194 195 $show_pro_hints = true; 193 196 ?> 194 197 <div class="wrap arcai-wrap"> … … 197 200 <div class="arcai-columns"> 198 201 <div class="arcai-main"> 202 203 <?php $this->render_review_prompt(); ?> 199 204 200 205 <form method="post" action="options.php" class="arcai-settings"> … … 244 249 </td> 245 250 </tr> 251 <?php if ( $show_pro_hints ) : ?> 252 <?php $this->render_pro_hint_row( __( 'Custom fields', 'archivist-ai' ), __( 'Make custom fields, ACF fields and taxonomies searchable too, e.g. a product’s price or an event’s venue and date.', 'archivist-ai' ) ); ?> 253 <?php endif; ?> 246 254 </table> 255 <?php 256 ?> 247 257 </section> 248 258 … … 270 280 </td> 271 281 </tr> 272 <tr> 273 <th scope="row"><label for="arcai-chat-bg"><?php esc_html_e( 'Background color', 'archivist-ai' ); ?></label></th> 274 <td> 275 <input type="color" id="arcai-chat-bg" name="<?php echo esc_attr( Arcai_Settings::OPTION ); ?>[chat_bg]" value="<?php echo esc_attr( $settings['chat_bg'] ); ?>" /> 276 <p class="description"><?php esc_html_e( 'Text and lines switch to light automatically on a dark background.', 'archivist-ai' ); ?></p> 277 </td> 278 </tr> 279 <tr> 280 <th scope="row"><label for="arcai-chat-font"><?php esc_html_e( 'Font', 'archivist-ai' ); ?></label></th> 281 <td> 282 <select id="arcai-chat-font" name="<?php echo esc_attr( Arcai_Settings::OPTION ); ?>[chat_font]"> 283 <?php foreach ( Arcai_Settings::fonts() as $key => $label ) : ?> 284 <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $settings['chat_font'], $key ); ?>><?php echo esc_html( $label ); ?></option> 285 <?php endforeach; ?> 286 </select> 287 <p class="description"><?php esc_html_e( 'For questions and answers. Small labels keep the monospace style.', 'archivist-ai' ); ?></p> 288 </td> 289 </tr> 290 <tr> 291 <th scope="row"><?php esc_html_e( 'Corners', 'archivist-ai' ); ?></th> 292 <td> 293 <fieldset class="arcai-segmented"> 294 <legend class="screen-reader-text"><?php esc_html_e( 'Corners', 'archivist-ai' ); ?></legend> 295 <?php foreach ( Arcai_Settings::corners() as $key => $label ) : ?> 296 <label> 297 <input type="radio" name="<?php echo esc_attr( Arcai_Settings::OPTION ); ?>[chat_corners]" value="<?php echo esc_attr( $key ); ?>" <?php checked( $settings['chat_corners'], $key ); ?> /> 298 <span class="arcai-corner-<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $label ); ?></span> 299 </label> 300 <?php endforeach; ?> 301 </fieldset> 302 </td> 303 </tr> 282 <?php 283 ?> 304 284 <tr> 305 285 <th scope="row"><label for="arcai-greeting"><?php esc_html_e( 'Greeting message', 'archivist-ai' ); ?></label></th> … … 308 288 <?php 309 289 ?> 290 <?php if ( $show_pro_hints ) : ?> 291 <?php $this->render_pro_hint_row( __( 'Your style', 'archivist-ai' ), __( 'Background color, font and corner style, plus your own answer instructions: tone, language and house rules.', 'archivist-ai' ) ); ?> 292 <?php endif; ?> 310 293 </table> 311 294 <?php $this->render_chat_preview( $settings ); ?> … … 428 411 <p class="description"><?php esc_html_e( 'Computed from OpenAI list prices for the tokens each call used.', 'archivist-ai' ); ?></p> 429 412 </section> 413 414 <?php if ( $show_pro_hints ) : ?> 415 <?php $this->render_pro_card(); ?> 416 <?php endif; ?> 430 417 431 418 </div> … … 474 461 } 475 462 463 /** 464 * A settings-table row pointing to a Pro feature. 465 */ 466 private function render_pro_hint_row( $label, $text ) { 467 ?> 468 <tr class="arcai-pro-hint"> 469 <th scope="row"><?php echo esc_html( $label ); ?></th> 470 <td> 471 <span class="arcai-pro-badge">Pro</span> 472 <?php echo esc_html( $text ); ?> 473 <a href="<?php echo esc_url( arcai_fs()->get_upgrade_url() ); ?>"><?php esc_html_e( 'See Pro', 'archivist-ai' ); ?></a> 474 </td> 475 </tr> 476 <?php 477 } 478 479 /** 480 * Sidebar summary of what Pro adds. 481 */ 482 private function render_pro_card() { 483 $features = array( 484 __( 'Reader questions report: what people ask, and what your archive could not answer', 'archivist-ai' ), 485 __( 'Custom fields, ACF fields and taxonomies in search', 'archivist-ai' ), 486 __( 'Your own answer instructions: tone, language, house rules', 'archivist-ai' ), 487 __( 'Full styling: background, font, corners', 'archivist-ai' ), 488 __( 'Answer caching and subscriber-only mode', 'archivist-ai' ), 489 ); 490 ?> 491 <section class="arcai-card arcai-pro-card"> 492 <header class="arcai-card-head"> 493 <p class="arcai-kicker">Pro</p> 494 <h2><?php esc_html_e( 'Go further', 'archivist-ai' ); ?></h2> 495 </header> 496 <ul> 497 <?php foreach ( $features as $feature ) : ?> 498 <li><?php echo esc_html( $feature ); ?></li> 499 <?php endforeach; ?> 500 </ul> 501 <p class="arcai-actions"> 502 <a class="button button-primary" href="<?php echo esc_url( arcai_fs()->get_upgrade_url() ); ?>"><?php esc_html_e( 'See Pro plans', 'archivist-ai' ); ?></a> 503 </p> 504 </section> 505 <?php 506 } 507 508 /** 509 * One-time request for a wordpress.org review, shown on this screen only 510 * once the chat has answered enough questions to judge it. 511 */ 512 private function render_review_prompt() { 513 if ( 'done' === get_option( 'arcai_review_prompt' ) || Arcai_Usage::event_count( 'chat_answer' ) < 20 ) { 514 return; 515 } 516 $url = function ( $choice ) { 517 return wp_nonce_url( admin_url( 'admin-post.php?action=arcai_review_prompt&choice=' . $choice ), 'arcai_review_prompt' ); 518 }; 519 ?> 520 <section class="arcai-card arcai-review"> 521 <p> 522 <strong><?php esc_html_e( 'Your archive has answered over 20 questions.', 'archivist-ai' ); ?></strong> 523 <?php esc_html_e( 'If Archivist AI is useful to you, a short review on WordPress.org helps other publishers find it.', 'archivist-ai' ); ?> 524 </p> 525 <p class="arcai-actions"> 526 <a class="button button-primary" href="<?php echo esc_url( $url( 'review' ) ); ?>" target="_blank" rel="noopener"><?php esc_html_e( 'Leave a review', 'archivist-ai' ); ?></a> 527 <a class="button" href="<?php echo esc_url( $url( 'dismiss' ) ); ?>"><?php esc_html_e( 'No thanks', 'archivist-ai' ); ?></a> 528 </p> 529 </section> 530 <?php 531 } 532 533 /** 534 * Either choice hides the review prompt for good. 535 */ 536 public function handle_review_prompt() { 537 if ( ! current_user_can( 'manage_options' ) ) { 538 wp_die( esc_html__( 'Permission denied.', 'archivist-ai' ) ); 539 } 540 check_admin_referer( 'arcai_review_prompt' ); 541 update_option( 'arcai_review_prompt', 'done', false ); 542 543 $choice = isset( $_GET['choice'] ) ? sanitize_key( wp_unslash( $_GET['choice'] ) ) : ''; 544 if ( 'review' === $choice ) { 545 wp_redirect( 'https://wordpress.org/support/plugin/archivist-ai/reviews/#new-post' ); // phpcs:ignore WordPress.Security.SafeRedirect.wp_redirect_wp_redirect -- fixed wordpress.org URL. 546 exit; 547 } 548 wp_safe_redirect( admin_url( 'admin.php?page=archivist-ai' ) ); 549 exit; 550 } 551 552 /** 553 * Background, font and corner rows (Pro appearance settings). 554 */ 555 556 /** 557 * Custom answer instructions row (Pro). 558 */ 559 560 /** 561 * Per post type: which custom fields and taxonomies to add to the indexed 562 * text (Pro field mapping). 563 */ 564 476 565 477 566 private function verify_ajax() {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)