[wp-trac] [WordPress Trac] #46082: Why returning $menu_array[x] instead of $title

WordPress Trac noreply at wordpress.org
Wed Jan 23 16:02:40 UTC 2019


#46082: Why returning $menu_array[x] instead of $title
------------------------------+-----------------------------
 Reporter:  subrataemfluence  |      Owner:  (none)
     Type:  enhancement       |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Administration    |    Version:
 Severity:  normal            |   Keywords:  dev-feedback
  Focuses:                    |
------------------------------+-----------------------------
 {{{
 File: wp-admin/includes/plugin.php
 Function: get_admin_page_title()
 }}}


 In lines `1613, 1616, 1637, 1645 and 1660` the following pattern of
 assignments and return the value are used:


 {{{
 $title = $menu_array[x];
 return $menu_array[x];

 }}}

 where `$tile` is `global`.

 What is the difference between the following returning patterns


 {{{
 $title = $menu_array[x];
 return $menu_array[x];
 }}}


 AND


 {{{
 $title = $menu_array[x];
 return $title;
 }}}


 Since we are already updating the the global variable `$title` with that
 of `$menu_array[x]`, why can't we just return `$title` instead of
 `$menu_array[x]`? For every single request `global $title` will receive a
 new value.

 In `line 1620` the return pattern is usual:


 {{{
 $title = $menu_array[0];
 return $title;
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/46082>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list