Plugin Directory

Changeset 1047432


Ignore:
Timestamp:
12/17/2014 07:25:58 PM (11 years ago)
Author:
freakingid
Message:

Multisite changes to TEST

Location:
content-scheduler/trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • content-scheduler/trunk/content-scheduler-settings.php

    r1047426 r1047432  
    3535
    3636    var $pagehook, $page_id, $settings_field, $options;
     37    var $debug = true;
    3738   
    3839    function __construct() {
     
    5051        // register new setting Group
    5152        register_setting( $this->settings_field, $this->settings_field, array( $this, 'sanitize_plugin_options' ) );
    52         add_option( $this->settings_field, Content_Scheduler_Settings::$default_settings );
    5353       
    5454        // Add SECTIONS to the setting group
     
    627627        function ContentScheduler_drawoptions_fn()
    628628        {
    629             // Get our current options out of the database? -pk
    630             $ContentScheduler_Options = get_option('ContentScheduler_Options');
    631629            ?>
    632630            <div class="wrap">
    633631                <?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>
    635633                <form action="options.php" method="post">
    636634                <?php
  • content-scheduler/trunk/content-scheduler.php

    r1047430 r1047432  
    3636define( 'PEK_CONTENT_SCHEDULER_DIR', plugin_dir_path( __FILE__ ) );
    3737define( 'PEK_CONTENT_SCHEDULER_URL', plugin_dir_url( __FILE__ ) );
    38 define( 'PEK_CONTENT_SCHEDULER_DEBUG', true );
    3938if ( ! defined( 'WP_CONTENT_URL' ) )
    4039    define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
     
    5453    class ContentScheduler {
    5554        var $settings, $options_page, $options;
     55        var $debug = true;
    5656       
    5757        function __construct() {
     
    9090           
    9191            // 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            }
    110104
    111105            // Shortcodes
     
    131125        */
    132126        function network_propagate($pfunction, $networkwide) {
    133             global $wpdb;
     127            global $wpdb;           
    134128
    135129            if (function_exists('is_multisite') && is_multisite()) {
    136130                // check if it is a network activation - if so, run the activation function
    137131                // for each blog id
     132                /*
     133                // Note, we do not want network activation to be a thing for CS right now
    138134                if ($networkwide) {
    139135                    $old_blog = $wpdb->blogid;
     
    147143                    return;
    148144                }   
     145                */
    149146            }
    150147            call_user_func($pfunction, $networkwide);
     
    224221
    225222            /*
    226                 2. Register our expiration event into wp-cron schedule
     223                2. Register our expiration and notification events into wp-cron schedule
    227224            */
    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                */
    254246            }
    255247        } // end activate_function
     
    261253        // TODO: Still need to review what we do during deactivation
    262254        function _deactivate() {
    263             $current_blog_id = get_current_blog_id();
    264             // it is a networked site activation
    265             // NOTE: Multisite version
    266255            /*
    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
    271257            */
    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            }
    278272        } // end deactivate_function()
    279273
     
    362356            global $current_user;
    363357            // What is minimum level required to see CS?
    364             // $this->options = get_option('ContentScheduler_Options');
    365358            $min_level = $this->options['min-level'];
    366359       
     
    418411            // Get the current value, if there is one
    419412            $the_data = get_post_meta( $post->ID, '_cs-enable-schedule', true );
     413            $the_data = ( empty( $the_data ) ? 'Disable' : $the_data );
    420414            // Checkbox for scheduling this Post / Page, or ignoring
    421415            $items = array( "Disable", "Enable");
     
    444438            echo '<label for="cs-expire-date">' . __("Expiration date and hour", 'contentscheduler' ) . '</label><br />';
    445439            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.';
    447441        }
    448442
     
    508502            {
    509503                // get the default value from the database
    510                 // $this->options = get_option('ContentScheduler_Options');
    511504                $default_expiration_array = $this->options['exp-default'];
    512505                if( !empty( $default_expiration_array ) )
     
    575568            // For testing, we can set it to like 120 (2 min)
    576569            // 1. Check options for desired interval.
    577             // $options = get_option('ContentScheduler_Options');
    578570            if( ! empty( $this->options['exp-period'] ) )
    579571            {
     
    682674        function answer_expiration_event()
    683675        {
    684             // we should get our options right now, and decide if we need to proceed or not.
    685             // $options = get_option('ContentScheduler_Options');
    686676            // Do we need to process expirations?
    687677            if( $this->options['exp-status'] != '0' )
     
    741731            global $current_user;
    742732            // Check to see if we really want to add our column
    743             // $options = get_option('ContentScheduler_Options');
    744733            if( $this->options['show-columns'] == '1' )
    745734            {
     
    766755                global $wpdb, $post, $current_user;
    767756                // Check to see if we really want to add our column
    768                 // $options = get_option('ContentScheduler_Options');
    769757                if( $this->options['show-columns'] == '1' ) {
    770758                    // Check to see if current user has permissions to see
     
    791779                            // convert
    792780                            $ed = DateUtilities::getReadableDateFromTimestamp( $timestamp );
     781                            if( empty( $ed ) ) {
     782                                $ed = "Date misunderstood";
     783                            }
    793784                        } else {
    794                             $ed = "Date misunderstood";
     785                            $ed = "No date set";
    795786                        }
    796787                        // determine whether expiration is enabled or disabled
     
    826817            global $current_user;
    827818            // Check to see if we have rights to see stuff
    828             // $options = get_option('ContentScheduler_Options');
    829819            $min_level = $this->options['min-level'];
    830820            get_currentuserinfo();
  • content-scheduler/trunk/includes/DateUtilities.php

    r1047427 r1047432  
    1414            // return $timestamp + $datetime->getOffset();
    1515            $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 );
    1820            // put together and return
    1921            return $dateString . " " . $timeString;
     
    4244         */
    4345        private static function wp_get_timezone_string() {
     46            $blog_timezone = get_option( 'timezone_string' );
     47            $blog_gmt_offset = get_option( 'gmt_offset', 0 );
    4448            // if site timezone string exists, return it
    45             if ( $timezone = get_option( 'timezone_string' ) )
     49            if ( $timezone = $blog_timezone )
    4650                return $timezone;
    4751            // 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 ) )
    4953                return 'UTC';
    5054            // adjust UTC offset from hours to seconds
  • content-scheduler/trunk/includes/process-notifications.php

    r1047426 r1047432  
    22            global $wpdb;
    33            // get options
    4             // $options = get_option('ContentScheduler_Options');
    54            // get days of notification offset
    65            $notice_days = $this->options['notify-before'];
  • content-scheduler/trunk/includes/process-page.php

    r1047425 r1047432  
    11<?php
    2             // $options = get_option('ContentScheduler_Options');
    32            // Now, make the array we would pass to wp_update_post
    43            // 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  
    11<?php
    2             // $options = get_option('ContentScheduler_Options');
    32            // STICKINESS (Pages do not have STICKY ability)
    43            // Note: This is stored in the options table, and is not part of post_update
     
    87            if( $sticky_change == '1' )
    98            {
    10                 $sticky_posts = get_option('sticky_posts');
     9                $sticky_posts = get_option( 'sticky_posts' );
    1110                if( ! empty( $sticky_posts ) )
    1211                {
  • content-scheduler/trunk/includes/update-minlevel-options.php

    r1047425 r1047432  
    55
    66// Get the min-level option
    7 // $options = get_option('ContentScheduler_Options');
    87if( isset( $this->options['min-level'] ) )
    98{
     
    5352    // now update the option in the database
    5453    $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    }
    5660} // end if checking for existence of min-level option
    5761// else do nothing
  • content-scheduler/trunk/includes/update-postmeta-names.php

    r479969 r1047432  
    55// cs-enable-schedule > _cs-enable-schedule
    66// Can we just do a MySQL search and replace?
     7// NOTE: This might not work for a multisite...
    78/*
    89update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);
  • content-scheduler/trunk/uninstall.php

    r479979 r1047432  
    55    Before a plugin can be uninstalled, it has to be deactivated.
    66*/
     7/*
    78    // Uninstall plugin options
    89    if ( !defined('WP_UNINSTALL_PLUGIN') )
     
    7576        }   
    7677    } // end delete_function()
     78    */
    7779?>
Note: See TracChangeset for help on using the changeset viewer.