Changeset 1047432
- Timestamp:
- 12/17/2014 07:25:58 PM (11 years ago)
- Location:
- content-scheduler/trunk
- Files:
-
- 9 edited
-
content-scheduler-settings.php (modified) (3 diffs)
-
content-scheduler.php (modified) (17 diffs)
-
includes/DateUtilities.php (modified) (2 diffs)
-
includes/process-notifications.php (modified) (1 diff)
-
includes/process-page.php (modified) (1 diff)
-
includes/process-post.php (modified) (2 diffs)
-
includes/update-minlevel-options.php (modified) (2 diffs)
-
includes/update-postmeta-names.php (modified) (1 diff)
-
uninstall.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
content-scheduler/trunk/content-scheduler-settings.php
r1047426 r1047432 35 35 36 36 var $pagehook, $page_id, $settings_field, $options; 37 var $debug = true; 37 38 38 39 function __construct() { … … 50 51 // register new setting Group 51 52 register_setting( $this->settings_field, $this->settings_field, array( $this, 'sanitize_plugin_options' ) ); 52 add_option( $this->settings_field, Content_Scheduler_Settings::$default_settings );53 53 54 54 // Add SECTIONS to the setting group … … 627 627 function ContentScheduler_drawoptions_fn() 628 628 { 629 // Get our current options out of the database? -pk630 $ContentScheduler_Options = get_option('ContentScheduler_Options');631 629 ?> 632 630 <div class="wrap"> 633 631 <?php screen_icon("options-general"); ?> 634 <h2>Content Scheduler <?php echo $ ContentScheduler_Options['version']; ?></h2>632 <h2>Content Scheduler <?php echo $$this->options['version']; ?></h2> 635 633 <form action="options.php" method="post"> 636 634 <?php -
content-scheduler/trunk/content-scheduler.php
r1047430 r1047432 36 36 define( 'PEK_CONTENT_SCHEDULER_DIR', plugin_dir_path( __FILE__ ) ); 37 37 define( 'PEK_CONTENT_SCHEDULER_URL', plugin_dir_url( __FILE__ ) ); 38 define( 'PEK_CONTENT_SCHEDULER_DEBUG', true );39 38 if ( ! defined( 'WP_CONTENT_URL' ) ) 40 39 define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); … … 54 53 class ContentScheduler { 55 54 var $settings, $options_page, $options; 55 var $debug = true; 56 56 57 57 function __construct() { … … 90 90 91 91 // add a cron action for expiration check 92 // I think this is still valid, even after 3.4 changes 93 // for now assume it is not a multisite 94 // schedule hooks to 'contentscheduler' action, which does callback 95 // TODO I think this needs to be different for multisite! Need the current_blog thing added to end? 96 add_action ('contentscheduler', array( $this, 'answer_expiration_event') ); 97 // TODO 98 // add_action ('contentschedulernotify', array( $this, 'answer_notification_event' ) ); 99 100 /* 101 if ( $this->is_network_site() ) 102 { 103 add_action ('content_scheduler'.$current_blog->blog_id, array( $this, 'answer_expiration_event') ); 104 } 105 else 106 { 107 add_action ('content_scheduler', array( $this, 'answer_expiration_event') ); 108 } 109 */ 92 if( is_multisite () ) { 93 // we need to add our action hook for just the current site, using blogID in the name 94 $blog_id = get_current_blog_id(); 95 add_action( 'contentscheduler' . $blog_id, array( $this, 'answer_expiration_event' ) ); 96 // TODO for notifications later 97 // add_action ('contentschedulernotify' . $blog_id, array( $this, 'answer_notification_event' ) ); 98 } else { 99 // it's okay to just use normal action hook 100 add_action ('contentscheduler', array( $this, 'answer_expiration_event') ); 101 // TODO for notifications later 102 // add_action ('contentschedulernotify', array( $this, 'answer_notification_event' ) ); 103 } 110 104 111 105 // Shortcodes … … 131 125 */ 132 126 function network_propagate($pfunction, $networkwide) { 133 global $wpdb; 127 global $wpdb; 134 128 135 129 if (function_exists('is_multisite') && is_multisite()) { 136 130 // check if it is a network activation - if so, run the activation function 137 131 // for each blog id 132 /* 133 // Note, we do not want network activation to be a thing for CS right now 138 134 if ($networkwide) { 139 135 $old_blog = $wpdb->blogid; … … 147 143 return; 148 144 } 145 */ 149 146 } 150 147 call_user_func($pfunction, $networkwide); … … 224 221 225 222 /* 226 2. Register our expiration eventinto wp-cron schedule223 2. Register our expiration and notification events into wp-cron schedule 227 224 */ 228 $current_blog_id = get_current_blog_id(); 229 // Test for the event already existing before you schedule the event again 230 // for expirations 231 // NOTE: The following is only valid for multisite because of the current_blog_id var 232 // TODO: To get this multisite version to work, we also have to add current_blog_id to our add_action for CS callback above in init 233 /* 234 if( !wp_next_scheduled( 'contentscheduler'.$current_blog_id ) ) { 235 // NOTE: For some reason there seems to be a problem on some systems where the hook must not contain underscores or uppercase characters. 236 // We previously used content_scheduler_(blogid) 237 // http://codex.wordpress.org/Function_Reference/wp_schedule_event 238 wp_schedule_event( time(), 'contsched_usertime', 'contentscheduler'.$current_blog_id ); 239 // wp_schedule_event( time(), 'hourly', 'content_scheduler_'.$current_blog_id ); 240 // TODO 241 // wp_schedule_event( time(), 'contsched_usertime', 'contentschedulernotify'.$current_blog_id ); 242 } 243 */ 244 // non-multisite version 245 if( !wp_next_scheduled( 'contentscheduler' ) ) { 246 // NOTE: For some reason there seems to be a problem on some systems where the hook must not contain underscores or uppercase characters. 247 // We previously used content_scheduler_(blogid) 248 // http://codex.wordpress.org/Function_Reference/wp_schedule_event 249 // TODO time() is UTC for right now, and that is okay 250 wp_schedule_event( time(), 'contsched_usertime', 'contentscheduler' ); 251 // wp_schedule_event( time(), 'hourly', 'content_scheduler_'.$current_blog_id ); 252 // TODO 253 // wp_schedule_event( time(), 'contsched_usertime', 'contentschedulernotify'.$current_blog_id ); 225 if( is_multisite () ) { 226 $blog_id = get_current_blog_id(); 227 if ( !wp_next_scheduled( 'contentscheduler' . $blog_id ) ) { 228 wp_schedule_event( time(), 'contsched_usertime', 'contentscheduler' . $blog_id ); 229 } 230 /* 231 // TODO later for notifications 232 if ( !wp_next_scheduled( 'contentschedulernotify' . $blog_id ) ) { 233 wp_schedule_event( time(), 'contsched_usertime', 'contentschedulernotify' . $blog_id ); 234 } 235 */ 236 } else { 237 if ( !wp_next_scheduled( 'contentscheduler' ) ) { 238 wp_schedule_event( time(), 'contsched_usertime', 'contentscheduler' ); 239 } 240 /* 241 // TODO for notifications later 242 if ( !wp_next_scheduled( 'contentschedulernotify' ) ) { 243 wp_schedule_event( time(), 'contentschedulernotify' ); 244 } 245 */ 254 246 } 255 247 } // end activate_function … … 261 253 // TODO: Still need to review what we do during deactivation 262 254 function _deactivate() { 263 $current_blog_id = get_current_blog_id();264 // it is a networked site activation265 // NOTE: Multisite version266 255 /* 267 // for expirations 268 wp_clear_scheduled_hook('contentscheduler'.$current_blog_id); 269 // for notifications 270 wp_clear_scheduled_hook('contentschedulernotify'.$current_blog_id); 256 1. Clear our expiration and notification events into wp-cron schedule 271 257 */ 272 // non-multisite version 273 // for expirations 274 wp_clear_scheduled_hook('contentscheduler'); 275 // for notifications 276 wp_clear_scheduled_hook('contentschedulernotify'); 277 258 if( is_multisite () ) { 259 $blog_id = get_current_blog_id(); 260 wp_clear_scheduled_hook( 'contentscheduler' . $blog_id ); 261 /* 262 // TODO later for notifications 263 wp_clear_scheduled_hook( 'contentschedulernotify' . $blog_id ); 264 */ 265 } else { 266 wp_clear_scheduled_hook( 'contentscheduler' ); 267 /* 268 // TODO later for notifications 269 wp_clear_scheduled_hook( 'contentschedulernotify' ); 270 */ 271 } 278 272 } // end deactivate_function() 279 273 … … 362 356 global $current_user; 363 357 // What is minimum level required to see CS? 364 // $this->options = get_option('ContentScheduler_Options');365 358 $min_level = $this->options['min-level']; 366 359 … … 418 411 // Get the current value, if there is one 419 412 $the_data = get_post_meta( $post->ID, '_cs-enable-schedule', true ); 413 $the_data = ( empty( $the_data ) ? 'Disable' : $the_data ); 420 414 // Checkbox for scheduling this Post / Page, or ignoring 421 415 $items = array( "Disable", "Enable"); … … 444 438 echo '<label for="cs-expire-date">' . __("Expiration date and hour", 'contentscheduler' ) . '</label><br />'; 445 439 echo '<input type="text" id="cs-expire-date" name="_cs-expire-date" value="'.$datestring.'" size="25" />'; 446 echo '<br />Input date and time in any valid Date and Time format ,<br />e.g., Year-Month-Day Hour:Min:Sec, 2010-11-25 08:00:00';440 echo '<br />Input date and time in any valid Date and Time format.'; 447 441 } 448 442 … … 508 502 { 509 503 // get the default value from the database 510 // $this->options = get_option('ContentScheduler_Options');511 504 $default_expiration_array = $this->options['exp-default']; 512 505 if( !empty( $default_expiration_array ) ) … … 575 568 // For testing, we can set it to like 120 (2 min) 576 569 // 1. Check options for desired interval. 577 // $options = get_option('ContentScheduler_Options');578 570 if( ! empty( $this->options['exp-period'] ) ) 579 571 { … … 682 674 function answer_expiration_event() 683 675 { 684 // we should get our options right now, and decide if we need to proceed or not.685 // $options = get_option('ContentScheduler_Options');686 676 // Do we need to process expirations? 687 677 if( $this->options['exp-status'] != '0' ) … … 741 731 global $current_user; 742 732 // Check to see if we really want to add our column 743 // $options = get_option('ContentScheduler_Options');744 733 if( $this->options['show-columns'] == '1' ) 745 734 { … … 766 755 global $wpdb, $post, $current_user; 767 756 // Check to see if we really want to add our column 768 // $options = get_option('ContentScheduler_Options');769 757 if( $this->options['show-columns'] == '1' ) { 770 758 // Check to see if current user has permissions to see … … 791 779 // convert 792 780 $ed = DateUtilities::getReadableDateFromTimestamp( $timestamp ); 781 if( empty( $ed ) ) { 782 $ed = "Date misunderstood"; 783 } 793 784 } else { 794 $ed = " Date misunderstood";785 $ed = "No date set"; 795 786 } 796 787 // determine whether expiration is enabled or disabled … … 826 817 global $current_user; 827 818 // Check to see if we have rights to see stuff 828 // $options = get_option('ContentScheduler_Options');829 819 $min_level = $this->options['min-level']; 830 820 get_currentuserinfo(); -
content-scheduler/trunk/includes/DateUtilities.php
r1047427 r1047432 14 14 // return $timestamp + $datetime->getOffset(); 15 15 $localTimestamp = $unixTimestamp + $datetime->getOffset(); 16 $dateString = date_i18n( get_option( 'date_format' ), $localTimestamp ); 17 $timeString = date( get_option( 'time_format' ), $localTimestamp ); 16 $blog_date_format = get_option( 'date_format' ); 17 $blog_time_format = get_option( 'time_format' ); 18 $dateString = date_i18n( $blog_date_format, $localTimestamp ); 19 $timeString = date( $blog_time_format, $localTimestamp ); 18 20 // put together and return 19 21 return $dateString . " " . $timeString; … … 42 44 */ 43 45 private static function wp_get_timezone_string() { 46 $blog_timezone = get_option( 'timezone_string' ); 47 $blog_gmt_offset = get_option( 'gmt_offset', 0 ); 44 48 // if site timezone string exists, return it 45 if ( $timezone = get_option( 'timezone_string' ))49 if ( $timezone = $blog_timezone ) 46 50 return $timezone; 47 51 // get UTC offset, if it isn't set then return UTC 48 if ( 0 === ( $utc_offset = get_option( 'gmt_offset', 0 )) )52 if ( 0 === ( $utc_offset = $blog_gmt_offset ) ) 49 53 return 'UTC'; 50 54 // adjust UTC offset from hours to seconds -
content-scheduler/trunk/includes/process-notifications.php
r1047426 r1047432 2 2 global $wpdb; 3 3 // get options 4 // $options = get_option('ContentScheduler_Options');5 4 // get days of notification offset 6 5 $notice_days = $this->options['notify-before']; -
content-scheduler/trunk/includes/process-page.php
r1047425 r1047432 1 1 <?php 2 // $options = get_option('ContentScheduler_Options');3 2 // Now, make the array we would pass to wp_update_post 4 3 // This is a local variable, so each time process_post is called, it will be new -
content-scheduler/trunk/includes/process-post.php
r1047425 r1047432 1 1 <?php 2 // $options = get_option('ContentScheduler_Options');3 2 // STICKINESS (Pages do not have STICKY ability) 4 3 // Note: This is stored in the options table, and is not part of post_update … … 8 7 if( $sticky_change == '1' ) 9 8 { 10 $sticky_posts = get_option('sticky_posts');9 $sticky_posts = get_option( 'sticky_posts' ); 11 10 if( ! empty( $sticky_posts ) ) 12 11 { -
content-scheduler/trunk/includes/update-minlevel-options.php
r1047425 r1047432 5 5 6 6 // Get the min-level option 7 // $options = get_option('ContentScheduler_Options');8 7 if( isset( $this->options['min-level'] ) ) 9 8 { … … 53 52 // now update the option in the database 54 53 $this->options['min-level'] = $new_level; 55 update_option( 'ContentScheduler_Options', $this->options ); 54 if( is_multisite () ) { 55 $blog_id = get_current_blog_id(); 56 update_blog_option( $blog_id, 'ContentScheduler_Options', $this->options ); 57 } else { 58 update_option( 'ContentScheduler_Options', $this->options ); 59 } 56 60 } // end if checking for existence of min-level option 57 61 // else do nothing -
content-scheduler/trunk/includes/update-postmeta-names.php
r479969 r1047432 5 5 // cs-enable-schedule > _cs-enable-schedule 6 6 // Can we just do a MySQL search and replace? 7 // NOTE: This might not work for a multisite... 7 8 /* 8 9 update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’); -
content-scheduler/trunk/uninstall.php
r479979 r1047432 5 5 Before a plugin can be uninstalled, it has to be deactivated. 6 6 */ 7 /* 7 8 // Uninstall plugin options 8 9 if ( !defined('WP_UNINSTALL_PLUGIN') ) … … 75 76 } 76 77 } // end delete_function() 78 */ 77 79 ?>
Note: See TracChangeset
for help on using the changeset viewer.