Changeset 3112420
- Timestamp:
- 07/04/2024 11:42:22 AM (21 months ago)
- Location:
- seowriting
- Files:
-
- 5 edited
- 11 copied
-
tags/1.7.0 (copied) (copied from seowriting/trunk)
-
tags/1.7.0/assets (copied) (copied from seowriting/trunk/assets)
-
tags/1.7.0/assets/js/settings.js (modified) (2 diffs)
-
tags/1.7.0/classes (copied) (copied from seowriting/trunk/classes)
-
tags/1.7.0/classes/api-client.php (copied) (copied from seowriting/trunk/classes/api-client.php) (2 diffs)
-
tags/1.7.0/classes/post-meta.php (copied) (copied from seowriting/trunk/classes/post-meta.php)
-
tags/1.7.0/readme.txt (copied) (copied from seowriting/trunk/readme.txt) (2 diffs)
-
tags/1.7.0/seowriting.php (copied) (copied from seowriting/trunk/seowriting.php) (12 diffs)
-
tags/1.7.0/tpl (copied) (copied from seowriting/trunk/tpl)
-
tags/1.7.0/tpl/settings/settings.tpl.php (copied) (copied from seowriting/trunk/tpl/settings/settings.tpl.php)
-
tags/1.7.0/uninstall.php (copied) (copied from seowriting/trunk/uninstall.php)
-
tags/1.7.0/utils.php (copied) (copied from seowriting/trunk/utils.php)
-
trunk/assets/js/settings.js (modified) (2 diffs)
-
trunk/classes/api-client.php (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/seowriting.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seowriting/tags/1.7.0/assets/js/settings.js
r3056072 r3112420 75 75 if (d.success) { 76 76 if ('auth_url' in d) { 77 window.location.assign(d.auth_url); 77 var a = document.createElement('a'); 78 a.href = d.auth_url; 79 a.target = '_blank'; 80 a.dispatchEvent(new MouseEvent('click', { 81 view: window, 82 bubbles: true, 83 cancelable: true 84 })); 85 //window.location.assign(d.auth_url); 78 86 } 79 87 else { … … 83 91 } 84 92 } 85 if(type == 'disconnect'){93 if(type === 'disconnect'){ 86 94 disableBtn(conection_button, false); 87 95 $('.conection-blok').removeClass('connected'); -
seowriting/tags/1.7.0/classes/api-client.php
r3056086 r3112420 79 79 80 80 return wp_remote_request($url, $args); 81 } 82 83 /** 84 * @param string $newVersion 85 * @return bool 86 */ 87 public function update($newVersion) 88 { 89 $settings = $this->plugin->getSettings(); 90 $this->request('update', [ 91 'api_key' => $settings['api_key'], 92 'new_version' => $newVersion, 93 ]); 94 95 return true; 81 96 } 82 97 … … 132 147 'error' => $this->error, 133 148 ]; 149 } 150 151 /** 152 * @param $status string 153 * @param $data 154 */ 155 public function changePostStatus($status, $data) 156 { 157 return $this->request('post_' . $status, $data); 134 158 } 135 159 -
seowriting/tags/1.7.0/readme.txt
r3102248 r3112420 5 5 Requires at least: 4.9 6 6 Requires PHP: 5.6.20 7 Stable tag: 1. 6.27 Stable tag: 1.7.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 22 22 23 23 == Changelog == 24 25 = 1.7.0 (2024/07/04) = 26 27 Feature: 28 * Export posts to create knowledge base. 29 * Authorization on the [https://seowriting.ai/](https://seowriting.ai/?utm_source=wp_plugin_changelog) website is performed in a new tab. 24 30 25 31 = 1.6.2 (2024/06/13) = -
seowriting/tags/1.7.0/seowriting.php
r3102248 r3112420 9 9 * Plugin Name: SEOWriting 10 10 * Description: SEOWriting - AI Writing Tool Plugin For Text Generation 11 * Version: 1. 6.211 * Version: 1.7.0 12 12 * Author: SEOWriting 13 13 * Author URI: https://seowriting.ai/?utm_source=wp_plugin … … 28 28 public $plugin_slug; 29 29 public $plugin_path; 30 public $version = '1. 6.2';30 public $version = '1.7.0'; 31 31 /** 32 32 * @var \SEOWriting\APIClient|null … … 43 43 const SCHEMA_TYPE_MICRODATA = 'microdata'; 44 44 const SCHEMA_TYPE_OFF = 'off'; 45 46 const SEOWRITING_PHP = 'seowriting.php'; 45 47 46 48 public function __construct() … … 83 85 if (is_admin()) { 84 86 $this->adminPages(); 85 add_filter('plugin_action_links_' . plugin_basename($this->plugin_path . 'seowriting.php'), [$this, 'adminSettingsLink']);87 add_filter('plugin_action_links_' . plugin_basename($this->plugin_path . self::SEOWRITING_PHP), [$this, 'adminSettingsLink']); 86 88 87 89 register_deactivation_hook(__FILE__, [$this, 'deactivate']); … … 98 100 add_filter('the_content', [$this, 'restoreSchemaSection'], 20); 99 101 add_action("wp_head", [$this, 'printJSONLD'], 20); 102 103 add_action('transition_post_status', [$this, 'onChangePostStatus'], 10, 3); 104 add_action('upgrader_process_complete', [$this, 'onUpdate'], 10, 2); 105 106 } 107 108 /** 109 * @param $new_status string 110 * @param $old_status string 111 * @param $post WP_Post 112 * @return bool 113 */ 114 public function onChangePostStatus($new_status, $old_status, $post) 115 { 116 $status = ''; 117 if ( 118 ($old_status === 'auto-draft' && $new_status === 'publish') 119 || ($old_status === 'pending' && $new_status === 'publish') 120 || ($old_status === 'draft' && $new_status === 'publish') 121 || ($old_status === 'publish' && $new_status === 'publish') 122 ) { 123 $status = 'update'; 124 } else if ( 125 ($old_status === 'publish' && $new_status === 'pending') 126 || ($old_status === 'publish' && $new_status === 'draft') 127 || ($old_status === 'publish' && $new_status === 'trash') 128 ) { 129 $status = 'delete'; 130 } 131 if ($status === '') { 132 return false; 133 } 134 $settings = $this->getSettings(); 135 $this->getAPIClient()->changePostStatus($status, [ 136 'post_id' => $post->ID, 137 'api_key' => $settings['api_key'], 138 ]); 139 140 return true; 141 } 142 143 /** 144 * @param $upgrader_object 145 * @param $options 146 * @return bool 147 */ 148 public function onUpdate($upgrader_object, $options) 149 { 150 return $this->getAPIClient()->update($this->version); 100 151 } 101 152 … … 369 420 'authors' => $this->getAuthors() 370 421 ]; 422 } elseif ($action === 'get_posts') { 423 $rs = [ 424 'result' => 1, 425 'posts' => $this->getPosts() 426 ]; 427 } elseif ($action === 'get_post') { 428 $rs = [ 429 'result' => 1, 430 'post' => $this->getPost(isset($post['post_id']) ? sanitize_text_field($post['post_id']) : '') 431 ]; 432 } elseif ($action === 'get_version') { 433 $rs = [ 434 'result' => 1, 435 'version' => $this->getVersion() 436 ]; 371 437 } else { 372 438 $rs = [ … … 379 445 } 380 446 return null; 447 } 448 449 private function isDisabledSchema() 450 { 451 return get_option('sw_shema_type') === self::SCHEMA_TYPE_OFF; 381 452 } 382 453 … … 405 476 406 477 return $content; 407 }408 409 /**410 * @return bool411 */412 private function isDisabledSchema()413 {414 return get_option('sw_shema_type') === self::SCHEMA_TYPE_OFF;415 478 } 416 479 … … 515 578 516 579 $isDisabled = !$this->isMicrodataSchema() && $this->isDisabledSchema(); 517 $out = '<section' .($isDisabled ? '' : ' itemscope itemtype="https://schema.org/FAQPage"').'>';580 $out = '<section' . ($isDisabled ? '' : ' itemscope itemtype="https://schema.org/FAQPage"') . '>'; 518 581 $out .= '<h2>' . $title . '</h2>'; 519 582 for ($i = 0; $i < $count; $i++) { 520 583 if (isset($answers[$i]) && isset($questions[$i])) { 521 $out .= '<div' .($isDisabled ? '' : ' itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"').'>'522 . '<h3' .($isDisabled ? '' : ' itemprop="name"').'>' . $questions[$i] . '</h3>'523 . '<div' .($isDisabled ? '' : ' itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"').'>'524 . '<div' .($isDisabled ? '' : ' itemprop="text"').'>' . $answers[$i] . '</div>'584 $out .= '<div' . ($isDisabled ? '' : ' itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"') . '>' 585 . '<h3' . ($isDisabled ? '' : ' itemprop="name"') . '>' . $questions[$i] . '</h3>' 586 . '<div' . ($isDisabled ? '' : ' itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"') . '>' 587 . '<div' . ($isDisabled ? '' : ' itemprop="text"') . '>' . $answers[$i] . '</div>' 525 588 . '</div>' 526 589 . '</div>'; … … 715 778 } 716 779 780 public function getVersion() 781 { 782 return $this->version; 783 } 784 785 public function getPost($post_id) 786 { 787 $post = get_post($post_id); 788 if (!$post || !($post instanceof WP_Post) || $post->post_status !== 'publish') { 789 return false; 790 } 791 return [ 792 'id' => (int)$post->ID, 793 'content' => $post->post_content, 794 'title' => $post->post_title, 795 'url' => get_permalink($post->ID), 796 ]; 797 } 798 799 public function getPosts() 800 { 801 $pages = get_pages(); 802 $posts = array_merge(get_posts([ 803 'numberposts' => -1, 804 'post_type' => 'post', 805 ]), $pages === false ? [] : $pages); 806 807 $result = []; 808 foreach ($posts as $post) { 809 if (!($post instanceof WP_Post) || $post->post_status !== 'publish') { 810 continue; 811 } 812 /** @var WP_Post $post */ 813 $result[] = [ 814 'id' => (int)$post->ID, 815 'content' => $post->post_content, 816 'title' => $post->post_title, 817 'url' => get_permalink($post->ID), 818 ]; 819 } 820 821 return $result; 822 } 823 717 824 /** 718 825 * @return array<array<string, int|string>> … … 749 856 ]); 750 857 751 $ array= [];858 $result = []; 752 859 foreach ($categories as $category) { 753 860 /** @var WP_Term $category */ 754 $ array[] = [861 $result[] = [ 755 862 'id' => (int)$category->term_id, 756 863 'name' => $category->name, … … 759 866 } 760 867 761 return $ array;868 return $result; 762 869 } 763 870 -
seowriting/trunk/assets/js/settings.js
r3056072 r3112420 75 75 if (d.success) { 76 76 if ('auth_url' in d) { 77 window.location.assign(d.auth_url); 77 var a = document.createElement('a'); 78 a.href = d.auth_url; 79 a.target = '_blank'; 80 a.dispatchEvent(new MouseEvent('click', { 81 view: window, 82 bubbles: true, 83 cancelable: true 84 })); 85 //window.location.assign(d.auth_url); 78 86 } 79 87 else { … … 83 91 } 84 92 } 85 if(type == 'disconnect'){93 if(type === 'disconnect'){ 86 94 disableBtn(conection_button, false); 87 95 $('.conection-blok').removeClass('connected'); -
seowriting/trunk/classes/api-client.php
r3056086 r3112420 79 79 80 80 return wp_remote_request($url, $args); 81 } 82 83 /** 84 * @param string $newVersion 85 * @return bool 86 */ 87 public function update($newVersion) 88 { 89 $settings = $this->plugin->getSettings(); 90 $this->request('update', [ 91 'api_key' => $settings['api_key'], 92 'new_version' => $newVersion, 93 ]); 94 95 return true; 81 96 } 82 97 … … 132 147 'error' => $this->error, 133 148 ]; 149 } 150 151 /** 152 * @param $status string 153 * @param $data 154 */ 155 public function changePostStatus($status, $data) 156 { 157 return $this->request('post_' . $status, $data); 134 158 } 135 159 -
seowriting/trunk/readme.txt
r3102248 r3112420 5 5 Requires at least: 4.9 6 6 Requires PHP: 5.6.20 7 Stable tag: 1. 6.27 Stable tag: 1.7.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 22 22 23 23 == Changelog == 24 25 = 1.7.0 (2024/07/04) = 26 27 Feature: 28 * Export posts to create knowledge base. 29 * Authorization on the [https://seowriting.ai/](https://seowriting.ai/?utm_source=wp_plugin_changelog) website is performed in a new tab. 24 30 25 31 = 1.6.2 (2024/06/13) = -
seowriting/trunk/seowriting.php
r3102248 r3112420 9 9 * Plugin Name: SEOWriting 10 10 * Description: SEOWriting - AI Writing Tool Plugin For Text Generation 11 * Version: 1. 6.211 * Version: 1.7.0 12 12 * Author: SEOWriting 13 13 * Author URI: https://seowriting.ai/?utm_source=wp_plugin … … 28 28 public $plugin_slug; 29 29 public $plugin_path; 30 public $version = '1. 6.2';30 public $version = '1.7.0'; 31 31 /** 32 32 * @var \SEOWriting\APIClient|null … … 43 43 const SCHEMA_TYPE_MICRODATA = 'microdata'; 44 44 const SCHEMA_TYPE_OFF = 'off'; 45 46 const SEOWRITING_PHP = 'seowriting.php'; 45 47 46 48 public function __construct() … … 83 85 if (is_admin()) { 84 86 $this->adminPages(); 85 add_filter('plugin_action_links_' . plugin_basename($this->plugin_path . 'seowriting.php'), [$this, 'adminSettingsLink']);87 add_filter('plugin_action_links_' . plugin_basename($this->plugin_path . self::SEOWRITING_PHP), [$this, 'adminSettingsLink']); 86 88 87 89 register_deactivation_hook(__FILE__, [$this, 'deactivate']); … … 98 100 add_filter('the_content', [$this, 'restoreSchemaSection'], 20); 99 101 add_action("wp_head", [$this, 'printJSONLD'], 20); 102 103 add_action('transition_post_status', [$this, 'onChangePostStatus'], 10, 3); 104 add_action('upgrader_process_complete', [$this, 'onUpdate'], 10, 2); 105 106 } 107 108 /** 109 * @param $new_status string 110 * @param $old_status string 111 * @param $post WP_Post 112 * @return bool 113 */ 114 public function onChangePostStatus($new_status, $old_status, $post) 115 { 116 $status = ''; 117 if ( 118 ($old_status === 'auto-draft' && $new_status === 'publish') 119 || ($old_status === 'pending' && $new_status === 'publish') 120 || ($old_status === 'draft' && $new_status === 'publish') 121 || ($old_status === 'publish' && $new_status === 'publish') 122 ) { 123 $status = 'update'; 124 } else if ( 125 ($old_status === 'publish' && $new_status === 'pending') 126 || ($old_status === 'publish' && $new_status === 'draft') 127 || ($old_status === 'publish' && $new_status === 'trash') 128 ) { 129 $status = 'delete'; 130 } 131 if ($status === '') { 132 return false; 133 } 134 $settings = $this->getSettings(); 135 $this->getAPIClient()->changePostStatus($status, [ 136 'post_id' => $post->ID, 137 'api_key' => $settings['api_key'], 138 ]); 139 140 return true; 141 } 142 143 /** 144 * @param $upgrader_object 145 * @param $options 146 * @return bool 147 */ 148 public function onUpdate($upgrader_object, $options) 149 { 150 return $this->getAPIClient()->update($this->version); 100 151 } 101 152 … … 369 420 'authors' => $this->getAuthors() 370 421 ]; 422 } elseif ($action === 'get_posts') { 423 $rs = [ 424 'result' => 1, 425 'posts' => $this->getPosts() 426 ]; 427 } elseif ($action === 'get_post') { 428 $rs = [ 429 'result' => 1, 430 'post' => $this->getPost(isset($post['post_id']) ? sanitize_text_field($post['post_id']) : '') 431 ]; 432 } elseif ($action === 'get_version') { 433 $rs = [ 434 'result' => 1, 435 'version' => $this->getVersion() 436 ]; 371 437 } else { 372 438 $rs = [ … … 379 445 } 380 446 return null; 447 } 448 449 private function isDisabledSchema() 450 { 451 return get_option('sw_shema_type') === self::SCHEMA_TYPE_OFF; 381 452 } 382 453 … … 405 476 406 477 return $content; 407 }408 409 /**410 * @return bool411 */412 private function isDisabledSchema()413 {414 return get_option('sw_shema_type') === self::SCHEMA_TYPE_OFF;415 478 } 416 479 … … 515 578 516 579 $isDisabled = !$this->isMicrodataSchema() && $this->isDisabledSchema(); 517 $out = '<section' .($isDisabled ? '' : ' itemscope itemtype="https://schema.org/FAQPage"').'>';580 $out = '<section' . ($isDisabled ? '' : ' itemscope itemtype="https://schema.org/FAQPage"') . '>'; 518 581 $out .= '<h2>' . $title . '</h2>'; 519 582 for ($i = 0; $i < $count; $i++) { 520 583 if (isset($answers[$i]) && isset($questions[$i])) { 521 $out .= '<div' .($isDisabled ? '' : ' itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"').'>'522 . '<h3' .($isDisabled ? '' : ' itemprop="name"').'>' . $questions[$i] . '</h3>'523 . '<div' .($isDisabled ? '' : ' itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"').'>'524 . '<div' .($isDisabled ? '' : ' itemprop="text"').'>' . $answers[$i] . '</div>'584 $out .= '<div' . ($isDisabled ? '' : ' itemscope itemprop="mainEntity" itemtype="https://schema.org/Question"') . '>' 585 . '<h3' . ($isDisabled ? '' : ' itemprop="name"') . '>' . $questions[$i] . '</h3>' 586 . '<div' . ($isDisabled ? '' : ' itemscope itemprop="acceptedAnswer" itemtype="https://schema.org/Answer"') . '>' 587 . '<div' . ($isDisabled ? '' : ' itemprop="text"') . '>' . $answers[$i] . '</div>' 525 588 . '</div>' 526 589 . '</div>'; … … 715 778 } 716 779 780 public function getVersion() 781 { 782 return $this->version; 783 } 784 785 public function getPost($post_id) 786 { 787 $post = get_post($post_id); 788 if (!$post || !($post instanceof WP_Post) || $post->post_status !== 'publish') { 789 return false; 790 } 791 return [ 792 'id' => (int)$post->ID, 793 'content' => $post->post_content, 794 'title' => $post->post_title, 795 'url' => get_permalink($post->ID), 796 ]; 797 } 798 799 public function getPosts() 800 { 801 $pages = get_pages(); 802 $posts = array_merge(get_posts([ 803 'numberposts' => -1, 804 'post_type' => 'post', 805 ]), $pages === false ? [] : $pages); 806 807 $result = []; 808 foreach ($posts as $post) { 809 if (!($post instanceof WP_Post) || $post->post_status !== 'publish') { 810 continue; 811 } 812 /** @var WP_Post $post */ 813 $result[] = [ 814 'id' => (int)$post->ID, 815 'content' => $post->post_content, 816 'title' => $post->post_title, 817 'url' => get_permalink($post->ID), 818 ]; 819 } 820 821 return $result; 822 } 823 717 824 /** 718 825 * @return array<array<string, int|string>> … … 749 856 ]); 750 857 751 $ array= [];858 $result = []; 752 859 foreach ($categories as $category) { 753 860 /** @var WP_Term $category */ 754 $ array[] = [861 $result[] = [ 755 862 'id' => (int)$category->term_id, 756 863 'name' => $category->name, … … 759 866 } 760 867 761 return $ array;868 return $result; 762 869 } 763 870
Note: See TracChangeset
for help on using the changeset viewer.