PluginProbe
bBlocks – Essential Gutenberg Blocks & Patterns Collection / 2.1.7
bBlocks – Essential Gutenberg Blocks & Patterns Collection v2.1.7
2.1.7 2.1.6 2.1.5 2.1.4 2.1.3 2.1.2 2.1.1 2.1.0 2.0.43 2.0.42 2.0.41 2.0.40 2.0.39 2.0.38 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 107 releases
← All changes | includes/Ai.php +5 -6 2.0.432.1.7 View file →
@@ -73,9 +73,9 @@
73 73 }
74 74
75 75 public function handle_open_ai_generation() {
76 76 // Verify nonce
77 - if ( ! wp_verify_nonce( $_POST['nonce'], 'wp_ajax' ) ) {
77 + if ( ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['nonce'] ?? '' ) ), 'wp_ajax' ) ) {
78 78 wp_send_json_error( [ 'message' => 'Security check failed' ] );
79 79 return;
80 80 }
81 81
@@ -84,9 +84,9 @@
84 84 wp_send_json_error( [ 'message' => 'Insufficient permissions' ] );
85 85 return;
86 86 }
87 87
88 - $prompt = sanitize_text_field( $_POST['prompt'] );
88 + $prompt = sanitize_text_field( wp_unslash( $_POST['prompt'] ?? '' ) );
89 89
90 90 if ( empty( $prompt ) ) {
91 91 wp_send_json_error( [ 'message' => 'Prompt is required' ] );
92 92 return;
@@ -108,10 +108,10 @@
108 108 }
109 109
110 110 private function call_ai_service( $prompt ) {
111 111 $api_data = get_option( 'bBlocksApiKeys', [] );
112 - $openAi = $api_data['openAi'];
113 - $api_key = $openAi['key'];
112 + $openAi = isset( $api_data['openAi'] ) && is_array( $api_data['openAi'] ) ? $api_data['openAi'] : [];
113 + $api_key = $openAi['key'] ?? '';
114 114
115 115 // Check if API key is set
116 116 if ( empty( $api_key ) ) {
117 117 wp_send_json_error( [ 'message' => 'OpenAI API key is not configured. Please set it in Settings.' ] );
@@ -192,6 +192,5 @@
192 192 // return new WP_Error( 'invalid_response', 'Invalid response format from AI service' );
193 193 }
194 194 }
195 195 new BBlocksAi();
196 -}
197 -?>
196 +}