Kadence Blocks

repository·master·Indexed 43 days ago

https://github.com/stellarwp/kadence-blocks

A page builder toolkit for the WordPress Gutenberg editor providing over 20 custom blocks for high-performance, responsive layouts. Includes a Performance Optimizer to improve Core Web Vitals (LCP, CLS, INP) via client-side analysis and server-side resource optimization, as well as a REST API for managing optimization data.

Tokens
7.8K
Snippets
27
Records
42
Agent score
53%

What's inside Kadence Blocks

  1. Overview of Kadence Blocks

    master
    Kadence Blocks is a page builder toolkit for the WordPress Gutenberg editor. It provides over 20 custom blocks designed for high performance, accessibility, and design flexibility. It allows users to build complex, responsive layouts directly within the native WordPress editor without writing code.
  2. Key Features of Kadence Blocks

    master

    Kadence Blocks is built around several core functional pillars:

    • Intelligent Load: Only loads necessary CSS or JavaScript for the specific blocks used on a page to maintain performance.
    • Responsive Controls: Allows tweaking design settings (padding, margins, typography) specifically for desktop, tablet, and mobile views.
    • Design Library: Provides hundreds of pre-built patterns and pages to accelerate site assembly.
    • Typography & Color: Access to 900+ Google fonts, gradients, overlays, and parallax backgrounds.
    • Configurable Defaults: Define default settings for blocks to ensure consistency across a site.
    • Setting Visibility Controls: Ability to hide specific block settings from certain user roles.
  3. Available Custom Blocks

    master

    Kadence Blocks includes a variety of specialized blocks for layout and content:

    • Accordion: Customizable panels that can contain other blocks.
    • Advanced Button: Single or multiple buttons with hover controls and icon support.
    • Advanced Form: Contact and marketing forms with styling controls.
    • Advanced Gallery: Photo galleries, carousels, and sliders.
    • Advanced Text: Headings and paragraphs with responsive typography and Inline AI editing.
    • Countdown: Urgency-inducing timers (Pro includes evergreen campaigns).
    • Count Up: Animated number counters.
    • Info Box: Content boxes with icons/images, titles, and descriptions.
    • Icon: Access to 1500+ SVG icons.
    • Icon List: Engaging lists with icon support.
    • Lottie Animation: Support for importing and controlling Lottie animations.
    • Posts: Grid displays for blog posts.
    • Progress Bar: Visual goal/satisfaction indicators.
    • Row Layout: Container for nested blocks in columns.
    • Section: Designable content areas within Row Layouts.
    • Show More: Content previews with adjustable sizes and fade-outs.
    • Spacer / Divider: Control spacing and dividers with per-device height settings.
    • Table of Contents: Automatic anchor links and smooth scrolling for headings.
    • Tabs: Vertical or horizontal tab layouts.
    • Testimonials: Carousel or grid displays for social proof.
  4. How the Kadence Performance Optimizer works

    master

    The Optimizer improves Core Web Vitals (LCP, CLS, INP) using a two-phase process:

    1. Analysis Phase (Client-side): When optimization is triggered in wp-admin, JavaScript (via @stellarwp/perf-analyzer-client) analyzes the page to detect critical images, section heights, and optimal image sizes for desktop and mobile viewports.
    2. Application Phase (Server-side): On subsequent requests, the stored analysis data is used to apply optimizations such as proper lazy loading, content-visibility: auto for below-the-fold sections, and optimal image sizes attributes.

    Hash-Based Invalidation: To ensure optimizations remain accurate, the system compares HTML hashes on each request. If the HTML hash differs from the stored hash for a specific viewport, the data is marked isStale = true and re-optimization is required.

  5. Enable the Kadence Performance Optimizer

    master

    The Optimizer can be enabled globally through the Gutenberg editor interface:

    1. Open a post or page in the block editor.
    2. Click the Kadence "K" icon in the top toolbar to open Kadence Blocks Controls.
    3. Expand the Performance Optimizer panel.
    4. Toggle "Globally Enable The Performance Optimizer".

    This setting is stored in the kadence_blocks_settings option under the key performance_optimizer_enabled.

  6. Upgrade to Kadence Blocks Pro

    master

    Upgrading to the Pro version unlocks advanced features including:

    • Advanced Blocks: Advanced Query Loop, Advanced Slider, Image Overlay, Modal, Post Grid/Carousel, Product Carousel, Repeater, and Split Content.
    • Premium Functionality: Animate on Scroll, Custom Icons, Custom Fonts, Dynamic Content (integrating with ACF, MetaBox, WooCommerce, etc.), and Page Specific Scripts.
    • Expanded Design Library: Access to over 800+ additional patterns.
  7. Understand the kadenceHomeParams configuration object

    master

    The KadenceBlocksHome component consumes a global configuration object named kadenceHomeParams (attached to the window object). This object controls the dashboard's logic and visibility.

    Available Properties

    • isAuthorized: Boolean indicating if the user is authenticated for AI features.
    • isNetworkAdmin: Boolean indicating if the user has network-level administrative privileges.
    • isNetworkEnabled: Boolean indicating if the network features are enabled.
    • pro: String 'true' or other values indicating if the user has a Pro license.
    • homeContent: An object containing configuration for actionCards and knowledgeBase.
    • disconnectUrl: The URL used to revoke AI access.

    Logic for showControls

    Controls are shown if:

    • The user is a Network Admin AND the network is enabled.
    • OR, the user is NOT a Network Admin AND the network is NOT enabled.
  8. Debug the Kadence Performance Optimizer

    master

    To troubleshoot the Optimizer, use the following methods:

    Enable Debug Logging

    Set WP_DEBUG to true in your wp-config.php. Logs are prefixed with [Kadence Blocks]: and written to the PHP error log.

    define( 'WP_DEBUG', true );

    Verify Optimization Status

    • Visual Check: Look for the kb-optimized class on the <body> tag.
    • Preview Mode: Add ?kadence_optimizer_preview=1 to any URL to view the optimized version, bypassing skip rules (like logged-in user restrictions).

    Programmatic Access

    You can retrieve stored analysis data via the Store container:

    $store = KadenceWP//... (truncated for brevity)
    $path = new \KadenceWP\KadenceBlocks\Optimizer\Path\Path( '/my-page/', $post_id );
    $analysis = $store->get( $path );
  9. Add custom ignored query variables to Skip Rules

    master

    The Ignored_Query_Var_Rule skips optimization when specific query parameters are present. You can add your own custom query variables to this list using the kadence_blocks_optimizer_rule_skip_query_vars filter.

    add_filter( 'kadence_blocks_optimizer_rule_skip_query_vars', static fn( array $vars ): array => [
        ...$vars,
        'my_custom_preview',
    ]);
  10. Exclude sections from Section Lazy Loading

    master

    The Optimizer applies content-visibility: auto to below-the-fold Kadence Row and Column blocks. If a section causes layout shifts (CLS) or requires immediate rendering (like parallax sections), you can exclude it using the kadence_blocks_optimizer_section_lazy_load_excluded_classes filter.

    // Exclude specific classes from section lazy loading.
    add_filter( 'kadence_blocks_optimizer_section_lazy_load_excluded_classes', static fn( array $classes ): array => [
        ...$classes,
        'my-parallax-section',
    ]);