Home>Support>register_frontend_styles to footer

register_frontend_styles to footer

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

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. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 4 years, 10 months ago Alex S
    Hi, I Work Here

    Hi,

    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

  2. 4 years, 10 months ago fpweb

    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);
    }
    
  3. 4 years, 10 months ago Alex S
    Hi, I Work Here

    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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More