Plugin Directory

Changeset 706934


Ignore:
Timestamp:
05/02/2013 01:03:17 PM (13 years ago)
Author:
freakingid
Message:

Merge 1.0 changes into WPSVN release branch

Location:
content-scheduler/trunk
Files:
2 added
4 edited

Legend:

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

    r579494 r706934  
    22/*
    33Plugin Name: Content Scheduler
    4 Plugin URI: http://structurewebdev.com/wordpress-plugins/content-scheduler/
     4Plugin URI: http://paulekaiser.com/wordpress-plugins/content-scheduler/
    55Description: Set Posts and Pages to automatically expire. Upon expiration, delete, change categories, status, or unstick posts. Also notify admin and author of expiration.
    6 Version: 0.9.9
     6Version: 1.0.0
    77Author: Paul Kaiser
    88Author URI: http://paulekaiser.com
     
    5959            // adds our plugin options page
    6060            add_action('admin_menu', array($this, 'ContentScheduler_addoptions_page_fn'));
    61             // add a cron action for expiration check and notification check
     61            // add a cron action for expiration check
    6262            // I think this is still valid, even after 3.4 changes
    6363            if ( $this->is_network_site() )
    6464            {
    6565                add_action ('content_scheduler'.$current_blog->blog_id, array( $this, 'answer_expiration_event') );
    66                 add_action ('content_scheduler_notify'.$current_blog->blog_id, array( $this, 'answer_notification_event') );
    6766            }
    6867            else
    6968            {
    7069                add_action ('content_scheduler', array( $this, 'answer_expiration_event') );
    71                 add_action ('content_scheduler_notify', array( $this, 'answer_notification_event') );
    7270            }
    7371            // ==========
     
    345343        } // end draw_min_level_fn()
    346344       
    347         // 8/8/2011 11:51:41 PM -pk
    348         // 0.9.7 We are removing this option.
    349         /*
    350         // Notify upon expiration?
    351         function draw_notify_expire_fn()
    352         {
    353             // get this plugin's options from the database
    354             $options = get_option('ContentScheduler_Options');
    355             // make array of radio button items
    356             $items = array(
    357                             array('1', __("Notify on expiration", 'contentscheduler'), __("Notify when expiration changes posts / pages.", 'contentscheduler') ),
    358                             array('0', __("Do not notify on expiration", 'contentscheduler'), __("Do not notify when expiration changes posts / pages.", 'contentscheduler') )
    359                             );
    360             // Step through and spit out each item as radio button
    361             foreach( $items as $item )
    362             {
    363                 $checked = ($options['notify-expire'] == $item[0] ) ? ' checked="checked" ' : '';
    364                 echo "<label><input ".$checked." value='$item[0]' name='ContentScheduler_Options[notify-expire]' type='radio' /> $item[1] &mdash; $item[2]</label><br />";
    365             } // end foreach
    366         } // draw_notify_expire_fn()
    367         */
    368        
    369         // Notify number of days before expiration?
    370         function draw_notify_before_fn()
    371         {
    372             // get this plugin's options from the database
    373             // This should have a default value of '0'
    374             $options = get_option('ContentScheduler_Options');
    375             $input_field = "<input id='notify-before' name='ContentScheduler_Options[notify-before]' size='10' type='text' value='{$options['notify-before']}' />";
    376             printf( __("Notify %s days before expiration.", 'contentscheduler'), $input_field );
    377             echo "<br />\n";
    378         } // end draw_notify_before_fn()
    379345        // Show expiration date in columnar lists?
    380346        function draw_show_columns_fn()
     
    607573            $arr_defaults = array
    608574            (
    609                 "version" => "0.9.9",
    610                 "exp-status" => "1",
     575                "version" => "1.0.0",
     576                  "exp-status" => "1",
    611577                "exp-period" => "1",
    612578                "chg-status" => "2",
     
    619585                "notify-author" => "0",
    620586                "notify-expire" => "0",
    621                 "notify-before" => "0",
    622587                "min-level" => "level_1",
    623588                "show-columns" => "0",
     
    696661                }
    697662                // We need to update the version string to our current version
    698                 $options['version'] = "0.9.8";
     663                $options['version'] = "1.0.0";
    699664                // make sure we have added any updated options
    700665                if (!function_exists('array_replace'))
     
    721686                    // wp_schedule_event( time(), 'hourly', 'content_scheduler_'.$current_blog_id );
    722687                }
    723                 // for notifications
    724                 if( !wp_next_scheduled( 'content_scheduler_notify_'.$current_blog_id ) )
    725                 {
    726                     wp_schedule_event( time(), 'hourly', 'content_scheduler_notify_'.$current_blog_id );
    727                 }
    728688            }
    729689            else
     
    735695                    wp_schedule_event( time(), 'contsched_usertime', 'content_scheduler' );
    736696                    // wp_schedule_event( time(), 'hourly', 'content_scheduler' );
    737                 }
    738                 // for notifications
    739                 if( !wp_next_scheduled( 'content_scheduler_notify' ) )
    740                 {
    741                     wp_schedule_event( time(), 'hourly', 'content_scheduler_notify' );
    742697                }
    743698            }
     
    815770            // Make sure tags are alphanumeric and that is all
    816771            // Testing tags-to-add, which should be a comma-delimited list of alphanumerics
     772            // trim out space from tags string
     773            $input['tags-to-add'] = trim( $input['tags-to-add'] );
    817774            if ( !empty( $input['tags-to-add'] ) )
    818775            {
    819776                $input['tags-to-add'] = filter_var( $input['tags-to-add'], FILTER_SANITIZE_STRING );
    820             }
    821             // Make sure notify-before is an integer value
    822             if ( empty( $input['notify-before'] ) )
    823             {
    824                 $input['notify-before'] = '0';
    825                 // return $input;
    826             }
    827             else
    828             {
    829                 // if it's not empty, let's keep moving
    830                 if ( ! sprintf("%u", $input['notify-before']) == $input['notify-before'])
    831                 {
    832                     // register an error, officially
    833                     add_settings_error('ContentScheduler_Options',
    834                         'settings_updated',
    835                         __('Only positive integers are accepted for "Notify before expiration".', 'contentscheduler'),
    836                         'error');
    837                 }
    838777            }
    839778            // We need to take inputs from the default expiration time and pack it up into an array.
     
    859798                wp_clear_scheduled_hook('content_scheduler_'.$blog_id);
    860799                wp_schedule_event( time(), 'contsched_usertime', 'content_scheduler_'.$blog_id );
    861                 // for notifications
    862                 wp_clear_scheduled_hook('content_scheduler_notify_'.$blog_id);
    863                 wp_schedule_event( time(), 'hourly', 'content_scheduler_notify_'.$current_blog_id );
    864800            }
    865801            else
     
    869805                wp_clear_scheduled_hook('content_scheduler');
    870806                wp_schedule_event( time(), 'contsched_usertime', 'content_scheduler' );
    871                 // for notifications
    872                 wp_clear_scheduled_hook('content_scheduler_notify');
    873                 wp_schedule_event( time(), 'hourly', 'content_scheduler_notify' );
    874807            }
    875808            // if we had an error, do we still return? Or not?
     
    1004937            $this->setup_timezone();
    1005938            // Checkbox for "enable scheduling"
    1006             $enabled = $_POST['_cs-enable-schedule'];
     939            $enabled = ( empty( $_POST['_cs-enable-schedule'] ) ? 'Disable' : $_POST['_cs-enable-schedule'] );
    1007940            // Value should be either 'Enable' or 'Disable'; otherwise something is screwy
    1008941            if( $enabled != 'Enable' AND $enabled != 'Disable' )
     
    10811014                    $date = '';
    10821015                    // For debug, we will set to 'INVALID'
    1083                     $date = 'INVALID';
     1016                    // $date = 'INVALID';
    10841017                }
    10851018            }
     
    12111144            } // end if
    12121145        }
    1213         // ====================
    1214         // Respond to a daily call from wp-cron checking for notification needs
    1215         function answer_notification_event()
    1216         {
    1217             // we should get our options right now, and decide if we need to proceed or not.
    1218             $options = get_option('ContentScheduler_Options');
    1219             // Do we need to process notifications?
    1220             if( $options['notify-on'] != '0' )
    1221             {
    1222                 // We need to process notifications
    1223                 // Note, these are only notifications that occur as a warning
    1224                 // BEFORE expiration
    1225                 $this->process_notifications();
    1226             } // end if
    1227         } // end answer_notification_event()
     1146
    12281147        // ==========================================================
    12291148        // Process Expirations
     
    12351154            include 'includes/process-expirations.php';
    12361155        } // end process_expirations()
    1237         // =============================================================
    1238         // Process Notifications
    1239         // =============================================================
    1240         function process_notifications()
    1241         {
    1242             // Check database for posts meeting notification-only criteria
    1243             // Hand them off to appropriate functions
    1244             include 'includes/process-notifications.php';           
    1245         } // end process_notifications()
    1246         // =============================================================
    1247         // == Perform NOTIFICATIONs
    1248         // =============================================================
    1249         // This function takes an array of arrays.
    1250         // The arrays contain a post_id and an array of user_ids
    1251         // The function then compiles one email per user and sends it by email.
    1252         // This method takes one item in the outside array per Post.
    1253         function do_notifications( $posts_to_notify, $why_notify )
    1254         {
    1255             // notify people of expiration or pending expiration
    1256             include 'includes/send-notifications.php'; 
    1257         } // end do_notifications()
     1156
    12581157// 11/23/2010 11:45:27 AM -pk
    12591158// Somehow, we need to retrieve the OPTIONS only Once, and then act upon them.
     
    12791178            include "includes/process-post.php";
    12801179        } // end process_custom()
     1180
    12811181        // ================================================================
    12821182        // == Conditionally Add Expiration date to Column views
  • content-scheduler/trunk/includes/init-admin.php

    r479969 r706934  
    134134                array($this, 'draw_notify_on_fn'),
    135135                'ContentScheduler_Page_Title',
    136                 'ContentScheduler_Not_ID');
    137             /*
    138             Textbox: Notify before expiration: 'exp-notify-before'
    139             * This is a number of days before expiration.
    140             */
    141             add_settings_field(
    142                 'notify-before',
    143                 __('Notify before expiration:', 'contentscheduler'),
    144                 array($this, 'draw_notify_before_fn'),
    145                 'ContentScheduler_Page_Title',
    146                 'ContentScheduler_Not_ID');
    147            
    148             // 8/8/2011 11:52:49 PM -pk
    149             // We are removing this option
    150             /*
    151             Checkbox: Notify upon expiration: 'exp-notify-when'
    152             */
    153             /*
    154             add_settings_field(
    155                 'notify-expire',
    156                 __('Notify upon expiration:', 'contentscheduler'),
    157                 array($this, 'draw_notify_expire_fn'),
    158                 'ContentScheduler_Page_Title',
    159                 'ContentScheduler_Not_ID');
    160             */
    161            
     136                'ContentScheduler_Not_ID');
    162137            /*
    163138            Checkbox: Notify admin: 'exp-notify-admin'
  • content-scheduler/trunk/includes/process-post.php

    r479969 r706934  
    11<?php
    22            $options = get_option('ContentScheduler_Options');
     3            // STICKINESS (Pages do not have STICKY ability)
     4            // Note: This is stored in the options table, and is not part of post_update
     5            // get the array of sticky posts
     6            // What do we want to do with stickiness?
     7            $sticky_change = $options['chg-sticky'];
     8            if( $sticky_change == '1' )
     9            {
     10                $sticky_posts = get_option('sticky_posts');
     11                if( ! empty( $sticky_posts ) )
     12                {
     13                    // Remove $postid from the $sticky_posts[] array
     14                    foreach( $sticky_posts as $key => $stuck_id )
     15                    {
     16                        if( $stuck_id == $postid )
     17                        {
     18                            // remove $key from $sticky_posts
     19                            unset( $sticky_posts[$key] );
     20                            break;
     21                        } // end if
     22                    } // end foreach
     23                    // Get the new array of stickies back into WP
     24                    update_option('sticky_posts', $sticky_posts);
     25                } // end if
     26            } // end if
     27
    328            // Now, make the array we would pass to wp_update_post
    429            // This is a local variable, so each time process_post is called, it will be new
     
    6590            } // end if - checking chg-cat-method
    6691            // =============================================================
    67             // TAGS (Check to see if the post type support post_tag first)
     92            // TAGS (Check to see if the post type support post_tag first)         
    6893            $proceed = false;
    6994            // Get the post type (we're using this same file for Posts and Custom Post Types)
     
    89114                    } // end if for post_tag support
    90115                } // end if for $post_type != post
     116               
    91117                if( $proceed == true )
    92118                {
    93                     // ===========================================================
    94119                    // First, check to see if we even want to do tags
    95                     // $tags_to_add = $options['tags-to-add']; // this is a comma-delimited string
    96                     // turn $tags_to_add into an array
    97                     // $tags_to_add = explode( ", ", $tags_to_add );
    98                    
    99                     // get entire list of tags from content scheduler settings
    100                     $tags_setting_list = explode( ",", $options['tags-to-add'] );
    101                     // for debug
    102                    
    103                     // make sure we just have a comma-separated list of alphanumeric entries
    104                     $tags_setting_list = filter_var_array( $tags_setting_list, FILTER_SANITIZE_STRING );
    105                    
    106                     // init arrays used for final operations
    107                     $tags_to_add = array();
    108                     $tags_to_remove = array();
    109                     $tags_absolute = array();
    110                     $final_tag_list = array();
    111                     // process the array by:
    112                     // a. remove spaces from items
    113                     // b. checking for "-" or "+" as first character
    114                     // -- i. Adding to appropriate array if there is such a character
    115                     foreach( $tags_setting_list as $cur_tag )
    116                     {
    117                         // trim any space
    118                         $cur_tag = trim( $cur_tag );
    119                         // we'll do trim() again on the + and - items, since there might be whitespace after the +/-
    120                         // check to see what the first character of the tag is
    121                         $first_char = substr( $cur_tag, 0, 1 );
    122                        
    123                         switch( $first_char )
    124                         {
    125                             case '+':
    126                                 $tags_to_add[] = trim( substr( $cur_tag, 1 ) );
    127                                 break;
    128                             case '-':
    129                                 $tags_to_remove[] = trim( substr( $cur_tag, 1 ) );
    130                                 break;
    131                             default:
    132                                 $tags_absolute[] = $cur_tag;
    133                         } // end switch
    134                     } // end foreach
    135 
    136                     // if $tags_absolute is not empty, then we will set the new tag list to just that array and we are done
    137                     if( !empty( $tags_absolute ) )
    138                     {
    139                         $final_tag_list = $tags_absolute;
    140                     }
    141                     else
    142                     {
     120                    $tags_to_add = $options['tags-to-add']; // this is a comma-delimited string
     121                    if( '' != $tags_to_add ) {
     122                      // we have some tags to work with
     123                      $tags_setting_list = explode( ",", $tags_to_add );
     124            // make sure we just have a comma-separated list of alphanumeric entries
     125            $tags_setting_list = filter_var_array( $tags_setting_list, FILTER_SANITIZE_STRING );
     126            // init arrays used for final operations
     127            $tags_to_add = array();
     128            $tags_to_remove = array();
     129            $final_tag_list = array();
     130            // process the array by:
     131            // a. remove spaces from items
     132            // b. checking for "-" or "+" as first character
     133            // -- i. Adding to appropriate array if there is such a character
     134            foreach( $tags_setting_list as $cur_tag )
     135            {
     136              // trim any space from front and back
     137              $cur_tag = trim( $cur_tag );
     138              // we'll do trim() again on the + and - items, since there might be whitespace after the +/-
     139              // check to see what the first character of the tag is
     140              $first_char = substr( $cur_tag, 0, 1 );
     141              switch( $first_char )
     142              {
     143                case '-':
     144                  $tags_to_remove[] = trim( substr( $cur_tag, 1 ) );
     145                  break;
     146                case '+':
     147                  $tags_to_add[] = trim( substr( $cur_tag, 1 ) );
     148                default:
     149                  $tags_to_add[] = trim( $cur_tag );
     150              } // end switch
     151            } // end foreach
     152           
    143153                        // get the current tags list for this post
    144154                        $cur_post_tags = get_the_tags( $postid ); // returns an array of objects
     
    147157                            // Make a new array to keep just the current tag list in
    148158                            $new_cur_post_tags = array();
    149                             // Step through $cur_post_tags objects, getting the 'name' parameter from each
    150159                            foreach( $cur_post_tags as $tag_object )
    151160                            {
    152161                                $new_cur_post_tags[] = $tag_object->name;
    153162                            }
    154                             // Add and remove tags as indicated
    155                             if ( !empty( $tags_to_remove ) )
    156                             {
    157                                 // remove any indicated tags
    158                                 $new_cur_post_tags = array_diff( $new_cur_post_tags, $tags_to_remove );
     163                            // Remove tags from current list
     164                            if( !empty( $tags_to_remove ) ) {
     165                              $new_cur_post_tags = array_diff( $new_cur_post_tags, $tags_to_remove );
    159166                            }
    160                             if ( !empty( $tags_to_add ) )
    161                             {
    162                                 // add any indicated tags
    163                                 $final_tag_list = array_merge( $new_cur_post_tags, $tags_to_add );
    164                             }
     167                            // Add tags to current list
     168              if( !empty( $tags_to_add ) ) {
     169                $new_cur_post_tags = array_merge( $new_cur_post_tags, $tags_to_add );
     170              }
     171              // now build final tag list. this could be better
     172              $final_tag_list = $new_cur_post_tags;
    165173                        }
    166174                        else
     
    168176                            // there were no current tags in the post, so we're just adding
    169177                            $final_tag_list = $tags_to_add;
    170                         }
    171                     } // end if checking for tags_absolute
    172                     // now I need all those tags comma delimited again (did we have to go into the array and back out of it to handle the duplicates?)
    173                     $final_tag_list = implode( ", ", $final_tag_list );
    174                     // add the tag list to our $update_post
    175                     $update_post['tags_input'] = $final_tag_list;
     178                        } // end if checking for empty current post tag list
     179
     180            // now I need all those tags comma delimited again (did we have to go into the array and back out of it to handle the duplicates?)
     181            $final_tag_list = implode( ", ", $final_tag_list );
     182            // add the tag list to our $update_post
     183            $update_post['tags_input'] = $final_tag_list;
     184                    } // end if for having tags_to_add
    176185                } // endif for $proceed == true
    177186            } // end if for post_type existing
     187
    178188            // =============================================================
    179189            // NOW ACTUALLY UPDATE THE POST RECORD
     
    192202                update_post_meta( $postid, '_cs-enable-schedule', 'Disable' );
    193203            }
    194             // The rest of this stuff is not actually stored in _posts
    195             // STICKINESS (Pages do not have STICKY ability)
    196             // Note: This is stored in the options table, and is not part of post_update
    197             // get the array of sticky posts
    198             // What do we want to do with stickiness?
    199             $sticky_change = $options['chg-sticky'];
    200             if( $sticky_change == '1' )
    201             {
    202                 $sticky_posts = get_option('sticky_posts');
    203                 if( ! empty( $sticky_posts ) )
    204                 {
    205                     // Remove $postid from the $sticky_posts[] array
    206                     foreach( $sticky_posts as $key => $stuck_id )
    207                     {
    208                         if( $stuck_id == $postid )
    209                         {
    210                             // remove $key from $sticky_posts
    211                             unset( $sticky_posts[$key] );
    212                             break;
    213                         } // end if
    214                     } // end foreach
    215                     // Get the new array of stickies back into WP
    216                     update_option('sticky_posts', $sticky_posts);
    217                 } // end if
    218             } // end if
    219204?>
  • content-scheduler/trunk/readme.txt

    r579494 r706934  
    77Author: Paul Kaiser (freakingid)
    88Requires at least: 2.9
    9 Tested up to: 3.4.1
    10 Stable tag: 0.9.9
     9Tested up to: 3.5.1
     10Stable tag: 1.0.0
    1111
    1212Schedule content to automatically expire and change at a certain time, and notify people of expiration.
     
    1414== Description ==
    1515
    16 Content Scheduler lets you control when content automatically expires, what to do with that content when it expires, and optionally how to provide notification to site contributors when the content expired.
     16Content Scheduler lets you control when content automatically expires, what to do with that content when it expires, and optionally provide notification to site contributors when the content expired.
    1717
    1818= Expiration Options =
     
    3131
    3232* When expiration occurs
    33 * A specific number of days before expiration occurs
    3433
    3534This reminder helps you keep content fresh, providing a reminder that content is out of date and needs updated or replaced. Content Scheduler lets you use notification tools without making any changes to content upon expiration, if you'd like.
    36 
    37 = More Information =
    38 
    39 Documentation included with the plugin in PDF format.
    40 Also see the developer's site, [Structure Web Development:](http://structurewebdev.com/)
    4135
    4236== Installation ==
     
    7973
    8074== Changelog ==
     75
     76= 1.0.0 =
     77* FIX: addition and removal of post tags
     78* CHANGE: removed option for setting absolute list of tags
     79* FIX: multiple unwanted notifications
     80* CHANGE: removed option for sending notifications prior to notification (only happens upon expiration event now)
    8181
    8282= 0.9.9 =
     
    124124* First public release.
    125125
     126== Upcoming ==
     127
     128a. Improved, more standard datepicker for expiration date/time field.
     129b. Removal of irrelevant "seconds" picking from date/time field.
     130c. Explore support for manipulating custom taxonomy terms upon expiration.
     131d. Explore support for manipulating custom meta values upon expiration.
     132e. Explore support for swapping content from a separate post upon expiration.
     133f. Revamped documentation.
     134g. Clean up settings panel.
     135
    126136== Upgrade Notice ==
Note: See TracChangeset for help on using the changeset viewer.