Plugin Directory

Changeset 1013039


Ignore:
Timestamp:
10/23/2014 07:11:39 PM (11 years ago)
Author:
farne
Message:

New version 1.0.0

Location:
post-status-scheduler
Files:
1 deleted
14 edited
10 copied

Legend:

Unmodified
Added
Removed
  • post-status-scheduler/tags/1.0.0/classes/event.php

    r960367 r1013039  
    2626            $this->id = $post_id;
    2727
     28      // Load the event post
     29      $this->post = get_post( $post_id );
     30
     31      // Load the event date
    2832            $this->date = get_post_meta( $post_id, 'scheduler_date', true );
    2933
     
    4953      $this->meta_key = get_post_meta( $post_id, 'scheduler_meta_key', true );
    5054
    51       //$this->date = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     55      // Get email notify
     56      $email_notify = get_post_meta( $post_id, 'scheduler_email_notify', true );
     57      $this->email_notify = !empty( $email_notify ) ? $email_notify : false;
    5258
    5359        }
    5460
    5561
     62    /**
     63     * save
     64     *
     65     * Save the scheduler postmeta
     66     */
    5667        public function save() {
    5768
     
    7283      update_post_meta( $this->id, 'scheduler_check_meta', $this->check_meta );
    7384      update_post_meta( $this->id, 'scheduler_meta_key', $this->meta_key );
     85
     86      // Email notification
     87      if( isset( $this->email_notify ) && $this->email_notify == true ) {
     88        update_post_meta( $this->id, 'scheduler_email_notify', true );
     89      } else {
     90        update_post_meta( $this->id, 'scheduler_email_notify', false );
     91      }
    7492
    7593        }
     
    107125      delete_post_meta( $post_id, 'scheduler_meta_key' );
    108126
     127      // Email notification
     128      delete_post_meta( $post_id, 'scheduler_email_notify' );
     129
    109130        }
    110131
    111132
     133    /**
     134     * __get
     135     *
     136     * Automagical get function for object
     137     * Returns the requested property if exists
     138     *
     139     * @param string $key
     140     *
     141     * @return $value|null
     142     */
    112143        public function __get( $key ) {
    113144            return isset( $this->data[$key] ) ? $this->data[$key] : null;
     
    115146
    116147
     148    /**
     149     * __set
     150     *
     151     * Automagical set function for object
     152     * Sets the property to the given value
     153     *
     154     * @param $key The property to set
     155     * @param $value The value to set the property with
     156     */
    117157        public function __set( $key, $value ) {
    118158            $this->data[$key] = $value;
    119159        }
     160
     161
     162    /**
     163     * __isset
     164     *
     165     * Automagical isset function for object
     166     *
     167     * @param string $value
     168     *
     169     * @return boolean
     170     */
     171    public function __isset( $value ) {
     172      return isset( $this->data[$value] );
     173    }
    120174
    121175
  • post-status-scheduler/tags/1.0.0/classes/scheduler.php

    r960367 r1013039  
    1717  require_once( 'event.php' );
    1818  require_once( 'taxonomy.php' );
     19  require_once( 'email.php' );
    1920
    2021  use \post_status_scheduler\Event as Event;
    2122  use \post_status_scheduler\Taxonomy as Taxonomy;
     23  use \post_status_scheduler\Settings as Settings;
     24  use \post_status_scheduler\Email as Email;
    2225   
     26  if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN' ) ) define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
     27
    2328  class Scheduler {
    2429
     
    4550      if( is_admin() ) {
    4651
    47         $this->options = get_option( 'post_status_scheduler' );
     52        $this->options = Settings::get_options();
    4853
    4954        if( !is_array( $this->options ) ) {
     
    6166
    6267        // Get saved options
    63         $scheduler_options = get_option( 'post_status_scheduler' );
     68        $scheduler_options = $this->options;
    6469        $scheduler_options = isset( $scheduler_options['allowed_posttypes'] ) ? $scheduler_options['allowed_posttypes'] : null;
    6570
     
    6772        if( isset( $pagenow ) && $pagenow == 'edit.php' ) {
    6873
    69           // Set the post type to post if it is not in address field
    70           if( !isset( $_GET['post_type'] ) ) {
     74          if( isset( $this->options['extra_column_enabled'] ) && $this->options['extra_column_enabled'] == true ) {
    7175           
    72             $post_type = 'post';
    73 
    74           } else {
    75            
    76             $post_type = $_GET['post_type'];
    77 
    78           }
    79 
    80           // Is this post type set to have unpublishing options?
    81           if( isset( $post_type ) && is_array( $scheduler_options ) && in_array( $post_type, $scheduler_options ) ) {
    82 
    83             foreach( $scheduler_options as $type ) {
     76            // Set the post type to post if it is not in address field
     77            if( !isset( $_GET['post_type'] ) ) {
    8478             
    85               // Add new columns
    86               add_filter( 'manage_'.$type.'_posts_columns', array( $this, 'add_column' ) );
    87               // Set column content
    88               add_action( 'manage_'.$type.'_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
    89               // Register column as sortable
    90               add_filter( "manage_edit-".$type."_sortable_columns", array( $this, 'register_sortable' ) );
     79              $post_type = 'post';
     80
     81            } else {
     82             
     83              $post_type = $_GET['post_type'];
    9184
    9285            }
    93            
    94             // The request to use as orderby
    95             add_filter( 'request', array( $this, 'orderby' ) );
     86
     87            // Is this post type set to have unpublishing options?
     88            if( isset( $post_type ) && is_array( $scheduler_options ) && in_array( $post_type, $scheduler_options ) ) {
     89
     90              foreach( $scheduler_options as $type ) {
     91               
     92                // Add new columns
     93                add_filter( 'manage_'.$type.'_posts_columns', array( $this, 'add_column' ) );
     94                // Set column content
     95                add_action( 'manage_'.$type.'_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
     96                // Register column as sortable
     97                add_filter( "manage_edit-".$type."_sortable_columns", array( $this, 'register_sortable' ) );
     98
     99              }
     100             
     101              // The request to use as orderby
     102              add_filter( 'request', array( $this, 'orderby' ) );
     103
     104            }
    96105
    97106          }
     
    173182      $event->meta_key = isset( $postdata['scheduler']['meta_key'] ) ? $postdata['scheduler']['meta_key'] : null;
    174183
     184      $event->email_notify = isset( $postdata['scheduler']['email-notify'] ) ? true : false;
     185
    175186      // Check if there is an old timestamp to clear away
    176187      //$old_timestamp = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     
    253264      $scheduler_status = $filter_result['status'];
    254265      $valid_statuses = $filter_result['valid_statuses'];
     266
     267      $executed_events = array();
    255268
    256269      if( $event->check_status ) {
     
    275288          }
    276289
     290          // Add the executed event
     291          $executed_events []= 'check_status';
     292
    277293        }
    278294
     
    284300        if( !empty( $event->meta_key ) ) {
    285301          delete_post_meta( $post_id, $event->meta_key );
     302
     303          // Add the executed event
     304          $executed_events []= 'check_meta';
    286305        }
    287306
     
    311330                // Update the categories
    312331                Taxonomy::set_terms( $post_id, array( $scheduler_category_to_add ), $scheduler_category_taxonomy, true );
     332
     333                // Add the executed event
     334                $executed_events []= 'check_category';
    313335         
    314336              }
     
    356378                  Taxonomy::set_terms( $post_id, $new_categories, $scheduler_category_taxonomy );
    357379
     380                  // Add the executed event
     381                  $executed_events []= 'check_category';
     382
    358383                }
    359384
     
    373398      // Remove post meta
    374399      Event::delete( $post_id );
     400
     401      $options = Settings::get_options();
     402
     403      // Checkto see if we should send an email notification
     404      //if( isset( $options['notification_email_enabled'] ) && $options['notification_email_enabled'] == true ) {
     405
     406        // Is the email notification checked on this event
     407        if( isset( $event->email_notify ) && $event->email_notify == true ) {
     408
     409          if( is_object( $event->post ) ) {
     410
     411            Email::update_notification( $event->post );
     412           
     413          }
     414
     415        }
     416
     417      //}
    375418
    376419      apply_filters( 'post_status_scheduler_after_execution', array( 'status' => $scheduler_status, 'valid_statuses' => $valid_statuses ), $post_id );
     
    422465      // Get valid post types set in module settings page
    423466      $allowed_posttypes = isset( $this->options['allowed_posttypes'] ) ? $this->options['allowed_posttypes'] : array();
     467      // Check if there are any meta keys to be shown
    424468      $meta_keys = isset( $this->options['meta_keys'] ) ? $this->options['meta_keys'] : array();
     469      // Check if email notification is set
     470      $use_notification = isset( $this->options['email_notification'] ) ? true : false;
     471
    425472      $categories = Taxonomy::get_posttype_terms( $post_type );
    426473
     
    458505        echo '<div class="misc-pub-section misc-pub-section-last" id="scheduler-wrapper">
    459506        <span id="timestamp" class="calendar-link before">'
    460         . '<label> ' . __( 'Schedule Status Change', 'post-status-scheduler' ) . '</label> <input type="checkbox" id="scheduler-use" name="scheduler[use]" ' . $checked . ' /><br />'
     507        . '<label> ' . __( 'Schedule Status Change', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> <input type="checkbox" id="scheduler-use" name="scheduler[use]" ' . $checked . ' /><br />'
    461508        . '<div id="scheduler-settings" ' . $show . ' >'
    462         . '<label>' . __( 'Date', 'post-status-scheduler' ) . '</label> '
     509        . '<label>' . __( 'Date', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    463510        . '<input type="text" id="schedulerdate" name="scheduler[date]" value="' .$date. '" maxlengt="10" readonly="true" /> '
    464         . '<label>' . __( 'Time', 'post-status-scheduler' ) . '</label> '
     511        . '<label>' . __( 'Time', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    465512        . '<input type="text" id="schedulertime" name="scheduler[time]" value="' . $time . '" maxlength="5" readonly="true" /><br /><br />'
    466513
     
    468515        . '<input type="checkbox" name="scheduler[post-status-check]" id="scheduler-status" ' . $scheduler_check_status_checked . ' /> ' . __( 'Change status', 'post-status-scheduler' ) . '<br />'
    469516        . '<div id="scheduler-status-box" ' . $scheduler_check_status_show . ' >'
    470         . '<label>' . __( 'Set status to', 'post-status-scheduler' ) . '</label> '
     517        . '<label>' . __( 'Set status to', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    471518        . '<select name="scheduler[status]" style="width: 98%;">';
    472519
     
    485532          echo '<input type="checkbox" name="scheduler[category-check]" id="scheduler-category" ' . $scheduler_check_category_checked . ' /> ' . __( 'Change categories', 'post-status-scheduler' ) . '<br />'
    486533          .'<div id="scheduler-category-box" ' . $scheduler_check_category_show . '>';
    487           echo __( 'The post will have the following categories on scheduled time', 'post-status-scheduler' );
     534          echo __( 'The post will have the following categories on scheduled time', POST_STATUS_SCHEDULER_TEXTDOMAIN );
    488535          echo '<select name="scheduler[category][]" multiple size="5">';
    489536           
     
    535582        // Meta keys
    536583        if( count( $meta_keys ) > 0 ) {
    537           echo '<input type="checkbox" name="scheduler[postmeta-check]" id="scheduler-postmeta" ' . $scheduler_check_meta_checked . ' /> ' . __( 'Remove postmeta', 'post-status-scheduler' ) . '<br />'
     584          echo '<input type="checkbox" name="scheduler[postmeta-check]" id="scheduler-postmeta" ' . $scheduler_check_meta_checked . ' /> ' . __( 'Remove postmeta', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '<br />'
    538585          .'<div id="scheduler-postmeta-box" ' . $scheduler_check_meta_show . ' >'
    539586          . '<select name="scheduler[meta_key]">';
     
    551598        }
    552599
     600        // Email notification option
     601        if( isset( $this->options['notification_email_enabled'] ) && $this->options['notification_email_enabled'] == true ) {
     602
     603          echo '<hr />';
     604
     605          if( isset( $event->email_notify ) && $event->email_notify == true ) {
     606            $email_notify_checked = ' checked="checked" ';
     607          } else {
     608            $email_notify_checked = '';
     609          }
     610
     611          // The checkbox for sending a notification email to author
     612          echo '<input type="checkbox" id="scheduler-email-notification" name="scheduler[email-notify]" disabled="" ' . $email_notify_checked . '/> ' . __( 'Send email notification on change', POST_STATUS_SCHEDULER_TEXTDOMAIN );
     613          echo '<p class="description">(' . get_the_author_meta( 'user_email', $post->post_author ) . ')</p>';
     614        }
    553615        echo '</div>'
    554616        .'</span></div>';
     
    573635        if( $key == 'date' ) {
    574636
    575           $new_columns['scheduler_date']    = __( 'Scheduled date',  'post-status-scheduler' );
     637          $new_columns['scheduler_date']    = __( 'Scheduled date',  POST_STATUS_SCHEDULER_TEXTDOMAIN );
    576638
    577639        }
     
    779841      // All valid post statuses to choose from
    780842      return array(
    781         'draft' => __( 'Draft', 'post-status-scheduler' ),
    782         'pending' => __( 'Pending', 'post-status-scheduler' ),
    783         'private' => __( 'Private', 'post-status-scheduler' ),
    784         'trash' =>  __( 'Trashbin', 'post-status-scheduler' ),
    785         'deleted' => __( 'Delete (forced)', 'post-status-scheduler' ),
     843        'draft' => __( 'Draft', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     844        'pending' => __( 'Pending', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     845        'private' => __( 'Private', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     846        'trash' =>  __( 'Trashbin', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     847        'deleted' => __( 'Delete (forced)', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
    786848      );
    787849
  • post-status-scheduler/tags/1.0.0/classes/settings.php

    r960367 r1013039  
    8989      add_settings_section(
    9090        'posttypes', // ID
    91         __( 'Post Types', 'post-status-scheduler' ), // Title
     91        __( 'Post Types and meta keys', 'post-status-scheduler' ), // Title
    9292        array( $this, 'print_section_info' ), // Callback
    9393        'post-status-scheduler' // Page
     
    9797        'allowed_posttypes', // ID
    9898        __( 'Check the post types you wish to display the Scheduler on', 'post-status-scheduler' ), // Title
    99         array( $this, 'id_number_callback' ), // Callback
     99        array( $this, 'allowed_posttypes_callback' ), // Callback
    100100        'post-status-scheduler', // Page
    101101        'posttypes' // Section           
     
    113113      /* SECTION NOTIFICATION EMAIL */
    114114
    115       /* Planned for release 0.4.0 */
    116 
    117       /*add_settings_section(
     115      add_settings_section(
    118116        'notifications', // ID
    119117        __( 'Notification', 'post-status-scheduler' ), // Title
     
    124122      add_settings_field(
    125123        'notification_email_enabled', // ID
    126         __( 'Enable email notification option on scheduled changes', 'post-status-scheduler' ), // Title
     124        __( 'Enable email notification option', 'post-status-scheduler' ), // Title
    127125        array( $this, 'notification_email_enabled_callback' ), // Callback
    128126        'post-status-scheduler', // Page
     
    130128      );
    131129
     130
     131      /* SECTION EXTRA COLUMN ON EDIT PAGE */
     132
     133      add_settings_section(
     134        'column', // ID
     135        __( 'Extra column', 'post-status-scheduler' ), // Title
     136        array( $this, 'print_column_section_info' ), // Callback
     137        'post-status-scheduler' // Page
     138      );
     139
    132140      add_settings_field(
    133         'notification_email_subject', // ID
    134         __( 'Email subject', 'post-status-scheduler' ), // Title
    135         array( $this, 'notification_email_subject_callback' ), // Callback
     141        'extra_column_enabled', // ID
     142        __( 'Enable extra column on posttype edit page', 'post-status-scheduler' ), // Title
     143        array( $this, 'extra_column_enabled_callback' ), // Callback
    136144        '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 
     145        'column' // Section           
     146      );
    148147
    149148    }
     
    186185      }
    187186
    188       /*if( isset( $input['notification_email_enabled'] ) ) {
     187      if( isset( $input['notification_email_enabled'] ) ) {
    189188
    190189        $new_input['notification_email_enabled'] = true;
     
    196195      }
    197196
    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       }*/
     197      if( isset( $input['extra_column_enabled'] ) ) {
     198
     199        $new_input['extra_column_enabled'] = true;
     200
     201      } else {
     202
     203        $new_input['extra_column_enabled'] = false;       
     204
     205      }
    209206
    210207      return $new_input;
    211208     
    212209    }
     210
    213211
    214212    /**
     
    221219    }
    222220
     221
    223222    /**
    224223     * Print the Section text
     
    226225    public function print_notification_section_info() {
    227226       
    228       print __( 'Edit the email settings used by the notification email on a scheduled change:', 'post-status-scheduler' );
     227      print __( 'Enabling this option makes it possible to send an email notification to the post author on a scheduled change execution.', 'post-status-scheduler' );
     228
     229    }
     230
     231
     232    /**
     233     * Print the Section text
     234     */
     235    public function print_column_section_info() {
     236       
     237      print __( 'Settings for adding extra column "Scheduled date" on edit page. This column will only be displayed on posttypes that are allowed for scheduling', 'post-status-scheduler' );
    229238
    230239    }
     
    236245     * Callback for the posttypes allowed
    237246     */
    238     public function id_number_callback() {
     247    public function allowed_posttypes_callback() {
    239248
    240249      // Get all valid public post types
     
    317326    public function notification_email_enabled_callback() {
    318327
    319       $options = get_option( 'post_status_scheduler' );
     328      $options = self::get_options();
    320329      $enabled = !empty( $options['notification_email_enabled'] ) ? $options['notification_email_enabled'] : '';
    321330      ?>
     
    327336
    328337
    329 
    330     /**
    331      * notification_email_subject_callback
     338    /**
     339     * notification_email_enabled_callback
    332340     *
    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 
     341     * Callback for the enabling of notification option
     342     */
     343    public function extra_column_enabled_callback() {
     344
     345      $options = self::get_options();
     346      $enabled = !empty( $options['extra_column_enabled'] ) ? $options['extra_column_enabled'] : '';
     347      ?>
     348
     349      <input type="checkbox" name="post_status_scheduler[extra_column_enabled]" <?php checked( $enabled, true ); ?> />
     350     
     351      <?php
     352    }
     353
     354
     355    public static function get_options() {
     356
     357      return get_option('post_status_scheduler');
     358
     359    }
    358360
    359361  }
    360362
    361 
    362363?>
  • post-status-scheduler/tags/1.0.0/js/scheduler.js

    r933176 r1013039  
    3333
    3434    }
     35
     36    toggle_email_notification();
    3537  });
    3638
     
    4547
    4648    }
     49
     50    toggle_email_notification();
    4751  });
    4852
     
    5761
    5862    }
     63
     64    toggle_email_notification();
    5965  });
    6066
     67  toggle_email_notification();
     68
     69  function toggle_email_notification() {
     70
     71    if( $('#scheduler-status').is(':checked') || $('#scheduler-category').is(':checked') || $('#scheduler-postmeta').is(':checked') ) {
     72
     73      $('#scheduler-email-notification').removeAttr('disabled');
     74
     75    } else {
     76
     77      $('#scheduler-email-notification').attr('disabled', 'disabled');
     78      $('#scheduler-email-notification').removeAttr('checked', 'checked');
     79
     80    }
     81
     82  }
     83
    6184});
  • post-status-scheduler/tags/1.0.0/languages/post-status-scheduler-sv_SE.pot

    r960367 r1013039  
    22msgstr ""
    33"Project-Id-Version: post-status-scheduler\n"
    4 "POT-Creation-Date: 2014-08-05 09:46+0100\n"
    5 "PO-Revision-Date: 2014-08-05 09:49+0100\n"
     4"POT-Creation-Date: 2014-10-23 15:58+0100\n"
     5"PO-Revision-Date: 2014-10-23 16:00+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:460
     17#: classes/email.php:25
     18msgid "Post Status Scheduler update"
     19msgstr "Uppdatering Post Status Scheduler"
     20
     21#: classes/email.php:33
     22msgid "A scheduled update has been executed at"
     23msgstr "En schemalagd ändring har blivit exekverad"
     24
     25#: classes/email.php:33
     26msgid "on your post"
     27msgstr "på din post"
     28
     29#: classes/email.php:34
     30msgid "Regards"
     31msgstr "Hälsningar"
     32
     33#: classes/scheduler.php:503
    1834msgid "Schedule Status Change"
    1935msgstr "Schemalägg statusändring"
    2036
    21 #: classes/scheduler.php:462
     37#: classes/scheduler.php:505
    2238msgid "Date"
    2339msgstr "Datum"
    2440
    25 #: classes/scheduler.php:464
     41#: classes/scheduler.php:507
    2642msgid "Time"
    2743msgstr "Tid"
    2844
    29 #: classes/scheduler.php:468
     45#: classes/scheduler.php:511
    3046msgid "Change status"
    3147msgstr "Ändra status"
    3248
    33 #: classes/scheduler.php:470
     49#: classes/scheduler.php:513
    3450msgid "Set status to"
    3551msgstr "Ändra status till"
    3652
    37 #: classes/scheduler.php:485
     53#: classes/scheduler.php:528
    3854msgid "Change categories"
    3955msgstr "Ändra kategorier"
    4056
    41 #: classes/scheduler.php:487
     57#: classes/scheduler.php:530
    4258msgid "The post will have the following categories on scheduled time"
    4359msgstr "Följande kategorier kommer att sättas vid schemalagd tid"
    4460
    45 #: classes/scheduler.php:537
     61#: classes/scheduler.php:580
    4662msgid "Remove postmeta"
    4763msgstr "Ta bort postmeta"
    4864
    49 #: classes/scheduler.php:575
     65#: classes/scheduler.php:608
     66msgid "Send email notification on change"
     67msgstr "Skicka epostnotifiering vid ändring"
     68
     69#: classes/scheduler.php:633
    5070msgid "Scheduled date"
    5171msgstr "Schemalagt datum"
    5272
    53 #: classes/scheduler.php:781
     73#: classes/scheduler.php:839
    5474msgid "Draft"
    5575msgstr "Utkast"
    5676
    57 #: classes/scheduler.php:782
     77#: classes/scheduler.php:840
    5878msgid "Pending"
    5979msgstr "Väntar på granskning"
    6080
    61 #: classes/scheduler.php:783
     81#: classes/scheduler.php:841
    6282msgid "Private"
    6383msgstr "Privat"
    6484
    65 #: classes/scheduler.php:784
     85#: classes/scheduler.php:842
    6686msgid "Trashbin"
    6787msgstr "Papperskorg"
    6888
    69 #: classes/scheduler.php:785
     89#: classes/scheduler.php:843
    7090msgid "Delete (forced)"
    7191msgstr "Radera (tvingad)"
     
    7696
    7797#: classes/settings.php:91
    78 msgid "Post Types"
    79 msgstr "Posttyper"
     98msgid "Post Types and meta keys"
     99msgstr "Posttyper och metakeys"
    80100
    81101#: classes/settings.php:98
     
    87107msgstr "Märk de metafält som skall vara valbara för borttagning"
    88108
    89 #: classes/settings.php:117
     109#: classes/settings.php:119
    90110msgid "Notification"
    91111msgstr "Notifikation"
    92112
    93 #: classes/settings.php:124
    94 msgid "Enable email notification option on scheduled changes"
    95 msgstr "Aktivera epostnotifikation vid schemalagda ändringar"
     113#: classes/settings.php:126
     114msgid "Enable email notification option"
     115msgstr "Aktivera epostnotifiering"
    96116
    97 #: classes/settings.php:132
    98 msgid "Email subject"
    99 msgstr "Epostämne"
    100 
    101 #: classes/settings.php:140
    102 msgid "Email body"
    103 msgstr "Epostmeddelande"
    104 
    105 #: classes/settings.php:217
     117#: classes/settings.php:190
    106118msgid "Enter your settings below:"
    107119msgstr "Ange inställningar nedan:"
    108120
    109 #: classes/settings.php:226
    110 msgid ""
    111 "Edit the email settings used by the notification email on a scheduled change:"
    112 msgstr "Ändra epostinställningarna som används vid notifikationsepost"
     121#: classes/settings.php:199
     122msgid "Email notification settings:"
     123msgstr "Inställningar för epostnotifiering"
     124
     125#~ msgid "Post Types"
     126#~ msgstr "Posttyper"
     127
     128#~ msgid "Email subject"
     129#~ msgstr "Epostämne"
     130
     131#~ msgid "Email body"
     132#~ msgstr "Epostmeddelande"
     133
     134#~ msgid ""
     135#~ "Edit the email settings used by the notification email on a scheduled "
     136#~ "change:"
     137#~ msgstr "Ändra epostinställningarna som används vid notifikationsepost"
    113138
    114139#~ msgid "Add or remove category"
  • post-status-scheduler/tags/1.0.0/languages/post-status-scheduler.pot

    r933176 r1013039  
    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 18:01+0100\n"
     4"POT-Creation-Date: 2014-10-23 15:50+0100\n"
     5"PO-Revision-Date: 2014-10-23 15:51+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:503
     18msgid "Schedule Status Change"
     19msgstr ""
     20
     21#: classes/scheduler.php:505
     22msgid "Date"
     23msgstr ""
     24
     25#: classes/scheduler.php:507
     26msgid "Time"
     27msgstr ""
     28
     29#: classes/scheduler.php:511
     30msgid "Change status"
     31msgstr ""
     32
     33#: classes/scheduler.php:513
     34msgid "Set status to"
     35msgstr ""
     36
     37#: classes/scheduler.php:528
     38msgid "Change categories"
     39msgstr ""
     40
     41#: classes/scheduler.php:530
     42msgid "The post will have the following categories on scheduled time"
     43msgstr ""
     44
     45#: classes/scheduler.php:580
     46msgid "Remove postmeta"
     47msgstr ""
     48
     49#: classes/scheduler.php:608
     50msgid "Send email notification on change"
     51msgstr ""
     52
     53#: classes/scheduler.php:633
     54msgid "Scheduled date"
     55msgstr ""
     56
     57#: classes/scheduler.php:839
    1858msgid "Draft"
    1959msgstr ""
    2060
    21 #: classes/scheduler.php:38
     61#: classes/scheduler.php:840
    2262msgid "Pending"
    2363msgstr ""
    2464
    25 #: classes/scheduler.php:39
     65#: classes/scheduler.php:841
    2666msgid "Private"
    2767msgstr ""
    2868
    29 #: classes/scheduler.php:40
     69#: classes/scheduler.php:842
    3070msgid "Trashbin"
    3171msgstr ""
    3272
    33 #: classes/scheduler.php:41
     73#: classes/scheduler.php:843
    3474msgid "Delete (forced)"
    3575msgstr ""
    3676
    37 #: classes/scheduler.php:468
    38 msgid "Schedule Status Change"
    39 msgstr ""
    40 
    41 #: classes/scheduler.php:470
    42 msgid "Date"
    43 msgstr ""
    44 
    45 #: classes/scheduler.php:472
    46 msgid "Time"
    47 msgstr ""
    48 
    49 #: classes/scheduler.php:476
    50 msgid "Change status"
    51 msgstr ""
    52 
    53 #: classes/scheduler.php:478
    54 msgid "Set status to"
    55 msgstr ""
    56 
    57 #: classes/scheduler.php:493
    58 msgid "Add or remove category"
    59 msgstr ""
    60 
    61 #: classes/scheduler.php:495
    62 msgid "Add"
    63 msgstr ""
    64 
    65 #: classes/scheduler.php:496
    66 msgid "Remove"
    67 msgstr ""
    68 
    69 #: classes/scheduler.php:513
    70 msgid "Remove postmeta"
    71 msgstr ""
    72 
    73 #: classes/scheduler.php:550
    74 msgid "Scheduled date"
    75 msgstr ""
    76 
    77 #: classes/settings.php:43 classes/settings.php:61
     77#: classes/settings.php:44 classes/settings.php:62
    7878msgid "Post Status Scheduler"
    7979msgstr ""
    8080
    81 #: classes/settings.php:88
    82 msgid "Post Types"
     81#: classes/settings.php:91
     82msgid "Post Types and meta keys"
    8383msgstr ""
    8484
    85 #: classes/settings.php:95
     85#: classes/settings.php:98
    8686msgid "Check the post types you wish to display the Scheduler on"
    8787msgstr ""
    8888
    89 #: classes/settings.php:103
     89#: classes/settings.php:106
    9090msgid "Mark allowed meta fields to be shown as removable"
    9191msgstr ""
    9292
    93 #: classes/settings.php:157
     93#: classes/settings.php:119
     94msgid "Notification"
     95msgstr ""
     96
     97#: classes/settings.php:126
     98msgid "Enable email notification option"
     99msgstr ""
     100
     101#: classes/settings.php:190
    94102msgid "Enter your settings below:"
    95103msgstr ""
     104
     105#: classes/settings.php:199
     106msgid "Email notification settings:"
     107msgstr ""
  • post-status-scheduler/tags/1.0.0/post-status-scheduler.php

    r960369 r1013039  
    55  Plugin Name: Post Status Scheduler
    66  Description: Change status, category or postmeta of any post type at a scheduled timestamp.
    7   Version: 0.3.0
     7  Version: 1.0.0
    88  Author: Andreas Färnstrand <[email protected]>
    99  Author URI: http://www.farnstranddev.se
     
    2828*/
    2929
     30  // Exit if accessed directly
     31  if ( !defined( 'ABSPATH' ) ) exit;
     32
    3033  use post_status_scheduler as post_status_scheduler;
    3134
     
    3639    require_once 'classes/shortcode.php';
    3740
    38         define( 'POST_STATUS_SCHEDULER_PLUGIN_PATH', plugin_dir_url( __FILE__ ) );
    39         define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
    40     define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__) ) .'/languages' );
    41     define( 'POST_STATUS_SCHEDULER_VERSION', '0.3.0' );
     41        if( !defined( 'POST_STATUS_SCHEDULER_PLUGIN_PATH' ) )        define( 'POST_STATUS_SCHEDULER_PLUGIN_PATH', plugin_dir_url( __FILE__ ) );
     42        if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN' ) )         define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
     43    if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH' ) )    define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__) ) .'/languages' );
     44    if( !defined( 'POST_STATUS_SCHEDULER_VERSION' ) )            define( 'POST_STATUS_SCHEDULER_VERSION', '1.0.0' );
    4245
     46    // Create a new scheduler instance
    4347    $pss = new \post_status_scheduler\Scheduler();
    4448
     49    // Create a new settings instance
    4550    if( is_admin() ) {
    4651        $settings = new \post_status_scheduler\Settings();
    4752    }
    4853
     54    // Create shortcodes
    4955    $pss_shortcodes = new \post_status_scheduler\Shortcode();
    5056
  • post-status-scheduler/tags/1.0.0/readme.txt

    r984682 r1013039  
    44Requires at least: 3.9
    55Tested up to: 4.0
    6 Stable tag: 0.3.0
     6Stable tag: 1.0.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414Post Status Scheduler allows for scheduling of post status changes, category adding or removing and
    1515removing of postmeta on any given date or time. It can be activated on any post type and shows
    16 up on the post edit screen in the publish section.
     16up on the post edit screen in the publish section. From version 1.0.0 it has a feature for sending
     17an email notification to the post author on the scheduled update.
    1718
    1819= Shortcodes =
    1920
    2021* [pss_scheduled_time post_id="<your post id>"] can be used to get the post's scheduled date and time.
     22
     23= Filters =
     24Scheduled Update:
     25* post_status_scheduler_before_execution
     26* post_status_scheduler_after_execution
     27
     28Email Notification ( version 1.0.0 ):
     29* post_status_scheduler_email_notification_recipient_email
     30* post_status_scheduler_email_notification_subject
     31* post_status_scheduler_email_notification_date
     32* post_status_scheduler_email_notification_body
    2133
    2234== Installation ==
     
    32443. Edit page without post meta option activated.
    33454. Edit page with post meta option activated.
     465. Edit page with email notification option.
    3447
    3548= What Translations are included? =
     
    3952== Changelog ==
    4053
     54= 1.0.0 =
     55* New feature for sending email notification to post author when executing a scheduled update.
     56* New feature makes it possible to show/remove the "Scheduled date" column on posttype edit page.
     57* Code cleanup.
     58
    4159= 0.3.0 =
    42 * Rewritten to support setting multiple categories on scheduled time. I have tried to make sure that it will still work with previously scheduled changes in previous versions of the plugin.
    43 * A little bit of code clean up.
     60* Rewritten plugin to support setting multiple categories on scheduled time. I have tried to make sure that it will still work with previously scheduled changes in previous versions of the plugin.
     61* A little bit of code clean up and refactoring.
    4462
    4563= 0.2.1 =
  • post-status-scheduler/trunk/classes/event.php

    r960367 r1013039  
    2626            $this->id = $post_id;
    2727
     28      // Load the event post
     29      $this->post = get_post( $post_id );
     30
     31      // Load the event date
    2832            $this->date = get_post_meta( $post_id, 'scheduler_date', true );
    2933
     
    4953      $this->meta_key = get_post_meta( $post_id, 'scheduler_meta_key', true );
    5054
    51       //$this->date = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     55      // Get email notify
     56      $email_notify = get_post_meta( $post_id, 'scheduler_email_notify', true );
     57      $this->email_notify = !empty( $email_notify ) ? $email_notify : false;
    5258
    5359        }
    5460
    5561
     62    /**
     63     * save
     64     *
     65     * Save the scheduler postmeta
     66     */
    5667        public function save() {
    5768
     
    7283      update_post_meta( $this->id, 'scheduler_check_meta', $this->check_meta );
    7384      update_post_meta( $this->id, 'scheduler_meta_key', $this->meta_key );
     85
     86      // Email notification
     87      if( isset( $this->email_notify ) && $this->email_notify == true ) {
     88        update_post_meta( $this->id, 'scheduler_email_notify', true );
     89      } else {
     90        update_post_meta( $this->id, 'scheduler_email_notify', false );
     91      }
    7492
    7593        }
     
    107125      delete_post_meta( $post_id, 'scheduler_meta_key' );
    108126
     127      // Email notification
     128      delete_post_meta( $post_id, 'scheduler_email_notify' );
     129
    109130        }
    110131
    111132
     133    /**
     134     * __get
     135     *
     136     * Automagical get function for object
     137     * Returns the requested property if exists
     138     *
     139     * @param string $key
     140     *
     141     * @return $value|null
     142     */
    112143        public function __get( $key ) {
    113144            return isset( $this->data[$key] ) ? $this->data[$key] : null;
     
    115146
    116147
     148    /**
     149     * __set
     150     *
     151     * Automagical set function for object
     152     * Sets the property to the given value
     153     *
     154     * @param $key The property to set
     155     * @param $value The value to set the property with
     156     */
    117157        public function __set( $key, $value ) {
    118158            $this->data[$key] = $value;
    119159        }
     160
     161
     162    /**
     163     * __isset
     164     *
     165     * Automagical isset function for object
     166     *
     167     * @param string $value
     168     *
     169     * @return boolean
     170     */
     171    public function __isset( $value ) {
     172      return isset( $this->data[$value] );
     173    }
    120174
    121175
  • post-status-scheduler/trunk/classes/scheduler.php

    r960367 r1013039  
    1717  require_once( 'event.php' );
    1818  require_once( 'taxonomy.php' );
     19  require_once( 'email.php' );
    1920
    2021  use \post_status_scheduler\Event as Event;
    2122  use \post_status_scheduler\Taxonomy as Taxonomy;
     23  use \post_status_scheduler\Settings as Settings;
     24  use \post_status_scheduler\Email as Email;
    2225   
     26  if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN' ) ) define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
     27
    2328  class Scheduler {
    2429
     
    4550      if( is_admin() ) {
    4651
    47         $this->options = get_option( 'post_status_scheduler' );
     52        $this->options = Settings::get_options();
    4853
    4954        if( !is_array( $this->options ) ) {
     
    6166
    6267        // Get saved options
    63         $scheduler_options = get_option( 'post_status_scheduler' );
     68        $scheduler_options = $this->options;
    6469        $scheduler_options = isset( $scheduler_options['allowed_posttypes'] ) ? $scheduler_options['allowed_posttypes'] : null;
    6570
     
    6772        if( isset( $pagenow ) && $pagenow == 'edit.php' ) {
    6873
    69           // Set the post type to post if it is not in address field
    70           if( !isset( $_GET['post_type'] ) ) {
     74          if( isset( $this->options['extra_column_enabled'] ) && $this->options['extra_column_enabled'] == true ) {
    7175           
    72             $post_type = 'post';
    73 
    74           } else {
    75            
    76             $post_type = $_GET['post_type'];
    77 
    78           }
    79 
    80           // Is this post type set to have unpublishing options?
    81           if( isset( $post_type ) && is_array( $scheduler_options ) && in_array( $post_type, $scheduler_options ) ) {
    82 
    83             foreach( $scheduler_options as $type ) {
     76            // Set the post type to post if it is not in address field
     77            if( !isset( $_GET['post_type'] ) ) {
    8478             
    85               // Add new columns
    86               add_filter( 'manage_'.$type.'_posts_columns', array( $this, 'add_column' ) );
    87               // Set column content
    88               add_action( 'manage_'.$type.'_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
    89               // Register column as sortable
    90               add_filter( "manage_edit-".$type."_sortable_columns", array( $this, 'register_sortable' ) );
     79              $post_type = 'post';
     80
     81            } else {
     82             
     83              $post_type = $_GET['post_type'];
    9184
    9285            }
    93            
    94             // The request to use as orderby
    95             add_filter( 'request', array( $this, 'orderby' ) );
     86
     87            // Is this post type set to have unpublishing options?
     88            if( isset( $post_type ) && is_array( $scheduler_options ) && in_array( $post_type, $scheduler_options ) ) {
     89
     90              foreach( $scheduler_options as $type ) {
     91               
     92                // Add new columns
     93                add_filter( 'manage_'.$type.'_posts_columns', array( $this, 'add_column' ) );
     94                // Set column content
     95                add_action( 'manage_'.$type.'_posts_custom_column', array( $this, 'custom_column' ), 10, 2);
     96                // Register column as sortable
     97                add_filter( "manage_edit-".$type."_sortable_columns", array( $this, 'register_sortable' ) );
     98
     99              }
     100             
     101              // The request to use as orderby
     102              add_filter( 'request', array( $this, 'orderby' ) );
     103
     104            }
    96105
    97106          }
     
    173182      $event->meta_key = isset( $postdata['scheduler']['meta_key'] ) ? $postdata['scheduler']['meta_key'] : null;
    174183
     184      $event->email_notify = isset( $postdata['scheduler']['email-notify'] ) ? true : false;
     185
    175186      // Check if there is an old timestamp to clear away
    176187      //$old_timestamp = get_post_meta( $post->ID, 'post_status_scheduler_date', true );
     
    253264      $scheduler_status = $filter_result['status'];
    254265      $valid_statuses = $filter_result['valid_statuses'];
     266
     267      $executed_events = array();
    255268
    256269      if( $event->check_status ) {
     
    275288          }
    276289
     290          // Add the executed event
     291          $executed_events []= 'check_status';
     292
    277293        }
    278294
     
    284300        if( !empty( $event->meta_key ) ) {
    285301          delete_post_meta( $post_id, $event->meta_key );
     302
     303          // Add the executed event
     304          $executed_events []= 'check_meta';
    286305        }
    287306
     
    311330                // Update the categories
    312331                Taxonomy::set_terms( $post_id, array( $scheduler_category_to_add ), $scheduler_category_taxonomy, true );
     332
     333                // Add the executed event
     334                $executed_events []= 'check_category';
    313335         
    314336              }
     
    356378                  Taxonomy::set_terms( $post_id, $new_categories, $scheduler_category_taxonomy );
    357379
     380                  // Add the executed event
     381                  $executed_events []= 'check_category';
     382
    358383                }
    359384
     
    373398      // Remove post meta
    374399      Event::delete( $post_id );
     400
     401      $options = Settings::get_options();
     402
     403      // Checkto see if we should send an email notification
     404      //if( isset( $options['notification_email_enabled'] ) && $options['notification_email_enabled'] == true ) {
     405
     406        // Is the email notification checked on this event
     407        if( isset( $event->email_notify ) && $event->email_notify == true ) {
     408
     409          if( is_object( $event->post ) ) {
     410
     411            Email::update_notification( $event->post );
     412           
     413          }
     414
     415        }
     416
     417      //}
    375418
    376419      apply_filters( 'post_status_scheduler_after_execution', array( 'status' => $scheduler_status, 'valid_statuses' => $valid_statuses ), $post_id );
     
    422465      // Get valid post types set in module settings page
    423466      $allowed_posttypes = isset( $this->options['allowed_posttypes'] ) ? $this->options['allowed_posttypes'] : array();
     467      // Check if there are any meta keys to be shown
    424468      $meta_keys = isset( $this->options['meta_keys'] ) ? $this->options['meta_keys'] : array();
     469      // Check if email notification is set
     470      $use_notification = isset( $this->options['email_notification'] ) ? true : false;
     471
    425472      $categories = Taxonomy::get_posttype_terms( $post_type );
    426473
     
    458505        echo '<div class="misc-pub-section misc-pub-section-last" id="scheduler-wrapper">
    459506        <span id="timestamp" class="calendar-link before">'
    460         . '<label> ' . __( 'Schedule Status Change', 'post-status-scheduler' ) . '</label> <input type="checkbox" id="scheduler-use" name="scheduler[use]" ' . $checked . ' /><br />'
     507        . '<label> ' . __( 'Schedule Status Change', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> <input type="checkbox" id="scheduler-use" name="scheduler[use]" ' . $checked . ' /><br />'
    461508        . '<div id="scheduler-settings" ' . $show . ' >'
    462         . '<label>' . __( 'Date', 'post-status-scheduler' ) . '</label> '
     509        . '<label>' . __( 'Date', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    463510        . '<input type="text" id="schedulerdate" name="scheduler[date]" value="' .$date. '" maxlengt="10" readonly="true" /> '
    464         . '<label>' . __( 'Time', 'post-status-scheduler' ) . '</label> '
     511        . '<label>' . __( 'Time', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    465512        . '<input type="text" id="schedulertime" name="scheduler[time]" value="' . $time . '" maxlength="5" readonly="true" /><br /><br />'
    466513
     
    468515        . '<input type="checkbox" name="scheduler[post-status-check]" id="scheduler-status" ' . $scheduler_check_status_checked . ' /> ' . __( 'Change status', 'post-status-scheduler' ) . '<br />'
    469516        . '<div id="scheduler-status-box" ' . $scheduler_check_status_show . ' >'
    470         . '<label>' . __( 'Set status to', 'post-status-scheduler' ) . '</label> '
     517        . '<label>' . __( 'Set status to', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '</label> '
    471518        . '<select name="scheduler[status]" style="width: 98%;">';
    472519
     
    485532          echo '<input type="checkbox" name="scheduler[category-check]" id="scheduler-category" ' . $scheduler_check_category_checked . ' /> ' . __( 'Change categories', 'post-status-scheduler' ) . '<br />'
    486533          .'<div id="scheduler-category-box" ' . $scheduler_check_category_show . '>';
    487           echo __( 'The post will have the following categories on scheduled time', 'post-status-scheduler' );
     534          echo __( 'The post will have the following categories on scheduled time', POST_STATUS_SCHEDULER_TEXTDOMAIN );
    488535          echo '<select name="scheduler[category][]" multiple size="5">';
    489536           
     
    535582        // Meta keys
    536583        if( count( $meta_keys ) > 0 ) {
    537           echo '<input type="checkbox" name="scheduler[postmeta-check]" id="scheduler-postmeta" ' . $scheduler_check_meta_checked . ' /> ' . __( 'Remove postmeta', 'post-status-scheduler' ) . '<br />'
     584          echo '<input type="checkbox" name="scheduler[postmeta-check]" id="scheduler-postmeta" ' . $scheduler_check_meta_checked . ' /> ' . __( 'Remove postmeta', POST_STATUS_SCHEDULER_TEXTDOMAIN ) . '<br />'
    538585          .'<div id="scheduler-postmeta-box" ' . $scheduler_check_meta_show . ' >'
    539586          . '<select name="scheduler[meta_key]">';
     
    551598        }
    552599
     600        // Email notification option
     601        if( isset( $this->options['notification_email_enabled'] ) && $this->options['notification_email_enabled'] == true ) {
     602
     603          echo '<hr />';
     604
     605          if( isset( $event->email_notify ) && $event->email_notify == true ) {
     606            $email_notify_checked = ' checked="checked" ';
     607          } else {
     608            $email_notify_checked = '';
     609          }
     610
     611          // The checkbox for sending a notification email to author
     612          echo '<input type="checkbox" id="scheduler-email-notification" name="scheduler[email-notify]" disabled="" ' . $email_notify_checked . '/> ' . __( 'Send email notification on change', POST_STATUS_SCHEDULER_TEXTDOMAIN );
     613          echo '<p class="description">(' . get_the_author_meta( 'user_email', $post->post_author ) . ')</p>';
     614        }
    553615        echo '</div>'
    554616        .'</span></div>';
     
    573635        if( $key == 'date' ) {
    574636
    575           $new_columns['scheduler_date']    = __( 'Scheduled date',  'post-status-scheduler' );
     637          $new_columns['scheduler_date']    = __( 'Scheduled date',  POST_STATUS_SCHEDULER_TEXTDOMAIN );
    576638
    577639        }
     
    779841      // All valid post statuses to choose from
    780842      return array(
    781         'draft' => __( 'Draft', 'post-status-scheduler' ),
    782         'pending' => __( 'Pending', 'post-status-scheduler' ),
    783         'private' => __( 'Private', 'post-status-scheduler' ),
    784         'trash' =>  __( 'Trashbin', 'post-status-scheduler' ),
    785         'deleted' => __( 'Delete (forced)', 'post-status-scheduler' ),
     843        'draft' => __( 'Draft', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     844        'pending' => __( 'Pending', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     845        'private' => __( 'Private', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     846        'trash' =>  __( 'Trashbin', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
     847        'deleted' => __( 'Delete (forced)', POST_STATUS_SCHEDULER_TEXTDOMAIN ),
    786848      );
    787849
  • post-status-scheduler/trunk/classes/settings.php

    r960367 r1013039  
    8989      add_settings_section(
    9090        'posttypes', // ID
    91         __( 'Post Types', 'post-status-scheduler' ), // Title
     91        __( 'Post Types and meta keys', 'post-status-scheduler' ), // Title
    9292        array( $this, 'print_section_info' ), // Callback
    9393        'post-status-scheduler' // Page
     
    9797        'allowed_posttypes', // ID
    9898        __( 'Check the post types you wish to display the Scheduler on', 'post-status-scheduler' ), // Title
    99         array( $this, 'id_number_callback' ), // Callback
     99        array( $this, 'allowed_posttypes_callback' ), // Callback
    100100        'post-status-scheduler', // Page
    101101        'posttypes' // Section           
     
    113113      /* SECTION NOTIFICATION EMAIL */
    114114
    115       /* Planned for release 0.4.0 */
    116 
    117       /*add_settings_section(
     115      add_settings_section(
    118116        'notifications', // ID
    119117        __( 'Notification', 'post-status-scheduler' ), // Title
     
    124122      add_settings_field(
    125123        'notification_email_enabled', // ID
    126         __( 'Enable email notification option on scheduled changes', 'post-status-scheduler' ), // Title
     124        __( 'Enable email notification option', 'post-status-scheduler' ), // Title
    127125        array( $this, 'notification_email_enabled_callback' ), // Callback
    128126        'post-status-scheduler', // Page
     
    130128      );
    131129
     130
     131      /* SECTION EXTRA COLUMN ON EDIT PAGE */
     132
     133      add_settings_section(
     134        'column', // ID
     135        __( 'Extra column', 'post-status-scheduler' ), // Title
     136        array( $this, 'print_column_section_info' ), // Callback
     137        'post-status-scheduler' // Page
     138      );
     139
    132140      add_settings_field(
    133         'notification_email_subject', // ID
    134         __( 'Email subject', 'post-status-scheduler' ), // Title
    135         array( $this, 'notification_email_subject_callback' ), // Callback
     141        'extra_column_enabled', // ID
     142        __( 'Enable extra column on posttype edit page', 'post-status-scheduler' ), // Title
     143        array( $this, 'extra_column_enabled_callback' ), // Callback
    136144        '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 
     145        'column' // Section           
     146      );
    148147
    149148    }
     
    186185      }
    187186
    188       /*if( isset( $input['notification_email_enabled'] ) ) {
     187      if( isset( $input['notification_email_enabled'] ) ) {
    189188
    190189        $new_input['notification_email_enabled'] = true;
     
    196195      }
    197196
    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       }*/
     197      if( isset( $input['extra_column_enabled'] ) ) {
     198
     199        $new_input['extra_column_enabled'] = true;
     200
     201      } else {
     202
     203        $new_input['extra_column_enabled'] = false;       
     204
     205      }
    209206
    210207      return $new_input;
    211208     
    212209    }
     210
    213211
    214212    /**
     
    221219    }
    222220
     221
    223222    /**
    224223     * Print the Section text
     
    226225    public function print_notification_section_info() {
    227226       
    228       print __( 'Edit the email settings used by the notification email on a scheduled change:', 'post-status-scheduler' );
     227      print __( 'Enabling this option makes it possible to send an email notification to the post author on a scheduled change execution.', 'post-status-scheduler' );
     228
     229    }
     230
     231
     232    /**
     233     * Print the Section text
     234     */
     235    public function print_column_section_info() {
     236       
     237      print __( 'Settings for adding extra column "Scheduled date" on edit page. This column will only be displayed on posttypes that are allowed for scheduling', 'post-status-scheduler' );
    229238
    230239    }
     
    236245     * Callback for the posttypes allowed
    237246     */
    238     public function id_number_callback() {
     247    public function allowed_posttypes_callback() {
    239248
    240249      // Get all valid public post types
     
    317326    public function notification_email_enabled_callback() {
    318327
    319       $options = get_option( 'post_status_scheduler' );
     328      $options = self::get_options();
    320329      $enabled = !empty( $options['notification_email_enabled'] ) ? $options['notification_email_enabled'] : '';
    321330      ?>
     
    327336
    328337
    329 
    330     /**
    331      * notification_email_subject_callback
     338    /**
     339     * notification_email_enabled_callback
    332340     *
    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 
     341     * Callback for the enabling of notification option
     342     */
     343    public function extra_column_enabled_callback() {
     344
     345      $options = self::get_options();
     346      $enabled = !empty( $options['extra_column_enabled'] ) ? $options['extra_column_enabled'] : '';
     347      ?>
     348
     349      <input type="checkbox" name="post_status_scheduler[extra_column_enabled]" <?php checked( $enabled, true ); ?> />
     350     
     351      <?php
     352    }
     353
     354
     355    public static function get_options() {
     356
     357      return get_option('post_status_scheduler');
     358
     359    }
    358360
    359361  }
    360362
    361 
    362363?>
  • post-status-scheduler/trunk/js/scheduler.js

    r933176 r1013039  
    3333
    3434    }
     35
     36    toggle_email_notification();
    3537  });
    3638
     
    4547
    4648    }
     49
     50    toggle_email_notification();
    4751  });
    4852
     
    5761
    5862    }
     63
     64    toggle_email_notification();
    5965  });
    6066
     67  toggle_email_notification();
     68
     69  function toggle_email_notification() {
     70
     71    if( $('#scheduler-status').is(':checked') || $('#scheduler-category').is(':checked') || $('#scheduler-postmeta').is(':checked') ) {
     72
     73      $('#scheduler-email-notification').removeAttr('disabled');
     74
     75    } else {
     76
     77      $('#scheduler-email-notification').attr('disabled', 'disabled');
     78      $('#scheduler-email-notification').removeAttr('checked', 'checked');
     79
     80    }
     81
     82  }
     83
    6184});
  • post-status-scheduler/trunk/languages/post-status-scheduler-sv_SE.pot

    r960367 r1013039  
    22msgstr ""
    33"Project-Id-Version: post-status-scheduler\n"
    4 "POT-Creation-Date: 2014-08-05 09:46+0100\n"
    5 "PO-Revision-Date: 2014-08-05 09:49+0100\n"
     4"POT-Creation-Date: 2014-10-23 15:58+0100\n"
     5"PO-Revision-Date: 2014-10-23 16:00+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:460
     17#: classes/email.php:25
     18msgid "Post Status Scheduler update"
     19msgstr "Uppdatering Post Status Scheduler"
     20
     21#: classes/email.php:33
     22msgid "A scheduled update has been executed at"
     23msgstr "En schemalagd ändring har blivit exekverad"
     24
     25#: classes/email.php:33
     26msgid "on your post"
     27msgstr "på din post"
     28
     29#: classes/email.php:34
     30msgid "Regards"
     31msgstr "Hälsningar"
     32
     33#: classes/scheduler.php:503
    1834msgid "Schedule Status Change"
    1935msgstr "Schemalägg statusändring"
    2036
    21 #: classes/scheduler.php:462
     37#: classes/scheduler.php:505
    2238msgid "Date"
    2339msgstr "Datum"
    2440
    25 #: classes/scheduler.php:464
     41#: classes/scheduler.php:507
    2642msgid "Time"
    2743msgstr "Tid"
    2844
    29 #: classes/scheduler.php:468
     45#: classes/scheduler.php:511
    3046msgid "Change status"
    3147msgstr "Ändra status"
    3248
    33 #: classes/scheduler.php:470
     49#: classes/scheduler.php:513
    3450msgid "Set status to"
    3551msgstr "Ändra status till"
    3652
    37 #: classes/scheduler.php:485
     53#: classes/scheduler.php:528
    3854msgid "Change categories"
    3955msgstr "Ändra kategorier"
    4056
    41 #: classes/scheduler.php:487
     57#: classes/scheduler.php:530
    4258msgid "The post will have the following categories on scheduled time"
    4359msgstr "Följande kategorier kommer att sättas vid schemalagd tid"
    4460
    45 #: classes/scheduler.php:537
     61#: classes/scheduler.php:580
    4662msgid "Remove postmeta"
    4763msgstr "Ta bort postmeta"
    4864
    49 #: classes/scheduler.php:575
     65#: classes/scheduler.php:608
     66msgid "Send email notification on change"
     67msgstr "Skicka epostnotifiering vid ändring"
     68
     69#: classes/scheduler.php:633
    5070msgid "Scheduled date"
    5171msgstr "Schemalagt datum"
    5272
    53 #: classes/scheduler.php:781
     73#: classes/scheduler.php:839
    5474msgid "Draft"
    5575msgstr "Utkast"
    5676
    57 #: classes/scheduler.php:782
     77#: classes/scheduler.php:840
    5878msgid "Pending"
    5979msgstr "Väntar på granskning"
    6080
    61 #: classes/scheduler.php:783
     81#: classes/scheduler.php:841
    6282msgid "Private"
    6383msgstr "Privat"
    6484
    65 #: classes/scheduler.php:784
     85#: classes/scheduler.php:842
    6686msgid "Trashbin"
    6787msgstr "Papperskorg"
    6888
    69 #: classes/scheduler.php:785
     89#: classes/scheduler.php:843
    7090msgid "Delete (forced)"
    7191msgstr "Radera (tvingad)"
     
    7696
    7797#: classes/settings.php:91
    78 msgid "Post Types"
    79 msgstr "Posttyper"
     98msgid "Post Types and meta keys"
     99msgstr "Posttyper och metakeys"
    80100
    81101#: classes/settings.php:98
     
    87107msgstr "Märk de metafält som skall vara valbara för borttagning"
    88108
    89 #: classes/settings.php:117
     109#: classes/settings.php:119
    90110msgid "Notification"
    91111msgstr "Notifikation"
    92112
    93 #: classes/settings.php:124
    94 msgid "Enable email notification option on scheduled changes"
    95 msgstr "Aktivera epostnotifikation vid schemalagda ändringar"
     113#: classes/settings.php:126
     114msgid "Enable email notification option"
     115msgstr "Aktivera epostnotifiering"
    96116
    97 #: classes/settings.php:132
    98 msgid "Email subject"
    99 msgstr "Epostämne"
    100 
    101 #: classes/settings.php:140
    102 msgid "Email body"
    103 msgstr "Epostmeddelande"
    104 
    105 #: classes/settings.php:217
     117#: classes/settings.php:190
    106118msgid "Enter your settings below:"
    107119msgstr "Ange inställningar nedan:"
    108120
    109 #: classes/settings.php:226
    110 msgid ""
    111 "Edit the email settings used by the notification email on a scheduled change:"
    112 msgstr "Ändra epostinställningarna som används vid notifikationsepost"
     121#: classes/settings.php:199
     122msgid "Email notification settings:"
     123msgstr "Inställningar för epostnotifiering"
     124
     125#~ msgid "Post Types"
     126#~ msgstr "Posttyper"
     127
     128#~ msgid "Email subject"
     129#~ msgstr "Epostämne"
     130
     131#~ msgid "Email body"
     132#~ msgstr "Epostmeddelande"
     133
     134#~ msgid ""
     135#~ "Edit the email settings used by the notification email on a scheduled "
     136#~ "change:"
     137#~ msgstr "Ändra epostinställningarna som används vid notifikationsepost"
    113138
    114139#~ msgid "Add or remove category"
  • post-status-scheduler/trunk/languages/post-status-scheduler.pot

    r933176 r1013039  
    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 18:01+0100\n"
     4"POT-Creation-Date: 2014-10-23 15:50+0100\n"
     5"PO-Revision-Date: 2014-10-23 15:51+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:503
     18msgid "Schedule Status Change"
     19msgstr ""
     20
     21#: classes/scheduler.php:505
     22msgid "Date"
     23msgstr ""
     24
     25#: classes/scheduler.php:507
     26msgid "Time"
     27msgstr ""
     28
     29#: classes/scheduler.php:511
     30msgid "Change status"
     31msgstr ""
     32
     33#: classes/scheduler.php:513
     34msgid "Set status to"
     35msgstr ""
     36
     37#: classes/scheduler.php:528
     38msgid "Change categories"
     39msgstr ""
     40
     41#: classes/scheduler.php:530
     42msgid "The post will have the following categories on scheduled time"
     43msgstr ""
     44
     45#: classes/scheduler.php:580
     46msgid "Remove postmeta"
     47msgstr ""
     48
     49#: classes/scheduler.php:608
     50msgid "Send email notification on change"
     51msgstr ""
     52
     53#: classes/scheduler.php:633
     54msgid "Scheduled date"
     55msgstr ""
     56
     57#: classes/scheduler.php:839
    1858msgid "Draft"
    1959msgstr ""
    2060
    21 #: classes/scheduler.php:38
     61#: classes/scheduler.php:840
    2262msgid "Pending"
    2363msgstr ""
    2464
    25 #: classes/scheduler.php:39
     65#: classes/scheduler.php:841
    2666msgid "Private"
    2767msgstr ""
    2868
    29 #: classes/scheduler.php:40
     69#: classes/scheduler.php:842
    3070msgid "Trashbin"
    3171msgstr ""
    3272
    33 #: classes/scheduler.php:41
     73#: classes/scheduler.php:843
    3474msgid "Delete (forced)"
    3575msgstr ""
    3676
    37 #: classes/scheduler.php:468
    38 msgid "Schedule Status Change"
    39 msgstr ""
    40 
    41 #: classes/scheduler.php:470
    42 msgid "Date"
    43 msgstr ""
    44 
    45 #: classes/scheduler.php:472
    46 msgid "Time"
    47 msgstr ""
    48 
    49 #: classes/scheduler.php:476
    50 msgid "Change status"
    51 msgstr ""
    52 
    53 #: classes/scheduler.php:478
    54 msgid "Set status to"
    55 msgstr ""
    56 
    57 #: classes/scheduler.php:493
    58 msgid "Add or remove category"
    59 msgstr ""
    60 
    61 #: classes/scheduler.php:495
    62 msgid "Add"
    63 msgstr ""
    64 
    65 #: classes/scheduler.php:496
    66 msgid "Remove"
    67 msgstr ""
    68 
    69 #: classes/scheduler.php:513
    70 msgid "Remove postmeta"
    71 msgstr ""
    72 
    73 #: classes/scheduler.php:550
    74 msgid "Scheduled date"
    75 msgstr ""
    76 
    77 #: classes/settings.php:43 classes/settings.php:61
     77#: classes/settings.php:44 classes/settings.php:62
    7878msgid "Post Status Scheduler"
    7979msgstr ""
    8080
    81 #: classes/settings.php:88
    82 msgid "Post Types"
     81#: classes/settings.php:91
     82msgid "Post Types and meta keys"
    8383msgstr ""
    8484
    85 #: classes/settings.php:95
     85#: classes/settings.php:98
    8686msgid "Check the post types you wish to display the Scheduler on"
    8787msgstr ""
    8888
    89 #: classes/settings.php:103
     89#: classes/settings.php:106
    9090msgid "Mark allowed meta fields to be shown as removable"
    9191msgstr ""
    9292
    93 #: classes/settings.php:157
     93#: classes/settings.php:119
     94msgid "Notification"
     95msgstr ""
     96
     97#: classes/settings.php:126
     98msgid "Enable email notification option"
     99msgstr ""
     100
     101#: classes/settings.php:190
    94102msgid "Enter your settings below:"
    95103msgstr ""
     104
     105#: classes/settings.php:199
     106msgid "Email notification settings:"
     107msgstr ""
  • post-status-scheduler/trunk/post-status-scheduler.php

    r960369 r1013039  
    55  Plugin Name: Post Status Scheduler
    66  Description: Change status, category or postmeta of any post type at a scheduled timestamp.
    7   Version: 0.3.0
     7  Version: 1.0.0
    88  Author: Andreas Färnstrand <[email protected]>
    99  Author URI: http://www.farnstranddev.se
     
    2828*/
    2929
     30  // Exit if accessed directly
     31  if ( !defined( 'ABSPATH' ) ) exit;
     32
    3033  use post_status_scheduler as post_status_scheduler;
    3134
     
    3639    require_once 'classes/shortcode.php';
    3740
    38         define( 'POST_STATUS_SCHEDULER_PLUGIN_PATH', plugin_dir_url( __FILE__ ) );
    39         define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
    40     define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__) ) .'/languages' );
    41     define( 'POST_STATUS_SCHEDULER_VERSION', '0.3.0' );
     41        if( !defined( 'POST_STATUS_SCHEDULER_PLUGIN_PATH' ) )        define( 'POST_STATUS_SCHEDULER_PLUGIN_PATH', plugin_dir_url( __FILE__ ) );
     42        if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN' ) )         define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN', 'post_status_scheduler' );
     43    if( !defined( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH' ) )    define( 'POST_STATUS_SCHEDULER_TEXTDOMAIN_PATH', dirname( plugin_basename( __FILE__) ) .'/languages' );
     44    if( !defined( 'POST_STATUS_SCHEDULER_VERSION' ) )            define( 'POST_STATUS_SCHEDULER_VERSION', '1.0.0' );
    4245
     46    // Create a new scheduler instance
    4347    $pss = new \post_status_scheduler\Scheduler();
    4448
     49    // Create a new settings instance
    4550    if( is_admin() ) {
    4651        $settings = new \post_status_scheduler\Settings();
    4752    }
    4853
     54    // Create shortcodes
    4955    $pss_shortcodes = new \post_status_scheduler\Shortcode();
    5056
  • post-status-scheduler/trunk/readme.txt

    r984682 r1013039  
    44Requires at least: 3.9
    55Tested up to: 4.0
    6 Stable tag: 0.3.0
     6Stable tag: 1.0.0
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1414Post Status Scheduler allows for scheduling of post status changes, category adding or removing and
    1515removing of postmeta on any given date or time. It can be activated on any post type and shows
    16 up on the post edit screen in the publish section.
     16up on the post edit screen in the publish section. From version 1.0.0 it has a feature for sending
     17an email notification to the post author on the scheduled update.
    1718
    1819= Shortcodes =
    1920
    2021* [pss_scheduled_time post_id="<your post id>"] can be used to get the post's scheduled date and time.
     22
     23= Filters =
     24Scheduled Update:
     25* post_status_scheduler_before_execution
     26* post_status_scheduler_after_execution
     27
     28Email Notification ( version 1.0.0 ):
     29* post_status_scheduler_email_notification_recipient_email
     30* post_status_scheduler_email_notification_subject
     31* post_status_scheduler_email_notification_date
     32* post_status_scheduler_email_notification_body
    2133
    2234== Installation ==
     
    32443. Edit page without post meta option activated.
    33454. Edit page with post meta option activated.
     465. Edit page with email notification option.
    3447
    3548= What Translations are included? =
     
    3952== Changelog ==
    4053
     54= 1.0.0 =
     55* New feature for sending email notification to post author when executing a scheduled update.
     56* New feature makes it possible to show/remove the "Scheduled date" column on posttype edit page.
     57* Code cleanup.
     58
    4159= 0.3.0 =
    42 * Rewritten to support setting multiple categories on scheduled time. I have tried to make sure that it will still work with previously scheduled changes in previous versions of the plugin.
    43 * A little bit of code clean up.
     60* Rewritten plugin to support setting multiple categories on scheduled time. I have tried to make sure that it will still work with previously scheduled changes in previous versions of the plugin.
     61* A little bit of code clean up and refactoring.
    4462
    4563= 0.2.1 =
Note: See TracChangeset for help on using the changeset viewer.