[wp-trac] [WordPress Trac] #58946: Specificity of _admin_bar_bump_cb() echo and violation of MVC by that function

WordPress Trac noreply at wordpress.org
Mon Jul 31 14:19:59 UTC 2023


#58946: Specificity of _admin_bar_bump_cb() echo and violation of MVC by that
function
----------------------------+-----------------------------
 Reporter:  letraceursnork  |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  6.2.2
 Severity:  minor           |   Keywords:  needs-patch
  Focuses:                  |
----------------------------+-----------------------------
 ./wp-icnludes/admin-bar.php:1219

 What in the world is that?

 {{{#!php
 <?php
 /**
  * Prints default admin bar callback.
  *
  * @since 3.1.0
  */
 function _admin_bar_bump_cb() {
         $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : '
 type="text/css"';
         ?>
 <style<?php echo $type_attr; ?> media="screen">
         html { margin-top: 32px !important; }
         @media screen and ( max-width: 782px ) {
                 html { margin-top: 46px !important; }
         }
 </style>
         <?php
 }
 }}}
 First of all, why `!important`?
 Second of all, why `782px` exactly? I couldn't find any framework that
 considering `782px` as a breakpoint, the most popular `sm` breakpoint
 (between mobiles and tablets) is `768px`
 Then we come to hardcoded `32px` and `46px`. I just wanted to say about
 CSS-properties to handle this situation, when I found `--wp-admin--admin-
 bar--height` property inside `html` style and it customizes just like that
 - `32px` and `46px` on `<782px`. So, why not using this?

 About MVC violation: what is <html>-layout doing in "functions"-like file?
 This one should describe functions and internal logic, not layouts, we
 have View-layer for that, or at least sprintf()

 At last, what does this function do anyway? Just in a nutshell, I believe,
 this one "customizes" #wpadminbar for those themes who doesn't have its
 own add_filter() customization for it. Well, why not just include the CSS-
 file directly?

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


More information about the wp-trac mailing list