Skip to content

Commit a31a9a8

Browse files
Fix AI features visibility and menu registration
Critical fixes for AI features not appearing: 1. **Add AI Settings menu item**: - Register submenu page in Admin::registerAdminMenu() - Add Admin::renderAISettingsPage() method - Menu now appears under Visualizer menu 2. **Fix AI chat sidebar visibility**: - Call _renderAIConfigurationGroup() from _renderGeneralSettings() - Added to both Google.php and ChartJS.php sidebars - AI chat now shows in chart editor for all chart types 3. **Fix page URL references**: - Changed 'viz-ai-settings' to 'visualizer-ai-settings' - Updated links in Sidebar.php and Types.php - "Configure AI Settings" buttons now work correctly Fixes reported issues: - AI Settings menu not visible - Permission denied error (wrong page slug) - AI chat interface not showing in sidebar
1 parent 3916959 commit a31a9a8

5 files changed

Lines changed: 31 additions & 2 deletions

File tree

classes/Visualizer/Module/Admin.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,16 @@ public function registerAdminMenu() {
746746
'admin.php?page=' . Visualizer_Plugin::NAME . '&vaction=addnew'
747747
);
748748

749+
// Add AI Settings submenu
750+
add_submenu_page(
751+
Visualizer_Plugin::NAME,
752+
__( 'AI Settings', 'visualizer' ),
753+
__( 'AI Settings', 'visualizer' ),
754+
'edit_posts',
755+
'visualizer-ai-settings',
756+
array( $this, 'renderAISettingsPage' )
757+
);
758+
749759
$this->_supportPage = add_submenu_page(
750760
Visualizer_Plugin::NAME,
751761
__( 'Support', 'visualizer' ),
@@ -969,6 +979,19 @@ public function renderSupportPage() {
969979
include_once VISUALIZER_ABSPATH . '/templates/support.php';
970980
}
971981

982+
/**
983+
* Renders AI Settings page.
984+
*
985+
* @since 3.12.0
986+
*
987+
* @access public
988+
* @return void
989+
*/
990+
public function renderAISettingsPage() {
991+
$render = new Visualizer_Render_Page_AISettings();
992+
$render->render();
993+
}
994+
972995
/**
973996
* Renders visualizer library page.
974997
*

classes/Visualizer/Render/Page/Types.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ protected function _renderContent() {
8383
echo '<span class="dashicons dashicons-lock" style="font-size: 48px; color: #999; margin-bottom: 10px;"></span>';
8484
echo '<h3 style="margin: 10px 0; color: #666;">' . esc_html__( 'AI Features - API Key Required', 'visualizer' ) . '</h3>';
8585
echo '<p style="margin: 10px 0; color: #666;">' . esc_html__( 'Configure your AI API key to use AI-powered chart creation from images.', 'visualizer' ) . '</p>';
86-
echo '<a href="' . admin_url( 'admin.php?page=viz-ai-settings' ) . '" class="button button-primary" style="margin-top: 10px;">';
86+
echo '<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" class="button button-primary" style="margin-top: 10px;">';
8787
echo esc_html__( 'Configure AI Settings', 'visualizer' );
8888
echo '</a>';
8989
echo '</div>';

classes/Visualizer/Render/Sidebar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,7 @@ protected function _renderAIConfigurationGroup() {
864864
sprintf(
865865
// translators: %1$s - HTML link tag, %2$s - HTML closing link tag.
866866
esc_html__( 'Chat with AI to customize your chart. Ask questions, get suggestions, or describe what you want. The AI understands your chart type and current configuration. %1$sConfigure API keys%2$s', 'visualizer' ),
867-
'<a href="' . admin_url( 'admin.php?page=viz-ai-settings' ) . '" target="_blank">',
867+
'<a href="' . admin_url( 'admin.php?page=visualizer-ai-settings' ) . '" target="_blank">',
868868
'</a>'
869869
)
870870
);

classes/Visualizer/Render/Sidebar/ChartJS.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,9 @@ protected function _renderChartTitleSettings() {
198198
* @access protected
199199
*/
200200
protected function _renderGeneralSettings() {
201+
// AI Configuration Group - render first
202+
$this->_renderAIConfigurationGroup();
203+
201204
self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
202205
self::_renderSectionStart();
203206
self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );

classes/Visualizer/Render/Sidebar/Google.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ protected function _renderRoleField( $index ) {
171171
* @access protected
172172
*/
173173
protected function _renderGeneralSettings() {
174+
// AI Configuration Group - render first
175+
$this->_renderAIConfigurationGroup();
176+
174177
self::_renderGroupStart( esc_html__( 'General Settings', 'visualizer' ) );
175178
self::_renderSectionStart();
176179
self::_renderSectionDescription( esc_html__( 'Configure title, font styles, tooltip, legend and else settings for the chart.', 'visualizer' ) );

0 commit comments

Comments
 (0)