[wp-trac] [WordPress Trac] #41558: create a (reusable) wp_default_admin_scripts

WordPress Trac noreply at wordpress.org
Thu Aug 3 23:53:49 UTC 2017


#41558: create a (reusable) wp_default_admin_scripts
--------------------------------+-----------------------------
 Reporter:  drzraf              |      Owner:
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Themes              |    Version:  4.8.1
 Severity:  normal              |   Keywords:
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 I had to create an admin-like form in the frontend, for guests submitting
 content.
 I needed to provide {{{meta/post-box}}}, {{{autocompletion}}} and needed
 {{{media-views}}}, {{{wp-color-picker}}}, ...

 I thought {{{wp_enqueue_script()}}} would do the trick... until I
 discovered the {{{ if(is_admin()) }}} inside {{{wp_default_scripts()}}}. I
 had no other choice than copy/pasting ~210 WP LoC in my own PHP files

 Is there a really good reason for reserving all that cool client-side
 stuff to admin dashboard only?
 plugin/themes developers may want to load and use it for good and having
 all that libs already registered by core is useful.


 I suggest:
 1. moving all the admin-oriented script into
 {{{wp_default_admin_scripts()}}} which should be reusable (even if non-
 admin), and run it if (is_admin).
 2. moving all the {{{localize()}}} corresponding to these admin scripts
 into another {{{wp_default_admin_scripts_settings()}}}  function somehow
 wrapped by {{{if(! is_admin())}}}
 3. Document how to correctly bootstrap the dashboard in the frontend and a
 couple of common gotchas of these scripts (like that ajax-dashboard-
 pingback feature forcefully pulled as JS-dependencies and which can't be
 stopped, ...)

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


More information about the wp-trac mailing list