Use `selected()` where appropriate in `touch_time()`, `page_template_dropdown()`, and `parent_dropdown()`. Also, add proper docs.
Props meloniq, DrewAPicture. Fixes #25889. Built from https://develop.svn.wordpress.org/trunk@27188 git-svn-id: http://core.svn.wordpress.org/trunk@27047 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c1dbe9ab77
commit
ca4045ce76
|
@ -615,14 +615,15 @@ function meta_form( $post = null ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@internal Missing Short Description}}
|
* Print out HTML form date elements for editing post or comment publish date.
|
||||||
*
|
*
|
||||||
* @since 0.71
|
* @since 0.71
|
||||||
*
|
*
|
||||||
* @param unknown_type $edit
|
* @param int|bool $edit Accepts 1|true for editing the date, 0|false for adding the date.
|
||||||
* @param unknown_type $for_post
|
* @param int|bool $for_post Accepts 1|true for applying the date to a post, 0|false for a comment.
|
||||||
* @param unknown_type $tab_index
|
* @param int|bool $tab_index The tabindex attribute to add. Default 0.
|
||||||
* @param unknown_type $multi
|
* @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 ) {
|
function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||||
global $wp_locale, $comment;
|
global $wp_locale, $comment;
|
||||||
|
@ -655,11 +656,9 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||||
$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
|
$month = "<select " . ( $multi ? '' : 'id="mm" ' ) . "name=\"mm\"$tab_index_attribute>\n";
|
||||||
for ( $i = 1; $i < 13; $i = $i +1 ) {
|
for ( $i = 1; $i < 13; $i = $i +1 ) {
|
||||||
$monthnum = zeroise($i, 2);
|
$monthnum = zeroise($i, 2);
|
||||||
$month .= "\t\t\t" . '<option value="' . $monthnum . '"';
|
$month .= "\t\t\t" . '<option value="' . $monthnum . '" ' . selected( $i, $mm, false ) . '>';
|
||||||
if ( $i == $mm )
|
|
||||||
$month .= ' selected="selected"';
|
|
||||||
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
|
/* translators: 1: month number (01, 02, etc.), 2: month abbreviation */
|
||||||
$month .= '>' . sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
|
$month .= sprintf( __( '%1$s-%2$s' ), $monthnum, $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) ) . "</option>\n";
|
||||||
}
|
}
|
||||||
$month .= '</select>';
|
$month .= '</select>';
|
||||||
|
|
||||||
|
@ -680,7 +679,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||||
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
|
foreach ( array('mm', 'jj', 'aa', 'hh', 'mn') as $timeunit ) {
|
||||||
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
|
echo '<input type="hidden" id="hidden_' . $timeunit . '" name="hidden_' . $timeunit . '" value="' . $$timeunit . '" />' . "\n";
|
||||||
$cur_timeunit = 'cur_' . $timeunit;
|
$cur_timeunit = 'cur_' . $timeunit;
|
||||||
echo '<input type="hidden" id="'. $cur_timeunit . '" name="'. $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
|
echo '<input type="hidden" id="' . $cur_timeunit . '" name="' . $cur_timeunit . '" value="' . $$cur_timeunit . '" />' . "\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
@ -692,33 +691,31 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@internal Missing Short Description}}
|
* Print out <option> HTML elements for the page templates drop-down.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
*
|
||||||
* @param unknown_type $default
|
* @param string $default Optional. The template file name. Default empty.
|
||||||
*/
|
*/
|
||||||
function page_template_dropdown( $default = '' ) {
|
function page_template_dropdown( $default = '' ) {
|
||||||
$templates = get_page_templates();
|
$templates = get_page_templates();
|
||||||
ksort( $templates );
|
ksort( $templates );
|
||||||
foreach (array_keys( $templates ) as $template )
|
foreach ( array_keys( $templates ) as $template ) {
|
||||||
: if ( $default == $templates[$template] )
|
$selected = selected( $default, $templates[ $template ], false );
|
||||||
$selected = " selected='selected'";
|
echo "\n\t<option value='" . $templates[ $template ] . "' $selected>$template</option>";
|
||||||
else
|
}
|
||||||
$selected = '';
|
|
||||||
echo "\n\t<option value='".$templates[$template]."' $selected>$template</option>";
|
|
||||||
endforeach;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@internal Missing Short Description}}
|
* Print out <option> HTML elements for the page parents drop-down.
|
||||||
*
|
*
|
||||||
* @since 1.5.0
|
* @since 1.5.0
|
||||||
*
|
*
|
||||||
* @param unknown_type $default
|
* @param int $default Optional. The default page ID to be pre-selected. Default 0.
|
||||||
* @param unknown_type $parent
|
* @param int $parent Optional. The parent page ID. Default 0.
|
||||||
* @param unknown_type $level
|
* @param int $level Optional. Page depth level. Default 0.
|
||||||
* @return unknown
|
*
|
||||||
|
* @return void|bool Boolean False if page has no children, otherwise print out html elements
|
||||||
*/
|
*/
|
||||||
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
|
function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
@ -732,12 +729,9 @@ function parent_dropdown( $default = 0, $parent = 0, $level = 0 ) {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$pad = str_repeat( ' ', $level * 3 );
|
$pad = str_repeat( ' ', $level * 3 );
|
||||||
if ( $item->ID == $default)
|
$selected = selected( $default, $item->ID, false );
|
||||||
$current = ' selected="selected"';
|
|
||||||
else
|
|
||||||
$current = '';
|
|
||||||
|
|
||||||
echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
|
echo "\n\t<option class='level-$level' value='$item->ID' $selected>$pad " . esc_html($item->post_title) . "</option>";
|
||||||
parent_dropdown( $default, $item->ID, $level +1 );
|
parent_dropdown( $default, $item->ID, $level +1 );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -68,6 +68,19 @@ function permalink_anchor( $mode = 'id' ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Alias for get_permalink()
|
||||||
|
*
|
||||||
|
* @since 3.9.0
|
||||||
|
*
|
||||||
|
* @param int|WP_Post $id Optional. Post ID or post object, defaults to the current post.
|
||||||
|
* @param bool $leavename Optional. Whether to keep post name or page name, defaults to false.
|
||||||
|
* @return string|bool The permalink URL or false if post does not exist.
|
||||||
|
*/
|
||||||
|
function get_the_permalink( $id = 0, $leavename = false ) {
|
||||||
|
return get_permalink( $id, $leavename );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve full permalink for current post or post ID.
|
* Retrieve full permalink for current post or post ID.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue