Changeset 3086044
- Timestamp:
- 05/13/2024 05:58:14 PM (3 months ago)
- 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 5 5 * Create and display widgets 6 6 * 7 * @package Artiss-Draft-List7 * @package ist 8 8 */ 9 10 11 12 13 14 9 15 10 16 /** … … 27 33 'draft_list_widget', 28 34 __( 'Draft List', 'simple-draft-list' ), 29 array( 35 array( 30 36 'description' => __( 'WordPress plugin to manage and promote your unpublished content.', 'simple-draft-list' ), 31 37 'class' => 'dl-widget', … … 40 46 * Display the widget 41 47 * 42 * @uses adl_generate_code Generate the required code48 * @uses _generate_code Generate the required code 43 49 * 44 50 * @param string $args Arguments. … … 47 53 public function widget( $args, $instance ) { 48 54 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 } 50 74 51 75 // 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() ); 53 77 54 78 // Output the header. … … 65 89 // Generate the video and output it. 66 90 echo wp_kses( 67 adl_generate_code(91 _generate_code( 68 92 $instance['limit'], 69 93 $instance['type'], … … 123 147 124 148 // 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() ); 126 150 127 151 // Title field. … … 149 173 $field_name = $this->get_field_name( 'type' ); 150 174 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'] ) == '' ) { 152 176 echo " selected='selected'"; 153 177 } 154 178 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' ) { 156 180 echo " selected='selected'"; 157 181 } 158 182 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' ) { 160 184 echo " selected='selected'"; 161 185 } … … 166 190 $field_name = $this->get_field_name( 'order' ); 167 191 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'] ) == '' ) { 169 193 echo " selected='selected'"; 170 194 } 171 195 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' ) { 173 197 echo " selected='selected'"; 174 198 } 175 199 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' ) { 177 201 echo " selected='selected'"; 178 202 } 179 203 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' ) { 181 205 echo " selected='selected'"; 182 206 } 183 207 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' ) { 185 209 echo " selected='selected'"; 186 210 } 187 211 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' ) { 189 213 echo " selected='selected'"; 190 214 } … … 195 219 $field_name = $this->get_field_name( 'scheduled' ); 196 220 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'] ) ) { 198 222 echo " checked='checked'"; 199 223 } … … 204 228 $field_name = $this->get_field_name( 'pending' ); 205 229 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'] ) ) { 207 231 echo " checked='checked'"; 208 232 } … … 232 256 } 233 257 } 234 235 /**236 * Register Widget237 *238 * Register widget when loading the WP core239 */240 function adl_register_widgets() {241 register_widget( 'DraftListWidget' );242 }243 244 add_action( 'widgets_init', 'adl_register_widgets' );245 246 /**247 * Widget defaults248 *249 * Return default values for the widget250 */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 5 5 * Generate the draft list code 6 6 * 7 * @package Artiss-Draft-List7 * @package ist 8 8 */ 9 10 11 12 13 14 9 15 10 16 /** … … 14 20 * 15 21 * @param string $paras Parameters. 16 * @param string $content Content between shortcodes.17 22 * @return string Draft list output. 18 23 */ 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 24 function 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 ); 48 93 } 49 add_shortcode( 'drafts', 'adl_draft_list_shortcode' ); 94 95 add_shortcode( 'drafts', 'draft_list_shortcode' ); 50 96 51 97 /** … … 67 113 * @return string Draft list output. 68 114 */ 69 function adl_generate_code( $list_limit = '', $list_type = '', $list_order = '', $scheduled = '', $icon_folder = '', $date_format = '', $created = '', $modified = '', $template = '', $words = '', $pending = '' ) {115 function _generate_code( $list_limit = '', $list_type = '', $list_order = '', $scheduled = '', $icon_folder = '', $date_format = '', $created = '', $modified = '', $template = '', $words = '', $pending = '' ) { 70 116 71 117 // Validate the list type. 72 if ( ( 'post' != $list_type ) && ( 'page' != $list_type ) && ( '' != $list_type ) ) {118 if ( ( 'post' !== $list_type ) ) { 73 119 $list_type = 'error'; 74 120 } … … 85 131 86 132 // Set default values. 87 if ( '' == $list_limit ) {133 if ( '' == $list_limit ) { 88 134 $list_limit = 0; 89 135 } 90 if ( '' == $words ) {136 if ( '' == $words ) { 91 137 $words = 0; 92 138 } 93 if ( '' == $list_order ) {139 if ( '' == $list_order ) { 94 140 $list_order = 'da'; 95 141 } 96 if ( '' == $scheduled ) {142 if ( '' == $scheduled ) { 97 143 $scheduled = 'yes'; 98 144 } 99 if ( '' == $pending ) {145 if ( '' == $pending ) { 100 146 $pending = 'no'; 101 147 } 102 if ( '' == $date_format ) {148 if ( '' == $date_format ) { 103 149 $date_format = 'F j, Y, g:i a'; 104 150 } 105 if ( '' == $template ) {151 if ( '' == $template ) { 106 152 $template = '{{ul}}{{draft}}'; 107 153 } … … 113 159 $sort_sequence = ''; 114 160 115 if ( ( 'd' == $first_char ) || ( 'm'== $first_char ) ) {161 if ( ( 'd' ==== $first_char ) ) { 116 162 $sort_field = 'post_modified'; 117 163 } 118 if ( 'c' == $first_char ) {164 if ( 'c' == $first_char ) { 119 165 $sort_field = 'post_date'; 120 166 } 121 if ( 't' == $first_char ) {167 if ( 't' == $first_char ) { 122 168 $sort_field = 'post_title'; 123 169 } 124 if ( 'a' == $second_char ) {170 if ( 'a' == $second_char ) { 125 171 $sort_sequence = ' ASC'; 126 172 } 127 if ( 'd' == $second_char ) {173 if ( 'd' == $second_char ) { 128 174 $sort_sequence = ' DESC'; 129 175 } … … 132 178 $error = false; 133 179 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 ); 135 181 $error = true; 136 182 } 137 183 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 ); 155 201 $error = true; 156 202 } … … 159 205 $far_past = '2 January 1970'; 160 206 161 if ( '' != $created ) {207 if ( '' != $created ) { 162 208 $created = '-' . $created; 163 209 } else { … … 165 211 } 166 212 $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 ); 169 215 $error = true; 170 216 } 171 217 $created = gmdate( 'Y-m-d H:i:s', $created ); 172 218 173 if ( '' != $modified ) {219 if ( '' != $modified ) { 174 220 $modified = '-' . $modified; 175 221 } else { … … 177 223 } 178 224 $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 ); 181 227 $error = true; 182 228 } … … 187 233 // Define the type of list required. 188 234 $type = array( 'post', 'page' ); 189 if ( ( 'post' == $list_type ) || ( 'page'== $list_type ) ) {235 if ( ( 'post' ==== $list_type ) ) { 190 236 $type = $list_type; 191 237 } … … 193 239 $status = array( 'draft' ); 194 240 195 if ( true === $scheduled || 'true' == $scheduled || 'yes'== $scheduled ) {241 if ( true === $scheduled || 'true' ==== $scheduled ) { 196 242 array_push( $status, 'future' ); 197 243 } 198 if ( true === $pending || 'true' == $pending || 'yes'== $pending ) {244 if ( true === $pending || 'true' ==== $pending ) { 199 245 array_push( $status, 'pending' ); 200 246 } 201 247 202 248 // 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 ) ) { 204 250 $sql_content = ', post_content'; 205 251 $count = true; … … 222 268 // If template contains list tags at beginning, wrap these around output. 223 269 $list = false; 224 if ( ( ( '%ol%' == substr( $template, 0, 4 ) ) || ( '%ul%' == substr( $template, 0, 4 ) ) ) && ( 1 != $list_limit ) ) {270 if ( ( ( '%ol%' === $list_limit ) ) { 225 271 $list_type = substr( $template, 1, 2 ); 226 272 $code .= '<' . $list_type . ">\n"; … … 231 277 } 232 278 233 if ( ( ( '{{ol}}' == substr( $template, 0, 6 ) ) || ( '{{ul}}' == substr( $template, 0, 6 ) ) ) && ( 1 != $list_limit ) ) {279 if ( ( ( '{{ol}}' === $list_limit ) ) { 234 280 $list_type = substr( $template, 2, 2 ); 235 281 $code .= '<' . $list_type . ">\n"; … … 246 292 $post_title = $draft_data->post_title; 247 293 248 if ( '!' != substr( $post_title, 0, 1 ) ) {294 if ( '!' != substr( $post_title, 0, 1 ) ) { 249 295 250 296 // Extract fields from MySQL results. … … 267 313 268 314 // 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 ) ) ) { 270 316 $can_edit = true; 271 317 } else { … … 274 320 275 321 // If the current user can edit then allow a blank title. 276 if ( ( '' == $draft_title ) && ( $can_edit ) ) {322 if ( ( '' == $draft_title ) && ( $can_edit ) ) { 277 323 $draft_title = __( '[No Title]', 'simple-draft-list' ); 278 324 } … … 287 333 // Only output if the meta isn't set to exclude it, the limit hasn't been reached, 288 334 // 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 ) ) ) { 290 336 291 337 $post_status = $draft_data->post_status; … … 310 356 // Replace the icon tag. 311 357 $alt_title = __( 'Scheduled', 'simple-draft-list' ); 312 if ( 'future' == $post_status ) {313 if ( '' != $icon_folder ) {358 if ( 'future' == $post_status ) { 359 if ( '' != $icon_folder ) { 314 360 $icon_folder = get_bloginfo( 'template_url' ) . '/' . $icon_folder . '/'; 315 361 $icon_url = '<img src="' . $icon_folder . 'scheduled.png" alt="' . $alt_title . '" title="' . $alt_title . '">'; … … 326 372 $this_line = str_replace( '{{author}}', $author, $this_line ); 327 373 328 if ( '' != $author_url ) {374 if ( '' != $author_url ) { 329 375 $author_link = '<a href="' . $author_url . '">' . $author . '</a>'; 330 376 } else { … … 334 380 335 381 // Replace the draft tag. 336 if ( '' != $draft_title ) {382 if ( '' != $draft_title ) { 337 383 $draft = $draft_title; 338 384 } else { … … 354 400 // Replace the word and character counts. 355 401 if ( $count ) { 356 if ( strpos( $this_line, '{{words}}' ) != false ) {402 if ( strpos( $this_line, '{{words}}' ) != false ) { 357 403 $this_line = str_replace( '{{words}}', number_format( $word_count ), $this_line ); 358 404 } 359 if ( strpos( $this_line, '{{chars}}' ) != false ) {405 if ( strpos( $this_line, '{{chars}}' ) != false ) { 360 406 $this_line = str_replace( '{{chars}}', number_format( strlen( $post_content ) - substr_count( $post_content, ' ' ) ), $this_line ); 361 407 } 362 if ( strpos( $this_line, '{{chars+space}}' ) != false ) {408 if ( strpos( $this_line, '{{chars+space}}' ) != false ) { 363 409 $this_line = str_replace( '{{chars+space}}', number_format( strlen( $post_content ) ), $this_line ); 364 410 } … … 368 414 $category = get_the_category( $post_id ); 369 415 $category = $category[0]->cat_name; 370 if ( 'Uncategorized' == $category ) {416 if ( 'Uncategorized' == $category ) { 371 417 $category = ''; 372 418 } … … 376 422 $category_list = ''; 377 423 foreach ( ( get_the_category( $post_id ) ) as $category ) { 378 if ( 'Uncategorized' != $category->cat_name ) {424 if ( 'Uncategorized' != $category->cat_name ) { 379 425 $category_list .= ', ' . $category->cat_name; 380 426 } 381 427 } 382 if ( '' != $category_list ) {428 if ( '' != $category_list ) { 383 429 $category_list = substr( $category_list, 2 ); 384 430 } … … 388 434 // Now add the current line to the overall code output. 389 435 $code .= $this_line . "\n"; 390 $valid_draft++;436 ; 391 437 } 392 438 } … … 410 456 * @return string Template. 411 457 */ 412 function adl_convert_to_template( $icon = '', $author = '' ) {458 function _convert_to_template( $icon = '', $author = '' ) { 413 459 414 460 $template = '{{ul}}'; 415 if ( strtolower( $icon ) == 'left' ) {461 if ( strtolower( $icon ) == 'left' ) { 416 462 $template .= '{{icon}} '; 417 463 } 418 464 $template .= '{{draft}}'; 419 if ( strtolower( $author ) == 'yes' ) {465 if ( strtolower( $author ) == 'yes' ) { 420 466 $template .= ' ({{author}})'; 421 467 } 422 if ( strtolower( $icon ) == 'right' ) {468 if ( strtolower( $icon ) == 'right' ) { 423 469 $template .= ' {{icon}}'; 424 470 } … … 434 480 * @param string $error Error message. 435 481 * @param string $plugin_name The name of the plugin. 436 * @param string $ echoTrue 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. 437 483 * @return string True. 438 484 */ 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 );485 function = true ) { 486 487 $t = '<p style="color: #f00; font-weight: bold;">' . $plugin_name . ': ' . $error . "</p>\n"; 488 if ( $ ) { 489 echo esc_html( $t ); 444 490 return true; 445 491 } else { 446 return $ output;492 return $t; 447 493 } 448 494 } 449 -
simple-draft-list/trunk/inc/metabox.php
r2422945 r3086044 5 5 * Add a meta box to the page/post editor 6 6 * 7 * @package Artiss-Draft-List7 * @package ist 8 8 */ 9 10 11 12 13 14 9 15 10 16 /** … … 13 19 * Action to define a new meta box for post and page editor 14 20 */ 15 function adl_add_custom_box() {21 function _add_custom_box() { 16 22 17 23 $box_title = __( 'Draft List', 'simple-draft-list' ); 18 24 19 add_meta_box( ' adl_metaid', $box_title, 'adl_custom_box', 'post', 'side' );25 add_meta_box( '_custom_box', 'post', 'side' ); 20 26 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' ); 23 28 } 24 29 25 add_action( 'admin_init', ' adl_add_custom_box', 1 ); // backwards compatible (before WP 3.0).30 add_action( 'admin_init', '_add_custom_box', 1 ); // backwards compatible (before WP 3.0). 26 31 27 32 /** … … 32 37 * @param string $post Post details. 33 38 */ 34 function adl_custom_box( $post ) {39 function _custom_box( $post ) { 35 40 36 41 // Use nonce for verification. … … 40 45 // Now request the information. 41 46 42 echo '<label for=" adl_hide">' . esc_html__( 'Hide from Draft List?', 'simple-draft-list' ) . ' </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' ) . ' </label> '; 48 echo '<input type="checkbox" id="_hide" value="Yes"'; 49 if ( 'yes' == strtolower( get_post_meta( $post->ID, 'draft_hide', true ) ) ) { 45 50 echo ' checked="checked"'; 46 51 } 47 52 echo ' />'; 48 49 53 } 50 54 … … 56 60 * @param string $post_id Post ID. 57 61 */ 58 function adl_save_postdata( $post_id ) {62 function _save_postdata( $post_id ) { 59 63 60 64 // If this is an auto save routine and the form has not been submitted then don't do anything. … … 67 71 68 72 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__ ) ) ) { 70 74 return; // Input var okay. 71 75 } … … 75 79 76 80 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. 78 82 if ( ! current_user_can( 'edit_page', $post_id ) ) { 79 83 return; 80 84 } 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; 85 87 } 86 88 } … … 88 90 // Save the data. 89 91 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. 92 94 } else { 93 95 $data = ''; … … 95 97 96 98 update_post_meta( $post_id, 'draft_hide', $data ); 97 98 99 } 99 100 100 add_action( 'save_post', ' adl_save_postdata' );101 add_action( 'save_post', '_save_postdata' ); -
simple-draft-list/trunk/readme.txt
r3056349 r3086044 1 === Draft Li nks===1 === Draft Li === 2 2 Contributors: dartiss 3 3 Donate link: https://artiss.blog/donate 4 Tags: draft, li nk, menu, page, post4 Tags: draft, lit 5 5 Requires at least: 4.6 6 6 Tested up to: 6.5 7 7 Requires PHP: 7.4 8 Stable tag: 1.08 Stable tag: 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html 11 12 Add menu links that take you straight to your drafts. 11 README revision: 1.0 12 13 WordPress plugin to manage and promote your unpublished content. 13 14 14 15 == Description == 15 16 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 19 Draft 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 21 How 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 25 This 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 27 Key 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 21 37 22 38 Iconography is courtesy of the very talented [Janki Rathod](https://www.fiverr.com/jankirathore). 23 39 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 42 The 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 55 To 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 62 The 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 78 If {{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 82 If you wish to omit a page or post from the list then you can do this in 3 ways... 83 84 1. By giving the post a title beginning with an exclamation mark. You can then remove this before publishing the post. 85 2. The post and page editor has a meta box, where you can select to hide the page/post. 86 3. 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 90 If 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 92 There 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 94 Drafts 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 98 Sidebar 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 100 Save the result and that's it! You can use unlimited widgets, so you can add different lists to different sidebars. 25 101 26 102 == Installation == 27 103 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. 104 This 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 106 1. 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 107 2. 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 113 From version 2.5, 2 features have been removed... 114 115 1. 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. 116 2. 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... 32 117 33 118 == Screenshots == 34 119 35 1. An example o f how the links are shown in the menu120 1. An example o 36 121 37 122 == Changelog == 38 123 39 124 I 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 40 257 41 258 = 1.0 = … … 44 261 == Upgrade Notice == 45 262 46 = 1.0=47 * Initial release263 = = 264 * -
simple-draft-list/trunk/simple-draft-list.php
r2857945 r3086044 3 3 * Draft List 4 4 * 5 * @package Artiss-Draft-List5 * @package ist 6 6 * @author David Artiss 7 7 * @license GPL-2.0-or-later … … 9 9 * Plugin Name: Draft List 10 10 * Plugin URI: https://wordpress.org/plugins/simple-draft-list/ 11 * Description: 📝WordPress plugin to manage and promote your unpublished content.12 * Version: 2. 5.211 * Description: WordPress plugin to manage and promote your unpublished content. 12 * Version: 2. 13 13 * Requires at least: 4.6 14 * Requires PHP: 5.314 * Requires PHP: 15 15 * Author: David Artiss 16 16 * Author URI: https://artiss.blog … … 27 27 */ 28 28 29 30 31 32 33 34 35 36 37 38 39 40 29 41 // Require the various code components - all held within the inc folder. 30 42 31 require_once plugin_dir_path( __FILE__ ) . 'inc/s etup.php'; // Administration config.43 require_once plugin_dir_path( __FILE__ ) . 'inc/s 32 44 33 require_once plugin_dir_path( __FILE__ ) . 'inc/metabox.php'; // Add meta box to editor.45 require_once plugin_dir_path( __FILE__ ) . 'inc/metabox.php'; 34 46 35 require_once plugin_dir_path( __FILE__ ) . 'inc/class-draftlistwidget.php'; // Set-up widget.47 require_once plugin_dir_path( __FILE__ ) . 'inc/class-draftlistwidget.php'; 36 48 37 require_once plugin_dir_path( __FILE__ ) . 'inc/create-lists.php'; // Code to output draft list. 49 require_once plugin_dir_path( __FILE__ ) . 'inc/widget.php'; 50 51 require_once plugin_dir_path( __FILE__ ) . 'inc/create-lists.php';
Note: See TracChangeset
for help on using the changeset viewer.