/ wordpress / restai / admin / views / analytics.php
analytics.php
 1  <?php
 2  /**
 3   * Analytics page — mirrors RESTai's /statistics endpoints into WP admin.
 4   *
 5   * @package RESTai
 6   */
 7  
 8  if ( ! defined( 'ABSPATH' ) ) {
 9  	exit;
10  }
11  ?>
12  <div class="wrap restai-analytics">
13  	<h1><?php esc_html_e( 'RESTai Analytics', 'restai' ); ?></h1>
14  	<?php if ( ! \RESTai\Plugin::is_connected() ) : ?>
15  		<div class="notice notice-warning"><p>
16  			<?php
17  			printf(
18  				/* translators: %s settings link */
19  				esc_html__( 'Not connected. Configure your RESTai instance first in %s.', 'restai' ),
20  				'<a href="' . esc_url( admin_url( 'options-general.php?page=restai' ) ) . '">' . esc_html__( 'Settings → RESTai', 'restai' ) . '</a>'
21  			);
22  			?>
23  		</p></div>
24  		<?php return; ?>
25  	<?php endif; ?>
26  
27  	<?php $settings = get_option( 'restai_settings', array() ); ?>
28  	<?php if ( ! empty( $settings['enable_knowledge'] ) ) : ?>
29  		<div class="restai-knowledge-actions" style="margin: 12px 0; padding: 12px 14px; background:#fff; border:1px solid #e0e0e6; border-radius:6px;">
30  			<strong><?php esc_html_e( 'Knowledge sync', 'restai' ); ?></strong>
31  			<p style="margin: 4px 0 8px;">
32  				<?php esc_html_e( 'Push every published post and page into the Support Bot RAG project. Useful as a one-off seed when first enabling the support bot, or to recover after a vector store wipe.', 'restai' ); ?>
33  			</p>
34  			<button type="button" class="button button-primary" id="restai-push-all-knowledge">
35  				<?php esc_html_e( 'Push all to Support Bot', 'restai' ); ?>
36  			</button>
37  			<span id="restai-push-status" style="margin-left: 10px;"></span>
38  		</div>
39  	<?php else : ?>
40  		<div class="notice notice-info" style="margin: 12px 0;"><p>
41  			<?php
42  			printf(
43  				/* translators: %s settings link */
44  				esc_html__( 'Knowledge sync is disabled. Enable it in %s to surface the "Push all to Support Bot" action here.', 'restai' ),
45  				'<a href="' . esc_url( admin_url( 'options-general.php?page=restai' ) ) . '">' . esc_html__( 'Settings → RESTai', 'restai' ) . '</a>'
46  			);
47  			?>
48  		</p></div>
49  	<?php endif; ?>
50  
51  	<div id="restai-analytics-app" class="restai-analytics-app">
52  		<p class="description"><?php esc_html_e( 'Loading…', 'restai' ); ?></p>
53  	</div>
54  </div>