Make WordPress Core

Changeset 27188


Ignore:
Timestamp:
02/17/2014 10:26:14 PM (11 years ago)
Author:
wonderboymusic
Message:

Use selected() where appropriate in touch_time(), page_template_dropdown(), and parent_dropdown(). Also, add proper docs.

Props meloniq, DrewAPicture.
Fixes #25889.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/template.php

    r27137 r27188  
    616616
    617617/**
    618  * {@internal Missing Short Description}}
     618 * Print out HTML form date elements for editing post or comment publish 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      Accepts 1|true for editing the date, 0|false for adding the date.
     623 * @param int|bool $for_post  Accepts 1|true for applying the date to a post, 0|false for a comment.
     624 * @param int|bool $tab_index The tabindex attribute to add. Default 0.
     625 * @param int|bool $multi     Optional. Whether the additional fields and buttons should be added.
     626 *                            Default 0|false.
    626627 */
    627628function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
     
    656657    for ( $i = 1; $i < 13; $i = $i +1 ) {
    657658        $monthnum = zeroise($i, 2);
    658         $month .= "\t\t\t" . '<option value="' . $monthnum . '"';
    659         if ( $i == $mm )
    660             $month .= ' selected="selected"';
     659        $month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $i, $mm, false ) . '>';
    661660        /* 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";
     661        $month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
    663662    }
    664663    $month .= '</select>';
     
    681680        echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
    682681        $cur_timeunit = 'cur_' . $timeunit;
    683         echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
     682        echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
    684683    }
    685684?>
     
    693692
    694693/**
    695  * {@internal Missing Short Description}}
     694 * Print out <option> HTML elements for the page templates drop-down.
    696695 *
    697696 * @since 1.5.0
    698697 *
    699  * @param unknown_type $default
     698 * @param string $default Optional. The template file name. Default empty.
    700699 */
    701700function page_template_dropdown( $default = '' ) {
    702701    $templates = get_page_templates();
    703702    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;
    711 }
    712 
    713 /**
    714  * {@internal Missing Short Description}}
     703    foreach ( array_keys( $templates ) as $template ) {
     704        $selected = selected( $default, $templates[ $template ], false );
     705        echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>";
     706    }
     707}
     708
     709/**
     710 * Print out <option> HTML elements for the page parents drop-down.
    715711 *
    716712 * @since 1.5.0
    717713 *
    718  * @param unknown_type $default
    719  * @param unknown_type $parent
    720  * @param unknown_type $level
    721  * @return unknown
     714 * @param int $default Optional. The default page ID to be pre-selected. Default 0.
     715 * @param int $parent  Optional. The parent page ID. Default 0.
     716 * @param int $level   Optional. Page depth level. Default 0.
     717 *
     718 * @return void|bool Boolean False if page has no children, otherwise print out html elements
    722719 */
    723720function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
     
    733730
    734731            $pad = str_repeat( '&nbsp;', $level * 3 );
    735             if ( $item->ID == $default)
    736                 $current = ' selected="selected"';
    737             else
    738                 $current = '';
    739 
    740             echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
     732            $selected = selected( $default, $item->ID, false );
     733
     734            echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
    741735            parent_dropdown( $default, $item->ID, $level +1 );
    742736        }
  • trunk/src/wp-includes/link-template.php

    r27026 r27188  
    6767            break;
    6868    }
     69}
     70
     71/**
     72 * Alias for get_permalink()
     73 *
     74 * @since 3.9.0
     75 *
     76 * @param int|WP_Post $id Optional. Post ID or post object, defaults to the current post.
     77 * @param bool $leavename Optional. Whether to keep post name or page name, defaults to false.
     78 * @return string|bool The permalink URL or false if post does not exist.
     79 */
     80function get_the_permalink( $id = 0, $leavename = false ) {
     81    return get_permalink( $id, $leavename );
    6982}
    7083
Note: See TracChangeset for help on using the changeset viewer.