Skip to content

Commit

Permalink
Fix prompt trash error.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdharmesh committed Jan 4, 2024
1 parent d44866e commit d430494
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions includes/Classifai/Providers/OpenAI/ChatGPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ public function sanitize_settings( $new_settings ) {
if ( $this->feature_instance instanceof ExcerptGeneration ) {
$new_settings[ static::ID ]['generate_excerpt_prompt'] = $this->sanitize_prompts( 'generate_excerpt_prompt', $new_settings );
}

if ( $this->feature_instance instanceof ContentResizing ) {
$new_settings[ static::ID ]['number_of_suggestions'] = $this->sanitize_number_of_responses_field( 'number_of_suggestions', $new_settings, $settings );
$new_settings[ static::ID ]['condense_text_prompt'] = $this->sanitize_prompts( 'condense_text_prompt', $new_settings );
Expand Down Expand Up @@ -485,13 +485,19 @@ public function enqueue_editor_assets() {
* @param string $hook_suffix The current admin page.
*/
public function enqueue_admin_assets( string $hook_suffix ) {
// Load asset in OpenAI ChatGPT settings page.
$prompt_features = array(
'feature_title_generation',
'feature_excerpt_generation',
'feature_content_resizing',
);

// Load jQuery UI Dialog for prompt deletion.
if (
(
'tools_page_classifai' === $hook_suffix
&& ( isset( $_GET['tab'], $_GET['provider'] ) ) // phpcs:ignore
&& 'language_processing' === $_GET['tab'] // phpcs:ignore
&& 'openai_chatgpt' === $_GET['provider'] // phpcs:ignore
&& ( isset( $_GET['tab'], $_GET['feature'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
&& 'language_processing' === sanitize_text_field( wp_unslash( $_GET['tab'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
&& in_array( $_GET['feature'], $prompt_features, true ) // phpcs:ignore WordPress.Security.NonceVerification.Recommended
) ||
'admin_page_classifai_setup' === $hook_suffix
) {
Expand Down

0 comments on commit d430494

Please sign in to comment.