| 1 |
<?php |
| 2 |
defined( 'ABSPATH' ) || exit; |
| 3 |
|
| 4 |
add_filter( 'ultp_addons_config', 'ultp_chatgpt_config' ); |
| 5 |
/** |
| 6 |
* ChatGPT Addon Config |
| 7 |
* |
| 8 |
* @param array $config Addon Config. |
| 9 |
* @return array |
| 10 |
*/ |
| 11 |
function ultp_chatgpt_config( $config ) { |
| 12 |
$configuration = array( |
| 13 |
'name' => __( 'ChatGPT', 'ultimate-post' ), |
| 14 |
'desc' => __( 'PostX brings the ChatGPT into the WordPress Dashboard to let you generate content effortlessly. ', 'ultimate-post' ), |
| 15 |
'img' => ULTP_URL . 'assets/img/addons/ChatGPT.svg', |
| 16 |
'docs' => 'https://wpxpo.com/docs/postx/add-on/chatgpt-addon/', |
| 17 |
'live' => 'https://www.wpxpo.com/postx-chatgpt-wordpress-ai-content-generator/live_demo_args', |
| 18 |
'video' => 'https://www.youtube.com/watch?v=NE4BPw4OTAA', |
| 19 |
'is_pro' => false, |
| 20 |
'position' => 6 |
| 21 |
); |
| 22 |
$config['ultp_chatgpt'] = $configuration; |
| 23 |
return $config; |
| 24 |
} |
| 25 |
|
| 26 |
add_action( 'init', 'ultp_chatgpt_init' ); |
| 27 |
function ultp_chatgpt_init() { |
| 28 |
$settings = isset( $GLOBALS['ultp_settings'] ) ? $GLOBALS['ultp_settings'] : array(); |
| 29 |
if ( isset( $settings['ultp_chatgpt'] ) ) { |
| 30 |
add_filter( 'ultp_settings', 'get_chatgpt_settings', 10, 1 ); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
function get_chatgpt_settings( $config ) { |
| 35 |
$arr = array( |
| 36 |
'ultp_chatgpt' => array( |
| 37 |
'label' => __( 'ChatGPT', 'ultimate-post' ), |
| 38 |
'attr' => array( |
| 39 |
'chatgpt_heading' => array( |
| 40 |
'type' => 'heading', |
| 41 |
'label' => __( 'ChatGPT Settings', 'ultimate-post' ), |
| 42 |
), |
| 43 |
'chatgpt_secret_key' => array( |
| 44 |
'type' => 'text', |
| 45 |
'label' => __( 'OpenAI API Secret Key', 'ultimate-post' ), |
| 46 |
'desc' => __( 'For using ChatGPT addon, you have to add your OpenAI secret key.', 'ultimate-post' ), |
| 47 |
'link' => __( 'https://platform.openai.com/account/api-keys' ), |
| 48 |
'linkText' => __( 'Get key.', 'ultimate-post' ), |
| 49 |
), |
| 50 |
'chatgpt_model' => array( |
| 51 |
'type' => 'select', |
| 52 |
'label' => __( 'OpenAI Model', 'ultimate-post' ), |
| 53 |
'desc' => __( 'Choose your preferable OpenAI model', 'ultimate-post' ), |
| 54 |
'options' => array( |
| 55 |
'gpt-3.5-turbo' => 'gpt-3.5-turbo', |
| 56 |
'text-davinci-002' => 'text-davinci-002', |
| 57 |
'text-davinci-003' => 'text-davinci-003', |
| 58 |
'gpt-4' => 'gpt-4', |
| 59 |
), |
| 60 |
'default' => 'gpt-3.5-turbo' |
| 61 |
), |
| 62 |
'chatgpt_response_time' => array( |
| 63 |
'type' => 'number', |
| 64 |
'label' => __( 'Response Time', 'ultimate-post' ), |
| 65 |
'desc' => __( 'Choose your preferable OpenAI response time', 'ultimate-post' ), |
| 66 |
'default' => 60 |
| 67 |
), |
| 68 |
'chatgpt_max_tokens' => array( |
| 69 |
'type' => 'number', |
| 70 |
'label' => __( 'Max Tokens', 'ultimate-post' ), |
| 71 |
'desc' => __( 'Choose your preferable OpenAI max Number of Tokens to be generated by ChatGPT', 'ultimate-post' ), |
| 72 |
'default' => 400 |
| 73 |
), |
| 74 |
), |
| 75 |
), |
| 76 |
); |
| 77 |
return array_merge( $config, $arr ); |
| 78 |
} |