Plugin Directory

Changeset 382464


Ignore:
Timestamp:
05/08/2011 02:22:10 PM (15 years ago)
Author:
tetele
Message:

FEATURE: Ability to disable autoscheduling (by default - over-ridable from post edit page) for certain users.

Location:
automatic-post-scheduler/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • automatic-post-scheduler/trunk/plugin.php

    r382443 r382464  
    8080?>
    8181<div class="misc-pub-section" id="aps_schedule_post">
    82     <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>
     82    <label><input type="checkbox" id="aps_schedule_post" name="aps_schedule_post" <?php echo ( aps_current_user_disable_default() ) ? '' : 'checked="checked"'; ?>/> <?php _e( 'Schedule as soon as posible', 'autoscheduler' ); ?></label>
    8383</div>
    8484<?php
  • automatic-post-scheduler/trunk/settings.php

    r382439 r382464  
    9393}
    9494
     95function aps_current_user_disable_default( $uid = false ) {
     96    global $current_user;
     97   
     98    if( $uid === false )
     99        $uid = $current_user->ID;
     100    return get_user_meta( $uid, 'aps_disable_default', true );
     101}
     102
     103add_filter( 'personal_options', 'aps_user_options' );
     104function aps_user_options( $user ) {
     105    if( !user_can( $user->ID, 'publish_posts' ) )
     106        return;
     107    $disable_default = aps_current_user_disable_default();
     108    ?>
     109    <tr>
     110    <th scope="row"><?php _e( 'Automatic post scheduler', 'autoscheduler' ); ?></th>
     111    <td><label><input type="checkbox" value="1" <?php echo $disable_default ? 'checked="checked' : ""; ?>" name="aps_disable_default" id="aps_disable_default" /> <?php _e( 'Disable scheduling of my own posts by default (can be over-ridden for individual posts)' ); ?></label></td>
     112    </tr>
     113   
     114    <?php
     115}
     116
     117add_action( 'personal_options_update', 'aps_user_options_update' );
     118add_action( 'edit_user_profile_update', 'aps_user_options_update' );
     119
     120function aps_user_options_update( $uid ) {
     121    update_user_meta( $uid, 'aps_disable_default', isset($_POST['aps_disable_default']) ? $_POST['aps_disable_default'] : '' );
     122}
     123
    95124?>
Note: See TracChangeset for help on using the changeset viewer.