Skip to content
Guides

Include Lazy Blocks within theme or plugin

Lazy Blocks provides a powerful solution for creating custom blocks and comes as a separate plugin. Although designed primarily for individual use, it may also be used as a framework by both plugin and theme authors to power their free and premium products.

We encourage authors to include Lazy Blocks and have only a few simple rules to follow, which we hope you respect. This guide outlines the do's and don'ts when including Lazy Blocks within you plugin or theme.

Product Types

When talking about a WordPress product, we can consider it as either a plugin, theme, premium plugin or premium theme.

Our rules differ only if your product is considered as free or premium, and not if it is a plugin or theme.

Rules

Please see the following table of rules that govern the inclusion of our plugins.

Lazy BlocksLazy Blocks Pro
Include in a free plugin
Include in a free theme
Include in a premium pluginwith Agency plan
Include in a premium themewith Agency plan
Include in a "Lazy Blocks" extension plugins
Share license key information
Use as a selling point

If you would like to include Lazy Blocks Pro in your premium theme or plugin, required to purchase the Agency plan.

Notes about marketing

Although we love idea of you empowering your customers with custom blocks, we don't love the idea of you advertising this to boost sales.

When including Lazy Blocks Pro within your premium theme or premium plugin, please do not advertise this in your marketing material. For example, stay away from messages like "This theme also includes Lazy Blocks Pro – normally $$$ – for free!"

Notes about "Lazy Blocks" extension plugins

We do not allow Lazy Blocks or Lazy Blocks Pro to be included in any type of "Lazy Blocks" extension or plugin. For example, a plugin named "Lazy Blocks Pro Kit" that extends the plugin with extra features may not include Lazy Blocks Pro. In this case, the "Lazy Blocks Pro Kit" plugin should require Lazy Blocks Pro to be installed.

How to include plugin files

To include Lazy Blocks within your theme or plugin, please download the appropriate Lazy Blocks plugin files and copy them into your theme or plugin. We recommend using the folder inc/lzb within your product files.

Next, use the following code as a starter to customize and include the Lazy Blocks plugin into your theme or plugin.

PHP
if ( ! function_exists( 'lazyblocks' ) ) {
  // Define path and URL to the LZB plugin.
  $my_lzb_path = get_stylesheet_directory() . '/inc/lzb/';
  $my_lzb_url  = get_stylesheet_directory_uri() . '/inc/lzb/';
 
  // Include the LZB plugin.
  require_once $my_lzb_path . 'lazy-blocks.php';
 
  lazyblocks()->include_within( $my_lzb_url );
}

Or if you use Lazy Blocks v3.3.0 and older, use the following code:

PHP for old Lazy Blocks
// Define path and URL to the LZB plugin.
define( 'MY_LZB_PATH', get_stylesheet_directory() . '/inc/lzb/' );
define( 'MY_LZB_URL', get_stylesheet_directory_uri() . '/inc/lzb/' );
 
// Include the LZB plugin.
require_once MY_LZB_PATH . 'lazy-blocks.php';
 
// Customize the url setting to fix incorrect asset URLs.
add_filter( 'lzb/plugin_url', 'my_lzb_url' );
function my_lzb_url( $url ) {
  return MY_LZB_URL;
}

Was this article helpful?