No results found. Try again with different words?

Search must be at least 3 characters.

‹ BACK TO DOC

Assets API for Third-Party Plugins

Introducing the API to enqueue Spectra assets for third-party developers.

Now, You can load Spectra blocks’ assets anywhere using an instance of our class. For this, you need to use the post ID of the page where you have used blocks.

Here is how you can do this –

  • Create an instance of our SpectraB_Post_Assets class by passing argument a post ID of a page for which you need to load assets.
  • After creating the instance, call a function of the instance.

All the assets related to Spectra blocks will enqueued on the above page.

Here is an example –

add_action( 'wp_enqueue_scripts', 'enqueue_scripts_by_post_id' );

function enqueue_scripts_by_post_id() {

    // Create Instance. Pass the Post ID.
    $post_assets_instance = new SpectraB_Post_Assets( $post_id );

    // Enqueue the Assets.
    $post_assets_instance->enqueue_scripts();
}

Was this article helpful?


Did not find a solution? We are here to help you succeed.

Get access to growing library of 40+ innovative widgets and 300+ creative templates.

Ultimate Addons for Gutenberg Is Now Spectra - 

Download is Just A Click Away!

Enter your email address and be the first to learn about updates and new features.

Scroll to Top