Changeset 3179056
- Timestamp:
- 10/30/2024 06:28:44 PM (17 months ago)
- Location:
- seowriting
- Files:
-
- 3 edited
- 5 copied
-
tags/1.9.0 (copied) (copied from seowriting/trunk)
-
tags/1.9.0/assets/css/admin.css (copied) (copied from seowriting/trunk/assets/css/admin.css) (3 diffs)
-
tags/1.9.0/classes/settings-form.php (copied) (copied from seowriting/trunk/classes/settings-form.php)
-
tags/1.9.0/readme.txt (copied) (copied from seowriting/trunk/readme.txt) (2 diffs)
-
tags/1.9.0/seowriting.php (copied) (copied from seowriting/trunk/seowriting.php) (12 diffs)
-
trunk/assets/css/admin.css (modified) (3 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/seowriting.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
seowriting/tags/1.9.0/assets/css/admin.css
r3161934 r3179056 3 3 } 4 4 .seowriting-desc { 5 font-size: 12px;6 font-weight: normal;7 color: #7a919e;8 margin: 10px 0;9 line-height: 1.7;5 font-size: 12px; 6 font-weight: normal; 7 color: #7a919e; 8 margin: 10px 0; 9 line-height: 1.7; 10 10 } 11 11 .seowriting-desc+.seowriting-desc { 12 margin-top: -5px12 margin-top: -5px 13 13 } 14 14 .seowriting-wrap { … … 37 37 } 38 38 .conection-message{ 39 color: red;39 color: red; 40 40 } 41 41 .connected .conection-message{ 42 color: #25a32a;42 color: #25a32a; 43 43 } 44 44 #seowriting_conection_button{ 45 display: inline-block;45 display: inline-block; 46 46 padding: 2px 40px; 47 47 font-size: 18px; … … 71 71 .seowriting-table input { 72 72 max-width: 25rem; 73 width:100%;73 width:100%; 74 74 } 75 75 -
seowriting/tags/1.9.0/readme.txt
r3164954 r3179056 5 5 Requires at least: 4.9 6 6 Requires PHP: 5.6.20 7 Stable tag: 1. 8.77 Stable tag: 1.9.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 23 23 == Changelog == 24 24 25 = 1. 8.7 (2024/10/08) =25 = 1.9.0 (2024/10/30) = 26 26 27 27 Feature: 28 * Internal changes 29 30 = 1.8.6 (2024/10/03) = 31 32 Feature: 33 * Small UI update 34 35 = 1.8.5 (2024/10/01) = 36 37 Feature: 38 * Internal changes 28 * Publishing text with page type selection 39 29 40 30 = 1.8.4 (2024/09/04) = -
seowriting/tags/1.9.0/seowriting.php
r3164954 r3179056 9 9 * Plugin Name: SEOWriting 10 10 * Description: SEOWriting - AI Writing Tool Plugin For Text Generation 11 * Version: 1. 8.711 * Version: 1.9.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. 8.7';30 public $version = '1.9.0'; 31 31 /** 32 32 * @var \SEOWriting\APIClient|null … … 37 37 38 38 const SETTINGS_DEBUG_KEY = 'seowriting_debug'; 39 const SETTINGS_GENERATOR_NAME = 'seowriting'; 40 const SETTINGS_GENERATOR_NAME_KEY = 'seowriting_generator'; 39 41 const SETTINGS_KEY = 'seowriting_settings'; 40 42 const SETTINGS_PLUGIN_NAME_KEY = 'seowriting_plugin_name'; … … 105 107 add_action('requests-requests.before_parse', [$this, 'onAfterRequest'], 10, 6); 106 108 add_action('plugins_loaded', [$this, 'onPluginsLoaded']); 109 107 110 } 108 111 … … 469 472 'categories' => $this->getCategories(), 470 473 'authors' => $this->getAuthors(), 474 'types' => $this->getPostTypes(), 471 475 ]; 472 476 } elseif ($action === 'disconnect') { … … 516 520 'version' => $this->getVersion() 517 521 ]; 522 } elseif ($action === 'search_pages') { 523 $rs = [ 524 'result' => 1, 525 'pages' => $this->searchPages(sanitize_text_field($post['q']), isset($post['limit']) ? intval($post['limit']) : 10) 526 ]; 518 527 } else { 519 528 $rs = [ … … 779 788 private function publishPost($user_id, $data) 780 789 { 790 global $current_user; 791 781 792 $maxExecutionTime = (int)ini_get('max_execution_time'); 782 793 @set_time_limit(120); … … 803 814 $user_id = (int)$data['author_id']; 804 815 } 816 $current_user = new WP_User($user_id); 817 $post_type = isset($data['post_type']) ? $data['post_type'] : 'post'; 805 818 $new_post = [ 806 819 'post_title' => sanitize_text_field($data['theme']), … … 809 822 'post_date' => date('Y-m-d H:i:s', $post_time), 810 823 'post_author' => $user_id, 811 'post_type' => 'post', 812 'post_category' => $this->getPostCategory(isset($data['category']) ? sanitize_text_field($data['category']) : ''), 824 'post_type' => $post_type, 813 825 'post_excerpt' => isset($data['excerpt']) && (int)$data['excerpt'] === 1 814 826 ? (isset($data['description']) ? sanitize_text_field($data['description']) : '') … … 816 828 ]; 817 829 830 $taxonomies = get_object_taxonomies($post_type); 831 if (in_array('category', $taxonomies)) { 832 $new_post['post_category'] = $this->getPostCategory(isset($data['category']) ? sanitize_text_field($data['category']) : ''); 833 } else { 834 $ids = array_map('intval', explode(',', sanitize_text_field($data['category']))); 835 foreach ($ids as $id) { 836 $term = get_term($id); 837 if (!is_wp_error($term) && $term) { 838 /** @phpstan-ignore-next-line */ 839 $taxonomy_name = get_taxonomy($term->taxonomy)->labels->singular_name; 840 if (!isset($new_post['tax_input'])) { 841 $new_post['tax_input'] = []; 842 } 843 if (!isset($new_post['tax_input'][$taxonomy_name])) { 844 $new_post['tax_input'][$taxonomy_name] = []; 845 } 846 /** @phpstan-ignore-next-line */ 847 $new_post['tax_input'][$taxonomy_name][] = $term->name; 848 } 849 } 850 } 851 818 852 if (isset($data['post_slug'])) { 819 853 $slug = sanitize_title($data['post_slug']); 820 854 if (strlen($slug) > 0) { 821 855 $new_post['post_name'] = $slug; 856 } 857 } 858 859 if (isset($data['post_type']) && $data['post_type'] === 'page' && isset($data['parent_id'])) { 860 global $wpdb; 861 $new_post['post_parent'] = $data['parent_id']; 862 if (isset($data['sort_order'])) { 863 $new_post['menu_order'] = $data['sort_order']; 864 } else { 865 $sort_order = $wpdb->get_var($wpdb->prepare("select max(menu_order)+1 from $wpdb->posts where post_parent = %s", $data['parent_id'])); 866 if ($sort_order) { 867 $new_post['menu_order'] = $sort_order; 868 } 822 869 } 823 870 } … … 852 899 @set_time_limit($maxExecutionTime); 853 900 901 add_post_meta($post_id, self::SETTINGS_GENERATOR_NAME_KEY, self::SETTINGS_GENERATOR_NAME, true); 902 854 903 return [ 855 904 'result' => 1, … … 859 908 ]; 860 909 } 910 911 public function onSearchPages($where, $wp_query) 912 { 913 global $wpdb; 914 if ($search_term = $wp_query->get('post_title_like')) { 915 /** @phpstan-ignore-next-line */ 916 $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql($wpdb->esc_like($search_term)) . '%\''; 917 } 918 919 return $where; 920 } 921 922 /** 923 * @param string $query 924 * @param int $limit 925 */ 926 public function searchPages($query, $limit = 10) 927 { 928 if ($limit < 10) { 929 $limit = 10; 930 } 931 932 add_filter('posts_where', [$this, 'onSearchPages'], 10, 2); 933 $pages = new WP_Query([ 934 'post_type' => 'page', 935 'post_title_like' => $query, 936 'posts_per_page' => $limit, 937 'post_status' => 'publish', 938 ]); 939 remove_filter('posts_where', [$this, 'onSearchPages']); 940 941 $res = []; 942 if ($pages->have_posts()) { 943 while ($pages->have_posts()) { 944 $pages->the_post(); 945 $res[] = [ 946 'id' => get_the_ID(), 947 'title' => get_the_title(), 948 ]; 949 } 950 wp_reset_postdata(); 951 } 952 953 return $res; 954 } 955 861 956 862 957 public function getVersion() -
seowriting/trunk/assets/css/admin.css
r3161934 r3179056 3 3 } 4 4 .seowriting-desc { 5 font-size: 12px;6 font-weight: normal;7 color: #7a919e;8 margin: 10px 0;9 line-height: 1.7;5 font-size: 12px; 6 font-weight: normal; 7 color: #7a919e; 8 margin: 10px 0; 9 line-height: 1.7; 10 10 } 11 11 .seowriting-desc+.seowriting-desc { 12 margin-top: -5px12 margin-top: -5px 13 13 } 14 14 .seowriting-wrap { … … 37 37 } 38 38 .conection-message{ 39 color: red;39 color: red; 40 40 } 41 41 .connected .conection-message{ 42 color: #25a32a;42 color: #25a32a; 43 43 } 44 44 #seowriting_conection_button{ 45 display: inline-block;45 display: inline-block; 46 46 padding: 2px 40px; 47 47 font-size: 18px; … … 71 71 .seowriting-table input { 72 72 max-width: 25rem; 73 width:100%;73 width:100%; 74 74 } 75 75 -
seowriting/trunk/readme.txt
r3164954 r3179056 5 5 Requires at least: 4.9 6 6 Requires PHP: 5.6.20 7 Stable tag: 1. 8.77 Stable tag: 1.9.0 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 23 23 == Changelog == 24 24 25 = 1. 8.7 (2024/10/08) =25 = 1.9.0 (2024/10/30) = 26 26 27 27 Feature: 28 * Internal changes 29 30 = 1.8.6 (2024/10/03) = 31 32 Feature: 33 * Small UI update 34 35 = 1.8.5 (2024/10/01) = 36 37 Feature: 38 * Internal changes 28 * Publishing text with page type selection 39 29 40 30 = 1.8.4 (2024/09/04) = -
seowriting/trunk/seowriting.php
r3164954 r3179056 9 9 * Plugin Name: SEOWriting 10 10 * Description: SEOWriting - AI Writing Tool Plugin For Text Generation 11 * Version: 1. 8.711 * Version: 1.9.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. 8.7';30 public $version = '1.9.0'; 31 31 /** 32 32 * @var \SEOWriting\APIClient|null … … 37 37 38 38 const SETTINGS_DEBUG_KEY = 'seowriting_debug'; 39 const SETTINGS_GENERATOR_NAME = 'seowriting'; 40 const SETTINGS_GENERATOR_NAME_KEY = 'seowriting_generator'; 39 41 const SETTINGS_KEY = 'seowriting_settings'; 40 42 const SETTINGS_PLUGIN_NAME_KEY = 'seowriting_plugin_name'; … … 105 107 add_action('requests-requests.before_parse', [$this, 'onAfterRequest'], 10, 6); 106 108 add_action('plugins_loaded', [$this, 'onPluginsLoaded']); 109 107 110 } 108 111 … … 469 472 'categories' => $this->getCategories(), 470 473 'authors' => $this->getAuthors(), 474 'types' => $this->getPostTypes(), 471 475 ]; 472 476 } elseif ($action === 'disconnect') { … … 516 520 'version' => $this->getVersion() 517 521 ]; 522 } elseif ($action === 'search_pages') { 523 $rs = [ 524 'result' => 1, 525 'pages' => $this->searchPages(sanitize_text_field($post['q']), isset($post['limit']) ? intval($post['limit']) : 10) 526 ]; 518 527 } else { 519 528 $rs = [ … … 779 788 private function publishPost($user_id, $data) 780 789 { 790 global $current_user; 791 781 792 $maxExecutionTime = (int)ini_get('max_execution_time'); 782 793 @set_time_limit(120); … … 803 814 $user_id = (int)$data['author_id']; 804 815 } 816 $current_user = new WP_User($user_id); 817 $post_type = isset($data['post_type']) ? $data['post_type'] : 'post'; 805 818 $new_post = [ 806 819 'post_title' => sanitize_text_field($data['theme']), … … 809 822 'post_date' => date('Y-m-d H:i:s', $post_time), 810 823 'post_author' => $user_id, 811 'post_type' => 'post', 812 'post_category' => $this->getPostCategory(isset($data['category']) ? sanitize_text_field($data['category']) : ''), 824 'post_type' => $post_type, 813 825 'post_excerpt' => isset($data['excerpt']) && (int)$data['excerpt'] === 1 814 826 ? (isset($data['description']) ? sanitize_text_field($data['description']) : '') … … 816 828 ]; 817 829 830 $taxonomies = get_object_taxonomies($post_type); 831 if (in_array('category', $taxonomies)) { 832 $new_post['post_category'] = $this->getPostCategory(isset($data['category']) ? sanitize_text_field($data['category']) : ''); 833 } else { 834 $ids = array_map('intval', explode(',', sanitize_text_field($data['category']))); 835 foreach ($ids as $id) { 836 $term = get_term($id); 837 if (!is_wp_error($term) && $term) { 838 /** @phpstan-ignore-next-line */ 839 $taxonomy_name = get_taxonomy($term->taxonomy)->labels->singular_name; 840 if (!isset($new_post['tax_input'])) { 841 $new_post['tax_input'] = []; 842 } 843 if (!isset($new_post['tax_input'][$taxonomy_name])) { 844 $new_post['tax_input'][$taxonomy_name] = []; 845 } 846 /** @phpstan-ignore-next-line */ 847 $new_post['tax_input'][$taxonomy_name][] = $term->name; 848 } 849 } 850 } 851 818 852 if (isset($data['post_slug'])) { 819 853 $slug = sanitize_title($data['post_slug']); 820 854 if (strlen($slug) > 0) { 821 855 $new_post['post_name'] = $slug; 856 } 857 } 858 859 if (isset($data['post_type']) && $data['post_type'] === 'page' && isset($data['parent_id'])) { 860 global $wpdb; 861 $new_post['post_parent'] = $data['parent_id']; 862 if (isset($data['sort_order'])) { 863 $new_post['menu_order'] = $data['sort_order']; 864 } else { 865 $sort_order = $wpdb->get_var($wpdb->prepare("select max(menu_order)+1 from $wpdb->posts where post_parent = %s", $data['parent_id'])); 866 if ($sort_order) { 867 $new_post['menu_order'] = $sort_order; 868 } 822 869 } 823 870 } … … 852 899 @set_time_limit($maxExecutionTime); 853 900 901 add_post_meta($post_id, self::SETTINGS_GENERATOR_NAME_KEY, self::SETTINGS_GENERATOR_NAME, true); 902 854 903 return [ 855 904 'result' => 1, … … 859 908 ]; 860 909 } 910 911 public function onSearchPages($where, $wp_query) 912 { 913 global $wpdb; 914 if ($search_term = $wp_query->get('post_title_like')) { 915 /** @phpstan-ignore-next-line */ 916 $where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql($wpdb->esc_like($search_term)) . '%\''; 917 } 918 919 return $where; 920 } 921 922 /** 923 * @param string $query 924 * @param int $limit 925 */ 926 public function searchPages($query, $limit = 10) 927 { 928 if ($limit < 10) { 929 $limit = 10; 930 } 931 932 add_filter('posts_where', [$this, 'onSearchPages'], 10, 2); 933 $pages = new WP_Query([ 934 'post_type' => 'page', 935 'post_title_like' => $query, 936 'posts_per_page' => $limit, 937 'post_status' => 'publish', 938 ]); 939 remove_filter('posts_where', [$this, 'onSearchPages']); 940 941 $res = []; 942 if ($pages->have_posts()) { 943 while ($pages->have_posts()) { 944 $pages->the_post(); 945 $res[] = [ 946 'id' => get_the_ID(), 947 'title' => get_the_title(), 948 ]; 949 } 950 wp_reset_postdata(); 951 } 952 953 return $res; 954 } 955 861 956 862 957 public function getVersion()
Note: See TracChangeset
for help on using the changeset viewer.