<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[13553] trunk/wp-includes: Add id argument to wp_dropdown_users()
and wp_dropdown_categories().</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/13553">13553</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-03-02 18:36:49 +0000 (Tue, 02 Mar 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add id argument to wp_dropdown_users() and wp_dropdown_categories(). props johnbillion. Ensure we're escaping name and id in wp_dropdown_users(). fixes <a href="http://trac.wordpress.org/ticket/12132">#12132</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescategorytemplatephp">trunk/wp-includes/category-template.php</a></li>
<li><a href="#trunkwpincludesuserphp">trunk/wp-includes/user.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescategorytemplatephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/category-template.php (13552 => 13553)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/category-template.php        2010-03-02 18:08:14 UTC (rev 13552)
+++ trunk/wp-includes/category-template.php        2010-03-02 18:36:49 UTC (rev 13553)
</span><span class="lines">@@ -314,8 +314,9 @@
</span><span class="cx"> * 'echo' (bool|int) default is 1 - Whether to display or retrieve content.
</span><span class="cx"> * 'depth' (int) - The max depth.
</span><span class="cx"> * 'tab_index' (int) - Tab index for select element.
</span><del>- * 'name' (string) - The name attribute value for selected element.
- * 'class' (string) - The class attribute value for selected element.
</del><ins>+ * 'name' (string) - The name attribute value for select element.
+ * 'id' (string) - The ID attribute value for select element. Defaults to name if omitted.
+ * 'class' (string) - The class attribute value for select element.
</ins><span class="cx"> * 'selected' (int) - Which category ID is selected.
</span><span class="cx"> *
</span><span class="cx"> * The 'hierarchical' argument, which is disabled by default, will override the
</span><span class="lines">@@ -336,9 +337,10 @@
</span><span class="cx">                 'hide_empty' => 1, 'child_of' => 0,
</span><span class="cx">                 'exclude' => '', 'echo' => 1,
</span><span class="cx">                 'selected' => 0, 'hierarchical' => 0,
</span><del>-                'name' => 'cat', 'class' => 'postform',
-                'depth' => 0, 'tab_index' => 0,
-                'taxonomy' => 'category', 'hide_if_empty' => false
</del><ins>+                'name' => 'cat', 'id' => '',
+                'class' => 'postform', 'depth' => 0,
+                'tab_index' => 0, 'taxonomy' => 'category',
+                'hide_if_empty' => false
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         $defaults['selected'] = ( is_category() ) ? get_query_var( 'cat' ) : 0;
</span><span class="lines">@@ -357,11 +359,12 @@
</span><span class="cx">                 $tab_index_attribute = " tabindex=\"$tab_index\"";
</span><span class="cx">
</span><span class="cx">         $categories = get_terms( $taxonomy, $r );
</span><del>-        $name = esc_attr($name);
-        $class = esc_attr($class);
</del><ins>+        $name = esc_attr( $name );
+        $class = esc_attr( $class );
+        $id = $id ? esc_attr( $id ) : $name;
</ins><span class="cx">
</span><span class="cx">         if ( ! $r['hide_if_empty'] || ! empty($categories) )
</span><del>-                $output = "<select name='$name' id='$name' class='$class' $tab_index_attribute>\n";
</del><ins>+                $output = "<select name='$name' id='$id' class='$class' $tab_index_attribute>\n";
</ins><span class="cx">         else
</span><span class="cx">                 $output = '';
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesuserphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/user.php (13552 => 13553)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/user.php        2010-03-02 18:08:14 UTC (rev 13552)
+++ trunk/wp-includes/user.php        2010-03-02 18:36:49 UTC (rev 13553)
</span><span class="lines">@@ -403,11 +403,12 @@
</span><span class="cx"> * <li>order - Default is 'ASC'. Can also be 'DESC'.</li>
</span><span class="cx"> * <li>include - User IDs to include.</li>
</span><span class="cx"> * <li>exclude - User IDs to exclude.</li>
</span><del>- * <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element.</li>
</del><ins>+ * <li>multi - Default is 'false'. Whether to skip the ID attribute on the 'select' element. A 'true' value is overridden when id argument is set.</li>
</ins><span class="cx"> * <li>show - Default is 'display_name'. User table column to display. If the selected item is empty then the user_login will be displayed in parentesis</li>
</span><span class="cx"> * <li>echo - Default is '1'. Whether to display or retrieve content.</li>
</span><span class="cx"> * <li>selected - Which User ID is selected.</li>
</span><span class="cx"> * <li>name - Default is 'user'. Name attribute of select element.</li>
</span><ins>+ * <li>id - Default is the value of the 'name' parameter. ID attribute of select element.</li>
</ins><span class="cx"> * <li>class - Class attribute of select element.</li>
</span><span class="cx"> * <li>blog_id - ID of blog (Multisite only). Defaults to ID of current blog.</li>
</span><span class="cx"> * </ol>
</span><span class="lines">@@ -426,6 +427,7 @@
</span><span class="cx">                 'include' => '', 'exclude' => '', 'multi' => 0,
</span><span class="cx">                 'show' => 'display_name', 'echo' => 1,
</span><span class="cx">                 'selected' => 0, 'name' => 'user', 'class' => '', 'blog_id' => $GLOBALS['blog_id'],
</span><ins>+                'id' => '',
</ins><span class="cx">         );
</span><span class="cx">
</span><span class="cx">         $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
</span><span class="lines">@@ -459,9 +461,13 @@
</span><span class="cx">
</span><span class="cx">         $output = '';
</span><span class="cx">         if ( !empty($users) ) {
</span><del>-                $id = $multi ? "" : "id='$name'";
</del><ins>+                $name = esc_attr( $name );
+                if ( $multi && ! $id )
+                        $id = '';
+                else
+                        $id = $id ? " id='" . esc_attr( $id ) . "'" : "id='$name'";
</ins><span class="cx">
</span><del>-                $output = "<select name='$name' $id class='$class'>\n";
</del><ins>+                $output = "<select name='{$name}'{$id} class='$class'>\n";
</ins><span class="cx">
</span><span class="cx">                 if ( $show_option_all )
</span><span class="cx">                         $output .= "\t<option value='0'>$show_option_all</option>\n";
</span></span></pre>
</div>
</div>
</body>
</html>