Changeset 3237554
- Timestamp:
- 02/10/2025 03:42:07 AM (12 months ago)
- Location:
- ai-content-generation
- Files:
-
- 61 added
- 6 edited
-
tags/1.2.9 (added)
-
tags/1.2.9/assets (added)
-
tags/1.2.9/assets/css (added)
-
tags/1.2.9/assets/css/admin.css (added)
-
tags/1.2.9/assets/css/jquery-ui.css (added)
-
tags/1.2.9/assets/css/sweetalert2.min.css (added)
-
tags/1.2.9/assets/img (added)
-
tags/1.2.9/assets/img/Video.png (added)
-
tags/1.2.9/assets/img/icon.svg (added)
-
tags/1.2.9/assets/img/logo.png (added)
-
tags/1.2.9/assets/img/logo.svg (added)
-
tags/1.2.9/assets/js (added)
-
tags/1.2.9/assets/js/admin.js (added)
-
tags/1.2.9/assets/js/classic-editor.js (added)
-
tags/1.2.9/assets/js/post-generator.js (added)
-
tags/1.2.9/assets/js/seo.js (added)
-
tags/1.2.9/assets/js/showdown.min.js (added)
-
tags/1.2.9/assets/js/sweetalert2.all.min.js (added)
-
tags/1.2.9/assets/js/vue.global.js (added)
-
tags/1.2.9/assets/js/woocommerce.js (added)
-
tags/1.2.9/assets/js/wpwand-gutenberg.js (added)
-
tags/1.2.9/inc (added)
-
tags/1.2.9/inc/Finestics (added)
-
tags/1.2.9/inc/Finestics/Client.php (added)
-
tags/1.2.9/inc/Finestics/Insights.php (added)
-
tags/1.2.9/inc/WooCommerce.php (added)
-
tags/1.2.9/inc/admin.php (added)
-
tags/1.2.9/inc/api.php (added)
-
tags/1.2.9/inc/config.php (added)
-
tags/1.2.9/inc/data.php (added)
-
tags/1.2.9/inc/editor.php (added)
-
tags/1.2.9/inc/frontend.php (added)
-
tags/1.2.9/inc/gutenberg.php (added)
-
tags/1.2.9/inc/helper-functions.php (added)
-
tags/1.2.9/inc/modules (added)
-
tags/1.2.9/inc/modules/elementor (added)
-
tags/1.2.9/inc/modules/elementor/assets (added)
-
tags/1.2.9/inc/modules/elementor/assets/css (added)
-
tags/1.2.9/inc/modules/elementor/assets/css/editor.css (added)
-
tags/1.2.9/inc/modules/elementor/assets/css/jquery-ui.css (added)
-
tags/1.2.9/inc/modules/elementor/assets/img (added)
-
tags/1.2.9/inc/modules/elementor/assets/img/Video.png (added)
-
tags/1.2.9/inc/modules/elementor/assets/img/icon.png (added)
-
tags/1.2.9/inc/modules/elementor/assets/img/icon.svg (added)
-
tags/1.2.9/inc/modules/elementor/assets/js (added)
-
tags/1.2.9/inc/modules/elementor/assets/js/editor.js (added)
-
tags/1.2.9/inc/modules/elementor/assets/js/showdown.min.js (added)
-
tags/1.2.9/inc/modules/elementor/inc (added)
-
tags/1.2.9/inc/modules/elementor/inc/controls (added)
-
tags/1.2.9/inc/modules/elementor/inc/controls/text.php (added)
-
tags/1.2.9/inc/modules/elementor/inc/controls/textarea.php (added)
-
tags/1.2.9/inc/modules/elementor/inc/controls/wysiwyg.php (added)
-
tags/1.2.9/inc/modules/elementor/inc/elementor.php (added)
-
tags/1.2.9/inc/modules/elementor/readme.txt (added)
-
tags/1.2.9/inc/modules/elementor/wp-wand-elementor.php (added)
-
tags/1.2.9/inc/post-generator.php (added)
-
tags/1.2.9/inc/view (added)
-
tags/1.2.9/inc/view/post-generator.php (added)
-
tags/1.2.9/inc/white-label.php (added)
-
tags/1.2.9/readme.txt (added)
-
tags/1.2.9/wp-wand.php (added)
-
trunk/assets/js/wpwand-gutenberg.js (modified) (1 diff)
-
trunk/inc/admin.php (modified) (5 diffs)
-
trunk/inc/api.php (modified) (11 diffs)
-
trunk/inc/frontend.php (modified) (1 diff)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/wp-wand.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ai-content-generation/trunk/assets/js/wpwand-gutenberg.js
r3211354 r3237554 249 249 250 250 $(document).ready(function ($) { 251 let isEventBound = false; 252 251 253 wp.data.subscribe(function () { 252 254 if ('top' == wpwand_glb.toggler_positions && $('body').hasClass('block-editor-page')) { 253 254 255 if (!$('.edit-post-header-toolbar').find('.wpwand-trigger').length) { 255 256 256 $('.edit-post-header-toolbar').append('<a class="wpwand-trigger" href="#"><img src="' + wpwand_glb.logo + '">AI Assistant</a>') 257 258 257 } 259 258 } 260 259 if (0 == wpwand_glb.hide_ai_bar) { 261 262 260 if (!$('.editor-styles-wrapper').find('.wpwand-prompt-form').length) { 263 261 let prompt_form = '<div class="wpwand-prompt-form" id="wpwand-prompt-form"><div class="wpwand-dr-prompt-input"><img src="' + wpwand_glb.logo + '"> <a class="wpwand-ai-bar-hiw" href="https://wpwand.com/how-ai-assistant-work" target="_blank">See how it works</a> <input type="text" placeholder="Ask AI to write anything..."></div></div>'; 264 262 $('.editor-styles-wrapper').append(prompt_form); 265 263 266 267 $('#wpwand-prompt-form input').keypress(function (event) { 268 269 var keycode = (event.keyCode ? event.keyCode : event.which); 270 if (keycode == '13') { 271 const $this = $(this); 272 273 274 wpwand_prompt_ajax($this); 275 } 276 277 }); 278 } 279 } 280 281 264 // Only bind event if not already bound 265 if (!isEventBound) { 266 $(document).on('keydown', '#wpwand-prompt-form input', function(event) { 267 if (event.keyCode === 13 || event.which === 13) { 268 event.preventDefault(); 269 event.stopPropagation(); 270 const $this = $(this); 271 if ($this.val().trim()) { 272 wpwand_prompt_ajax($this); 273 } 274 return false; 275 } 276 }); 277 isEventBound = true; 278 } 279 } 280 } 282 281 }); 283 }) 282 }); 284 283 285 284 -
ai-content-generation/trunk/inc/admin.php
r3220881 r3237554 94 94 </td> 95 95 </tr> 96 <tr valign="top"> 97 <th scope="row"> 98 <label for="wpwand_deepseek_api_key"> 99 <?php esc_html_e('DeepSeek API Key', 'wp-wand'); ?> 100 <span class="wpwand-field-desc">Add your DeepSeek API key to activate 101 <?php echo esc_html(wpwand_brand_name()) ?> 102 </span> 103 </label> 104 </th> 105 <td class="wpwand-field"> 106 <input type="text" id="wpwand_deepseek_api_key" name="wpwand_deepseek_api_key" class="regular-text" 107 value="<?php echo esc_attr(wpwand_get_option('wpwand_deepseek_api_key')); ?>" /> 108 <div class="wpwand_api_key_status"> 109 110 <svg width="16" height="16" viewBox="0 0 16 16" fill="none" 111 xmlns="http://www.w3.org/2000/svg"> 112 <path fill-rule="evenodd" clip-rule="evenodd" 113 d="M8 16C12.4183 16 16 12.4183 16 8C16 3.58172 12.4183 0 8 0C3.58172 0 0 3.58172 0 8C0 12.4183 3.58172 16 8 16ZM11.7071 6.70711C12.0976 6.31658 12.0976 5.68342 11.7071 5.29289C11.3166 4.90237 10.6834 4.90237 10.2929 5.29289L7 8.58579L5.70711 7.29289C5.31658 6.90237 4.68342 6.90237 4.29289 7.29289C3.90237 7.68342 3.90237 8.31658 4.29289 8.70711L6.29289 10.7071C6.68342 11.0976 7.31658 11.0976 7.70711 10.7071L11.7071 6.70711Z" 114 fill="<?php echo esc_attr(WPWAND_DEEPSEEK_KEY) ? '#3BCB38' : '#D1D6DB' ?>" /> 115 </svg> 116 117 <span> 118 <?php printf($activate_text) // phpcs:ignore 119 ?> 120 </span> 121 </div> 122 </td> 123 </tr> 124 96 125 97 126 <?php if ((WPWAND_OPENAI_KEY) || (WPWAND_CLAUDE_KEY)): ?> … … 134 163 135 164 <?php endif; ?> 165 <?php if (WPWAND_DEEPSEEK_KEY): ?> 166 <optgroup label="DeepSeek Models"> 167 <option value="deepseek-reasoner" <?php selected(wpwand_get_option('wpwand_model', 'deepseek-reasoner'), 'deepseek-reasoner'); ?>> 168 <?php esc_html_e('DeepSeek Reasoner (R1)', 'wp-wand'); ?></option> 169 <option value="deepseek-chat" <?php selected(wpwand_get_option('wpwand_model', 'deepseek-chat'), 'deepseek-chat'); ?>> 170 <?php esc_html_e('DeepSeek Chat', 'wp-wand'); ?></option> 171 </optgroup> 172 173 <?php endif; ?> 136 174 </select> 137 175 </td> … … 321 359 ) 322 360 ); 361 register_setting( 362 'wpwand_settings_group', 363 'wpwand_deepseek_api_key', 364 array( 365 'type' => 'string', 366 'description' => esc_html__('DeepSeek API Key', 'wp-wand'), 367 'sanitize_callback' => 'sanitize_text_field', 368 'validate_callback' => 'wpwand_validate_deepseek_api_key', 369 ) 370 ); 323 371 324 372 … … 442 490 if (!preg_match('/^sk-/', $input)) { 443 491 add_settings_error('wpwand_api_key', 'wpwand_api_key_invalid', esc_html__('Invalid OpenAI API key format.', 'wp-wand')); 444 return get_option('wpwand_api_key');492 return wpwand_get_option('wpwand_api_key'); 445 493 } 446 494 … … 455 503 if (!preg_match('/^[a-zA-Z0-9_\-]+$/i', $input)) { 456 504 add_settings_error('wpwand_claude_api_key', 'wpwand_claude_api_key_invalid', esc_html__('Invalid Claude API key format.', 'wp-wand')); 457 return get_option('wpwand_claude_api_key');505 return wpwand_get_option('wpwand_claude_api_key'); 458 506 } 459 507 460 508 return $input; 461 509 } 510 511 /** 512 * Validate DeepSeek API Key 513 */ 514 function wpwand_validate_deepseek_api_key($input) 515 { 516 if (!preg_match('/^sk-/', $input)) { 517 add_settings_error('wpwand_deepseek_api_key', 'wpwand_deepseek_api_key_invalid', esc_html__('Invalid DeepSeek API key format.', 'wp-wand')); 518 return wpwand_get_option('wpwand_deepseek_api_key'); 519 } 520 521 return $input; 522 } 523 462 524 463 525 -
ai-content-generation/trunk/inc/api.php
r3220881 r3237554 61 61 foreach ($content->choices as $choice) { 62 62 $reply = isset($choice->message) ? $choice->message->content : $choice->text; 63 $reasoning_content = isset($choice->message->reasoning_content) ? $choice->message->reasoning_content : ''; 64 65 // <div class="wpwand-ai-reasoning"> 66 // ' . $reasoning_content . ' 67 // </div> 63 68 64 69 $text .= '<div class="wpwand-content"> 70 65 71 <button class="wpwand-copy-button" > 66 72 <svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"> … … 69 75 Copy to Clipboard 70 76 </button> 77 71 78 ' . $is_elementor . $is_gutenberg . '<div class="wpwand-ai-response">' . wpautop($reply) . ' 72 79 </div></div>'; … … 332 339 return 'claude'; 333 340 } 341 if ($model && strpos($model, 'deepseek') !== false) { 342 return 'deepseek'; 343 } 334 344 return 'openai'; 335 345 } … … 337 347 function wpwand_ai_error($error) 338 348 { 339 $source = isset($error->type) && strpos($error->type, 'claude') !== false ? 'claude' : 'openai';349 $source = isset($error->type) && strpos($error->type, 'claude') !== false ? 'claude' : (isset($error->type) && strpos($error->type, 'deepseek') !== false ? 'deepseek' : 'openai'); 340 350 $provider = ucfirst($source); 351 // if curl error then add server error / server is not responding 352 if (isset($error->message) && strpos($error->message, 'curl') !== false) { 353 return "{$provider} Error: Server is not responding"; 354 } 341 355 return "{$provider} Error: " . $error->message; 342 356 } 343 357 344 345 346 function wpwand_claude($prompt, $number_of_result = 1, $args = []) 358 /* 359 // deprecated 360 function wpwand_claude($prompt, $number_of_result = 1, $args = []) 347 361 { 348 362 try { … … 395 409 } 396 410 397 411 */ 398 412 399 413 function wpwand_openAi($prompt, $number_of_result = 1, $args = []) … … 445 459 array( 446 460 'role' => 'user', 447 'content' => "{$variation_prefix}{$prompt} You must write in {$args['language']}. {$args['biz_details']} {$args['targated_customer']} and don't add any other text"461 'content' => "{$variation_prefix}{$prompt} You must write in {$args['language']}. {$args['biz_details']} {$args['targated_customer']}" 448 462 ) 449 463 ), … … 484 498 } 485 499 500 function wpwand_generate_deepseek_content($prompt, $number_of_result, $args, $request_config) 501 { 502 $endpoint = 'https://api.deepseek.com/v1/chat/completions'; 503 504 505 return wpwand_generate_common_ai_content($endpoint, $prompt, $number_of_result, $args, $request_config); 506 } 507 486 508 function wpwand_generate_openai_content($prompt, $number_of_result, $args, $request_config) 487 509 { 488 510 $endpoint = 'https://api.openai.com/v1/chat/completions'; 489 $request_config['headers']['Authorization'] = 'Bearer ' . WPWAND_OPENAI_KEY; 490 491 $model = isset($args['model']) && !empty($args['model']) ? $args['model'] : 'gpt-3.5-turbo'; 511 512 513 514 /* $model = isset($args['model']) && !empty($args['model']) ? $args['model'] : 'gpt-3.5-turbo'; 492 515 $body = array( 493 516 'model' => $model, … … 518 541 if (isset($response_body->error)) { 519 542 throw new Exception($response_body->error->message); 520 } 521 522 return $response_body; 543 } */ 544 545 return wpwand_generate_common_ai_content($endpoint, $prompt, $number_of_result, $args, $request_config); 546 } 547 548 549 550 function wpwand_generate_common_ai_content($endpoint, $prompt, $number_of_result, $args, $request_config) 551 { 552 $model = isset($args['model']) && !empty($args['model']) ? $args['model'] : 'gpt-3.5-turbo'; 553 $request_config['headers']['Authorization'] = wpwand_api_source($model) == 'deepseek' ? 'Bearer ' . WPWAND_DEEPSEEK_KEY : 'Bearer ' . WPWAND_OPENAI_KEY; 554 555 // Base variations for multiple results 556 $variations = array( 557 "Provide a unique perspective on this: ", 558 "Give a different take on this topic: ", 559 "Approach this from another angle: ", 560 "Offer an alternative view on this: ", 561 "Present a fresh perspective on this: " 562 ); 563 564 $responses = array(); 565 566 // Make multiple requests for multiple results 567 for ($i = 0; $i < $number_of_result; $i++) { 568 // Add variation prefix for multiple results 569 $variation_prefix = $number_of_result > 1 ? ($variations[$i % count($variations)] ?? '') : ''; 570 571 $body = [ 572 'model' => $model, 573 'messages' => [ 574 [ 575 'role' => 'system', 576 'content' => "You are a professional content writer. You must follow the system instructions strictly." 577 ], 578 [ 579 'role' => 'system', 580 'content' => "You must write in {$args['language']}. {$args['biz_details']} {$args['targated_customer']}" 581 ], 582 [ 583 'role' => 'user', 584 'content' => "{$variation_prefix}{$prompt} . You must follow this instructions strictly. Don't add any other text/explanation/multiple results. Just write the content." 585 ] 586 ], 587 'temperature' => $args['temperature'] + ($i * 0.1), // Slightly vary temperature for diversity 588 'max_tokens' => $args['max_tokens'], 589 'frequency_penalty' => (float) wpwand_get_option('wpwand_frequency', 0), 590 'presence_penalty' => (float) wpwand_get_option('wpwand_presence_penalty', 0) 591 ]; 592 593 $response = wp_safe_remote_post($endpoint, array_merge( 594 $request_config, 595 array('body' => json_encode($body)) 596 )); 597 598 if (is_wp_error($response)) { 599 throw new Exception($response->get_error_message()); 600 } 601 602 $response_body = json_decode(wp_remote_retrieve_body($response)); 603 604 if (isset($response_body->error)) { 605 throw new Exception($response_body->error->message); 606 } 607 608 $responses[] = $response_body; 609 } 610 611 // Combine all responses into a single response object 612 $combined_response = new stdClass(); 613 $combined_response->choices = array(); 614 615 foreach ($responses as $resp) { 616 if (isset($resp->choices) && !empty($resp->choices)) { 617 $combined_response->choices[] = $resp->choices[0]; 618 } 619 } 620 621 return $combined_response; 523 622 } 524 623 … … 558 657 559 658 $is_claude = 'claude' === wpwand_api_source($args['model']); 659 $is_deepseek = 'deepseek' === wpwand_api_source($args['model']); 560 660 561 661 // Generate content based on the model type … … 566 666 throw new Exception('Claude API key is missing'); 567 667 } 668 } else if ($is_deepseek) { 669 if (WPWAND_DEEPSEEK_KEY && !empty(WPWAND_DEEPSEEK_KEY)) { 670 $response = wpwand_generate_deepseek_content($prompt, $number_of_result, $args, $request_config); 671 } else { 672 throw new Exception('DeepSeek API key is missing'); 673 } 568 674 } else { 569 675 if (WPWAND_OPENAI_KEY && !empty(WPWAND_OPENAI_KEY)) { … … 579 685 'error' => (object) [ 580 686 'message' => $e->getMessage(), 581 'type' => $is_claude ? 'claude_error' : 'openai_error',687 'type' => $is_claude ? 'claude_error' : ($is_deepseek ? 'deepseek_error' : 'openai_error'), 582 688 'code' => 500 583 689 ] -
ai-content-generation/trunk/inc/frontend.php
r3220881 r3237554 31 31 32 32 33 <?php if (!WPWAND_OPENAI_KEY && !WPWAND_CLAUDE_KEY ): ?>33 <?php if (!WPWAND_OPENAI_KEY && !WPWAND_CLAUDE_KEY && !WPWAND_DEEPSEEK_KEY): ?> 34 34 <!-- wp wand api missing notice --> 35 35 -
ai-content-generation/trunk/readme.txt
r3220882 r3237554 5 5 Requires at least: 5.0 6 6 Tested up to: 6.7.1 7 Stable Tag: 1.2. 87 Stable Tag: 1.2.9 8 8 License: GPL-2.0+ 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.txt … … 308 308 == Changelog == 309 309 310 = 1.2.9 = 311 * New: Deepseek R1 Added. 312 * New: Deepseek Chat Added. 313 * Fixed: Minor issues. 314 310 315 = 1.2.8 = 311 316 * New: Claude 3.5 Sonnet Added. -
ai-content-generation/trunk/wp-wand.php
r3220881 r3237554 5 5 * Plugin URI: https://wpwand.com/ 6 6 * Description: WP Wand is a AI content generation plugin for WordPress that helps your team create high quality content 10X faster and 50x cheaper. No monthly subscription required. 7 * Version: 1.2. 87 * Version: 1.2.9 8 8 * Author: WP Wand 9 9 * Author URI: https://wpwand.com/ … … 37 37 if (!defined('WPWAND_CLAUDE_KEY')) { 38 38 define('WPWAND_CLAUDE_KEY', get_option('wpwand_claude_api_key', false)); 39 } 40 if (!defined('WPWAND_DEEPSEEK_KEY')) { 41 define('WPWAND_DEEPSEEK_KEY', get_option('wpwand_deepseek_api_key', false)); 39 42 } 40 43 define('WPWAND_AI_CHARACTER', '');
Note: See TracChangeset
for help on using the changeset viewer.