X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/6c8f14c09105d0afa4c1574215c59b5021040e76..refs/tags/wordpress-4.0:/wp-admin/includes/template.php diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 788a4bd5..30dcf0fc 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -21,34 +21,92 @@ * @since 2.5.1 */ class Walker_Category_Checklist extends Walker { - var $tree_type = 'category'; - var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this + public $tree_type = 'category'; + public $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this - function start_lvl( &$output, $depth = 0, $args = array() ) { + /** + * Starts the list before the elements are added. + * + * @see Walker:start_lvl() + * + * @since 2.5.1 + * + * @param string $output Passed by reference. Used to append additional content. + * @param int $depth Depth of category. Used for tab indentation. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function start_lvl( &$output, $depth = 0, $args = array() ) { $indent = str_repeat("\t", $depth); $output .= "$indent\n"; } - function start_el( &$output, $category, $depth, $args, $id = 0 ) { - extract($args); - if ( empty($taxonomy) ) + /** + * Start the element output. + * + * @see Walker::start_el() + * + * @since 2.5.1 + * + * @param string $output Passed by reference. Used to append additional content. + * @param object $category The current term object. + * @param int $depth Depth of the term in reference to parents. Default 0. + * @param array $args An array of arguments. @see wp_terms_checklist() + * @param int $id ID of the current term. + */ + public function start_el( &$output, $category, $depth = 0, $args = array(), $id = 0 ) { + if ( empty( $args['taxonomy'] ) ) { $taxonomy = 'category'; + } else { + $taxonomy = $args['taxonomy']; + } - if ( $taxonomy == 'category' ) + if ( $taxonomy == 'category' ) { $name = 'post_category'; - else - $name = 'tax_input['.$taxonomy.']'; + } else { + $name = 'tax_input[' . $taxonomy . ']'; + } + $args['popular_cats'] = empty( $args['popular_cats'] ) ? array() : $args['popular_cats']; + $class = in_array( $category->term_id, $args['popular_cats'] ) ? ' class="popular-category"' : ''; - $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; - $output .= "\n
  • " . ''; + $args['selected_cats'] = empty( $args['selected_cats'] ) ? array() : $args['selected_cats']; + + /** This filter is documented in wp-includes/category-template.php */ + $output .= "\n
  • " . + ''; } - function end_el( &$output, $category, $depth = 0, $args = array() ) { + /** + * Ends the element output, if needed. + * + * @see Walker::end_el() + * + * @since 2.5.1 + * + * @param string $output Passed by reference. Used to append additional content. + * @param object $category The current term object. + * @param int $depth Depth of the term in reference to parents. Default 0. + * @param array $args An array of arguments. @see wp_terms_checklist() + */ + public function end_el( &$output, $category, $depth = 0, $args = array() ) { $output .= "
  • \n"; } } @@ -87,7 +145,7 @@ function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $select * @param int $post_id * @param array $args */ -function wp_terms_checklist($post_id = 0, $args = array()) { +function wp_terms_checklist( $post_id = 0, $args = array() ) { $defaults = array( 'descendants_and_self' => 0, 'selected_cats' => false, @@ -96,41 +154,66 @@ function wp_terms_checklist($post_id = 0, $args = array()) { 'taxonomy' => 'category', 'checked_ontop' => true ); - $args = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); - extract( wp_parse_args($args, $defaults), EXTR_SKIP ); + /** + * Filter the taxonomy terms checklist arguments. + * + * @since 3.4.0 + * + * @see wp_terms_checklist() + * + * @param array $args An array of arguments. + * @param int $post_id The post ID. + */ + $params = apply_filters( 'wp_terms_checklist_args', $args, $post_id ); - if ( empty($walker) || !is_a($walker, 'Walker') ) + $r = wp_parse_args( $params, $defaults ); + + if ( empty( $r['walker'] ) || ! is_a( $r['walker'], 'Walker' ) ) { $walker = new Walker_Category_Checklist; + } else { + $walker = $r['walker']; + } - $descendants_and_self = (int) $descendants_and_self; + $taxonomy = $r['taxonomy']; + $descendants_and_self = (int) $r['descendants_and_self']; - $args = array('taxonomy' => $taxonomy); + $args = array( 'taxonomy' => $taxonomy ); - $tax = get_taxonomy($taxonomy); - $args['disabled'] = !current_user_can($tax->cap->assign_terms); + $tax = get_taxonomy( $taxonomy ); + $args['disabled'] = ! current_user_can( $tax->cap->assign_terms ); - if ( is_array( $selected_cats ) ) - $args['selected_cats'] = $selected_cats; - elseif ( $post_id ) - $args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids'))); - else + if ( is_array( $r['selected_cats'] ) ) { + $args['selected_cats'] = $r['selected_cats']; + } elseif ( $post_id ) { + $args['selected_cats'] = wp_get_object_terms( $post_id, $taxonomy, array_merge( $args, array( 'fields' => 'ids' ) ) ); + } else { $args['selected_cats'] = array(); - - if ( is_array( $popular_cats ) ) - $args['popular_cats'] = $popular_cats; - else - $args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) ); - + } + if ( is_array( $r['popular_cats'] ) ) { + $args['popular_cats'] = $r['popular_cats']; + } else { + $args['popular_cats'] = get_terms( $taxonomy, array( + 'fields' => 'ids', + 'orderby' => 'count', + 'order' => 'DESC', + 'number' => 10, + 'hierarchical' => false + ) ); + } if ( $descendants_and_self ) { - $categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) ); + $categories = (array) get_terms( $taxonomy, array( + 'child_of' => $descendants_and_self, + 'hierarchical' => 0, + 'hide_empty' => 0 + ) ); $self = get_term( $descendants_and_self, $taxonomy ); array_unshift( $categories, $self ); } else { - $categories = (array) get_terms($taxonomy, array('get' => 'all')); + $categories = (array) get_terms( $taxonomy, array( 'get' => 'all' ) ); } - if ( $checked_ontop ) { + if ( $r['checked_ontop'] ) { // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache) $checked_categories = array(); $keys = array_keys( $categories ); @@ -143,10 +226,10 @@ function wp_terms_checklist($post_id = 0, $args = array()) { } // Put checked cats on top - echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args)); + echo call_user_func_array( array( $walker, 'walk' ), array( $checked_categories, 0, $args ) ); } // Then the rest of them - echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args)); + echo call_user_func_array( array( $walker, 'walk' ), array( $categories, 0, $args ) ); } /** @@ -176,10 +259,6 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech $terms = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) ); $tax = get_taxonomy($taxonomy); - if ( ! current_user_can($tax->cap->assign_terms) ) - $disabled = 'disabled="disabled"'; - else - $disabled = ''; $popular_ids = array(); foreach ( (array) $terms as $term ) { @@ -192,8 +271,11 @@ function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $ech @@ -228,6 +310,8 @@ function wp_link_category_checklist( $link_id = 0 ) { foreach ( $categories as $category ) { $cat_id = $category->term_id; + + /** This filter is documented in wp-includes/category-template.php */ $name = esc_html( apply_filters( 'the_category', $category->name ) ); $checked = in_array( $cat_id, $checked_categories ) ? ' checked="checked"' : ''; echo '"; @@ -244,15 +328,16 @@ function wp_link_category_checklist( $link_id = 0 ) { */ function get_inline_data($post) { $post_type_object = get_post_type_object($post->post_type); - if ( ! current_user_can($post_type_object->cap->edit_post, $post->ID) ) + if ( ! current_user_can( 'edit_post', $post->ID ) ) return; $title = esc_textarea( trim( $post->post_title ) ); + /** This filter is documented in wp-admin/edit-tag-form.php */ echo '
    'strong,em,link,block,del,ins,img,ul,ol,li,code,spell,close' ); + $quicktags_settings = array( 'buttons' => 'strong,em,link,block,del,ins,img,ul,ol,li,code,close' ); wp_editor( '', 'replycontent', array( 'media_buttons' => false, 'tinymce' => false, 'quicktags' => $quicktags_settings ) ); ?>
    @@ -473,10 +583,10 @@ function _list_meta_row( $entry, &$count ) { if ( is_serialized( $entry['meta_value'] ) ) { if ( is_serialized_string( $entry['meta_value'] ) ) { - // this is a serialized string, so we should display it + // This is a serialized string, so we should display it. $entry['meta_value'] = maybe_unserialize( $entry['meta_value'] ); } else { - // this is a serialized array/object so we should NOT display it + // This is a serialized array/object so we should NOT display it. --$count; return; } @@ -489,7 +599,7 @@ function _list_meta_row( $entry, &$count ) { $delete_nonce = wp_create_nonce( 'delete-meta_' . $entry['meta_id'] ); $r .= "\n\t"; - $r .= "\n\t\t"; + $r .= "\n\t\t"; $r .= "\n\t\t
    "; $r .= get_submit_button( __( 'Delete' ), 'deletemeta small', "deletemeta[{$entry['meta_id']}]", false, array( 'data-wp-lists' => "delete:the-list:meta-{$entry['meta_id']}::_ajax_nonce=$delete_nonce" ) ); @@ -499,33 +609,49 @@ function _list_meta_row( $entry, &$count ) { $r .= wp_nonce_field( 'change-meta', '_ajax_nonce', false, false ); $r .= ""; - $r .= "\n\t\t\n\t"; + $r .= "\n\t\t\n\t"; return $r; } /** - * {@internal Missing Short Description}} + * Prints the form in the Custom Fields meta box. * * @since 1.2.0 + * + * @param WP_Post $post Optional. The post being edited. */ -function meta_form() { +function meta_form( $post = null ) { global $wpdb; - $limit = (int) apply_filters( 'postmeta_form_limit', 30 ); - $keys = $wpdb->get_col( " - SELECT meta_key + $post = get_post( $post ); + + /** + * Filter the number of custom fields to retrieve for the drop-down + * in the Custom Fields meta box. + * + * @since 2.1.0 + * + * @param int $limit Number of custom fields to retrieve. Default 30. + */ + $limit = apply_filters( 'postmeta_form_limit', 30 ); + $sql = "SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key - HAVING meta_key NOT LIKE '\_%' + HAVING meta_key NOT LIKE %s ORDER BY meta_key - LIMIT $limit" ); - if ( $keys ) - natcasesort($keys); + LIMIT %d"; + $keys = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) ); + if ( $keys ) { + natcasesort( $keys ); + $meta_key_input_id = 'metakeyselect'; + } else { + $meta_key_input_id = 'metakeyinput'; + } ?>

    - + @@ -539,6 +665,8 @@ function meta_form() { ID, $key ) ) + continue; echo "\n"; } ?> @@ -567,14 +695,15 @@ function meta_form() { } /** - * {@internal Missing Short Description}} + * Print out HTML form date elements for editing post or comment publish date. * * @since 0.71 * - * @param unknown_type $edit - * @param unknown_type $for_post - * @param unknown_type $tab_index - * @param unknown_type $multi + * @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date. + * @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment. + * @param int|bool $tab_index The tabindex attribute to add. Default 0. + * @param int|bool $multi Optional. Whether the additional fields and buttons should be added. + * Default 0|false. */ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { global $wp_locale, $comment; @@ -587,6 +716,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { if ( (int) $tab_index > 0 ) $tab_index_attribute = " tabindex=\"$tab_index\""; + // todo: Remove this? // echo '
    '; $time_adj = current_time('timestamp'); @@ -604,73 +734,78 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { $cur_hh = gmdate( 'H', $time_adj ); $cur_mn = gmdate( 'i', $time_adj ); - $month = "\n"; for ( $i = 1; $i < 13; $i = $i +1 ) { $monthnum = zeroise($i, 2); - $month .= "\t\t\t" . '\n"; + $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "\n"; } $month .= ''; - $day = ''; - $year = ''; - $hour = ''; - $minute = ''; + $day = ''; + $year = ''; + $hour = ''; + $minute = ''; echo '
    '; - /* translators: 1: month input, 2: day input, 3: year input, 4: hour input, 5: minute input */ - printf(__('%1$s%2$s, %3$s @ %4$s : %5$s'), $month, $day, $year, $hour, $minute); + /* translators: 1: month, 2: day, 3: year, 4: hour, 5: minute */ + printf( __( '%1$s %2$s, %3$s @ %4$s : %5$s' ), $month, $day, $year, $hour, $minute ); echo '
    '; if ( $multi ) return; echo "\n\n"; - foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) { - echo '' . "\n"; + $map = array( + 'mm' => array( $mm, $cur_mm ), + 'jj' => array( $jj, $cur_jj ), + 'aa' => array( $aa, $cur_aa ), + 'hh' => array( $hh, $cur_hh ), + 'mn' => array( $mn, $cur_mn ), + ); + foreach ( $map as $timeunit => $value ) { + list( $unit, $curr ) = $value; + + echo '' . "\n"; $cur_timeunit = 'cur_' . $timeunit; - echo '' . "\n"; + echo '' . "\n"; } ?>

    - +

    HTML elements for the page templates drop-down. * * @since 1.5.0 * - * @param unknown_type $default + * @param string $default Optional. The template file name. Default empty. */ function page_template_dropdown( $default = '' ) { - $templates = get_page_templates(); + $templates = get_page_templates( get_post() ); ksort( $templates ); - foreach (array_keys( $templates ) as $template ) - : if ( $default == $templates[$template] ) - $selected = " selected='selected'"; - else - $selected = ''; - echo "\n\t"; - endforeach; + foreach ( array_keys( $templates ) as $template ) { + $selected = selected( $default, $templates[ $template ], false ); + echo "\n\t"; + } } /** - * {@internal Missing Short Description}} + * Print out "; + echo "\n\t"; parent_dropdown( $default, $item->ID, $level +1 ); } } else { @@ -697,57 +829,6 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) { } } -/** - * {@internal Missing Short Description}} - * - * @since 2.0.0 - * - * @param unknown_type $id - * @return unknown - */ -function the_attachment_links( $id = false ) { - $id = (int) $id; - $post = get_post( $id ); - - if ( $post->post_type != 'attachment' ) - return false; - - $icon = wp_get_attachment_image( $post->ID, 'thumbnail', true ); - $attachment_data = wp_get_attachment_metadata( $id ); - $thumb = isset( $attachment_data['thumb'] ); -?> - -
    - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - html elements for role selectors * @@ -759,7 +840,7 @@ function wp_dropdown_roles( $selected = false ) { $p = ''; $r = ''; - $editable_roles = get_editable_roles(); + $editable_roles = array_reverse( get_editable_roles() ); foreach ( $editable_roles as $role => $details ) { $name = translate_user_role($details['name'] ); @@ -779,15 +860,25 @@ function wp_dropdown_roles( $selected = false ) { * @param string $action The action attribute for the form. */ function wp_import_upload_form( $action ) { + + /** + * Filter the maximum allowed upload size for import files. + * + * @since 2.3.0 + * + * @see wp_max_upload_size() + * + * @param int $max_upload_size Allowed upload size. Default 1 MB. + */ $bytes = apply_filters( 'import_upload_size_limit', wp_max_upload_size() ); - $size = wp_convert_bytes_to_hr( $bytes ); + $size = size_format( $bytes ); $upload_dir = wp_upload_dir(); if ( ! empty( $upload_dir['error'] ) ) : ?>

    -
    +

    () @@ -805,12 +896,23 @@ function wp_import_upload_form( $action ) { * * @since 2.5.0 * - * @param string $id String for use in the 'id' attribute of tags. - * @param string $title Title of the meta box. - * @param string $callback Function that fills the box with the desired content. The function should echo its output. - * @param string|object $screen Optional. The screen on which to show the box (post, page, link). Defaults to current screen. - * @param string $context Optional. The context within the page where the boxes should show ('normal', 'advanced'). - * @param string $priority Optional. The priority within the context where the boxes should show ('high', 'low'). + * @param string $id String for use in the 'id' attribute of tags. + * @param string $title Title of the meta box. + * @param callback $callback Function that fills the box with the desired content. + * The function should echo its output. + * @param string|WP_Screen $screen Optional. The screen on which to show the box (like a post + * type, 'link', or 'comment'). Default is the current screen. + * @param string $context Optional. The context within the screen where the boxes + * should display. Available contexts vary from screen to + * screen. Post edit screen contexts include 'normal', 'side', + * and 'advanced'. Comments screen contexts include 'normal' + * and 'side'. Menus meta boxes (accordion sections) all use + * the 'side' context. Global default is 'advanced'. + * @param string $priority Optional. The priority within the context where the boxes + * should show ('high', 'low'). Default 'default'. + * @param array $callback_args Optional. Data that should be set as the $args property + * of the box array (which is the second parameter passed + * to your callback). Default null. */ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advanced', $priority = 'default', $callback_args = null ) { global $wp_meta_boxes; @@ -839,23 +941,30 @@ function add_meta_box( $id, $title, $callback, $screen = null, $context = 'advan // If core box previously deleted, don't add if ( false === $wp_meta_boxes[$page][$a_context][$a_priority][$id] ) return; - // If box was added with default priority, give it core priority to maintain sort order + + /* + * If box was added with default priority, give it core priority to + * maintain sort order. + */ if ( 'default' == $a_priority ) { $wp_meta_boxes[$page][$a_context]['core'][$id] = $wp_meta_boxes[$page][$a_context]['default'][$id]; unset($wp_meta_boxes[$page][$a_context]['default'][$id]); } return; } - // If no priority given and id already present, use existing priority + // If no priority given and id already present, use existing priority. if ( empty($priority) ) { $priority = $a_priority; - // else if we're adding to the sorted priority, we don't know the title or callback. Grab them from the previously added context/priority. + /* + * Else, if we're adding to the sorted priority, we don't know the title + * or callback. Grab them from the previously added context/priority. + */ } elseif ( 'sorted' == $priority ) { $title = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['title']; $callback = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['callback']; $callback_args = $wp_meta_boxes[$page][$a_context][$a_priority][$id]['args']; } - // An id can be in only one priority and one context + // An id can be in only one priority and one context. if ( $priority != $a_priority || $context != $a_context ) unset($wp_meta_boxes[$page][$a_context][$a_priority][$id]); } @@ -917,7 +1026,6 @@ function do_meta_boxes( $screen, $context, $object ) { if ( false == $box || ! $box['title'] ) continue; $i++; - $style = ''; $hidden_class = in_array($box['id'], $hidden) ? ' hide-if-js' : ''; echo '

    ' . "\n"; if ( 'dashboard_browser_nag' != $box['id'] ) @@ -968,6 +1076,82 @@ function remove_meta_box($id, $screen, $context) { $wp_meta_boxes[$page][$context][$priority][$id] = false; } +/** + * Meta Box Accordion Template Function + * + * Largely made up of abstracted code from {@link do_meta_boxes()}, this + * function serves to build meta boxes as list items for display as + * a collapsible accordion. + * + * @since 3.6.0 + * + * @uses global $wp_meta_boxes Used to retrieve registered meta boxes. + * + * @param string|object $screen The screen identifier. + * @param string $context The meta box context. + * @param mixed $object gets passed to the section callback function as first parameter. + * @return int number of meta boxes as accordion sections. + */ +function do_accordion_sections( $screen, $context, $object ) { + global $wp_meta_boxes; + + wp_enqueue_script( 'accordion' ); + + if ( empty( $screen ) ) + $screen = get_current_screen(); + elseif ( is_string( $screen ) ) + $screen = convert_to_screen( $screen ); + + $page = $screen->id; + + $hidden = get_hidden_meta_boxes( $screen ); + ?> +
    +
      + +
    • +

      + + +

      +
      +
      + +
      +
      +
    • + +
    +
    + $id, 'title' => $title, 'callback' => $callback); } @@ -1046,13 +1223,6 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default', $page = 'reading'; } - if ( !isset($wp_settings_fields) ) - $wp_settings_fields = array(); - if ( !isset($wp_settings_fields[$page]) ) - $wp_settings_fields[$page] = array(); - if ( !isset($wp_settings_fields[$page][$section]) ) - $wp_settings_fields[$page][$section] = array(); - $wp_settings_fields[$page][$section][$id] = array('id' => $id, 'title' => $title, 'callback' => $callback, 'args' => $args); } @@ -1072,7 +1242,7 @@ function add_settings_field($id, $title, $callback, $page, $section = 'default', function do_settings_sections( $page ) { global $wp_settings_sections, $wp_settings_fields; - if ( ! isset( $wp_settings_sections ) || !isset( $wp_settings_sections[$page] ) ) + if ( ! isset( $wp_settings_sections[$page] ) ) return; foreach ( (array) $wp_settings_sections[$page] as $section ) { @@ -1107,11 +1277,11 @@ function do_settings_sections( $page ) { function do_settings_fields($page, $section) { global $wp_settings_fields; - if ( !isset($wp_settings_fields) || !isset($wp_settings_fields[$page]) || !isset($wp_settings_fields[$page][$section]) ) + if ( ! isset( $wp_settings_fields[$page][$section] ) ) return; foreach ( (array) $wp_settings_fields[$page][$section] as $field ) { - echo ''; + echo ''; if ( !empty($field['args']['label_for']) ) echo ''; else @@ -1148,16 +1318,12 @@ function do_settings_fields($page, $section) { function add_settings_error( $setting, $code, $message, $type = 'error' ) { global $wp_settings_errors; - if ( !isset($wp_settings_errors) ) - $wp_settings_errors = array(); - - $new_error = array( + $wp_settings_errors[] = array( 'setting' => $setting, - 'code' => $code, + 'code' => $code, 'message' => $message, - 'type' => $type + 'type' => $type ); - $wp_settings_errors[] = $new_error; } /** @@ -1185,23 +1351,25 @@ function add_settings_error( $setting, $code, $message, $type = 'error' ) { function get_settings_errors( $setting = '', $sanitize = false ) { global $wp_settings_errors; - // If $sanitize is true, manually re-run the sanitizisation for this option - // This allows the $sanitize_callback from register_setting() to run, adding - // any settings errors you want to show by default. + /* + * If $sanitize is true, manually re-run the sanitization for this option + * This allows the $sanitize_callback from register_setting() to run, adding + * any settings errors you want to show by default. + */ if ( $sanitize ) sanitize_option( $setting, get_option( $setting ) ); - // If settings were passed back from options.php then use them + // If settings were passed back from options.php then use them. if ( isset( $_GET['settings-updated'] ) && $_GET['settings-updated'] && get_transient( 'settings_errors' ) ) { $wp_settings_errors = array_merge( (array) $wp_settings_errors, get_transient( 'settings_errors' ) ); delete_transient( 'settings_errors' ); } - // Check global in case errors have been added on this pageload + // Check global in case errors have been added on this pageload. if ( ! count( $wp_settings_errors ) ) return array(); - // Filter the results to those of a specific setting if one was set + // Filter the results to those of a specific setting if one was set. if ( $setting ) { $setting_errors = array(); foreach ( (array) $wp_settings_errors as $key => $details ) { @@ -1266,26 +1434,29 @@ function settings_errors( $setting = '', $sanitize = false, $hide_on_update = fa */ function find_posts_div($found_action = '') { ?> -