Plugin Directory

Changeset 960367


Ignore:
Timestamp:
08/05/2014 08:24:39 AM (12 years ago)
Author:
farne
Message:

Version 0.3.0 of the plugin.

Location:
post-status-scheduler
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • post-status-scheduler/trunk/classes/scheduler.php

    r933176 r960367  
    1414
    1515  namespace post_status_scheduler;
     16
     17  require_once( 'event.php' );
     18  require_once( 'taxonomy.php' );
     19
     20  use \post_status_scheduler\Event as Event;
     21  use \post_status_scheduler\Taxonomy as Taxonomy;
    1622   
    1723  class Scheduler {
     
    150156      $date = isset( $postdata['scheduler']['date'] ) && strlen( $postdata['scheduler']['date'] ) == 10 ? $postdata['scheduler']['date'] : null;
    151157      $time = isset( $postdata['scheduler']['time'] ) && strlen( $postdata['scheduler']['time'] ) == 5 ? $postdata['scheduler']['time'] : null;
    152       $scheduler_check_status = isset( $postdata['scheduler']['post-status-check'] ) ? true : false;
    153       $scheduler_status = isset( $postdata['scheduler']['status'] ) ? $postdata['scheduler']['status'] : null;
     158
     159      // Create a new event container
     160      $event = new Event( $post_id );
     161
     162      $event->check_status = isset( $postdata['scheduler']['post-status-check'] ) ? true : false;
     163      $event->status = isset( $postdata['scheduler']['status'] ) ? $postdata['scheduler']['status'] : null;
    154164     
    155       $scheduler_check_category = isset( $postdata['scheduler']['category-check'] ) ? true : false;
    156       $scheduler_category_action = isset( $postdata['scheduler']['category-action'] ) ? $postdata['scheduler']['category-action'] : null;
    157       $scheduler_category = isset( $postdata['scheduler']['category'] ) ? $postdata['scheduler']['category'] : null;
    158 
    159       $scheduler_check_meta = isset( $postdata['scheduler']['postmeta-check'] ) ? true : false;
    160       $scheduler_meta_key = isset( $postdata['scheduler']['meta_key'] ) ? $postdata['scheduler']['meta_key'] : null;
     165      // Categories
     166      $event->check_category = isset( $postdata['scheduler']['category-check'] ) ? true : false;
     167
     168      // Adding categories
     169      $event->category_action = isset( $postdata['scheduler']['category-action'] ) ? true : false;
     170      $event->category = isset( $postdata['scheduler']['category'] ) ? $postdata['scheduler']['category'] : array();
     171
     172      $event->check_meta = isset( $postdata['scheduler']['postmeta-check'] ) ? true : false;
     173      $event->meta_key = isset( $postdata['scheduler']['meta_key'] ) ? $postdata['scheduler']['meta_key'] : null;
    161174
    162175      // Check if there is an old timestamp to clear away
    163       $old_timestamp = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     176      //$old_timestamp = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     177      $old_timestamp = Scheduler::previous_schedule( $post->ID );
    164178
    165179      // Is there a timestamp to save?
    166180      if( !empty( $date ) && !empty( $time ) && isset( $postdata['scheduler']['use'] ) ) {
    167181
    168         $new_timestamp = strtotime( $date . ' ' . $time . ':00' );
    169 
    170         // Abort if not a valid timestamp
    171         if( !isset( $new_timestamp ) || !is_int( $new_timestamp ) ) return $post_id;
     182        if( !$new_timestamp = Scheduler::create_timestamp( $date, $time ) ) {
     183         
     184          return $post_id;
     185
     186        }
    172187
    173188        // Remove old scheduled event and post meta tied to the post
     
    175190
    176191          Scheduler::unschedule( $post->ID );
    177           Scheduler::delete_meta( $post->ID );
    178 
    179         }
    180        
    181 
    182         // Get the current system time to compare with the new scheduler timestamp
    183         $system_time = microtime( true );
    184         $gmt = get_gmt_from_date( date( 'Y-m-d H:i:s', $new_timestamp ),'U');
    185 
    186         // The gmt needs to be bigger than the current system time
    187         if( $gmt <= $system_time ) return $post_id;
     192          Event::delete( $post->ID );
     193
     194        }
     195
     196
     197        if( !$gmt = Scheduler::check_gmt_against_system_time( $new_timestamp ) ) return $post_id;
    188198
    189199        // Clear old scheduled time if there is one
     
    197207        if( $scheduling_result ) {
    198208
    199           update_post_meta( $post->ID, 'scheduler_date', $new_timestamp );
    200 
    201           // Post status
    202           update_post_meta( $post->ID, 'scheduler_check_status', $scheduler_check_status );
    203           update_post_meta( $post->ID, 'scheduler_status', $scheduler_status );
    204 
    205           // post category
    206           update_post_meta( $post->ID, 'scheduler_check_category', $scheduler_check_category );
    207           update_post_meta( $post->ID, 'scheduler_category_action', $scheduler_category_action );
    208           update_post_meta( $post->ID, 'scheduler_category', $scheduler_category );
     209          $event->date = $new_timestamp;
     210          $event->save();
    209211         
    210           // post meta
    211           update_post_meta( $post->ID, 'scheduler_check_meta', $scheduler_check_meta );
    212           update_post_meta( $post->ID, 'scheduler_meta_key', $scheduler_meta_key );
    213 
    214212          apply_filters( 'post_status_scheduler_after_scheduling_success', $post->ID );
    215213
     
    229227
    230228          // Remove post meta
    231           Scheduler::delete_meta( $post->ID );
     229          Event::delete( $post->ID );
    232230
    233231        }
     
    245243     */
    246244    public function schedule_post_status_change( $post_id ) {
    247      
     245
    248246      // Get all scheduler postmeta data
    249       $scheduler_check_status = get_post_meta( $post_id, 'scheduler_check_status', true );
    250       $scheduler_check_status = !empty( $scheduler_check_status ) ? true : false;
    251       $scheduler_status = get_post_meta( $post_id, 'scheduler_status', true );
    252 
    253       $scheduler_check_category = get_post_meta( $post_id, 'scheduler_check_category', true );
    254       $scheduler_check_category = !empty(  $scheduler_check_category ) ? true : false;
    255       $scheduler_category_action = get_post_meta( $post_id, 'scheduler_category_action', true );
    256       $scheduler_category = get_post_meta( $post_id, 'scheduler_category', true );
    257 
    258       if( !empty( $scheduler_category ) ) {
    259        
    260         $scheduler_category_splits = explode( '_', $scheduler_category );
    261         if( count( $scheduler_category_splits ) == 2 ) {
    262          
    263           $scheduler_category = $scheduler_category_splits[0];
    264           $scheduler_category_taxonomy = $scheduler_category_splits[1];
    265        
    266         }
    267 
    268       }
    269 
    270       $scheduler_check_meta = get_post_meta( $post_id, 'scheduler_check_meta', true );
    271       $scheduler_check_meta = !empty( $scheduler_check_meta ) ? true : false;
    272       $scheduler_meta_key = get_post_meta( $post_id, 'scheduler_meta_key', true );
    273      
     247      $event = new Event( $post_id );
     248
    274249      $valid_statuses = array_keys( Scheduler::post_statuses() );
    275250
    276251      // Add a filter for developers to change the flow
    277       $filter_result = apply_filters( 'post_status_scheduler_before_execution', array( 'status' => $scheduler_status, 'valid_statuses' => $valid_statuses ), $post_id );
     252      $filter_result = apply_filters( 'post_status_scheduler_before_execution', array( 'status' => $event->status, 'valid_statuses' => $valid_statuses ), $post_id );
    278253      $scheduler_status = $filter_result['status'];
    279254      $valid_statuses = $filter_result['valid_statuses'];
    280255
    281       if( $scheduler_check_status ) {
     256      if( $event->check_status ) {
    282257
    283258        // Execute the scheduled status change
    284         if( in_array( $scheduler_status, $valid_statuses ) ) {
    285 
    286           switch( $scheduler_status ) {
     259        if( in_array( $event->status, $valid_statuses ) ) {
     260
     261          switch( $event->status ) {
    287262            case 'draft':
    288263            case 'pending':
    289264            case 'private':
    290               wp_update_post( array( 'ID' => $post_id, 'post_status' => $scheduler_status ) );
     265              wp_update_post( array( 'ID' => $post_id, 'post_status' => $event->status ) );
    291266              break;
    292267            case 'trash':
     
    305280
    306281      // If user just wish to remove a post meta
    307       if( $scheduler_check_meta ) {
    308 
    309         if( !empty( $scheduler_meta_key ) ) {
    310           delete_post_meta( $post_id, $scheduler_meta_key );
    311         }
    312 
    313       }
    314 
    315 
    316       // If user wish to add or remove a category
    317       if( $scheduler_check_category ) {
    318 
    319         if( !empty( $scheduler_category_action ) ) {
    320 
    321           if( $scheduler_category_action == 'add' ) {
    322 
    323             wp_set_post_terms( $post_id, array( $scheduler_category ), $scheduler_category_taxonomy, true );
    324 
    325           } else if( $scheduler_category_action == 'remove' ) {
    326 
    327             $categories = wp_get_post_terms( $post_id, $scheduler_category_taxonomy );
    328             $new_categories = array();
    329 
    330             if( count( $categories ) > 0 ) {
    331 
    332               foreach( $categories as $key => $category ) {
    333 
    334                 array_push( $new_categories, $category->term_id );
    335 
     282      if( $event->check_meta ) {
     283
     284        if( !empty( $event->meta_key ) ) {
     285          delete_post_meta( $post_id, $event->meta_key );
     286        }
     287
     288      }
     289
     290
     291      // Add and remove categories
     292      if( $event->check_category ) {
     293
     294        if( is_array( $event->category ) ) {
     295
     296          if( count( $event->category ) > 0 ) {
     297
     298            // Reset all categories
     299            Taxonomy::reset_all_terms( $post_id );
     300
     301            foreach( $event->category as $scheduler_cat ) {
     302
     303              $scheduler_category_splits = explode( '_', $scheduler_cat );
     304              if( count( $scheduler_category_splits ) >= 2 ) {
     305           
     306                // Get the category id
     307                $scheduler_category_to_add = array_shift( $scheduler_category_splits );
     308                // Get the taxonomy of the category
     309                $scheduler_category_taxonomy = implode( '_', $scheduler_category_splits );
     310
     311                // Update the categories
     312                Taxonomy::set_terms( $post_id, array( $scheduler_category_to_add ), $scheduler_category_taxonomy, true );
     313         
    336314              }
    337315
    338316            }
    339 
    340             $position = array_search( $scheduler_category, $new_categories );
    341             unset( $new_categories[$position] );
    342 
    343             wp_set_post_terms( $post_id, $new_categories, $scheduler_category_taxonomy );
     317          }
     318
     319        } else { // This is here for legacy reasons, versions <= 0.2.1
     320
     321          if( is_string( $event->category ) && strlen( $event->category ) > 0 ) {
     322           
     323            if( !empty( $event->category_action ) ) {
     324       
     325              $scheduler_category_splits = explode( '_', $event->category );
     326              if( count( $scheduler_category_splits ) >= 2 ) {
     327           
     328                // Get the category id
     329                $scheduler_category = array_shift( $scheduler_category_splits );
     330
     331                // Get the taxonomy of the category
     332                $scheduler_category_taxonomy = implode( '_', $scheduler_category_splits );
     333
     334                if( $scheduler_category_action == 'add' ) {
     335
     336                  Taxonomy::set_terms( $post_id, array( $scheduler_category ), $scheduler_category_taxonomy, true );
     337
     338                } else if( $event->category_action == 'remove' ) {
     339
     340                  $categories = Taxonomy::get_terms( $post_id, $scheduler_category_taxonomy );
     341                  $new_categories = array();
     342
     343                  if( count( $categories ) > 0 ) {
     344
     345                    foreach( $categories as $key => $category ) {
     346
     347                      array_push( $new_categories, $category->term_id );
     348
     349                    }
     350
     351                  }
     352
     353                  $position = array_search( $scheduler_category, $new_categories );
     354                  unset( $new_categories[$position] );
     355
     356                  Taxonomy::set_terms( $post_id, $new_categories, $scheduler_category_taxonomy );
     357
     358                }
     359
     360              }
     361
     362            }
    344363
    345364          }
     
    353372     
    354373      // Remove post meta
    355       Scheduler::delete_meta( $post_id );
     374      Event::delete( $post_id );
    356375
    357376      apply_filters( 'post_status_scheduler_after_execution', array( 'status' => $scheduler_status, 'valid_statuses' => $valid_statuses ), $post_id );
     
    399418      global $post, $post_type;
    400419
     420      $event = new Event( $post->ID );
     421
    401422      // Get valid post types set in module settings page
    402423      $allowed_posttypes = isset( $this->options['allowed_posttypes'] ) ? $this->options['allowed_posttypes'] : array();
    403424      $meta_keys = isset( $this->options['meta_keys'] ) ? $this->options['meta_keys'] : array();
    404       $categories = Scheduler::get_posttype_categories( $post_type );
    405      
    406       $scheduler_check_status = get_post_meta( $post->ID, 'scheduler_check_status', true );
    407       $scheduler_check_status = !empty( $scheduler_check_status ) ? true : false;
    408       $scheduler_status = get_post_meta( $post->ID, 'scheduler_status', true );
    409 
    410       $scheduler_check_category = get_post_meta( $post->ID, 'scheduler_check_category', true );
    411       $scheduler_check_category = !empty(  $scheduler_check_category ) ? true : false;
    412       $scheduler_category_action = get_post_meta( $post->ID, 'scheduler_category_action', true );
    413       if( empty( $scheduler_category_action ) ) $scheduler_category_action = 'add';
    414       $scheduler_category = get_post_meta( $post->ID, 'scheduler_category', true );
    415 
    416       $scheduler_check_meta = get_post_meta( $post->ID, 'scheduler_check_meta', true );
    417       $scheduler_check_meta = !empty( $scheduler_check_meta ) ? true : false;
    418       $scheduler_meta_key = get_post_meta( $post->ID, 'scheduler_meta_key', true );
     425      $categories = Taxonomy::get_posttype_terms( $post_type );
     426
     427      $post_categories = Taxonomy::get_all_terms( $post->ID );
     428      $post_categories = Taxonomy::setup_post_terms( $post_categories, $categories );
    419429
    420430      // Do not show HTML if there are no valid post types or current edit page is not for a valid post type
    421431      if( count( $allowed_posttypes ) && in_array( $post_type, $allowed_posttypes ) ) {
    422432       
    423         $date = get_post_meta( $post->ID, 'scheduler_date', true );
    424         $status = get_post_meta( $post->ID, 'scheduler_status', true );
     433        $date = $event->date;
     434        $status = $event->status;
    425435
    426436        $date = isset( $date ) && strlen( $date ) > 0 ? date( 'Y-m-d H:i', $date ) : null;
     
    436446        $show = empty( $date ) ? ' style="display: none;" ' : '';
    437447
    438         $scheduler_check_status_checked = ( $scheduler_check_status ) ? ' checked="checked" ' : '';
    439         $scheduler_check_status_show = ( !$scheduler_check_status ) ? ' style="display: none;" ' : '';
    440 
    441         $scheduler_check_category_checked = ( $scheduler_check_category ) ? ' checked="checked" ' : '';
    442         $scheduler_check_category_show = ( !$scheduler_check_category ) ? ' style="display: none;" ' : '';
    443 
    444         $scheduler_check_meta_checked = ( $scheduler_check_meta ) ? ' checked="checked" ' : '';
    445         $scheduler_check_meta_show = ( !$scheduler_check_meta ) ? ' style="display: none;" ' : '';
     448        $scheduler_check_status_checked = ( $event->check_status ) ? ' checked="checked" ' : '';
     449        $scheduler_check_status_show = ( !$event->check_status ) ? ' style="display: none;" ' : '';
     450
     451        $scheduler_check_category_checked = ( $event->check_category ) ? ' checked="checked" ' : '';
     452        $scheduler_check_category_show = ( !$event->check_category ) ? ' style="display: none;" ' : '';
     453
     454        $scheduler_check_meta_checked = ( $event->check_meta ) ? ' checked="checked" ' : '';
     455        $scheduler_check_meta_show = ( !$event->check_meta ) ? ' style="display: none;" ' : '';
    446456
    447457        // Write the HTML
     
    473483        if( count( $categories ) > 0 ) {
    474484
    475           echo '<input type="checkbox" name="scheduler[category-check]" id="scheduler-category" ' . $scheduler_check_category_checked . ' /> ' . __( 'Add or remove category', 'post-status-scheduler' ) . '<br />'
     485          echo '<input type="checkbox" name="scheduler[category-check]" id="scheduler-category" ' . $scheduler_check_category_checked . ' /> ' . __( 'Change categories', 'post-status-scheduler' ) . '<br />'
    476486          .'<div id="scheduler-category-box" ' . $scheduler_check_category_show . '>';
    477           echo '<input type="radio" value="add" name="scheduler[category-action]" ' . checked( $scheduler_category_action, 'add', false ) . ' /> ' . __( 'Add', 'post-status-scheduler' ) . '<br />'
    478           . '<input type="radio" value="remove" name="scheduler[category-action]" ' . checked( $scheduler_category_action, 'remove', false ) . ' /> ' . __( 'Remove', 'post-status-scheduler' ) . '<br />'
    479           . '<select name="scheduler[category]">';
    480 
    481           if( count( $categories ) > 0 ) {
    482             foreach( $categories as $category ) {
    483 
    484               echo sprintf( '<option value="%s">%s</option>', $category->term_id.'_'.$category->taxonomy, $category->name );
     487          echo __( 'The post will have the following categories on scheduled time', 'post-status-scheduler' );
     488          echo '<select name="scheduler[category][]" multiple size="5">';
     489           
     490          // Need this for legacy reasons. Used to be a string, versions <= 0.2.1
     491          if( is_string( $event->category ) ) {
     492
     493            if( $event->category_action == 'add' ) {
     494
     495              if( !in_array( $event->category, $post_categories ) ) array_push( $post_categories, $event->category );
     496
     497
     498            } else if( $event->category_action == 'remove' ) {
     499             
     500              if( ( $key = array_search( $event->category, $post_categories ) ) !== false ) {
     501               
     502                unset( $post_categories[$key] );
     503             
     504              } else if( in_array( $category->term_id.'_'.$category->taxonomy, $post_categories ) ) {
     505               
     506                $selected = ' selected="selected" ';
     507             
     508              }
    485509
    486510            }
     511
    487512          }
    488513
    489           echo '</select><br />'
    490           . '</div>';
     514          // Loop categories and check if selected
     515          foreach( $categories as $category ) {
     516
     517            if( is_array( $event->category ) ) {
     518
     519              $selected = in_array( $category->term_id.'_'.$category->taxonomy, $event->category ) ? ' selected="selected" ' : '';
     520           
     521            } else {
     522
     523              $selected = in_array( $category->term_id.'_'.$category->taxonomy, $post_categories ) ? ' selected="selected" ' : '';
     524
     525            }
     526
     527            echo sprintf( '<option value="%s"%s>%s</option>', $category->term_id.'_'.$category->taxonomy, $selected, $category->name );
     528
     529          }
     530
     531          echo '</select></div>';
     532
    491533        }
    492534
     
    612654
    613655    /**
     656     * check_gmt_against_system_time
     657     *
     658     * @param integer $new_timestamp
     659     *
     660     * @return integer $gmt;
     661     */
     662    public static function check_gmt_against_system_time( $new_timestamp ) {
     663
     664      // Get the current system time to compare with the new scheduler timestamp
     665        $system_time = microtime( true );
     666        $gmt = get_gmt_from_date( date( 'Y-m-d H:i:s', $new_timestamp ),'U');
     667
     668        // The gmt needs to be bigger than the current system time
     669        if( $gmt <= $system_time ) return false;
     670
     671        return $gmt;
     672
     673    }
     674
     675
     676    /**
     677     * create_timestamp
     678     *
     679     * Create a new timestamp from given date and time
     680     *
     681     * @param string $date
     682     * @param string $time
     683     *
     684     * @return boolen|integer
     685     */
     686    public static function create_timestamp( $date, $time ) {
     687
     688       $timestamp = strtotime( $date . ' ' . $time . ':00' );
     689
     690        //Abort if not a valid timestamp
     691        if( !isset( $timestamp ) || !is_int( $timestamp ) ) return false;
     692
     693        return $timestamp;
     694
     695    }
     696
     697
     698    /**
     699     * previous_schedule
     700     *
     701     * Return a previously scheduled time for this post
     702     *
     703     * @param $post_id
     704     *
     705     * @return string
     706     */
     707    public static function previous_schedule( $post_id ) {
     708
     709      return get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     710
     711    }
     712
     713
     714    /**
    614715     * list_meta_keys
    615716     *
     
    665766    }
    666767
    667 
    668     /**
    669      * delete_meta
    670      *
    671      * Deletes the old postmeta for the post given
    672      *
    673      * @param int $postid
    674      */
    675     public static function delete_meta( $post_id ) {
    676 
    677       // Remove post meta
    678       delete_post_meta( $post_id, 'scheduler_date' );
    679          
    680       // post status
    681       delete_post_meta( $post_id, 'scheduler_check_status' );
    682       delete_post_meta( $post_id, 'scheduler_status' );
    683 
    684       // post category
    685       delete_post_meta( $post_id, 'scheduler_check_category' );
    686       delete_post_meta( $post_id, 'scheduler_category_action' );
    687       delete_post_meta( $post_id, 'scheduler_category' );
    688      
    689       // post meta
    690       delete_post_meta( $post_id, 'scheduler_check_meta' );
    691       delete_post_meta( $post_id, 'scheduler_meta_key' );
    692 
    693     }
    694 
    695 
    696     /**
    697      * get_posttype_categories
    698      *
    699      * Get all categories registered to a post type
    700      *
    701      * @param string $post_type
    702      * @return array
    703      */
    704     public static function get_posttype_categories( $post_type ) {
    705 
    706       $taxonomies = get_object_taxonomies( $post_type );
    707 
    708       $args = array(
    709         'type'                     => $post_type,
    710         'orderby'                  => 'name',
    711         'order'                    => 'ASC',
    712         'hide_empty'               => false,
    713         'taxonomy'                 => $taxonomies,
    714       );
    715 
    716       $categories = get_categories( $args );
    717 
    718       return $categories;
    719 
    720     }
    721768
    722769
     
    741788    }
    742789
     790
    743791  }
    744792
  • post-status-scheduler/trunk/classes/settings.php

    r933176 r960367  
    8585      );
    8686
     87      /* SECTION POSTTYPES */
     88
    8789      add_settings_section(
    8890        'posttypes', // ID
     
    9092        array( $this, 'print_section_info' ), // Callback
    9193        'post-status-scheduler' // Page
    92       ); 
     94      );
    9395
    9496      add_settings_field(
     
    108110      );
    109111
     112
     113      /* SECTION NOTIFICATION EMAIL */
     114
     115      /* Planned for release 0.4.0 */
     116
     117      /*add_settings_section(
     118        'notifications', // ID
     119        __( 'Notification', 'post-status-scheduler' ), // Title
     120        array( $this, 'print_notification_section_info' ), // Callback
     121        'post-status-scheduler' // Page
     122      );
     123
     124      add_settings_field(
     125        'notification_email_enabled', // ID
     126        __( 'Enable email notification option on scheduled changes', 'post-status-scheduler' ), // Title
     127        array( $this, 'notification_email_enabled_callback' ), // Callback
     128        'post-status-scheduler', // Page
     129        'notifications' // Section           
     130      );
     131
     132      add_settings_field(
     133        'notification_email_subject', // ID
     134        __( 'Email subject', 'post-status-scheduler' ), // Title
     135        array( $this, 'notification_email_subject_callback' ), // Callback
     136        'post-status-scheduler', // Page
     137        'notifications' // Section           
     138      );
     139
     140      add_settings_field(
     141        'notification_email_body', // ID
     142        __( 'Email body', 'post-status-scheduler' ), // Title
     143        array( $this, 'notification_email_body_callback' ), // Callback
     144        'post-status-scheduler', // Page
     145        'notifications' // Section           
     146      );*/
     147
     148
    110149    }
    111150
     
    147186      }
    148187
     188      /*if( isset( $input['notification_email_enabled'] ) ) {
     189
     190        $new_input['notification_email_enabled'] = true;
     191
     192      } else {
     193
     194        $new_input['notification_email_enabled'] = false;       
     195
     196      }
     197
     198      if( isset( $input['notification_email_subject'] ) ) {
     199
     200        $new_input['notification_email_subject'] = esc_attr( $input['notification_email_subject'] );
     201
     202      }
     203
     204      if( isset( $input['notification_email_body'] ) ) {
     205
     206        $new_input['notification_email_body'] = esc_attr( $input['notification_email_body'] );
     207
     208      }*/
     209
    149210      return $new_input;
    150211     
     
    157218       
    158219        print __( 'Enter your settings below:', 'post-status-scheduler' );
     220
     221    }
     222
     223    /**
     224     * Print the Section text
     225     */
     226    public function print_notification_section_info() {
     227       
     228      print __( 'Edit the email settings used by the notification email on a scheduled change:', 'post-status-scheduler' );
    159229
    160230    }
     
    240310
    241311
     312    /**
     313     * notification_email_enabled_callback
     314     *
     315     * Callback for the enabling of notification option
     316     */
     317    public function notification_email_enabled_callback() {
     318
     319      $options = get_option( 'post_status_scheduler' );
     320      $enabled = !empty( $options['notification_email_enabled'] ) ? $options['notification_email_enabled'] : '';
     321      ?>
     322
     323      <input type="checkbox" name="post_status_scheduler[notification_email_enabled]" <?php checked( $enabled, true ); ?> />
     324     
     325      <?php
     326    }
     327
     328
     329
     330    /**
     331     * notification_email_subject_callback
     332     *
     333     * Callback for the subject of the notification email
     334     */
     335    public function notification_email_subject_callback() {
     336
     337      $options = get_option( 'post_status_scheduler' );
     338      $subject = !empty( $options['notification_email_subject'] ) ? $options['notification_email_subject'] : '';
     339      printf( '<input type="text" name="post_status_scheduler[notification_email_subject]" value="%s" />', $subject );
     340
     341    }
     342
     343
     344    /**
     345     * notification_email_body_callback
     346     *
     347     * Callback for the body of the notification email
     348     */
     349    public function notification_email_body_callback() {
     350
     351      $options = get_option( 'post_status_scheduler' );
     352      $body = !empty( $options['notification_email_body'] ) ? $options['notification_email_body'] : '';
     353
     354      printf( '<textarea name="post_status_scheduler[notification_email_body]">%s</textarea>', $body );
     355
     356    }
     357
     358
    242359  }
    243360
  • post-status-scheduler/trunk/languages/post-status-scheduler-sv_SE.pot

    r933176 r960367  
    22msgstr ""
    33"Project-Id-Version: post-status-scheduler\n"
    4 "POT-Creation-Date: 2014-06-11 17:53+0100\n"
    5 "PO-Revision-Date: 2014-06-11 21:15+0100\n"
     4"POT-Creation-Date: 2014-08-05 09:46+0100\n"
     5"PO-Revision-Date: 2014-08-05 09:49+0100\n"
    66"Last-Translator: Andeas Färnstrand <[email protected]>\n"
    77"Language-Team:  <[email protected]>\n"
     
    1515"X-Poedit-SearchPath-0: .\n"
    1616
    17 #: classes/scheduler.php:37
     17#: classes/scheduler.php:460
     18msgid "Schedule Status Change"
     19msgstr "Schemalägg statusändring"
     20
     21#: classes/scheduler.php:462
     22msgid "Date"
     23msgstr "Datum"
     24
     25#: classes/scheduler.php:464
     26msgid "Time"
     27msgstr "Tid"
     28
     29#: classes/scheduler.php:468
     30msgid "Change status"
     31msgstr "Ändra status"
     32
     33#: classes/scheduler.php:470
     34msgid "Set status to"
     35msgstr "Ändra status till"
     36
     37#: classes/scheduler.php:485
     38msgid "Change categories"
     39msgstr "Ändra kategorier"
     40
     41#: classes/scheduler.php:487
     42msgid "The post will have the following categories on scheduled time"
     43msgstr "Följande kategorier kommer att sättas vid schemalagd tid"
     44
     45#: classes/scheduler.php:537
     46msgid "Remove postmeta"
     47msgstr "Ta bort postmeta"
     48
     49#: classes/scheduler.php:575
     50msgid "Scheduled date"
     51msgstr "Schemalagt datum"
     52
     53#: classes/scheduler.php:781
    1854msgid "Draft"
    1955msgstr "Utkast"
    2056
    21 #: classes/scheduler.php:38
     57#: classes/scheduler.php:782
    2258msgid "Pending"
    2359msgstr "Väntar på granskning"
    2460
    25 #: classes/scheduler.php:39
     61#: classes/scheduler.php:783
    2662msgid "Private"
    2763msgstr "Privat"
    2864
    29 #: classes/scheduler.php:40
     65#: classes/scheduler.php:784
    3066msgid "Trashbin"
    3167msgstr "Papperskorg"
    3268
    33 #: classes/scheduler.php:41
     69#: classes/scheduler.php:785
    3470msgid "Delete (forced)"
    3571msgstr "Radera (tvingad)"
    3672
    37 #: classes/scheduler.php:468
    38 msgid "Schedule Status Change"
    39 msgstr "Schemalägg statusändring"
    40 
    41 #: classes/scheduler.php:470
    42 msgid "Date"
    43 msgstr "Datum"
    44 
    45 #: classes/scheduler.php:472
    46 msgid "Time"
    47 msgstr "Tid"
    48 
    49 #: classes/scheduler.php:476
    50 msgid "Change status"
    51 msgstr "Ändra status"
    52 
    53 #: classes/scheduler.php:478
    54 msgid "Set status to"
    55 msgstr "Ändra status till"
    56 
    57 #: classes/scheduler.php:493
    58 msgid "Add or remove category"
    59 msgstr "Lägg till eller ta bort kategori"
    60 
    61 #: classes/scheduler.php:495
    62 msgid "Add"
    63 msgstr "Lägg till"
    64 
    65 #: classes/scheduler.php:496
    66 msgid "Remove"
    67 msgstr "Ta bort"
    68 
    69 #: classes/scheduler.php:513
    70 msgid "Remove postmeta"
    71 msgstr "Ta bort postmeta"
    72 
    73 #: classes/scheduler.php:550
    74 msgid "Scheduled date"
    75 msgstr "Schemalagt datum"
    76 
    77 #: classes/settings.php:43 classes/settings.php:61
     73#: classes/settings.php:44 classes/settings.php:62
    7874msgid "Post Status Scheduler"
    7975msgstr "Post Status Scheduler"
    8076
    81 #: classes/settings.php:88
     77#: classes/settings.php:91
    8278msgid "Post Types"
    8379msgstr "Posttyper"
    8480
    85 #: classes/settings.php:95
     81#: classes/settings.php:98
    8682msgid "Check the post types you wish to display the Scheduler on"
    8783msgstr "Kryssa i de posttyper som du vill visa schemaläggaren på"
    8884
    89 #: classes/settings.php:103
     85#: classes/settings.php:106
    9086msgid "Mark allowed meta fields to be shown as removable"
    9187msgstr "Märk de metafält som skall vara valbara för borttagning"
    9288
    93 #: classes/settings.php:157
     89#: classes/settings.php:117
     90msgid "Notification"
     91msgstr "Notifikation"
     92
     93#: classes/settings.php:124
     94msgid "Enable email notification option on scheduled changes"
     95msgstr "Aktivera epostnotifikation vid schemalagda ändringar"
     96
     97#: classes/settings.php:132
     98msgid "Email subject"
     99msgstr "Epostämne"
     100
     101#: classes/settings.php:140
     102msgid "Email body"
     103msgstr "Epostmeddelande"
     104
     105#: classes/settings.php:217
    94106msgid "Enter your settings below:"
    95107msgstr "Ange inställningar nedan:"
     108
     109#: classes/settings.php:226
     110msgid ""
     111"Edit the email settings used by the notification email on a scheduled change:"
     112msgstr "Ändra epostinställningarna som används vid notifikationsepost"
     113
     114#~ msgid "Add or remove category"
     115#~ msgstr "Lägg till eller ta bort kategori"
     116
     117#~ msgid "Add"
     118#~ msgstr "Lägg till"
     119
     120#~ msgid "Remove"
     121#~ msgstr "Ta bort"
  • post-status-scheduler/trunk/post-status-scheduler.php

    r934729 r960367  
    3939        define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
    4040    define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__) ) .'/languages' );
     41    define( 'POST_STATUS_SCHEDULER_VERSION', '0.3.1' );
    4142
    4243    $pss = new \post_status_scheduler\Scheduler();
  • post-status-scheduler/trunk/readme.txt

    r934729 r960367  
    44Requires at least: 3.9
    55Tested up to: 3.9.1
    6 Stable tag: 0.2.1
     6Stable tag: 0.3.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1515removing of postmeta on any given date or time. It can be activated on any post type and shows
    1616up on the post edit screen in the publish section.
     17
     18= Shortcodes =
     19
     20* [pss_scheduled_time post_id="<your post id>"] can be used to get the post's scheduled date and time.
    1721
    1822== Installation ==
     
    3539== Changelog ==
    3640
     41= 0.3.0 =
     42* Rewritten to support setting multiple categories on scheduled time.
     43* A little bit of code clean up.
     44
    3745= 0.2.1 =
    3846* Added shortcode for getting the date and time for the scheduled post change
Note: See TracChangeset for help on using the changeset viewer.