Plugin Directory

Changeset 3194088


Ignore:
Timestamp:
11/21/2024 11:44:57 AM (4 months ago)
Author:
infinitnet
Message:

v2.3.4 release

Location:
content-update-scheduler
Files:
2 edited
3 copied

Legend:

Unmodified
Added
Removed
  • content-update-scheduler/tags/2.3.4/content-update-scheduler.php

    r3174532 r3194088  
    88 * Author: Infinitnet
    99 * Author URI: https://infinitnet.io/
    10  * Version: 2.3.3
     10 * Version: 2.3.4
    1111 * License: GPLv3
    1212 * Text Domain: content-update-scheduler
     
    227227        self::register_post_status();
    228228
     229        // Get all public post types plus 'product' (maintaining existing behavior)
    229230        $post_types = array_merge(
    230231            get_post_types(array('public' => true), 'names'),
    231232            array('product')
    232233        );
    233        
     234
     235        /**
     236         * Filter to exclude specific post types from content update scheduling
     237         *
     238         * @param array $excluded_post_types Array of post type names to exclude
     239         * @return array Modified array of post type names to exclude
     240         */
     241        $excluded_post_types = apply_filters('content_update_scheduler_excluded_post_types', array());
     242
     243        // Ensure excluded_post_types is an array
     244        $excluded_post_types = is_array($excluded_post_types) ? $excluded_post_types : array();
     245
     246        // Remove excluded post types
     247        $post_types = array_diff($post_types, $excluded_post_types);
     248
     249        // Remove duplicates and ensure valid post types
     250        $post_types = array_unique($post_types);
    234251        foreach ($post_types as $post_type) {
    235             add_filter('manage_edit-' . $post_type . '_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
    236             add_action('manage_' . $post_type . '_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
    237             add_action('add_meta_boxes', array( 'ContentUpdateScheduler', 'add_meta_boxes_page' ), 10, 2);
    238         }
    239 
    240         // Specific filter for WooCommerce products
     252            if (post_type_exists($post_type)) {
     253                add_filter('manage_edit-' . $post_type . '_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
     254                add_action('manage_' . $post_type . '_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
     255                add_action('add_meta_boxes', array( 'ContentUpdateScheduler', 'add_meta_boxes_page' ), 10, 2);
     256            }
     257        }
     258
     259        // Specific filter for WooCommerce products (maintaining existing behavior)
    241260        add_filter('manage_edit-product_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
    242261        add_action('manage_product_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
     
    589608                </div>
    590609            </p>
     610            <div class="misc-pub-section">
     611                <label>
     612                    <input type="checkbox"
     613                           name="<?php echo esc_attr(self::$_cus_publish_status); ?>_keep_dates"
     614                           id="<?php echo esc_attr(self::$_cus_publish_status); ?>_keep_dates"
     615                           <?php checked(get_post_meta($post->ID, self::$_cus_publish_status . '_keep_dates', true), 'yes'); ?>>
     616                    <?php esc_html_e('Keep original publication date', 'cus-scheduleupdate-td'); ?>
     617                </label>
     618                <p class="description">
     619                    <?php esc_html_e('If checked, the original publication date will be preserved when this update is published.', 'cus-scheduleupdate-td'); ?>
     620                </p>
     621            </div>
    591622        </div>
    592623        <script type="text/javascript">
     
    780811        // and finally referencing the original post.
    781812        update_post_meta($new_post_id, self::$_cus_publish_status . '_original', $original);
     813       
     814        // Ensure the keep_dates setting is not copied from previous scheduled updates
     815        delete_post_meta($new_post_id, self::$_cus_publish_status . '_keep_dates');
    782816
    783817        // Handle WooCommerce products
     
    9721006                }
    9731007               
     1008                // Save keep_dates preference
     1009                $keep_dates_key = self::$_cus_publish_status . '_keep_dates';
     1010                if (isset($_POST[$keep_dates_key])) {
     1011                    update_post_meta($post_id, $keep_dates_key, 'yes');
     1012                } else {
     1013                    delete_post_meta($post_id, $keep_dates_key);
     1014                }
     1015
    9741016                // Verify the event was scheduled
    9751017                $next_scheduled = wp_next_scheduled('cus_publish_post', array($post_id));
     
    10851127            $post->post_parent = $orig->post_parent;
    10861128            $post->post_status = $orig->post_status;
    1087             $post_date = wp_date('Y-m-d H:i:s');
    1088 
    1089             /**
    1090              * Filter the new posts' post date
    1091              *
    1092              * @param string  $post_date the date to be used, must be in the form of `Y-m-d H:i:s`.
    1093              * @param WP_Post $post      the scheduled update post.
    1094              * @param WP_Post $orig      the original post.
    1095              */
    1096             $post_date = apply_filters('ContentUpdateScheduler\\publish_post_date', $post_date, $post, $orig);
    1097 
    1098             $post->post_date = $post_date;
    1099             $post->post_date_gmt = get_gmt_from_date($post_date);
     1129           
     1130            $keep_dates = get_post_meta($post_id, self::$_cus_publish_status . '_keep_dates', true) === 'yes';
     1131
     1132            if ($keep_dates) {
     1133                // Keep original dates but update modified date
     1134                $post->post_date = $orig->post_date;
     1135                $post->post_date_gmt = $orig->post_date_gmt;
     1136                $post->post_modified = wp_date('Y-m-d H:i:s');
     1137                $post->post_modified_gmt = get_gmt_from_date($post->post_modified);
     1138            } else {
     1139                // Use new dates
     1140                $post_date = wp_date('Y-m-d H:i:s');
     1141               
     1142                /**
     1143                 * Filter the new posts' post date
     1144                 *
     1145                 * @param string  $post_date the date to be used, must be in the form of `Y-m-d H:i:s`.
     1146                 * @param WP_Post $post      the scheduled update post.
     1147                 * @param WP_Post $orig      the original post.
     1148                 */
     1149                $post_date = apply_filters('ContentUpdateScheduler\\publish_post_date', $post_date, $post, $orig);
     1150
     1151                $post->post_date = $post_date;
     1152                $post->post_date_gmt = get_gmt_from_date($post_date);
     1153                $post->post_modified = $post_date;
     1154                $post->post_modified_gmt = $post->post_date_gmt;
     1155            }
    11001156
    11011157            delete_post_meta($orig->ID, self::$_cus_publish_status . '_pubdate');
  • content-update-scheduler/tags/2.3.4/readme.txt

    r3174532 r3194088  
    33Tags: schedule, scheduling, update, republish, publication
    44Requires at least: 5.0
    5 Tested up to: 6.6.1
    6 Stable tag: 2.3.3
    7 Requires PHP: 7.3
     5Tested up to: 6.7
     6Stable tag: 2.3.4
     7Requires PHP: 7.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    4949Yes, it has been tested with Elementor and Oxygen Builder. It may also work with other page builders.
    5050
     51= How can I exclude post types from Content Update Scheduler?
     52
     53You can use below filter to exclude post types:
     54
     55```
     56add_filter('content_update_scheduler_excluded_post_types', function($excluded_post_types) {
     57    // Replace EXCLUDE_THIS with the name of the post type you want to exclude
     58    $excluded_post_types[] = 'EXCLUDE_THIS';
     59    return array_unique($excluded_post_types);
     60    });
     61```
     62
    5163== Changelog ==
     64
     65= 2.3.4 =
     66* feat: Add per-post option to preserve original publication date
     67* refactor: Enhance custom post type support with opt-out filter mechanism
    5268
    5369= 2.3.3 =
  • content-update-scheduler/trunk/content-update-scheduler.php

    r3174532 r3194088  
    88 * Author: Infinitnet
    99 * Author URI: https://infinitnet.io/
    10  * Version: 2.3.3
     10 * Version: 2.3.4
    1111 * License: GPLv3
    1212 * Text Domain: content-update-scheduler
     
    227227        self::register_post_status();
    228228
     229        // Get all public post types plus 'product' (maintaining existing behavior)
    229230        $post_types = array_merge(
    230231            get_post_types(array('public' => true), 'names'),
    231232            array('product')
    232233        );
    233        
     234
     235        /**
     236         * Filter to exclude specific post types from content update scheduling
     237         *
     238         * @param array $excluded_post_types Array of post type names to exclude
     239         * @return array Modified array of post type names to exclude
     240         */
     241        $excluded_post_types = apply_filters('content_update_scheduler_excluded_post_types', array());
     242
     243        // Ensure excluded_post_types is an array
     244        $excluded_post_types = is_array($excluded_post_types) ? $excluded_post_types : array();
     245
     246        // Remove excluded post types
     247        $post_types = array_diff($post_types, $excluded_post_types);
     248
     249        // Remove duplicates and ensure valid post types
     250        $post_types = array_unique($post_types);
    234251        foreach ($post_types as $post_type) {
    235             add_filter('manage_edit-' . $post_type . '_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
    236             add_action('manage_' . $post_type . '_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
    237             add_action('add_meta_boxes', array( 'ContentUpdateScheduler', 'add_meta_boxes_page' ), 10, 2);
    238         }
    239 
    240         // Specific filter for WooCommerce products
     252            if (post_type_exists($post_type)) {
     253                add_filter('manage_edit-' . $post_type . '_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
     254                add_action('manage_' . $post_type . '_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
     255                add_action('add_meta_boxes', array( 'ContentUpdateScheduler', 'add_meta_boxes_page' ), 10, 2);
     256            }
     257        }
     258
     259        // Specific filter for WooCommerce products (maintaining existing behavior)
    241260        add_filter('manage_edit-product_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' ));
    242261        add_action('manage_product_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2);
     
    589608                </div>
    590609            </p>
     610            <div class="misc-pub-section">
     611                <label>
     612                    <input type="checkbox"
     613                           name="<?php echo esc_attr(self::$_cus_publish_status); ?>_keep_dates"
     614                           id="<?php echo esc_attr(self::$_cus_publish_status); ?>_keep_dates"
     615                           <?php checked(get_post_meta($post->ID, self::$_cus_publish_status . '_keep_dates', true), 'yes'); ?>>
     616                    <?php esc_html_e('Keep original publication date', 'cus-scheduleupdate-td'); ?>
     617                </label>
     618                <p class="description">
     619                    <?php esc_html_e('If checked, the original publication date will be preserved when this update is published.', 'cus-scheduleupdate-td'); ?>
     620                </p>
     621            </div>
    591622        </div>
    592623        <script type="text/javascript">
     
    780811        // and finally referencing the original post.
    781812        update_post_meta($new_post_id, self::$_cus_publish_status . '_original', $original);
     813       
     814        // Ensure the keep_dates setting is not copied from previous scheduled updates
     815        delete_post_meta($new_post_id, self::$_cus_publish_status . '_keep_dates');
    782816
    783817        // Handle WooCommerce products
     
    9721006                }
    9731007               
     1008                // Save keep_dates preference
     1009                $keep_dates_key = self::$_cus_publish_status . '_keep_dates';
     1010                if (isset($_POST[$keep_dates_key])) {
     1011                    update_post_meta($post_id, $keep_dates_key, 'yes');
     1012                } else {
     1013                    delete_post_meta($post_id, $keep_dates_key);
     1014                }
     1015
    9741016                // Verify the event was scheduled
    9751017                $next_scheduled = wp_next_scheduled('cus_publish_post', array($post_id));
     
    10851127            $post->post_parent = $orig->post_parent;
    10861128            $post->post_status = $orig->post_status;
    1087             $post_date = wp_date('Y-m-d H:i:s');
    1088 
    1089             /**
    1090              * Filter the new posts' post date
    1091              *
    1092              * @param string  $post_date the date to be used, must be in the form of `Y-m-d H:i:s`.
    1093              * @param WP_Post $post      the scheduled update post.
    1094              * @param WP_Post $orig      the original post.
    1095              */
    1096             $post_date = apply_filters('ContentUpdateScheduler\\publish_post_date', $post_date, $post, $orig);
    1097 
    1098             $post->post_date = $post_date;
    1099             $post->post_date_gmt = get_gmt_from_date($post_date);
     1129           
     1130            $keep_dates = get_post_meta($post_id, self::$_cus_publish_status . '_keep_dates', true) === 'yes';
     1131
     1132            if ($keep_dates) {
     1133                // Keep original dates but update modified date
     1134                $post->post_date = $orig->post_date;
     1135                $post->post_date_gmt = $orig->post_date_gmt;
     1136                $post->post_modified = wp_date('Y-m-d H:i:s');
     1137                $post->post_modified_gmt = get_gmt_from_date($post->post_modified);
     1138            } else {
     1139                // Use new dates
     1140                $post_date = wp_date('Y-m-d H:i:s');
     1141               
     1142                /**
     1143                 * Filter the new posts' post date
     1144                 *
     1145                 * @param string  $post_date the date to be used, must be in the form of `Y-m-d H:i:s`.
     1146                 * @param WP_Post $post      the scheduled update post.
     1147                 * @param WP_Post $orig      the original post.
     1148                 */
     1149                $post_date = apply_filters('ContentUpdateScheduler\\publish_post_date', $post_date, $post, $orig);
     1150
     1151                $post->post_date = $post_date;
     1152                $post->post_date_gmt = get_gmt_from_date($post_date);
     1153                $post->post_modified = $post_date;
     1154                $post->post_modified_gmt = $post->post_date_gmt;
     1155            }
    11001156
    11011157            delete_post_meta($orig->ID, self::$_cus_publish_status . '_pubdate');
  • content-update-scheduler/trunk/readme.txt

    r3174532 r3194088  
    33Tags: schedule, scheduling, update, republish, publication
    44Requires at least: 5.0
    5 Tested up to: 6.6.1
    6 Stable tag: 2.3.3
    7 Requires PHP: 7.3
     5Tested up to: 6.7
     6Stable tag: 2.3.4
     7Requires PHP: 7.4
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
     
    4949Yes, it has been tested with Elementor and Oxygen Builder. It may also work with other page builders.
    5050
     51= How can I exclude post types from Content Update Scheduler?
     52
     53You can use below filter to exclude post types:
     54
     55```
     56add_filter('content_update_scheduler_excluded_post_types', function($excluded_post_types) {
     57    // Replace EXCLUDE_THIS with the name of the post type you want to exclude
     58    $excluded_post_types[] = 'EXCLUDE_THIS';
     59    return array_unique($excluded_post_types);
     60    });
     61```
     62
    5163== Changelog ==
     64
     65= 2.3.4 =
     66* feat: Add per-post option to preserve original publication date
     67* refactor: Enhance custom post type support with opt-out filter mechanism
    5268
    5369= 2.3.3 =
Note: See TracChangeset for help on using the changeset viewer.