WebDevStudios / WDS-Simple-Page-Builder

Uses existing template parts in the currently-active theme to build a customized page with rearrangeable elements.
GNU General Public License v2.0
136 stars 25 forks source link

Option to enqueue scripts if needed per part #2

Closed colorful-tones closed 9 years ago

colorful-tones commented 9 years ago

Wondering if we can pass an optional argument through wds_page_builder_load_parts() to either of the following places that would allow user to wp_register_script() in their theme's functions.php, and then pass the argument to enqueue for certain part(s):

An example, in functions.php (or our _s /inc/scripts.php):

    wp_register_script( 'packery', get_stylesheet_directory_uri() . '/bower_components/packery/dist/packery.pkgd.js', NULL, $version, true );

then in template where we want to output parts we reference and pass the $handle parameter from wp_register_script:

<?php do_action( 'wds_page_builder_load_parts', 'packery' ); ?>
colorful-tones commented 9 years ago

Actually, this would not work, because this is assuming you already know which template the parts are being loaded on, therefore you could just enqueue conditionally based on that in functions.php