Plugin Directory

Changeset 3330977


Ignore:
Timestamp:
07/20/2025 03:23:27 PM (9 months ago)
Author:
muchatai
Message:

Update to version 2.0.40 from GitHub

Location:
muchat-ai
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • muchat-ai/tags/2.0.40/includes/Models/Page.php

    r3330738 r3330977  
    6868            $args['post__not_in'] = $pages_to_exclude;
    6969        }
    70 
    71         // Add a WHERE clause to filter out empty content
    72         add_filter('posts_where', function ($where) {
    73             global $wpdb;
    74             $where .= " AND {$wpdb->posts}.post_content != ''";
    75             return $where;
    76         }, 10, 1);
    77 
    7870
    7971        // Set pagination parameters
     
    151143
    152144    /**
    153      * Check if a page is valid (not a WooCommerce page and has content)
    154      *
    155      * @param \WP_Post $page
    156      * @return bool
    157      */
    158     private function is_valid_page($page)
    159     {
    160         if (empty($page) || empty($page->post_content)) {
    161             return false;
    162         }
    163 
    164         $pages_to_exclude = $this->get_pages_to_exclude();
    165 
    166         // If the page is one of the excluded system pages, return false
    167         if (in_array($page->ID, $pages_to_exclude)) {
    168             return false;
    169         }
    170 
    171         // Check that the content is not empty and not just whitespace characters
    172         $content = trim(wp_strip_all_tags($page->post_content));
    173         return !empty($content);
    174     }
    175 
    176     /**
    177145     * Get page ID by slug
    178146     */
     
    212180    protected function format_page($page)
    213181    {
    214         if (empty($page->post_content)) {
    215             return null;
    216         }
    217 
    218         $pages_to_exclude = $this->get_pages_to_exclude();
    219 
    220         // If the page is one of the excluded system pages, return null
    221         if (in_array($page->ID, $pages_to_exclude)) {
    222             return null;
    223         }
    224 
    225         // Check that the content is not empty and not just whitespace characters
    226         $content = trim(wp_strip_all_tags($page->post_content));
    227         if (empty($content)) {
    228             return null;
    229         }
    230 
    231182        $data = [];
    232183        $enabled_fields = $this->get_enabled_fields('page');
     
    259210        }
    260211
    261         return $this->formatter->remove_empty_values($data);
     212        $cleaned_data = $this->formatter->remove_empty_values($data);
     213
     214        // Ensure the ID is always present to prevent the page from being filtered out
     215        if (!isset($cleaned_data['id'])) {
     216            $cleaned_data['id'] = $page->ID;
     217        }
     218
     219        return $cleaned_data;
    262220    }
    263221
  • muchat-ai/tags/2.0.40/includes/Models/Post.php

    r3330738 r3330977  
    6363        }
    6464
    65         // Add a meta query to exclude posts with empty content
    66         $args['meta_query'] = [
    67             [
    68                 'key' => '_wp_old_slug', // A non-existent key to satisfy the structure, the real filtering is done by the where filter.
    69             ],
    70         ];
    71 
    72         // Add a WHERE clause to filter out empty content. This is more efficient than a meta_query on post_content.
    73         add_filter('posts_where', function ($where) {
    74             global $wpdb;
    75             $where .= " AND {$wpdb->posts}.post_content != ''";
    76             return $where;
    77         });
    78 
    7965        // Set pagination parameters
    8066        $requested_offset = $params['skip'] ?? 0;
     
    134120    protected function format_post($post)
    135121    {
    136         if (empty($post->post_content)) {
    137             return null;
    138         }
    139 
    140         // Check that the content is not empty and not just whitespace characters
    141         $content = trim(wp_strip_all_tags($post->post_content));
    142         if (empty($content)) {
    143             return null;
    144         }
    145 
    146122        $data = [];
    147123        $enabled_fields = $this->get_enabled_fields('post');
     
    180156        }
    181157
    182         return $this->formatter->remove_empty_values($data);
     158        $cleaned_data = $this->formatter->remove_empty_values($data);
     159
     160        // Ensure the ID is always present to prevent the post from being filtered out
     161        if (!isset($cleaned_data['id'])) {
     162            $cleaned_data['id'] = $post->ID;
     163        }
     164
     165        return $cleaned_data;
    183166    }
    184167
  • muchat-ai/tags/2.0.40/muchat-ai.php

    r3330925 r3330977  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.39
     7 * Version: 2.0.40
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.39');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.40');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/tags/2.0.40/readme.txt

    r3330925 r3330977  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.39
     6Stable tag: 2.0.40
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    7676== Changelog ==
    7777
     78= 2.0.40 =
     79* Bugfix: Fix pages api empty value
     80
    7881= 2.0.39 =
    7982* Feature: Added check app status
  • muchat-ai/trunk/includes/Models/Page.php

    r3330738 r3330977  
    6868            $args['post__not_in'] = $pages_to_exclude;
    6969        }
    70 
    71         // Add a WHERE clause to filter out empty content
    72         add_filter('posts_where', function ($where) {
    73             global $wpdb;
    74             $where .= " AND {$wpdb->posts}.post_content != ''";
    75             return $where;
    76         }, 10, 1);
    77 
    7870
    7971        // Set pagination parameters
     
    151143
    152144    /**
    153      * Check if a page is valid (not a WooCommerce page and has content)
    154      *
    155      * @param \WP_Post $page
    156      * @return bool
    157      */
    158     private function is_valid_page($page)
    159     {
    160         if (empty($page) || empty($page->post_content)) {
    161             return false;
    162         }
    163 
    164         $pages_to_exclude = $this->get_pages_to_exclude();
    165 
    166         // If the page is one of the excluded system pages, return false
    167         if (in_array($page->ID, $pages_to_exclude)) {
    168             return false;
    169         }
    170 
    171         // Check that the content is not empty and not just whitespace characters
    172         $content = trim(wp_strip_all_tags($page->post_content));
    173         return !empty($content);
    174     }
    175 
    176     /**
    177145     * Get page ID by slug
    178146     */
     
    212180    protected function format_page($page)
    213181    {
    214         if (empty($page->post_content)) {
    215             return null;
    216         }
    217 
    218         $pages_to_exclude = $this->get_pages_to_exclude();
    219 
    220         // If the page is one of the excluded system pages, return null
    221         if (in_array($page->ID, $pages_to_exclude)) {
    222             return null;
    223         }
    224 
    225         // Check that the content is not empty and not just whitespace characters
    226         $content = trim(wp_strip_all_tags($page->post_content));
    227         if (empty($content)) {
    228             return null;
    229         }
    230 
    231182        $data = [];
    232183        $enabled_fields = $this->get_enabled_fields('page');
     
    259210        }
    260211
    261         return $this->formatter->remove_empty_values($data);
     212        $cleaned_data = $this->formatter->remove_empty_values($data);
     213
     214        // Ensure the ID is always present to prevent the page from being filtered out
     215        if (!isset($cleaned_data['id'])) {
     216            $cleaned_data['id'] = $page->ID;
     217        }
     218
     219        return $cleaned_data;
    262220    }
    263221
  • muchat-ai/trunk/includes/Models/Post.php

    r3330738 r3330977  
    6363        }
    6464
    65         // Add a meta query to exclude posts with empty content
    66         $args['meta_query'] = [
    67             [
    68                 'key' => '_wp_old_slug', // A non-existent key to satisfy the structure, the real filtering is done by the where filter.
    69             ],
    70         ];
    71 
    72         // Add a WHERE clause to filter out empty content. This is more efficient than a meta_query on post_content.
    73         add_filter('posts_where', function ($where) {
    74             global $wpdb;
    75             $where .= " AND {$wpdb->posts}.post_content != ''";
    76             return $where;
    77         });
    78 
    7965        // Set pagination parameters
    8066        $requested_offset = $params['skip'] ?? 0;
     
    134120    protected function format_post($post)
    135121    {
    136         if (empty($post->post_content)) {
    137             return null;
    138         }
    139 
    140         // Check that the content is not empty and not just whitespace characters
    141         $content = trim(wp_strip_all_tags($post->post_content));
    142         if (empty($content)) {
    143             return null;
    144         }
    145 
    146122        $data = [];
    147123        $enabled_fields = $this->get_enabled_fields('post');
     
    180156        }
    181157
    182         return $this->formatter->remove_empty_values($data);
     158        $cleaned_data = $this->formatter->remove_empty_values($data);
     159
     160        // Ensure the ID is always present to prevent the post from being filtered out
     161        if (!isset($cleaned_data['id'])) {
     162            $cleaned_data['id'] = $post->ID;
     163        }
     164
     165        return $cleaned_data;
    183166    }
    184167
  • muchat-ai/trunk/muchat-ai.php

    r3330925 r3330977  
    55 * Plugin URI: https://mu.chat
    66 * Description: Muchat, a powerful tool for customer support using artificial intelligence
    7  * Version: 2.0.39
     7 * Version: 2.0.40
    88 * Author: Muchat
    99 * Text Domain: muchat-ai
     
    2727
    2828// Define plugin constants with unique prefix
    29 define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.39');
     29define('MUCHAT_AI_CHATBOT_PLUGIN_VERSION', '2.0.40');
    3030// define('MUCHAT_AI_CHATBOT_CACHE_DURATION', HOUR_IN_SECONDS);
    3131define('MUCHAT_AI_CHATBOT_PLUGIN_FILE', __FILE__);
  • muchat-ai/trunk/readme.txt

    r3330925 r3330977  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 2.0.39
     6Stable tag: 2.0.40
    77Requires PHP: 7.4
    88License: GPLv2 or later
     
    7676== Changelog ==
    7777
     78= 2.0.40 =
     79* Bugfix: Fix pages api empty value
     80
    7881= 2.0.39 =
    7982* Feature: Added check app status
Note: See TracChangeset for help on using the changeset viewer.