register_frontend_styles to footer
Hi!
Im making my own modules to page builder.
It is possible to load CSS in footer like JS files?
Im trying to find this in plugin sorce code, but I can’t found.
It is possible to set globaly for all widgets?
function initialize()
{
$this->register_frontend_scripts(
array(
array(
$this->so_plugin_slug,
$this->so_plugin_url . 'tpl/script.js',
array('jquery'),
self::SO_PLUGIN_VER,
true // add to fotter
),
)
);
$this->register_frontend_styles(
array(
array($this->so_plugin_slug, $this->so_plugin_url . 'tpl/main.min.css', array(), self::SO_PLUGIN_VER),
)
);
}This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
3Hi,
register_frontend_styles is a helper function for wp_enqueue_style. This function doesn’t work in the same way as wp_enqueue_script so it’s not possible to tell WordPress to output the script to the footer when registering them.
You could override enqueue_frontend_scripts and hook into wp_footer and output your CSS there. You’ll need to do this for each widget however as this method – and related styling – is widget specific.
Kind regards,
Alex
hmm something like this in my widget?
function enqueue_frontend_scripts( $instance ) { $this->enqueue_registered_scripts( $instance ); add_action('get_footer', $this->enqueue_registered_styles( $instance)); do_action('siteorigin_widgets_enqueue_frontend_scripts_' . $this->id_base, $instance, $this); }Hi Fpweb,
I recommend using wp_footer instead of get_footer. You add a hook for get_footer and then use $this->enqueue_registered_styles( $instance).
Kind regards,
Alex
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.