<!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" />
<title>[53104] trunk: Administration: Allow floats for menu positions.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { 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 { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#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>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/53104">53104</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/53104","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>peterwilsoncc</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2022-04-08 06:15:02 +0000 (Fri, 08 Apr 2022)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Administration: Allow floats for menu positions.

Permit plugin authors to pass the menu position as a float in `add_menu_page()` and `add_submenu_page()`. This allows for a common practice within major plugins to avoid menu collisions by passing a float.

Follow up to <a href="https://core.trac.wordpress.org/changeset/52569">[52569]</a>.

Props justinbusa, dd32, welcher, SergeyBiryukov, kirtan95, audrasjb, Cybr, chaion07, costdev, peterwilsoncc.
See <a href="https://core.trac.wordpress.org/ticket/40927">#40927</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludespluginphp">trunk/src/wp-admin/includes/plugin.php</a></li>
<li><a href="#trunktestsphpunittestsadminincludesPluginphp">trunk/tests/phpunit/tests/admin/includesPlugin.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludespluginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/plugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/plugin.php    2022-04-08 05:58:09 UTC (rev 53103)
+++ trunk/src/wp-admin/includes/plugin.php      2022-04-08 06:15:02 UTC (rev 53104)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1284,20 +1284,20 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @global array $_registered_pages
</span><span class="cx" style="display: block; padding: 0 10px">  * @global array $_parent_pages
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string   $page_title The text to be displayed in the title tags of the page when the menu is selected.
- * @param string   $menu_title The text to be used for the menu.
- * @param string   $capability The capability required for this menu to be displayed to the user.
- * @param string   $menu_slug  The slug name to refer to this menu by. Should be unique for this menu page and only
- *                             include lowercase alphanumeric, dashes, and underscores characters to be compatible
- *                             with sanitize_key().
- * @param callable $function   Optional. The function to be called to output the content for this page.
- * @param string   $icon_url   Optional. The URL to the icon to be used for this menu.
- *                             * Pass a base64-encoded SVG using a data URI, which will be colored to match
- *                               the color scheme. This should begin with 'data:image/svg+xml;base64,'.
- *                             * Pass the name of a Dashicons helper class to use a font icon,
- *                               e.g. 'dashicons-chart-pie'.
- *                             * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS.
- * @param int      $position   Optional. The position in the menu order this item should appear.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string    $page_title The text to be displayed in the title tags of the page when the menu is selected.
+ * @param string    $menu_title The text to be used for the menu.
+ * @param string    $capability The capability required for this menu to be displayed to the user.
+ * @param string    $menu_slug  The slug name to refer to this menu by. Should be unique for this menu page and only
+ *                              include lowercase alphanumeric, dashes, and underscores characters to be compatible
+ *                              with sanitize_key().
+ * @param callable  $function   Optional. The function to be called to output the content for this page.
+ * @param string    $icon_url   Optional. The URL to the icon to be used for this menu.
+ *                              * Pass a base64-encoded SVG using a data URI, which will be colored to match
+ *                                the color scheme. This should begin with 'data:image/svg+xml;base64,'.
+ *                              * Pass the name of a Dashicons helper class to use a font icon,
+ *                                e.g. 'dashicons-chart-pie'.
+ *                              * Pass 'none' to leave div.wp-menu-image empty so an icon can be added via CSS.
+ * @param int|float $position   Optional. The position in the menu order this item should appear.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return string The resulting page's hook_suffix.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1323,27 +1323,22 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( null === $position ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( null === $position || ! is_numeric( $position ) ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $menu[] = $new_menu;
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        } elseif ( isset( $menu[ "$position" ] ) ) {
-               $position            = $position + substr( base_convert( md5( $menu_slug . $menu_title ), 16, 10 ), -5 ) * 0.00001;
-               $menu[ "$position" ] = $new_menu;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ } elseif ( isset( $menu[ (string) $position ] ) ) {
+               $collision_avoider = base_convert( substr( md5( $menu_slug . $menu_title ), -4 ), 16, 10 ) * 0.00001;
+               $position          = (string) ( $position + $collision_avoider );
+               $menu[ $position ] = $new_menu;
</ins><span class="cx" style="display: block; padding: 0 10px">         } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( ! is_int( $position ) ) {
-                       _doing_it_wrong(
-                               __FUNCTION__,
-                               sprintf(
-                                       /* translators: %s: add_menu_page() */
-                                       __( 'The seventh parameter passed to %s should be an integer representing menu position.' ),
-                                       '<code>add_menu_page()</code>'
-                               ),
-                               '6.0.0'
-                       );
-                       // If the position is not a string (i.e. float), convert it to string.
-                       if ( ! is_string( $position ) ) {
-                               $position = (string) $position;
-                       }
-               }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         /*
+                * Cast menu position to a string.
+                *
+                * This allows for floats to be passed as the position. PHP will normally cast a float to an
+                * integer value, this ensures the float retains its mantissa (positive fractional part).
+                *
+                * A string containing an integer value, eg "10", is treated as a numeric index.
+                */
+               $position          = (string) $position;
</ins><span class="cx" style="display: block; padding: 0 10px">                 $menu[ $position ] = $new_menu;
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1374,17 +1369,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @global array $_registered_pages
</span><span class="cx" style="display: block; padding: 0 10px">  * @global array $_parent_pages
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string   $parent_slug The slug name for the parent menu (or the file name of a standard
- *                              WordPress admin page).
- * @param string   $page_title  The text to be displayed in the title tags of the page when the menu
- *                              is selected.
- * @param string   $menu_title  The text to be used for the menu.
- * @param string   $capability  The capability required for this menu to be displayed to the user.
- * @param string   $menu_slug   The slug name to refer to this menu by. Should be unique for this menu
- *                              and only include lowercase alphanumeric, dashes, and underscores characters
- *                              to be compatible with sanitize_key().
- * @param callable $function    Optional. The function to be called to output the content for this page.
- * @param int      $position    Optional. The position in the menu order this item should appear.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string         $parent_slug The slug name for the parent menu (or the file name of a standard
+ *                                    WordPress admin page).
+ * @param string         $page_title  The text to be displayed in the title tags of the page when the menu
+ *                                    is selected.
+ * @param string         $menu_title  The text to be used for the menu.
+ * @param string         $capability  The capability required for this menu to be displayed to the user.
+ * @param string         $menu_slug   The slug name to refer to this menu by. Should be unique for this menu
+ *                                    and only include lowercase alphanumeric, dashes, and underscores characters
+ *                                    to be compatible with sanitize_key().
+ * @param callable       $function    Optional. The function to be called to output the content for this page.
+ * @param int|float      $position    Optional. The position in the menu order this item should appear.
</ins><span class="cx" style="display: block; padding: 0 10px">  * @return string|false The resulting page's hook_suffix, or false if the user does not have the capability required.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '', $position = null ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -1418,43 +1413,43 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        $new_sub_menu = array( $menu_title, $capability, $menu_slug, $page_title );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( ! is_int( $position ) ) {
-               if ( null !== $position ) {
-                       _doing_it_wrong(
-                               __FUNCTION__,
-                               sprintf(
-                                       /* translators: %s: add_submenu_page() */
-                                       __( 'The seventh parameter passed to %s should be an integer representing menu position.' ),
-                                       '<code>add_submenu_page()</code>'
-                               ),
-                               '5.3.0'
-                       );
-               }
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        if ( null !== $position && ! is_numeric( $position ) ) {
+               _doing_it_wrong(
+                       __FUNCTION__,
+                       sprintf(
+                               /* translators: %s: add_submenu_page() */
+                               __( 'The seventh parameter passed to %s should be an integer representing menu position.' ),
+                               '<code>add_submenu_page()</code>'
+                       ),
+                       '5.3.0'
+               );
+               $position = null;
+       }
+
+       if (
+               null === $position ||
+               ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) )
+       ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $submenu[ $parent_slug ][] = $new_sub_menu;
</span><span class="cx" style="display: block; padding: 0 10px">        } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Append the submenu if the parent item is not present in the submenu,
-               // or if position is equal or higher than the number of items in the array.
-               if ( ! isset( $submenu[ $parent_slug ] ) || $position >= count( $submenu[ $parent_slug ] ) ) {
-                       $submenu[ $parent_slug ][] = $new_sub_menu;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Test for a negative position.
+               $position = max( $position, 0 );
+               if ( 0 === $position ) {
+                       // For negative or `0` positions, prepend the submenu.
+                       array_unshift( $submenu[ $parent_slug ], $new_sub_menu );
</ins><span class="cx" style="display: block; padding: 0 10px">                 } else {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                        // Test for a negative position.
-                       $position = max( $position, 0 );
-                       if ( 0 === $position ) {
-                               // For negative or `0` positions, prepend the submenu.
-                               array_unshift( $submenu[ $parent_slug ], $new_sub_menu );
-                       } else {
-                               // Grab all of the items before the insertion point.
-                               $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
-                               // Grab all of the items after the insertion point.
-                               $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true );
-                               // Add the new item.
-                               $before_items[] = $new_sub_menu;
-                               // Merge the items.
-                               $submenu[ $parent_slug ] = array_merge( $before_items, $after_items );
-                       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                 // Grab all of the items before the insertion point.
+                       $before_items = array_slice( $submenu[ $parent_slug ], 0, $position, true );
+                       // Grab all of the items after the insertion point.
+                       $after_items = array_slice( $submenu[ $parent_slug ], $position, null, true );
+                       // Add the new item.
+                       $before_items[] = $new_sub_menu;
+                       // Merge the items.
+                       $submenu[ $parent_slug ] = array_merge( $before_items, $after_items );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px">         // Sort the parent array.
</span><span class="cx" style="display: block; padding: 0 10px">        ksort( $submenu[ $parent_slug ] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span></span></pre></div>
<a id="trunktestsphpunittestsadminincludesPluginphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/admin/includesPlugin.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/admin/includesPlugin.php        2022-04-08 05:58:09 UTC (rev 53103)
+++ trunk/tests/phpunit/tests/admin/includesPlugin.php  2022-04-08 06:15:02 UTC (rev 53104)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -256,8 +256,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 0, 0 ),                     // Insert at the beginning of the menu if 0 is passed.
</span><span class="cx" style="display: block; padding: 0 10px">                        array( -1, 0 ),                    // Negative numbers are treated the same as passing 0.
</span><span class="cx" style="display: block; padding: 0 10px">                        array( -7, 0 ),                    // Negative numbers are treated the same as passing 0.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        array( '-7', 0 ),                  // Negative numbers are treated the same as passing 0.
</ins><span class="cx" style="display: block; padding: 0 10px">                         array( 1, 1 ),                     // Insert as the second item.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        array( '1', 1 ),                   // Insert as the second item.
+                       array( 1.5, 1 ),                   // Insert as the second item.
+                       array( '1.5', 1 ),                 // Insert as the second item.
</ins><span class="cx" style="display: block; padding: 0 10px">                         array( 3, 3 ),                     // Insert as the 4th item.
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+                        array( '3', 3 ),                   // Insert as the 4th item.
+                       array( '3e0', 3 ),                 // Insert as the 4th item.
+                       array( 3.5, 3 ),                   // Insert as the 4th item.
+                       array( '3.5', 3 ),                 // Insert as the 4th item.
</ins><span class="cx" style="display: block; padding: 0 10px">                         array( $menu_count, $menu_count ), // Numbers equal to the number of items are added at the end.
</span><span class="cx" style="display: block; padding: 0 10px">                        array( 123456, $menu_count ),      // Numbers higher than the number of items are added at the end.
</span><span class="cx" style="display: block; padding: 0 10px">                );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -314,7 +322,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Setup a menu with some items.
</span><span class="cx" style="display: block; padding: 0 10px">                add_menu_page( 'Main Menu', 'Main Menu', 'manage_options', 'main_slug', 'main_page_callback' );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_submenu_page( 'main_slug', 'SubMenu 1', 'SubMenu 1', 'manage_options', 'submenu_page_1', 'submenu_callback_1', '2' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         add_submenu_page( 'main_slug', 'SubMenu 1', 'SubMenu 1', 'manage_options', 'submenu_page_1', 'submenu_callback_1', 'First' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Clean up the temporary user.
</span><span class="cx" style="display: block; padding: 0 10px">                wp_set_current_user( $current_user );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -329,8 +337,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><span class="cx" style="display: block; padding: 0 10px">         * @ticket 54798
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function test_passing_string_as_position_fires_doing_it_wrong_menu() {
-               $this->setExpectedIncorrectUsage( 'add_menu_page' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function test_passing_float_as_position_does_not_override_int() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 global $submenu, $menu;
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Reset menus.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -342,17 +349,19 @@
</span><span class="cx" style="display: block; padding: 0 10px">                set_current_screen( 'dashboard' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Setup a menu with some items.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                add_menu_page( 'Main Menu', 'Main Menu', 'manage_options', 'main_slug', 'main_page_callback', 'icon_url', '1' );
-               add_menu_page( 'Main Menu 1', 'Main Menu 1', 'manage_options', 'main1_slug', 'main1_page_callback', 'icon_url1', 1.5 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         add_menu_page( 'Main Menu 1', 'Main Menu 1', 'manage_options', 'main_slug_1', 'main_page_callback_1', 'icon_url_1', 1 );
+               add_menu_page( 'Main Menu 2', 'Main Menu 2', 'manage_options', 'main_slug_2', 'main_page_callback_2', 'icon_url_2', 2 );
+               add_menu_page( 'Main Menu 1.5', 'Main Menu 1.5', 'manage_options', 'main_slug_15', 'main_page_callback_15', 'icon_url_15', 1.5 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                // Clean up the temporary user.
</span><span class="cx" style="display: block; padding: 0 10px">                wp_set_current_user( $current_user );
</span><span class="cx" style="display: block; padding: 0 10px">                wp_delete_user( $admin_user );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // Verify the menu was inserted.
-               $this->assertSame( 'main_slug', $menu[1][2] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         // Verify the menus were inserted.
+               $this->assertSame( 'main_slug_1', $menu[1][2] );
+               $this->assertSame( 'main_slug_2', $menu[2][2] );
</ins><span class="cx" style="display: block; padding: 0 10px">                 // Verify the menu was inserted correctly on passing float as position.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertSame( 'main1_slug', $menu['1.5'][2] );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( 'main_slug_15', $menu['1.5'][2] );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        public function test_is_plugin_active_true() {
</span></span></pre>
</div>
</div>

</body>
</html>