@@ -459,16 +459,21 @@ private function default_content() {
459459 * @return string
460460 */
461461 private function chat_gpt_rewrite () {
462- $ content = call_user_func ( array ( $ this , $ this ->current_job ->tag ) );
463- $ content = wp_strip_all_tags ( $ content );
464- $ content = substr ( $ content , 0 , apply_filters ( 'feedzy_chat_gpt_content_limit ' , 3000 ) );
465- $ content = str_replace ( array ( '{content} ' ), array ( $ content ), $ this ->current_job ->data ->ChatGPT );
462+ // Return prompt content if openAI class doesn't exist.
466463 if ( ! class_exists ( '\Feedzy_Rss_Feeds_Pro_Openai ' ) ) {
467- return $ content ;
464+ return $ this -> current_job -> data -> ChatGPT ;
468465 }
469- $ openai = new \Feedzy_Rss_Feeds_Pro_Openai ();
470- $ content = $ openai ->call_api ( $ this ->settings , $ content , '' , array () );
471- return $ content ;
466+
467+ $ content = call_user_func ( array ( $ this , $ this ->current_job ->tag ) );
468+ $ content = wp_strip_all_tags ( $ content );
469+ $ content = substr ( $ content , 0 , apply_filters ( 'feedzy_chat_gpt_content_limit ' , 3000 ) );
470+ $ prompt_content = $ this ->current_job ->data ->ChatGPT ;
471+ $ content = str_replace ( array ( '{content} ' ), array ( $ content ), $ prompt_content );
472+ $ openai = new \Feedzy_Rss_Feeds_Pro_Openai ();
473+ $ rewrite_content = $ openai ->call_api ( $ this ->settings , $ content , '' , array () );
474+ // Replace prompt content string for specific cases.
475+ $ rewrite_content = str_replace ( explode ( '{content} ' , $ prompt_content ), '' , $ rewrite_content );
476+ return $ rewrite_content ;
472477 }
473478
474479 /**
0 commit comments