Changeset 382440
- Timestamp:
- 05/08/2011 01:26:11 PM (15 years ago)
- File:
-
- 1 edited
-
automatic-post-scheduler/trunk/plugin.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
automatic-post-scheduler/trunk/plugin.php
r313569 r382440 16 16 add_action( 'init', 'aps_init' ); 17 17 function aps_init() { 18 add_filter( 'wp_insert_post_data', 'aps_check_and_schedule' ); 18 // Attach checkbox to publish box on edit post page 19 add_action( 'post_submitbox_misc_actions', 'aps_publish_box' ); 20 21 // Actually delay/schedule post publishing 22 add_filter( 'wp_insert_post_data', 'aps_check_and_schedule', 10, 2 ); 19 23 } 20 24 … … 26 30 * 27 31 * @param object $data Post object 32 * @param object $postarr Raw HTTP POST data 28 33 * @return object Filtered post object 29 34 */ 30 function aps_check_and_schedule( $data ) { 35 function aps_check_and_schedule( $data, $postarr ) { 36 // check if scheduling should occur 37 if( !( isset( $postarr['aps_schedule_post'] ) && $postarr['aps_schedule_post'] ) ) 38 return $data; 39 31 40 // post_status is definately set, since we're using sanitized data. No check necessary 32 41 $post_status = $data['post_status']; 33 42 43 // only invoke upon publishing 34 44 if ( $post_status != 'publish' ) 35 45 return $data; … … 47 57 48 58 return $data; 59 } 60 61 /** 62 * Adds schedule checkbox on post page, in publish box (aka post submit box) 63 * 64 * @since 0.9.1 65 */ 66 function aps_publish_box() { 67 global $post; 68 if ( !current_user_can( 'publish_posts' ) || in_array( $post->post_status, array( 'publish', 'future' ) ) ) 69 return; 70 ?> 71 <div class="misc-pub-section" id="aps_schedule_post"> 72 <label><input type="checkbox" id="aps_schedule_post" name="aps_schedule_post" <?php echo ( $post->post_status == 'publish' ) ? '' : 'checked="checked"'; ?>/> <?php _e( 'Schedule as soon as posible', 'autoscheduler' ); ?></label> 73 </div> 74 <?php 49 75 } 50 76
Note: See TracChangeset
for help on using the changeset viewer.