Plugin Directory

Changeset 3086044

Timestamp:
05/13/2024 05:58:14 PM (3 months ago)
Author:
dartiss
Message:

Version 2.6

Location:
simple-draft-list/trunk
Files:
3 added
1 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • simple-draft-list/trunk/inc/class-draftlistwidget.php

    r2857945 r3086044  
    55 * Create and display widgets
    66 *
    7  * @package Artiss-Draft-List
     7 * @package ist
    88 */
     9
     10
     11
     12
     13
     14
    915
    1016/**
     
    2733            'draft_list_widget',
    2834            __( 'Draft List', 'simple-draft-list' ),
    29             array( 
     35            array(
    3036                'description'                 => __( 'WordPress plugin to manage and promote your unpublished content.', 'simple-draft-list' ),
    3137                'class'                       => 'dl-widget',
     
    4046     * Display the widget
    4147     *
    42      * @uses  adl_generate_code  Generate the required code
     48     * @uses  _generate_code  Generate the required code
    4349     *
    4450     * @param string $args       Arguments.
     
    4753    public function widget( $args, $instance ) {
    4854
    49         extract( $args, EXTR_SKIP );
     55        // Extract out any arguments.
     56
     57        $before_title  = '';
     58        $after_title   = '';
     59        $before_widget = '';
     60        $after_widget  = '';
     61
     62        if ( array_key_exists( 'before_title', $args ) ) {
     63            $before_title = $args['before_title'];
     64        }
     65        if ( array_key_exists( 'after_title', $args ) ) {
     66            $after_title = $args['after_title'];
     67        }
     68        if ( array_key_exists( 'before_widget', $args ) ) {
     69            $before_widget = $args['before_widget'];
     70        }
     71        if ( array_key_exists( 'after_widget', $args ) ) {
     72            $after_widget = $args['widget'];
     73        }
    5074
    5175        // Merge in default values.
    52         $instance = wp_parse_args( (array) $instance, adl_load_widget_defaults() );
     76        $instance = wp_parse_args( (array) $instance, _load_widget_defaults() );
    5377
    5478        // Output the header.
     
    6589        // Generate the video and output it.
    6690        echo wp_kses(
    67             adl_generate_code(
     91            _generate_code(
    6892                $instance['limit'],
    6993                $instance['type'],
     
    123147
    124148        // Merge in default values.
    125         $instance = wp_parse_args( (array) $instance, adl_load_widget_defaults() );
     149        $instance = wp_parse_args( (array) $instance, _load_widget_defaults() );
    126150
    127151        // Title field.
     
    149173        $field_name = $this->get_field_name( 'type' );
    150174        echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Draft Type', 'simple-draft-list' ) . ': </label><select name="' . esc_attr( $field_name ) . '" class="widefat" id="' . esc_attr( $field_id ) . '"><option value=""';
    151         if ( esc_html( $instance['type'] ) == '' ) {
     175        if ( esc_html( $instance['type'] ) == '' ) {
    152176            echo " selected='selected'";
    153177        }
    154178        echo '>' . esc_html__( 'Posts & Pages', 'simple-draft-list' ) . '</option><option value="page"';
    155         if ( esc_html( $instance['type'] ) == 'page' ) {
     179        if ( esc_html( $instance['type'] ) == 'page' ) {
    156180            echo " selected='selected'";
    157181        }
    158182        echo '>' . esc_html__( 'Pages', 'simple-draft-list' ) . '</option><option value="post"';
    159         if ( esc_html( $instance['type'] ) == 'post' ) {
     183        if ( esc_html( $instance['type'] ) == 'post' ) {
    160184            echo " selected='selected'";
    161185        }
     
    166190        $field_name = $this->get_field_name( 'order' );
    167191        echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Order', 'simple-draft-list' ) . ': </label><select name="' . esc_attr( $field_name ) . '" class="widefat" id="' . esc_attr( $field_id ) . '"><option value=""';
    168         if ( esc_html( $instance['order'] ) == '' ) {
     192        if ( esc_html( $instance['order'] ) == '' ) {
    169193            echo " selected='selected'";
    170194        }
    171195        echo '>' . esc_html__( 'Descending Modified Date', 'simple-draft-list' ) . '</option><option value="ma"';
    172         if ( esc_html( $instance['order'] ) == 'ma' ) {
     196        if ( esc_html( $instance['order'] ) == 'ma' ) {
    173197            echo " selected='selected'";
    174198        }
    175199        echo '>' . esc_html__( 'Ascending Modified Date', 'simple-draft-list' ) . '</option><option value="cd"';
    176         if ( esc_html( $instance['order'] ) == 'cd' ) {
     200        if ( esc_html( $instance['order'] ) == 'cd' ) {
    177201            echo " selected='selected'";
    178202        }
    179203        echo '>' . esc_html__( 'Descending Created Date', 'simple-draft-list' ) . '</option><option value="ca"';
    180         if ( esc_html( $instance['order'] ) == 'ca' ) {
     204        if ( esc_html( $instance['order'] ) == 'ca' ) {
    181205            echo " selected='selected'";
    182206        }
    183207        echo '>' . esc_html__( 'Ascending Created Date', 'simple-draft-list' ) . '</option><option value="td"';
    184         if ( esc_html( $instance['order'] ) == 'td' ) {
     208        if ( esc_html( $instance['order'] ) == 'td' ) {
    185209            echo " selected='selected'";
    186210        }
    187211        echo '>' . esc_html__( 'Descending Title', 'simple-draft-list' ) . '</option><option value="ta"';
    188         if ( esc_html( $instance['order'] ) == 'ta' ) {
     212        if ( esc_html( $instance['order'] ) == 'ta' ) {
    189213            echo " selected='selected'";
    190214        }
     
    195219        $field_name = $this->get_field_name( 'scheduled' );
    196220        echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Hide Scheduled Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="no"';
    197         if ( 'no' == esc_html( $instance['scheduled'] ) ) {
     221        if ( 'no' == esc_html( $instance['scheduled'] ) ) {
    198222            echo " checked='checked'";
    199223        }
     
    204228        $field_name = $this->get_field_name( 'pending' );
    205229        echo "\r\n" . '<p><label for="' . esc_attr( $field_id ) . '">' . esc_html__( 'Show Pending Posts', 'simple-draft-list' ) . ': </label><input type="checkbox" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="yes"';
    206         if ( 'yes' == esc_attr( $instance['pending'] ) ) {
     230        if ( 'yes' == esc_attr( $instance['pending'] ) ) {
    207231            echo " checked='checked'";
    208232        }
     
    232256    }
    233257}
    234 
    235 /**
    236  * Register Widget
    237  *
    238  * Register widget when loading the WP core
    239  */
    240 function adl_register_widgets() {
    241     register_widget( 'DraftListWidget' );
    242 }
    243 
    244 add_action( 'widgets_init', 'adl_register_widgets' );
    245 
    246 /**
    247  * Widget defaults
    248  *
    249  * Return default values for the widget
    250  */
    251 function adl_load_widget_defaults() {
    252     return array(
    253         'title'     => __( 'Coming Soon', 'simple-draft-list' ),
    254         'limit'     => '0',
    255         'type'      => '',
    256         'order'     => '',
    257         'scheduled' => 'yes',
    258         'pending'   => 'no',
    259         'folder'    => '',
    260         'date'      => 'F j, Y, g:i a',
    261         'created'   => '',
    262         'modified'  => '',
    263         'template'  => '{{ol}}{{draft}} {{icon}}',
    264     );
    265 }
  • simple-draft-list/trunk/inc/create-lists.php

    r2857945 r3086044  
    55 * Generate the draft list code
    66 *
    7  * @package Artiss-Draft-List
     7 * @package ist
    88 */
     9
     10
     11
     12
     13
     14
    915
    1016/**
     
    1420 *
    1521 * @param  string $paras   Parameters.
    16  * @param  string $content Content between shortcodes.
    1722 * @return string          Draft list output.
    1823 */
    19 function adl_draft_list_shortcode( $paras = '', $content = '' ) {
    20 
    21     extract(
    22         shortcode_atts(
    23             array(
    24                 'limit'     => '',
    25                 'type'      => '',
    26                 'order'     => '',
    27                 'scheduled' => '',
    28                 'icon'      => '',
    29                 'folder'    => '',
    30                 'author'    => '',
    31                 'template'  => '',
    32                 'date'      => '',
    33                 'created'   => '',
    34                 'modified'  => '',
    35                 'words'     => '',
    36                 'pending'   => '',
    37             ),
    38             $paras
    39         )
    40     );
    41 
    42     if ( '' == $template ) {
    43         $template = adl_convert_to_template( $icon, $author );
    44     }
    45 
    46     return adl_generate_code( $limit, $type, $order, $scheduled, $folder, $date, $created, $modified, $template, $words, $pending );
    47 
     24function draft_list_shortcode( $paras = '' ) {
     25
     26    // Set default parameter values.
     27
     28    $limit     = '';
     29    $type      = '';
     30    $order     = '';
     31    $scheduled = '';
     32    $icon      = '';
     33    $folder    = '';
     34    $author    = '';
     35    $template  = '';
     36    $date      = '';
     37    $created   = '';
     38    $modified  = '';
     39    $words     = '';
     40    $pending   = '';
     41
     42    // Assign to variable, if found in array.
     43
     44    if ( array_key_exists( 'limit', $paras ) ) {
     45        $limit = $paras['limit'];
     46    }
     47    if ( array_key_exists( 'type', $paras ) ) {
     48        $type = $paras['type'];
     49    }
     50    if ( array_key_exists( 'order', $paras ) ) {
     51        $order = $paras['order'];
     52    }
     53    if ( array_key_exists( 'scheduled', $paras ) ) {
     54        $scheduled = $paras['scheduled'];
     55    }
     56    if ( array_key_exists( 'icon', $paras ) ) {
     57        $icon = $paras['icon'];
     58    }
     59    if ( array_key_exists( 'folder', $paras ) ) {
     60        $folder = $paras['folder'];
     61    }
     62    if ( array_key_exists( 'author', $paras ) ) {
     63        $author = $paras['author'];
     64    }
     65    if ( array_key_exists( 'template', $paras ) ) {
     66        $template = $paras['template'];
     67    }
     68    if ( array_key_exists( 'date', $paras ) ) {
     69        $date = $paras['date'];
     70    }
     71    if ( array_key_exists( 'created', $paras ) ) {
     72        $created = $paras['created'];
     73    }
     74    if ( array_key_exists( 'modified', $paras ) ) {
     75        $modified = $paras['modified'];
     76    }
     77    if ( array_key_exists( 'words', $paras ) ) {
     78        $words = $paras['words'];
     79    }
     80    if ( array_key_exists( 'pending', $paras ) ) {
     81        $pending = $paras['pending'];
     82    }
     83
     84    // If there's no template, create a default one.
     85
     86    if ( '' === $template ) {
     87        $template = draft_list_convert_to_template( $icon, $author );
     88    }
     89
     90    // Generate the output.
     91
     92    return draft_list_generate_code( $limit, $type, $order, $scheduled, $folder, $date, $created, $modified, $template, $words, $pending );
    4893}
    49 add_shortcode( 'drafts', 'adl_draft_list_shortcode' );
     94
     95add_shortcode( 'drafts', 'draft_list_shortcode' );
    5096
    5197/**
     
    67113 * @return string               Draft list output.
    68114 */
    69 function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '', $scheduled = '', $icon_folder = '', $date_format = '', $created = '', $modified = '', $template = '', $words = '', $pending = '' ) {
     115function _generate_code( $list_limit = '', $list_type = '', $list_order = '', $scheduled = '', $icon_folder = '', $date_format = '', $created = '', $modified = '', $template = '', $words = '', $pending = '' ) {
    70116
    71117    // Validate the list type.
    72     if ( ( 'post' != $list_type ) && ( 'page' != $list_type ) && ( '' != $list_type ) ) {
     118    if ( ( 'post' !== $list_type ) ) {
    73119        $list_type = 'error';
    74120    }
     
    85131
    86132    // Set default values.
    87     if ( '' == $list_limit ) {
     133    if ( '' == $list_limit ) {
    88134        $list_limit = 0;
    89135    }
    90     if ( '' == $words ) {
     136    if ( '' == $words ) {
    91137        $words = 0;
    92138    }
    93     if ( '' == $list_order ) {
     139    if ( '' == $list_order ) {
    94140        $list_order = 'da';
    95141    }
    96     if ( '' == $scheduled ) {
     142    if ( '' == $scheduled ) {
    97143        $scheduled = 'yes';
    98144    }
    99     if ( '' == $pending ) {
     145    if ( '' == $pending ) {
    100146        $pending = 'no';
    101147    }
    102     if ( '' == $date_format ) {
     148    if ( '' == $date_format ) {
    103149        $date_format = 'F j, Y, g:i a';
    104150    }
    105     if ( '' == $template ) {
     151    if ( '' == $template ) {
    106152        $template = '{{ul}}{{draft}}';
    107153    }
     
    113159    $sort_sequence = '';
    114160
    115     if ( ( 'd' == $first_char ) || ( 'm' == $first_char ) ) {
     161    if ( ( 'd' ==== $first_char ) ) {
    116162        $sort_field = 'post_modified';
    117163    }
    118     if ( 'c' == $first_char ) {
     164    if ( 'c' == $first_char ) {
    119165        $sort_field = 'post_date';
    120166    }
    121     if ( 't' == $first_char ) {
     167    if ( 't' == $first_char ) {
    122168        $sort_field = 'post_title';
    123169    }
    124     if ( 'a' == $second_char ) {
     170    if ( 'a' == $second_char ) {
    125171        $sort_sequence = ' ASC';
    126172    }
    127     if ( 'd' == $second_char ) {
     173    if ( 'd' == $second_char ) {
    128174        $sort_sequence = ' DESC';
    129175    }
     
    132178    $error = false;
    133179    if ( ! is_numeric( $list_limit ) ) {
    134         $code .= adl_report_error( __( 'The limit is invalid - it must be a number', 'simple-draft-list' ), $plugin_name, false );
     180        $code .= _report_error( __( 'The limit is invalid - it must be a number', 'simple-draft-list' ), $plugin_name, false );
    135181        $error = true;
    136182    }
    137183    if ( ! is_numeric( $words ) ) {
    138         $code .= adl_report_error( __( 'The minimum number of words is invalid - it must be a number', 'simple-draft-list' ), $plugin_name, false );
    139         $error = true;
    140     }
    141     if ( ( '' == $sort_field ) || ( '' == $sort_sequence ) ) {
    142         $code .= adl_report_error( __( 'The order is invalid - please view the instructions for valid combinations', 'simple-draft-list' ), $plugin_name, false );
    143         $error = true;
    144     }
    145     if ( ( 'post' != $list_type ) && ( 'page' != $list_type ) && ( '' != $list_type ) ) {
    146         $code .= adl_report_error( __( "The list type is invalid - it must be blank, 'post' or 'page'.", 'simple-draft-list' ), $plugin_name, false );
    147         $error = true;
    148     }
    149     if ( ( 'no' != $scheduled ) && ( 'yes' != $scheduled ) ) {
    150         $code .= adl_report_error( __( "The scheduled parameter must be either 'Yes' or 'No'", 'simple-draft-list' ), $plugin_name, false );
    151         $error = true;
    152     }
    153     if ( strpos( $template, '%draft%' ) == false && strpos( $template, '{{draft}}' ) == false ) {
    154         $code .= adl_report_error( __( 'The template must include the {{draft}} tag', 'simple-draft-list' ), $plugin_name, false );
     184        $code .= _report_error( __( 'The minimum number of words is invalid - it must be a number', 'simple-draft-list' ), $plugin_name, false );
     185        $error = true;
     186    }
     187    if ( ( '' ==== $sort_sequence ) ) {
     188        $code .= _report_error( __( 'The order is invalid - please view the instructions for valid combinations', 'simple-draft-list' ), $plugin_name, false );
     189        $error = true;
     190    }
     191    if ( ( 'post' !== $list_type ) ) {
     192        $code .= _report_error( __( "The list type is invalid - it must be blank, 'post' or 'page'.", 'simple-draft-list' ), $plugin_name, false );
     193        $error = true;
     194    }
     195    if ( ( 'no' !== $scheduled ) ) {
     196        $code .= _report_error( __( "The scheduled parameter must be either 'Yes' or 'No'", 'simple-draft-list' ), $plugin_name, false );
     197        $error = true;
     198    }
     199    if ( strpos( $template, '%draft%' ) ==== false ) {
     200        $code .= _report_error( __( 'The template must include the {{draft}} tag', 'simple-draft-list' ), $plugin_name, false );
    155201        $error = true;
    156202    }
     
    159205    $far_past = '2 January 1970';
    160206
    161     if ( '' != $created ) {
     207    if ( '' != $created ) {
    162208        $created = '-' . $created;
    163209    } else {
     
    165211    }
    166212    $created = strtotime( $created );
    167     if ( ( -1 == $created ) || ( ! $created ) ) {
    168         $code .= adl_report_error( __( 'The created parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
     213    if ( ( -1 == $created ) || ( ! $created ) ) {
     214        $code .= _report_error( __( 'The created parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
    169215        $error = true;
    170216    }
    171217    $created = gmdate( 'Y-m-d H:i:s', $created );
    172218
    173     if ( '' != $modified ) {
     219    if ( '' != $modified ) {
    174220        $modified = '-' . $modified;
    175221    } else {
     
    177223    }
    178224    $modified = strtotime( $modified );
    179     if ( ( -1 == $modified ) || ( ! $modified ) ) {
    180         $code .= adl_report_error( __( 'The modified parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
     225    if ( ( -1 == $modified ) || ( ! $modified ) ) {
     226        $code .= _report_error( __( 'The modified parameter is invalid', 'simple-draft-list' ), $plugin_name, false );
    181227        $error = true;
    182228    }
     
    187233        // Define the type of list required.
    188234        $type = array( 'post', 'page' );
    189         if ( ( 'post' == $list_type ) || ( 'page' == $list_type ) ) {
     235        if ( ( 'post' ==== $list_type ) ) {
    190236            $type = $list_type;
    191237        }
     
    193239        $status = array( 'draft' );
    194240
    195         if ( true === $scheduled || 'true' == $scheduled || 'yes' == $scheduled ) {
     241        if ( true === $scheduled || 'true' ==== $scheduled ) {
    196242            array_push( $status, 'future' );
    197243        }
    198         if ( true === $pending || 'true' == $pending || 'yes' == $pending ) {
     244        if ( true === $pending || 'true' ==== $pending ) {
    199245            array_push( $status, 'pending' );
    200246        }
    201247
    202248        // Has a word or character count been requested?
    203         if ( ( $words > 0 ) || ( strpos( $template, '%words%' ) != false ) || ( strpos( $template, '{{words}}' ) != false ) || ( strpos( $template, '%chars%' ) != false ) || ( strpos( $template, '%chars+space%' ) != false ) || ( strpos( $template, '{{chars+space}}' ) != false ) ) {
     249        if ( ( $words > 0 ) || ( strpos( $template, '%words%' ) !== false ) ) {
    204250            $sql_content = ', post_content';
    205251            $count       = true;
     
    222268        // If template contains list tags at beginning, wrap these around output.
    223269        $list = false;
    224         if ( ( ( '%ol%' == substr( $template, 0, 4 ) ) || ( '%ul%' == substr( $template, 0, 4 ) ) ) && ( 1 != $list_limit ) ) {
     270        if ( ( ( '%ol%' === $list_limit ) ) {
    225271            $list_type = substr( $template, 1, 2 );
    226272            $code     .= '<' . $list_type . ">\n";
     
    231277        }
    232278
    233         if ( ( ( '{{ol}}' == substr( $template, 0, 6 ) ) || ( '{{ul}}' == substr( $template, 0, 6 ) ) ) && ( 1 != $list_limit ) ) {
     279        if ( ( ( '{{ol}}' === $list_limit ) ) {
    234280            $list_type = substr( $template, 2, 2 );
    235281            $code     .= '<' . $list_type . ">\n";
     
    246292            $post_title = $draft_data->post_title;
    247293
    248             if ( '!' != substr( $post_title, 0, 1 ) ) {
     294            if ( '!' != substr( $post_title, 0, 1 ) ) {
    249295
    250296                // Extract fields from MySQL results.
     
    267313
    268314                // Does the current user have editor privileges for the current post type.
    269                 if ( ( ( current_user_can( 'edit_posts' ) ) && ( 'post' == $post_type ) ) || ( ( current_user_can( 'edit_pages' ) ) && ( 'page' == $post_type ) ) ) {
     315                if ( ( ( current_user_can( 'edit_posts' ) ) && ( 'post' ==== $post_type ) ) ) {
    270316                    $can_edit = true;
    271317                } else {
     
    274320
    275321                // If the current user can edit then allow a blank title.
    276                 if ( ( '' == $draft_title ) && ( $can_edit ) ) {
     322                if ( ( '' == $draft_title ) && ( $can_edit ) ) {
    277323                    $draft_title = __( '[No Title]', 'simple-draft-list' );
    278324                }
     
    287333                // Only output if the meta isn't set to exclude it, the limit hasn't been reached,
    288334                // there are enough words in the post, the dates are fine and the title isn't blank.
    289                 if ( ( $date_accept ) && ( $enough_words ) && ( '' != $draft_title ) && ( 'yes' != strtolower( get_post_meta( $post_id, 'draft_hide', true ) ) ) && ( ( 0 == $list_limit ) || ( $valid_draft <= $list_limit ) ) ) {
     335                if ( ( $date_accept ) && ( $enough_words ) && ( '' !=== $list_limit ) || ( $valid_draft <= $list_limit ) ) ) {
    290336
    291337                    $post_status = $draft_data->post_status;
     
    310356                    // Replace the icon tag.
    311357                    $alt_title = __( 'Scheduled', 'simple-draft-list' );
    312                     if ( 'future' == $post_status ) {
    313                         if ( '' != $icon_folder ) {
     358                    if ( 'future' == $post_status ) {
     359                        if ( '' != $icon_folder ) {
    314360                            $icon_folder = get_bloginfo( 'template_url' ) . '/' . $icon_folder . '/';
    315361                            $icon_url    = '<img src="' . $icon_folder . 'scheduled.png" alt="' . $alt_title . '" title="' . $alt_title . '">';
     
    326372                    $this_line = str_replace( '{{author}}', $author, $this_line );
    327373
    328                     if ( '' != $author_url ) {
     374                    if ( '' != $author_url ) {
    329375                        $author_link = '<a href="' . $author_url . '">' . $author . '</a>';
    330376                    } else {
     
    334380
    335381                    // Replace the draft tag.
    336                     if ( '' != $draft_title ) {
     382                    if ( '' != $draft_title ) {
    337383                        $draft = $draft_title;
    338384                    } else {
     
    354400                    // Replace the word and character counts.
    355401                    if ( $count ) {
    356                         if ( strpos( $this_line, '{{words}}' ) != false ) {
     402                        if ( strpos( $this_line, '{{words}}' ) != false ) {
    357403                            $this_line = str_replace( '{{words}}', number_format( $word_count ), $this_line );
    358404                        }
    359                         if ( strpos( $this_line, '{{chars}}' ) != false ) {
     405                        if ( strpos( $this_line, '{{chars}}' ) != false ) {
    360406                            $this_line = str_replace( '{{chars}}', number_format( strlen( $post_content ) - substr_count( $post_content, ' ' ) ), $this_line );
    361407                        }
    362                         if ( strpos( $this_line, '{{chars+space}}' ) != false ) {
     408                        if ( strpos( $this_line, '{{chars+space}}' ) != false ) {
    363409                            $this_line = str_replace( '{{chars+space}}', number_format( strlen( $post_content ) ), $this_line );
    364410                        }
     
    368414                    $category = get_the_category( $post_id );
    369415                    $category = $category[0]->cat_name;
    370                     if ( 'Uncategorized' == $category ) {
     416                    if ( 'Uncategorized' == $category ) {
    371417                        $category = '';
    372418                    }
     
    376422                    $category_list = '';
    377423                    foreach ( ( get_the_category( $post_id ) ) as $category ) {
    378                         if ( 'Uncategorized' != $category->cat_name ) {
     424                        if ( 'Uncategorized' != $category->cat_name ) {
    379425                            $category_list .= ', ' . $category->cat_name;
    380426                        }
    381427                    }
    382                     if ( '' != $category_list ) {
     428                    if ( '' != $category_list ) {
    383429                        $category_list = substr( $category_list, 2 );
    384430                    }
     
    388434                    // Now add the current line to the overall code output.
    389435                    $code .= $this_line . "\n";
    390                     $valid_draft++;
     436                    ;
    391437                }
    392438            }
     
    410456 * @return string          Template.
    411457 */
    412 function adl_convert_to_template( $icon = '', $author = '' ) {
     458function _convert_to_template( $icon = '', $author = '' ) {
    413459
    414460    $template = '{{ul}}';
    415     if ( strtolower( $icon ) == 'left' ) {
     461    if ( strtolower( $icon ) == 'left' ) {
    416462        $template .= '{{icon}}&nbsp;';
    417463    }
    418464    $template .= '{{draft}}';
    419     if ( strtolower( $author ) == 'yes' ) {
     465    if ( strtolower( $author ) == 'yes' ) {
    420466        $template .= '&nbsp;({{author}})';
    421467    }
    422     if ( strtolower( $icon ) == 'right' ) {
     468    if ( strtolower( $icon ) == 'right' ) {
    423469        $template .= '&nbsp;{{icon}}';
    424470    }
     
    434480 * @param  string $error        Error message.
    435481 * @param  string $plugin_name  The name of the plugin.
    436  * @param  string $echo         True or false, depending on whether you wish to return or echo the results.
     482 * @param  string $       True or false, depending on whether you wish to return or echo the results.
    437483 * @return string               True.
    438484 */
    439 function adl_report_error( $error, $plugin_name, $echo = true ) {
    440 
    441     $output = '<p style="color: #f00; font-weight: bold;">' . $plugin_name . ': ' . $error . "</p>\n";
    442     if ( $echo ) {
    443         echo esc_html( $output );
     485function = true ) {
     486
     487    $t = '<p style="color: #f00; font-weight: bold;">' . $plugin_name . ': ' . $error . "</p>\n";
     488    if ( $ ) {
     489        echo esc_html( $t );
    444490        return true;
    445491    } else {
    446         return $output;
     492        return $t;
    447493    }
    448494}
    449 
  • simple-draft-list/trunk/inc/metabox.php

    r2422945 r3086044  
    55 * Add a meta box to the page/post editor
    66 *
    7  * @package Artiss-Draft-List
     7 * @package ist
    88 */
     9
     10
     11
     12
     13
     14
    915
    1016/**
     
    1319 * Action to define a new meta box for post and page editor
    1420 */
    15 function adl_add_custom_box() {
     21function _add_custom_box() {
    1622
    1723    $box_title = __( 'Draft List', 'simple-draft-list' );
    1824
    19     add_meta_box( 'adl_metaid', $box_title, 'adl_custom_box', 'post', 'side' );
     25    add_meta_box( '_custom_box', 'post', 'side' );
    2026
    21     add_meta_box( 'adl_metaid', $box_title, 'adl_custom_box', 'page', 'side' );
    22 
     27    add_meta_box( 'draft_list_metaid', $box_title, 'draft_list_custom_box', 'page', 'side' );
    2328}
    2429
    25 add_action( 'admin_init', 'adl_add_custom_box', 1 );  // backwards compatible (before WP 3.0).
     30add_action( 'admin_init', '_add_custom_box', 1 );  // backwards compatible (before WP 3.0).
    2631
    2732/**
     
    3237 * @param string $post Post details.
    3338 */
    34 function adl_custom_box( $post ) {
     39function _custom_box( $post ) {
    3540
    3641    // Use nonce for verification.
     
    4045    // Now request the information.
    4146
    42     echo '<label for="adl_hide">' . esc_html__( 'Hide from Draft List?', 'simple-draft-list' ) . '&nbsp;</label> ';
    43     echo '<input type="checkbox" id="adl_hide" name="adl_hide" value="Yes"';
    44     if ( 'yes' == strtolower( get_post_meta( $post->ID, 'draft_hide', true ) ) ) {
     47    echo '<label for="_hide">' . esc_html__( 'Hide from Draft List?', 'simple-draft-list' ) . '&nbsp;</label> ';
     48    echo '<input type="checkbox" id="_hide" value="Yes"';
     49    if ( 'yes' == strtolower( get_post_meta( $post->ID, 'draft_hide', true ) ) ) {
    4550        echo ' checked="checked"';
    4651    }
    4752    echo ' />';
    48 
    4953}
    5054
     
    5660 * @param string $post_id Post ID.
    5761 */
    58 function adl_save_postdata( $post_id ) {
     62function _save_postdata( $post_id ) {
    5963
    6064    // If this is an auto save routine and the form has not been submitted then don't do anything.
     
    6771
    6872    if ( isset( $_POST['artiss_draft_list_noncename'] ) ) { // Input var okay.
    69         if ( ! wp_verify_nonce( sanitize_text_field( $_POST['artiss_draft_list_noncename'] ), plugin_basename( __FILE__ ) ) ) {
     73        if ( ! wp_verify_nonce( sanitize_text_field( ), plugin_basename( __FILE__ ) ) ) {
    7074            return; // Input var okay.
    7175        }
     
    7579
    7680    if ( isset( $_POST['post_type'] ) ) { // Input var okay.
    77         if ( 'page' == sanitize_text_field( $_POST['post_type'] ) ) { // Input var okay.
     81        if ( 'page' == ) ) { // Input var okay.
    7882            if ( ! current_user_can( 'edit_page', $post_id ) ) {
    7983                return;
    8084            }
    81         } else {
    82             if ( ! current_user_can( 'edit_post', $post_id ) ) {
    83                 return;
    84             }
     85        } elseif ( ! current_user_can( 'edit_post', $post_id ) ) {
     86            return;
    8587        }
    8688    }
     
    8890    // Save the data.
    8991
    90     if ( isset( $_POST['adl_hide'] ) ) { // Input var okay.
    91         $data = sanitize_text_field( $_POST['adl_hide'] ); // Input var okay.
     92    if ( isset( $_POST['_hide'] ) ) { // Input var okay.
     93        $data = sanitize_text_field( ); // Input var okay.
    9294    } else {
    9395        $data = '';
     
    9597
    9698    update_post_meta( $post_id, 'draft_hide', $data );
    97 
    9899}
    99100
    100 add_action( 'save_post', 'adl_save_postdata' );
     101add_action( 'save_post', '_save_postdata' );
  • simple-draft-list/trunk/readme.txt

    r3056349 r3086044  
    1 === Draft Links ===
     1=== Draft Li ===
    22Contributors: dartiss
    33Donate link: https://artiss.blog/donate
    4 Tags: draft, link, menu, page, post
     4Tags: draft, lit
    55Requires at least: 4.6
    66Tested up to: 6.5
    77Requires PHP: 7.4
    8 Stable tag: 1.0
     8Stable tag:
    99License: GPLv2 or later
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
    11 
    12 Add menu links that take you straight to your drafts.
     11README revision: 1.0
     12
     13WordPress plugin to manage and promote your unpublished content.
    1314
    1415== Description ==
    1516
    16 Making it easier for you to access your drafts, this plugin will add links to the WP Admin menu to both yours and all drafts post and pages. Oh, and it will also show you how many drafts there are too.
    17 
    18 Just install and enable - there are no settings.
    19 
    20 The code passes [WordPress](https://github.com/WordPress/WordPress-Coding-Standards) and [WordPress VIP](https://github.com/Automattic/VIP-Coding-Standards) coding standards 🎉
     17**If you're upgrading from a previous release of Draft List (i.e. pre version 2.5) please check out the FAQ - a number of changes have been made in this release that you need to be aware of**
     18
     19Draft List allows you to both manage your draft and scheduled posts more easily but also to promote them by showing them on your site via shortcode or widget - use it to show your visitors what's "coming soon" or as a great SEO tool.
     20
     21How easy is it display a list of draft posts? Here's an example of how you could use it in a post or page...
     22
     23`[drafts limit=5 type=post order=ma scheduled=no template='{{ul}}{{[draft}} {{icon}}']`
     24
     25This would display a list of up to 5 draft posts in ascending modified date sequence, with an icon displayed to the right of each if the draft is scheduled.
     26
     27Key features include...
     28
     29* Both widgets and shortcodes are available for you to show off your up-coming content
     30* Output is highly configurable - create your own look by using a template, identify scheduled posts with an icon, sequence the results in various ways and even narrow down the results to a specific timeframe
     31* Click on any of the drafts posts listed to edit them
     32* A meta box in the editor screen allows you to omit individual posts from any list outputs
     33* Tested up to PHP 8.2
     34* Fully complies with WordPress coding standards
     35* Compliant with the stronger [WordPress VIP](https://wpvip.com/) coding standards, as well as compatibility with their platform
     36* Community plugin - visit the [Github page](https://github.com/dartiss/draft-list "Github") to get involved with the latest code development, request enhancements and report issues
    2137
    2238Iconography is courtesy of the very talented [Janki Rathod](https://www.fiverr.com/jankirathore).
    2339
    24 **Please visit the [Github page](https://github.com/dartiss/draft-links "Github") for the latest code development, planned enhancements and known issues**
     40== Shortcode Parameters ==
     41
     42The following shortcode parameters are valid...
     43
     44* **cache=** : How long to cache the output for, in hours. Defaults to half an hour. Set to `No` to not cache at all. Whenever you save a post any cache will be cleared to ensure that any lists are updated.
     45* **date=** : The format of any dates output. This uses the PHP date formatting system - [read here](http://uk3.php.net/manual/en/function.date.php "date") for the formatting codes. Defaults to `F j, Y, g:i a`.
     46* **folder=** : The scheduled icon will be, by default, the one in the plugin folder named `scheduled.png`. However, use this parameter to specify a folder within your theme that you'd prefer the icon to be fetched from.
     47* **limit=** : The maximum number of draft items to display. The default is 0, which is unlimited.
     48* **order=** : This is the sequence that you'd like to order the results in. It consists of 2 codes - the first is either `t`, `m` or `c` to represent the title, modified date or created date and the second is `a` or `d` for ascending or descending. Therefore `order=td` will display the results in descending title sequence. The default is descending modified date.
     49* **pending=** : True or false, where to include pending posts in the result. By default, pending posts will not be included.
     50* **scheduled=** : True or false, where to include scheduled posts in the result. By default, scheduled posts will be included.
     51* **template=** : This is the template which formats the output. See the section below on * *Templates** for further information.
     52* **type=** : This allows you to limit the results to either `post` or `page`. The default is both.
     53* **words=** : The minimum number of words that must be present in the draft for it to be included. Defaults to 0.
     54
     55To restrict the posts to a particular timeframe you can use the following 2 parameters. You simply state, in words, how long ago the posts must be dated for e.g. "2 days", "3 months", etc.
     56
     57* **created=** : his reflects how long ago the post/page must have been created for it to be listed. For example `6 months` would only list drafts that were created in the last 6 months.
     58* **modified=** : This reflects how long ago the post/page must have been modified last for it to be listed. For example `6 months` would only list drafts that have been modified in the last 6 months.
     59
     60== Templates ==
     61
     62The template parameter allows you to format the output by allowing you to specify how each line of output will display. A number of tags can be added, and you can mix these with HTML. The available tags are as follows...
     63
     64* **{{ul}}** - Specifies this is an un-ordered list (i.e. bullet point output). This MUST be specified at the beginning of the template if it is to be used.
     65* **{{ol}}** - Specifies this is an ordered list (i.e. number output). This MUST be specified at the beginning of the template if it is to be used.
     66* **{{icon}}** - This is the icon that indicates a scheduled post.
     67* **{{draft}}** - This is the post detail and is the only **REQUIRED** tag.
     68* **{{author}}** - This is the name of the post author.
     69* **{{author+link}}** - This is the name of the post author with, where available, a link to their URL.
     70* **{{words}}** - The number of words in the draft post.
     71* **{{chars}}** - The number of characters (exc. spaces) in the post.
     72* **{{chars+space}}** - The number of characters (inc. spaces) in the post.
     73* **{{created}}** - The date/time the post was created.
     74* **{{modified}}** - The date/time the post was last modified.
     75* **{{category}}** - Shows the first category assigned to the post.
     76* **{{categories}}** - Shows all categories assigned to the post, comma separated.
     77
     78If {{ul}} or {{ol}} are specified then all the appropriate list tags will be added to the output. If neither are used then it's assumed that line output will be controlled by yourself.
     79
     80== Omitting Posts/Pages from Results ==
     81
     82If you wish to omit a page or post from the list then you can do this in 3 ways...
     83
     841. By giving the post a title beginning with an exclamation mark. You can then remove this before publishing the post.
     852. The post and page editor has a meta box, where you can select to hide the page/post.
     863. You can add a custom field to a page/post with a name of 'draft_hide' and a value of 'Yes'
     87
     88== Edit Link ==
     89
     90If the current user can edit the draft item being listed then it will be linked to the appropriate edit page. The user then simply needs to click on the draft item to edit it.
     91
     92There are separate permissions for post and page editing, so an editor with just one permission may find that they can only edit some of the draft items.
     93
     94Drafts that don't have a title will not be shown on the list UNLESS the current user has edit privileges for the draft - in this case a title of [No Title] will be shown.
     95
     96== Using a Widget ==
     97
     98Sidebar widgets can be easily added. In Administration simply click on the `Widgets` option under the `Appearance` menu. `Draft Posts` will be one of the listed widgets. Drag it to the appropriate sidebar on the right hand side and then choose your options.
     99
     100Save the result and that's it! You can use unlimited widgets, so you can add different lists to different sidebars.
    25101
    26102== Installation ==
    27103
    28 Draft Links can be found and installed via the Plugin menu within WordPress administration (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually...
    29 
    30 1. Upload the entire `draft-links` folder to your `wp-content/plugins/` directory.
    31 2. Activate the plugin through the 'Plugins' menu in WordPress administration.
     104This plugin can be found and installed via the Plugin menu within WP Admin (Plugins -> Add New). Alternatively, it can be downloaded from WordPress.org and installed manually...
     105
     1061. Upload the entire unzipped plugin folder to your `wp-content/plugins/` directory, either from WP Admin (Plugins -> Add New), your favorite FTP client or any other file manager
     1072. Activate the plugin through the 'Plugins' menu in WP Admin (Plugins -> Installed Plugins)
     108
     109== Frequently Asked Questions ==
     110
     111= I've upgraded from a version before 2.5 and I hear things have changed. What's happening? =
     112
     113From version 2.5, 2 features have been removed...
     114
     1151. Caching has gone. This release has had some massive performance improvements which means it was no longer needed. It, more often than not, caused issues and many people have native caching on their site anyway.
     1162. The draft menus options have been removed. I've moved that functionality off to another plugin named [Draft Links](https://wordpress.org/plugins/draft-links/). If you want the menu links back, please install that. Why have they been removed? For a start, some people were installing this plugin JUST for that functionality, so it made sense for me to separate it. Additionally, the next FAQ answer is part of this too...
    32117
    33118== Screenshots ==
    34119
    35 1. An example of how the links are shown in the menu
     1201. An example o
    36121
    37122== Changelog ==
    38123
    39124I use semantic versioning, with the first release being 1.0.
     125
     126
     127
     128
     129
     130
     131
     132
     133
     134
     135
     136
     137
     138
     139
     140
     141
     142
     143
     144
     145
     146
     147
     148
     149
     150
     151
     152
     153
     154
     155
     156
     157
     158
     159
     160
     161
     162
     163
     164
     165
     166
     167
     168
     169
     170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
     184
     185
     186
     187
     188
     189
     190
     191
     192
     193
     194
     195
     196
     197
     198
     199
     200
     201
     202
     203
     204
     205
     206
     207
     208
     209
     210
     211
     212
     213
     214
     215
     216
     217
     218
     219
     220
     221
     222
     223
     224
     225
     226
     227
     228
     229
     230
     231
     232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
    40257
    41258= 1.0 =
     
    44261== Upgrade Notice ==
    45262
    46 = 1.0 =
    47 * Initial release
     263= =
     264*
  • simple-draft-list/trunk/simple-draft-list.php

    r2857945 r3086044  
    33 * Draft List
    44 *
    5  * @package           Artiss-Draft-List
     5 * @package           ist
    66 * @author            David Artiss
    77 * @license           GPL-2.0-or-later
     
    99 * Plugin Name:       Draft List
    1010 * Plugin URI:        https://wordpress.org/plugins/simple-draft-list/
    11  * Description:       📝 WordPress plugin to manage and promote your unpublished content.
    12  * Version:           2.5.2
     11 * Description:       WordPress plugin to manage and promote your unpublished content.
     12 * Version:           2.
    1313 * Requires at least: 4.6
    14  * Requires PHP:      5.3
     14 * Requires PHP:     
    1515 * Author:            David Artiss
    1616 * Author URI:        https://artiss.blog
     
    2727 */
    2828
     29
     30
     31
     32
     33
     34
     35
     36
     37
     38
     39
     40
    2941// Require the various code components - all held within the inc folder.
    3042
    31 require_once plugin_dir_path( __FILE__ ) . 'inc/setup.php';                 // Administration config.
     43require_once plugin_dir_path( __FILE__ ) . 'inc/s
    3244
    33 require_once plugin_dir_path( __FILE__ ) . 'inc/metabox.php';               // Add meta box to editor.
     45require_once plugin_dir_path( __FILE__ ) . 'inc/metabox.php';
    3446
    35 require_once plugin_dir_path( __FILE__ ) . 'inc/class-draftlistwidget.php'; // Set-up widget.
     47require_once plugin_dir_path( __FILE__ ) . 'inc/class-draftlistwidget.php';
    3648
    37 require_once plugin_dir_path( __FILE__ ) . 'inc/create-lists.php';          // Code to output draft list.
     49require_once plugin_dir_path( __FILE__ ) . 'inc/widget.php';
     50
     51require_once plugin_dir_path( __FILE__ ) . 'inc/create-lists.php';
Note: See TracChangeset for help on using the changeset viewer.