'Sage AI Embeddings',
'singular_name' => 'Sage AI Embedding',
'menu_name' => 'Sage AI Embeddings',
'public' => false,
'show_ui' => false,
'show_in_menu' => false,
'capability_type' => 'post',
'hierarchical' => false,
'supports' => array( 'title', 'editor', 'custom-fields' ),
'has_archive' => false,
'rewrite' => false,
'query_var' => false,
'can_export' => true,
);
register_post_type( 'sage-ai-embeddings', $labels );
}
public function show_licence_notice() {
$screen = get_current_screen();
// Only render this notice in the post editor.
if ( ! $screen || strpos( $screen->base, 'sage-ai-writer' ) === false ) {
return;
}
$pro_plugin = 'ai-content-generator-pro/ai-content-generator-pro.php';
$license_status = get_option( 'sage_ai_licenses_pro_status' );
if ( $license_status !== 'valid' ) {
if ( is_plugin_active( $pro_plugin ) ) {
echo '
';
printf( __( 'Your license key for Sage AI Writer Pro is not valid. Pro features will not work without an active license. Activate License ' ), admin_url( '/admin.php?page=sage_ai_licenses' ) );
echo '
';
}
}
// Render the notice's HTML.
return false;
}
/**
* Register submenu
*
* @return void
*/
public function register_sub_menu() {
add_menu_page( 'Sage AI', 'Sage AI Writer', 'manage_options', 'wp-ai-content-gen-settings', array( &$this, 'settings_layout' ) );
// adding bulk content gen page
add_submenu_page( 'wp-ai-content-gen-settings', 'Bulk Content', 'Bulk Content Generator', 'manage_options', 'wp_ai_content_gen_bulk', array( &$this, 'bulk_content_generator' ) );
// adding bulk content gen page
add_submenu_page( 'wp-ai-content-gen-settings', 'Chatbot', 'Chatbot', 'manage_options', 'wp_ai_content_chatbot', array( &$this, 'wp_sage_ai_chatbot' ) );
// adding AI Images
add_submenu_page( 'wp-ai-content-gen-settings', 'AI Images', 'AI Images', 'manage_options', 'wp_sage_ai_images', array( &$this, 'wp_sage_ai_images' ) );
// adding Embeddings
add_submenu_page( 'wp-ai-content-gen-settings', 'Embeddings', 'Embeddings', 'manage_options', 'wp_sage_ai_embeddings', array( &$this, 'wp_sage_ai_embeddings' ) );
// adding landing page gen page
add_submenu_page( 'wp-ai-content-gen-settings', 'Landing Pages', 'Landing Pages Generator', 'manage_options', 'wp_ai_content_gen_landing_page', array( &$this, 'landing_page_generator' ) );
add_submenu_page( 'wp-ai-content-gen-settings', 'Prompts', 'Prompts', 'manage_options', 'ai-content-writer-templates', array( &$this, 'template_page' ) );
add_submenu_page( 'wp-ai-content-gen-settings', 'Support', 'Support', 'manage_options', 'wp_ai_content_gen_support', array( &$this, 'support_text' ) );
}
public function template_page() {
?>
$taxonomy->name,
'hide_empty' => false,
)
);
$taxonomy_term_data = array();
foreach ( $taxonomy_terms as $taxonomy_term ) {
$taxonomy_term_data[] = array(
'term_id' => $taxonomy_term->term_id,
'name' => $taxonomy_term->name,
'slug' => $taxonomy_term->slug,
'count' => $taxonomy_term->count,
'isSelected' => false,
);
}
$taxonomies_data[] = array(
'name' => $taxonomy->name,
'label' => $taxonomy->label,
'data' => $taxonomy_term_data,
);
}
}
$categories = get_categories(
array(
'hide_empty' => false,
)
);
$post_categories = array();
if ( ! empty( $categories ) ) {
foreach ( $categories as $category ) {
$category_info = array(
'label' => $category->name,
'value' => $category->term_id,
);
$post_categories[] = $category_info;
}
}
// get post types.
$post_types = array();
$disallowed_post_types = array( 'product' );
$custom_post_types = get_post_types(
array(
'public' => true,
'_builtin' => false,
'show_in_rest' => true,
),
'objects'
);
$post_types[] = array(
'label' => 'Post',
'value' => 'post',
);
$post_types[] = array(
'label' => 'Page',
'value' => 'page',
);
foreach ( $custom_post_types as $custom_post_type ) {
if ( ! in_array( $custom_post_type->name, $disallowed_post_types ) ) {
$post_types[] = array(
'label' => $custom_post_type->label,
'value' => $custom_post_type->name,
);
}
}
$chatbot_data = get_option( 'wp_ai_content_chatbot_settings' );
$chatbot_data = isset( $chatbot_data ) ? $chatbot_data : array();
$aiAssistantPrompts = ! empty( $settings['ai_assistant_prompts'] ) ? json_decode( $settings['ai_assistant_prompts'] ) : array(
array(
'name' => 'Use as Prompt',
'value' => '[content]',
'replaceText' => true,
'readOnly' => true,
),
array(
'name' => 'Write a paragraph',
'value' => 'Write a paragraph about [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Rephrase',
'value' => 'Rephrase: [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Text Extender',
'value' => 'Expand on: [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Summarize',
'value' => 'Write a summary for [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Pros & Cons',
'value' => 'Write Pros & Cons for [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Generate Ideas',
'value' => 'Generate Ideas about [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Introduction',
'value' => 'Write Introduction for [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Conclusion',
'value' => 'Write Conclusion for [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Outline',
'value' => 'Write an Outline for [content]',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Convert to passive Voice',
'value' => 'Convert [content] to passive Voice',
'replaceText' => false,
'readOnly' => false,
),
array(
'name' => 'Convert to active Voice',
'value' => 'Convert [content] to active voice',
'replaceText' => false,
'readOnly' => false,
),
);
$license_status = get_option( 'sage_ai_licenses_pro_status' );
$pro_plugin = 'ai-content-generator-pro/ai-content-generator-pro.php';
if ( false === $license_status && is_plugin_active( $pro_plugin ) ) {
$license_status = 'invalid';
}
$embeddings_settings = get_option( 'sage_ai_embeddings_settings' );
$settings_array = array(
'apiKey' => ! empty( $settings['api_key'] ) ? $settings['api_key'] : '',
'model' => ! empty( $settings['model'] ) ? $settings['model'] : 'text-davinci-003',
'temperature' => ! empty( $settings['temperature'] ) ? $settings['temperature'] : '0.7',
'max_tokens' => ! empty( $settings['max_tokens'] ) ? $settings['max_tokens'] : '700',
'top_p' => ! empty( $settings['top_p'] ) ? $settings['top_p'] : '1',
'best_of' => ! empty( $settings['best_of'] ) ? $settings['best_of'] : '1',
'frequency_penalty' => ! empty( $settings['frequency_penalty'] ) ? $settings['frequency_penalty'] : '0.01',
'presence_penalty' => ! empty( $settings['presence_penalty'] ) ? $settings['presence_penalty'] : '0.01',
'image_size' => ! empty( $settings['image_size'] ) ? $settings['image_size'] : '512x512',
'apiPageUrl' => $apiPageUrl,
'aiAssistantPrompts' => $aiAssistantPrompts,
'chatbotData' => $chatbot_data,
'sageAjaxUrl' => admin_url( 'admin-ajax.php' ),
'pluginUrl' => WP_SAGE_AI_URL,
'categories' => $post_categories,
'postTypes' => $post_types,
'pixabayApi' => ! empty( $settings['pixabay_api'] ) ? $settings['pixabay_api'] : '',
'taxonomies' => $taxonomies_data,
'adminUrl' => admin_url(),
'licenses' => array(
'pro' => $license_status,
),
'embeddingSettings' => $embeddings_settings,
);
$queued_jobs = sage_ai_get_bulk_queue_data_with_changes();
$processor = get_option( 'sage_ai_bulk_job_queue_processor' );
if ( empty( $queued_jobs ) ) {
$queued_jobs = array();
}
if ( empty( $processor['status'] ) ) {
$processor['status'] = 'completed';
}
$queue_data = array(
'queued_jobs' => $queued_jobs,
'processor' => $processor['status'],
);
?>
'api_key' )
);
add_settings_field(
'model',
'Model',
array( $this, 'model_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array( 'field' => 'model' )
);
add_settings_field(
'temperature',
'Temperature',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'temperature',
'default' => '0.7',
)
);
add_settings_field(
'max_tokens',
'Max tokens',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'max_tokens',
'default' => '700',
)
);
add_settings_field(
'top_p',
'Top P',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'top_p',
'default' => '1',
)
);
add_settings_field(
'best_of',
'Best Of',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'best_of',
'default' => '1',
)
);
add_settings_field(
'frequency_penalty',
'Frequency Penality',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'frequency_penalty',
'default' => '0.01',
)
);
add_settings_field(
'presence_penalty',
'Presence Penality',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'presence_penalty',
'default' => '0.01',
)
);
add_settings_field(
'image_size',
'Image Size',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_gen_settings_section',
array(
'field' => 'image_size',
'default' => '512x512',
)
);
add_settings_section(
'wp_ai_content_assistant_settings_section',
'',
array( $this, 'assistant_section_callback' ),
'wp_ai_content_gen_settings'
);
add_settings_field(
'ai_assistant_prompts',
'Assistant Prompts',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_assistant_settings_section',
array(
'field' => 'ai_assistant_prompts',
'default' => '',
)
);
add_settings_section(
'wp_ai_content_integrations_section',
'',
array( $this, 'integrations_section_callback' ),
'wp_ai_content_gen_settings'
);
add_settings_field(
'pixabay_api',
'Pixabay API Key',
array( $this, 'settings_field' ),
'wp_ai_content_gen_settings',
'wp_ai_content_integrations_section',
array(
'field' => 'pixabay_api',
)
);
// register settings
register_setting( 'wp_ai_content_gen_settings', 'wp_ai_content_gen_settings' );
}
public function section_callback() {
$url_active_tab = isset( $_GET['active-tab'] ) ? $_GET['active-tab'] : '';
?>
Settings
AI Assistant
Integrations
';
// closing section div;
return;
}
// Render the output
echo ' ';
if ( 'api_key' === $args['field'] ) {
echo ' Get API Key ';
}
if ( 'pixabay_api' === $args['field'] ) {
echo ' Get API Key ';
}
}
public function model_field() {
$options = get_option( 'wp_ai_content_gen_settings' );
$value = isset( $options['model'] ) ? $options['model'] : 'text-davinci-003';
?>
value="gpt-4-0125-preview" >gpt-4 turbo
value="gpt-4" > gpt-4
value="gpt-4-32k" >gpt-4-32k
value="gpt-3.5-turbo" > gpt-3.5-turbo
value="text-davinci-003" > text-davinci-003 (deprecated)
value="text-davinci-002" > text-davinci-002 (deprecated)
value="text-curie-001" > text-curie-001 (deprecated)
value="text-babbage-001" > text-babbage-001 (deprecated)
value="text-ada-001" > text-ada-001 (deprecated)
If you have any questions, please contact us at wpaicontent.com