Plugin Directory

Changeset 1047423


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

Expirations working

Location:
content-scheduler/trunk
Files:
2 edited

Legend:

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

    r1047421 r1047423  
    219219            // Test for the event already existing before you schedule the event again
    220220            // for expirations
     221            // NOTE: The following is only valid for multisite because of the current_blog_id var
     222            /*
    221223            if( !wp_next_scheduled( 'contentscheduler'.$current_blog_id ) ) {
    222224                // NOTE: For some reason there seems to be a problem on some systems where the hook must not contain underscores or uppercase characters.
     
    228230                // wp_schedule_event( time(), 'contsched_usertime', 'contentschedulernotify'.$current_blog_id );
    229231            }
     232            */
     233            // non-multisite version
     234            if( !wp_next_scheduled( 'contentscheduler' ) ) {
     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' );
     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            }
    230243        } // end activate_function
    231244
     
    238251            $current_blog_id = get_current_blog_id();
    239252            // it is a networked site activation
     253            // NOTE: Multisite version
     254            /*
    240255            // for expirations
    241256            wp_clear_scheduled_hook('contentscheduler'.$current_blog_id);
    242257            // for notifications
    243258            wp_clear_scheduled_hook('contentschedulernotify'.$current_blog_id);
     259            */
     260            // non-multisite version
     261            // for expirations
     262            wp_clear_scheduled_hook('contentscheduler');
     263            // for notifications
     264            wp_clear_scheduled_hook('contentschedulernotify');
     265
    244266        } // end deactivate_function()
    245267
     
    620642        function answer_expiration_event()
    621643        {
     644            if( PEK_CONTENT_SCHEDULER_VERSION ) {
     645                error_log( __FILE__ . " :: " . __FUNCTION__ . " Top" );
     646            }
    622647            // we should get our options right now, and decide if we need to proceed or not.
    623648            $options = get_option('ContentScheduler_Options');
     
    627652                // We need to process expirations
    628653                $this->process_expirations();
    629             } // end if
     654            } else {
     655                if( PEK_CONTENT_SCHEDULER_VERSION ) {
     656                    error_log( "Expiration status is HOLD, so we won't process" );
     657                }
     658            }
     659
    630660        }
    631661        // Respond to a call from wp-cron checking for valid notification rules
     
    642672        function process_expirations()
    643673        {
     674            if( PEK_CONTENT_SCHEDULER_VERSION ) {
     675                error_log( __FILE__ . " :: " . __FUNCTION__ . " Top" );
     676            }
    644677            // Check database for posts meeting expiration criteria
    645678            // Hand them off to appropriate functions
  • content-scheduler/trunk/includes/process-expirations.php

    r1047421 r1047423  
    2525            if ( ! empty( $result ) )
    2626            {
     27                if( PEK_CONTENT_SCHEDULER_VERSION ) {
     28                    error_log( __FILE__ . " :: " . __FUNCTION__ . " Top" );
     29                    error_log( "We got results from our query" );
     30                    error_log( count( $result ) . " results were fetched" );
     31                }
     32
    2733                // See if we are supposed to NOTIFY upon expiration
    2834                // we do this in its own loop before deleting
     
    4349                if( $options['exp-status'] == '2' )
    4450                {
     51                    if( PEK_CONTENT_SCHEDULER_VERSION ) {
     52                        error_log( __FILE__ . " :: " . __FUNCTION__ . " Top" );
     53                        error_log( "We're only supposed to delete these" );
     54                    }
    4555                    // Delete all those posts
    4656                    foreach ( $result as $cur_post )
     
    5262                else
    5363                {
     64                    if( PEK_CONTENT_SCHEDULER_VERSION ) {
     65                        error_log( __FILE__ . " :: " . __FUNCTION__ . " Top" );
     66                        error_log( "We're supposed to fully process these" );
     67                    }
    5468                    // Proceed with the updating process                   
    5569                    // step through the results
Note: See TracChangeset for help on using the changeset viewer.