Changeset 3194088
- Timestamp:
- 11/21/2024 11:44:57 AM (4 months ago)
- 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 8 8 * Author: Infinitnet 9 9 * Author URI: https://infinitnet.io/ 10 * Version: 2.3. 310 * Version: 2.3.4 11 11 * License: GPLv3 12 12 * Text Domain: content-update-scheduler … … 227 227 self::register_post_status(); 228 228 229 // Get all public post types plus 'product' (maintaining existing behavior) 229 230 $post_types = array_merge( 230 231 get_post_types(array('public' => true), 'names'), 231 232 array('product') 232 233 ); 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); 234 251 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) 241 260 add_filter('manage_edit-product_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' )); 242 261 add_action('manage_product_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2); … … 589 608 </div> 590 609 </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> 591 622 </div> 592 623 <script type="text/javascript"> … … 780 811 // and finally referencing the original post. 781 812 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'); 782 816 783 817 // Handle WooCommerce products … … 972 1006 } 973 1007 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 974 1016 // Verify the event was scheduled 975 1017 $next_scheduled = wp_next_scheduled('cus_publish_post', array($post_id)); … … 1085 1127 $post->post_parent = $orig->post_parent; 1086 1128 $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 } 1100 1156 1101 1157 delete_post_meta($orig->ID, self::$_cus_publish_status . '_pubdate'); -
content-update-scheduler/tags/2.3.4/readme.txt
r3174532 r3194088 3 3 Tags: schedule, scheduling, update, republish, publication 4 4 Requires at least: 5.0 5 Tested up to: 6. 6.16 Stable tag: 2.3. 37 Requires PHP: 7. 35 Tested up to: 6.7 6 Stable tag: 2.3.4 7 Requires PHP: 7.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 49 49 Yes, it has been tested with Elementor and Oxygen Builder. It may also work with other page builders. 50 50 51 = How can I exclude post types from Content Update Scheduler? 52 53 You can use below filter to exclude post types: 54 55 ``` 56 add_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 51 63 == 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 52 68 53 69 = 2.3.3 = -
content-update-scheduler/trunk/content-update-scheduler.php
r3174532 r3194088 8 8 * Author: Infinitnet 9 9 * Author URI: https://infinitnet.io/ 10 * Version: 2.3. 310 * Version: 2.3.4 11 11 * License: GPLv3 12 12 * Text Domain: content-update-scheduler … … 227 227 self::register_post_status(); 228 228 229 // Get all public post types plus 'product' (maintaining existing behavior) 229 230 $post_types = array_merge( 230 231 get_post_types(array('public' => true), 'names'), 231 232 array('product') 232 233 ); 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); 234 251 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) 241 260 add_filter('manage_edit-product_columns', array( 'ContentUpdateScheduler', 'manage_pages_columns' )); 242 261 add_action('manage_product_posts_custom_column', array( 'ContentUpdateScheduler', 'manage_pages_custom_column' ), 10, 2); … … 589 608 </div> 590 609 </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> 591 622 </div> 592 623 <script type="text/javascript"> … … 780 811 // and finally referencing the original post. 781 812 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'); 782 816 783 817 // Handle WooCommerce products … … 972 1006 } 973 1007 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 974 1016 // Verify the event was scheduled 975 1017 $next_scheduled = wp_next_scheduled('cus_publish_post', array($post_id)); … … 1085 1127 $post->post_parent = $orig->post_parent; 1086 1128 $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 } 1100 1156 1101 1157 delete_post_meta($orig->ID, self::$_cus_publish_status . '_pubdate'); -
content-update-scheduler/trunk/readme.txt
r3174532 r3194088 3 3 Tags: schedule, scheduling, update, republish, publication 4 4 Requires at least: 5.0 5 Tested up to: 6. 6.16 Stable tag: 2.3. 37 Requires PHP: 7. 35 Tested up to: 6.7 6 Stable tag: 2.3.4 7 Requires PHP: 7.4 8 8 License: GPLv3 9 9 License URI: https://www.gnu.org/licenses/gpl-3.0.en.html … … 49 49 Yes, it has been tested with Elementor and Oxygen Builder. It may also work with other page builders. 50 50 51 = How can I exclude post types from Content Update Scheduler? 52 53 You can use below filter to exclude post types: 54 55 ``` 56 add_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 51 63 == 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 52 68 53 69 = 2.3.3 =
Note: See TracChangeset
for help on using the changeset viewer.