Make WordPress Core

Ticket #25889: 25889.patch

File 25889.patch, 4.2 KB (added by meloniq, 13 years ago)

use selected(), add head docs

  • wp-admin/includes/template.php

     
    615615}
    616616
    617617/**
    618  * {@internal Missing Short Description}}
     618 * Print out html form date elements for editing post or comment publishing date
    619619 *
    620620 * @since 0.71
    621621 *
    622  * @param unknown_type $edit
    623  * @param unknown_type $for_post
    624  * @param unknown_type $tab_index
    625  * @param unknown_type $multi
     622 * @param int|bool $edit (Optional) 1 - editing date, 0 - adding date
     623 * @param int|bool $for_post (Optional) 1 - post, 0 - comment
     624 * @param int|bool $tab_index (Optional) The tab index attribute to add
     625 * @param int|bool $multi (Optional) Whether the additional fields and buttons should be added
    626626 */
    627627function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
    628628        global $wp_locale, $comment;
     
    655655        $month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
    656656        for ( $i = 1; $i < 13; $i = $i +1 ) {
    657657                $monthnum = zeroise($i, 2);
    658                 $month .= "\t\t\t" . '<option value="' . $monthnum . '"';
    659                 if ( $i == $mm )
    660                         $month .= ' selected="selected"';
     658                $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $i, $mm, false ) . '>';
    661659                /* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
    662                 $month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
     660                $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
    663661        }
    664662        $month .= '</select>';
    665663
     
    680678        foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
    681679                echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
    682680                $cur_timeunit = 'cur_' . $timeunit;
    683                 echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
     681                echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
    684682        }
    685683?>
    686684
     
    692690}
    693691
    694692/**
    695  * {@internal Missing Short Description}}
     693 * Print out <option> html elements for page templates
    696694 *
    697695 * @since 1.5.0
    698696 *
    699  * @param unknown_type $default
     697 * @param string $default (Optional) The template file name
    700698 */
    701699function page_template_dropdown( $default = '' ) {
    702700        $templates = get_page_templates();
    703701        ksort( $templates );
    704         foreach (array_keys( $templates ) as $template )
    705                 : if ( $default == $templates[$template] )
    706                         $selected = " selected='selected'";
    707                 else
    708                         $selected = '';
    709         echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
    710         endforeach;
     702        foreach ( array_keys( $templates ) as $template ) {
     703                $selected = selected( $default, $templates[ $template ], false );
     704                echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>";
     705        }
    711706}
    712707
    713708/**
    714  * {@internal Missing Short Description}}
     709 * Print out <option> html elements for page parents
    715710 *
    716711 * @since 1.5.0
    717712 *
    718  * @param unknown_type $default
    719  * @param unknown_type $parent
    720  * @param unknown_type $level
    721  * @return unknown
     713 * @param int $default (Optional) The default page ID to be pre selected
     714 * @param int $parent (Optional) The parent page ID
     715 * @param int $level (Optional) The depth level
     716 *
     717 * @return void|bool Boolean False if page has no children, otherwise print out html elements
    722718 */
    723719function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
    724720        global $wpdb;
     
    732728                                continue;
    733729
    734730                        $pad = str_repeat( '&nbsp;', $level * 3 );
    735                         if ( $item->ID == $default)
    736                                 $current = ' selected="selected"';
    737                         else
    738                                 $current = '';
     731                        $selected = selected( $default, $item->ID, false );
    739732
    740                         echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
     733                        echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
    741734                        parent_dropdown( $default, $item->ID, $level +1 );
    742735                }
    743736        } else {