Plugin Directory

Changeset 3179056


Ignore:
Timestamp:
10/30/2024 06:28:44 PM (17 months ago)
Author:
seowriting
Message:

New version of plugin: 1.9.0

Location:
seowriting
Files:
3 edited
5 copied

Legend:

Unmodified
Added
Removed
  • seowriting/tags/1.9.0/assets/css/admin.css

    r3161934 r3179056  
    33}
    44.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;
    1010}
    1111.seowriting-desc+.seowriting-desc {
    12     margin-top: -5px
     12    margin-top: -5px
    1313}
    1414.seowriting-wrap {
     
    3737}
    3838.conection-message{
    39     color: red;
     39    color: red;
    4040}
    4141.connected .conection-message{
    42     color: #25a32a;
     42    color: #25a32a;
    4343}
    4444#seowriting_conection_button{
    45     display: inline-block;
     45    display: inline-block;
    4646    padding: 2px 40px;
    4747    font-size: 18px;
     
    7171.seowriting-table input {
    7272    max-width: 25rem;
    73     width:100%;
     73    width:100%;
    7474}
    7575
  • seowriting/tags/1.9.0/readme.txt

    r3164954 r3179056  
    55Requires at least: 4.9
    66Requires PHP: 5.6.20
    7 Stable tag: 1.8.7
     7Stable tag: 1.9.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2323== Changelog ==
    2424
    25 = 1.8.7 (2024/10/08) =
     25= 1.9.0 (2024/10/30) =
    2626
    2727Feature:
    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
    3929
    4030= 1.8.4 (2024/09/04) =
  • seowriting/tags/1.9.0/seowriting.php

    r3164954 r3179056  
    99 * Plugin Name:       SEOWriting
    1010 * Description:       SEOWriting - AI Writing Tool Plugin For Text Generation
    11  * Version:           1.8.7
     11 * Version:           1.9.0
    1212 * Author:            SEOWriting
    1313 * Author URI:        https://seowriting.ai/?utm_source=wp_plugin
     
    2828        public $plugin_slug;
    2929        public $plugin_path;
    30         public $version = '1.8.7';
     30        public $version = '1.9.0';
    3131        /**
    3232         * @var \SEOWriting\APIClient|null
     
    3737
    3838        const SETTINGS_DEBUG_KEY = 'seowriting_debug';
     39        const SETTINGS_GENERATOR_NAME = 'seowriting';
     40        const SETTINGS_GENERATOR_NAME_KEY = 'seowriting_generator';
    3941        const SETTINGS_KEY = 'seowriting_settings';
    4042        const SETTINGS_PLUGIN_NAME_KEY = 'seowriting_plugin_name';
     
    105107            add_action('requests-requests.before_parse', [$this, 'onAfterRequest'], 10, 6);
    106108            add_action('plugins_loaded', [$this, 'onPluginsLoaded']);
     109
    107110        }
    108111
     
    469472                            'categories' => $this->getCategories(),
    470473                            'authors' => $this->getAuthors(),
     474                            'types' => $this->getPostTypes(),
    471475                        ];
    472476                    } elseif ($action === 'disconnect') {
     
    516520                            'version' => $this->getVersion()
    517521                        ];
     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                        ];
    518527                    } else {
    519528                        $rs = [
     
    779788        private function publishPost($user_id, $data)
    780789        {
     790            global $current_user;
     791
    781792            $maxExecutionTime = (int)ini_get('max_execution_time');
    782793            @set_time_limit(120);
     
    803814                $user_id = (int)$data['author_id'];
    804815            }
     816            $current_user = new WP_User($user_id);
     817            $post_type = isset($data['post_type']) ? $data['post_type'] : 'post';
    805818            $new_post = [
    806819                'post_title' => sanitize_text_field($data['theme']),
     
    809822                'post_date' => date('Y-m-d H:i:s', $post_time),
    810823                '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,
    813825                'post_excerpt' => isset($data['excerpt']) && (int)$data['excerpt'] === 1
    814826                    ? (isset($data['description']) ? sanitize_text_field($data['description']) : '')
     
    816828            ];
    817829
     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
    818852            if (isset($data['post_slug'])) {
    819853                $slug = sanitize_title($data['post_slug']);
    820854                if (strlen($slug) > 0) {
    821855                    $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                    }
    822869                }
    823870            }
     
    852899            @set_time_limit($maxExecutionTime);
    853900
     901            add_post_meta($post_id, self::SETTINGS_GENERATOR_NAME_KEY, self::SETTINGS_GENERATOR_NAME, true);
     902
    854903            return [
    855904                'result' => 1,
     
    859908            ];
    860909        }
     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
    861956
    862957        public function getVersion()
  • seowriting/trunk/assets/css/admin.css

    r3161934 r3179056  
    33}
    44.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;
    1010}
    1111.seowriting-desc+.seowriting-desc {
    12     margin-top: -5px
     12    margin-top: -5px
    1313}
    1414.seowriting-wrap {
     
    3737}
    3838.conection-message{
    39     color: red;
     39    color: red;
    4040}
    4141.connected .conection-message{
    42     color: #25a32a;
     42    color: #25a32a;
    4343}
    4444#seowriting_conection_button{
    45     display: inline-block;
     45    display: inline-block;
    4646    padding: 2px 40px;
    4747    font-size: 18px;
     
    7171.seowriting-table input {
    7272    max-width: 25rem;
    73     width:100%;
     73    width:100%;
    7474}
    7575
  • seowriting/trunk/readme.txt

    r3164954 r3179056  
    55Requires at least: 4.9
    66Requires PHP: 5.6.20
    7 Stable tag: 1.8.7
     7Stable tag: 1.9.0
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    2323== Changelog ==
    2424
    25 = 1.8.7 (2024/10/08) =
     25= 1.9.0 (2024/10/30) =
    2626
    2727Feature:
    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
    3929
    4030= 1.8.4 (2024/09/04) =
  • seowriting/trunk/seowriting.php

    r3164954 r3179056  
    99 * Plugin Name:       SEOWriting
    1010 * Description:       SEOWriting - AI Writing Tool Plugin For Text Generation
    11  * Version:           1.8.7
     11 * Version:           1.9.0
    1212 * Author:            SEOWriting
    1313 * Author URI:        https://seowriting.ai/?utm_source=wp_plugin
     
    2828        public $plugin_slug;
    2929        public $plugin_path;
    30         public $version = '1.8.7';
     30        public $version = '1.9.0';
    3131        /**
    3232         * @var \SEOWriting\APIClient|null
     
    3737
    3838        const SETTINGS_DEBUG_KEY = 'seowriting_debug';
     39        const SETTINGS_GENERATOR_NAME = 'seowriting';
     40        const SETTINGS_GENERATOR_NAME_KEY = 'seowriting_generator';
    3941        const SETTINGS_KEY = 'seowriting_settings';
    4042        const SETTINGS_PLUGIN_NAME_KEY = 'seowriting_plugin_name';
     
    105107            add_action('requests-requests.before_parse', [$this, 'onAfterRequest'], 10, 6);
    106108            add_action('plugins_loaded', [$this, 'onPluginsLoaded']);
     109
    107110        }
    108111
     
    469472                            'categories' => $this->getCategories(),
    470473                            'authors' => $this->getAuthors(),
     474                            'types' => $this->getPostTypes(),
    471475                        ];
    472476                    } elseif ($action === 'disconnect') {
     
    516520                            'version' => $this->getVersion()
    517521                        ];
     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                        ];
    518527                    } else {
    519528                        $rs = [
     
    779788        private function publishPost($user_id, $data)
    780789        {
     790            global $current_user;
     791
    781792            $maxExecutionTime = (int)ini_get('max_execution_time');
    782793            @set_time_limit(120);
     
    803814                $user_id = (int)$data['author_id'];
    804815            }
     816            $current_user = new WP_User($user_id);
     817            $post_type = isset($data['post_type']) ? $data['post_type'] : 'post';
    805818            $new_post = [
    806819                'post_title' => sanitize_text_field($data['theme']),
     
    809822                'post_date' => date('Y-m-d H:i:s', $post_time),
    810823                '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,
    813825                'post_excerpt' => isset($data['excerpt']) && (int)$data['excerpt'] === 1
    814826                    ? (isset($data['description']) ? sanitize_text_field($data['description']) : '')
     
    816828            ];
    817829
     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
    818852            if (isset($data['post_slug'])) {
    819853                $slug = sanitize_title($data['post_slug']);
    820854                if (strlen($slug) > 0) {
    821855                    $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                    }
    822869                }
    823870            }
     
    852899            @set_time_limit($maxExecutionTime);
    853900
     901            add_post_meta($post_id, self::SETTINGS_GENERATOR_NAME_KEY, self::SETTINGS_GENERATOR_NAME, true);
     902
    854903            return [
    855904                'result' => 1,
     
    859908            ];
    860909        }
     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
    861956
    862957        public function getVersion()
Note: See TracChangeset for help on using the changeset viewer.