Skip to content

Commit 51f1f1e

Browse files
fix: better structure and module separation
1 parent ef23e8e commit 51f1f1e

4 files changed

Lines changed: 395 additions & 328 deletions

File tree

includes/admin/feedzy-rss-feeds-actions.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,13 +493,25 @@ private function chat_gpt_rewrite() {
493493
$content = wp_strip_all_tags( $content );
494494
$content = substr( $content, 0, apply_filters( 'feedzy_chat_gpt_content_limit', 3000 ) );
495495
$prompt_content = $this->current_job->data->ChatGPT;
496-
$ai_provider = 'openai';
496+
497+
$additional_data = array(
498+
'ai_provider' => 'openai',
499+
);
500+
497501
if ( isset( $this->current_job->data ) && isset( $this->current_job->data->aiProvider ) ) {
498-
$ai_provider = $this->current_job->data->aiProvider;
502+
$additional_data['ai_provider'] = $this->current_job->data->aiProvider;
499503
}
504+
505+
if (
506+
'openai' === $additional_data['ai_provider'] &&
507+
isset( $this->current_job->data ) && isset( $this->current_job->data->aiModel )
508+
) {
509+
$additional_data['ai_model'] = $this->current_job->data->aiModel;
510+
}
511+
500512
$content = str_replace( array( '{content}' ), array( $content ), $prompt_content );
501513
$openai = new \Feedzy_Rss_Feeds_Pro_Openai();
502-
$rewrite_content = $openai->call_api( $this->settings, $content, '', array( 'ai_provider' => $ai_provider ) );
514+
$rewrite_content = $openai->call_api( $this->settings, $content, '', $additional_data );
503515
// Replace prompt content string for specific cases.
504516
$rewrite_content = str_replace( explode( '{content}', $prompt_content ), '', trim( $rewrite_content, '"' ) );
505517
return $rewrite_content;

includes/admin/feedzy-rss-feeds-admin.php

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,39 @@ public function enqueue_styles_admin() {
214214
$asset_file = include FEEDZY_ABSPATH . '/build/action-popup/index.asset.php';
215215
wp_enqueue_script( $this->plugin_name . '_action_popup', FEEDZY_ABSURL . 'build/action-popup/index.js', array_merge( $asset_file['dependencies'], array( 'wp-editor', 'wp-api' ) ), $asset_file['version'], true );
216216

217+
$openai_model = '';
218+
$open_router_model = '';
219+
$integration_settings = get_option( 'feedzy-rss-feeds-settings', array() );
220+
221+
$all_open_ai_models = apply_filters( 'feedzy_openai_models', array() );
222+
$deprecated_open_ai_models = apply_filters( 'feedzy_openai_deprecated_models', array() );
223+
$active_open_ai_models = array_values( array_diff( $all_open_ai_models, $deprecated_open_ai_models ) );
224+
225+
if ( ! empty( $integration_settings['openai_api_model'] ) ) {
226+
$openai_model = $integration_settings['openai_api_model'];
227+
}
228+
229+
if ( ! empty( $integration_settings['openrouter_api_model'] ) ) {
230+
$open_router_model = $integration_settings['openrouter_api_model'];
231+
}
232+
217233
wp_localize_script(
218234
$this->plugin_name . '_action_popup',
219235
'feedzyData',
220236
array(
221-
'isPro' => feedzy_is_pro(),
222-
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
223-
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
224-
'apiLicenseStatus' => $this->api_license_status(),
225-
'isHighPrivileges' => current_user_can( 'manage_options' ),
226-
'languageList' => $this->get_lang_list(),
227-
'integrationSettings' => get_option( 'feedzy-rss-feeds-settings' ),
237+
'isPro' => feedzy_is_pro(),
238+
'isBusinessPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'business' ),
239+
'isAgencyPlan' => apply_filters( 'feedzy_is_license_of_type', false, 'agency' ),
240+
'apiLicenseStatus' => $this->api_license_status(),
241+
'isHighPrivileges' => current_user_can( 'manage_options' ),
242+
'languageList' => $this->get_lang_list(),
243+
'integrationSettings' => get_option( 'feedzy-rss-feeds-settings' ),
244+
'integrations' => array(
245+
'openAIModel' => $openai_model,
246+
'openRouterModel' => $open_router_model,
247+
),
248+
'activeOpenAIModels' => $active_open_ai_models,
249+
'deprecatedOpenAIModels' => $deprecated_open_ai_models,
228250
)
229251
);
230252

0 commit comments

Comments
 (0)