Enqueue System : enqueue_Xh

Discussions and requests related to new CMSimple features, plugins, templates etc. and how to develop.
Please don't ask for support at this forums!
utaka
Posts: 46
Joined: Fri Sep 18, 2015 6:00 am
Location: japanese
Contact:

Enqueue System : enqueue_Xh

Postby utaka » Thu Jan 28, 2016 3:38 pm

Enqure_Xh can be used Wordpress equivalent of Enqueue system.
Image

The Enqueue_Xh prevents Java script( jQuery ..) and style conflicts ,duplicat(Double reading).and Make the dependency
'To CMSimple_XH provide WordPress Enqueue system and equivalent function.


Download : https://github.com/bbfriend/enqueue_xh

Code: Select all

global $xh_scripts;
 print_scripts( $handles = false )
 register_script( $handle, $src, $deps = array(), $ver = false, $in_footer = false )
 localize_script( $handle, $object_name, $l10n )
 deregister_script( $handle )
 enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false )
 dequeue_script( $handle )
 script_is( $handle, $list = 'enqueued' )
 script_add_data( $handle, $key, $value ){
 print_head_scripts()
 print_footer_scripts

global $xh_styles;
 print_styles( $handles = false )
 add_inline_style( $handle, $data )
 add_inline_style( $handle, $data )
 deregister_style( $handle )
 enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' )
 dequeue_style( $handle )
 style_is( $handle, $list = 'enqueued' )
 style_add_data( $handle, $key, $value )

How to use. It is equivalent to the function of wordpress.The stinking looking it with a wp_ .
For example, please look for it enqueue_script ==> wp_enqueue_script

Operation check :Include Sample Plugin: dynamic_to_top_xh
Image
*Adds an automatic and dynamic "To Top" button in CMSimple_XH.
Original: wordpress Dynamic "To Top" Plugin
Last edited by utaka on Mon Sep 05, 2016 8:52 pm, edited 2 times in total.
******************************************************
Japan Site http://cmsimple-jp.org
Twitter Googe+ github
*I English is not a good . I'm sorry...
*Ich habe nicht eine gut Deutsch. Es tut mir leid ...
*Jeg kender ikke dansk
--Powered by Google Translate-----

utaka
Posts: 46
Joined: Fri Sep 18, 2015 6:00 am
Location: japanese
Contact:

Re: Enqueue System : enqueue_Xh

Postby utaka » Fri Feb 12, 2016 10:33 pm

Sorry . Mistake modification of release files :oops:

Ver0.4 release.
******************************************************
Japan Site http://cmsimple-jp.org
Twitter Googe+ github
*I English is not a good . I'm sorry...
*Ich habe nicht eine gut Deutsch. Es tut mir leid ...
*Jeg kender ikke dansk
--Powered by Google Translate-----

cmb
Posts: 11279
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Enqueue System : enqueue_Xh

Postby cmb » Sun Feb 26, 2017 4:41 pm

utaka wrote:The Enqueue_Xh prevents Java script( jQuery ..) and style conflicts ,duplicat(Double reading).and Make the dependency
'To CMSimple_XH provide WordPress Enqueue system and equivalent function.

Interesting! Thanks!

While the jQuery Plugin for CMSimple_XH already offers include_jQueryPlugin() which is a simplified form of wp_enqueue_script(), it may be reasonable to extend the system. Some thoughts:

  1. I don't know whether WP's enqueue system solves the issue of conflicting versions of a script, but IMHO that would be rather important. Consider one plugin is requiring version 1.x.y of a script, but another plugin requires version 2.x.y. Certainly, it would be possible to use different $handles, but both versions of the script might not work together. That is also a potential issue with regard to include_jqueryplugin(), though.
  2. While it is traditionally common to include JS by letting PHP generate the appropriate <script> tags, it's really not hard to do this by JS nowadays, and this way has advantages also. There are already several competing implementations, such as require.js, AMD and others. Of course, using a JS module loader requires some kind of initialization, so some kind of enqueue system would make sense nonetheless.
  3. Considering the script version issue (#1) and the usefulness of JS module loading (#2), it appears to be best to use only scripts which are offered as opaque modules. While this works for jQuery, as far as I know it doesn't work for jQuery plugins. Please correct me if I'm wrong.
  4. With regard to CSS there is already the possibility to @import other stylesheets from the plugin stylesheet. Including similar stylesheets usually isn't as much of an issue as including similar JS scripts.
That said, I generally like the idea of an enqueue system, but I have doubts, that adopting WordPress' enqueue system would be the best solution for CMSimple_XH. Some of it might be overkill, other parts may be missing, and generally, I don't think that a procedural API is the way to go nowadays – one or more (static) classes appear to be preferable, because they easily can be autoloaded when needed (note that CMSimple_XH 1.7 will have a general usable class autoloader).
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+

cmb
Posts: 11279
Joined: Tue Jun 21, 2011 11:04 am
Location: Mü-Sa, RLP, DE
Contact:

Re: Enqueue System : enqueue_Xh

Postby cmb » Sun Feb 26, 2017 6:44 pm

For the record: I've filed this as Github issue now.
Christoph M. Becker –Plugins for CMSimple_XH, but not for CMSimple 4+


Return to “Open Development”

Who is online

Users browsing this forum: No registered users and 2 guests