### GET /kb-optimizer/v1/optimize - Example Response Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Example JSON response from the GET endpoint. Shows the structure of the data object with isStale, desktop, mobile, and images fields. ```json { "data": { "isStale": false, "desktop": { "sections": [], "passed": false, "score": 0, "totalBytes": 0 }, "mobile": { "sections": [], "passed": false, "score": 0, "totalBytes": 0 }, "images": [] } } ``` -------------------------------- ### Basic usage example Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/asset.md Shows how to resolve the Asset service from the container and use its methods to get a URL, meta, and enqueue a script. ```php $asset = kadence_blocks()->get( \KadenceWP\KadenceBlocks\Asset\Asset::class ); $url = $asset->get_url( 'dist/blocks/accordion.css' ); $meta = $asset->get_meta( 'dist/blocks/accordion' ); $asset->enqueue_script( 'kb-custom', 'build/custom', 'js' ); ``` -------------------------------- ### GET /kb-optimizer/v1/optimize - Example Request Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Example JavaScript code using wp.apiFetch to make a GET request to the optimizer endpoint. The path includes post_id and post_path parameters. ```js const res = await wp.apiFetch({ path: `/kb-optimizer/v1/optimize?post_id=${postId}&post_path=${encodeURIComponent(path)}`, method: 'GET', }); ``` -------------------------------- ### Install JavaScript dependencies with bun install Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Installs JavaScript dependencies. The postinstall step builds the @kadence/* packages (helpers, icons, components) automatically. ```bash bun install ``` -------------------------------- ### Install PHP dependencies with composer install Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Installs Composer packages and runs Strauss post-install steps that prefix vendor namespaces into vendor/vendor-prefixed/. Never edit files in vendor/vendor-prefixed/ directly. ```bash composer install ``` -------------------------------- ### Start watch mode with bun run start Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Runs webpack watch and gulp watch concurrently for active development, rebuilding JS/CSS on change. ```bash bun run start ``` -------------------------------- ### Example usage of kadence_blocks_get_post_types() Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/helper-functions.md Shows how to call the function with no arguments to get all public REST-enabled post types, and with 'exclude_from_search' set to false to get searchable ones. ```php $types = kadence_blocks_get_post_types(); $searchable = kadence_blocks_get_post_types( [ 'exclude_from_search' => false ] ); ``` -------------------------------- ### Example: kadence_blocks_hex2rgba() conversion Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/helper-functions.md Example usage of kadence_blocks_hex2rgba() converting '#3182CE' with alpha 0.5 to 'rgba(49, 130, 206, 0.5)'. ```php echo kadence_blocks_hex2rgba( '#3182CE', 0.5 ); // rgba(49, 130, 206, 0.5) ``` -------------------------------- ### Example response from POST /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Shows the JSON response returned on successful creation (status 201). Contains success flag, post_id, and post_path. ```json { "data": { "success": true, "post_id": 12, "post_path": "/path/to/page/" } } ``` -------------------------------- ### Example of rendering a template part with kadence_blocks_get_template and get_template_html Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/helper-functions.md Demonstrates how to include a template part directly or capture its HTML output as a string. Both functions accept the same template name and arguments array. ```php kadence_blocks_get_template( 'form/field.php', [ 'field' => $field ] ); $html = kadence_blocks_get_template_html( 'form/field.php', [ 'field' => $field ] ); ``` -------------------------------- ### GET /kb-design-library/v1/get_local_contexts Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves local contexts. ```APIDOC ## GET /kb-design-library/v1/get_local_contexts ### Description Retrieves local contexts. ### Method GET ### Endpoint `/kb-design-library/v1/get_local_contexts` ### Authentication Requires `edit_posts` capability. ### Response Returns local contexts. ``` -------------------------------- ### Error handling example Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/asset.md Demonstrates graceful fallback when no asset meta file exists, using the returned version to add an inline script. ```php $asset = kadence_blocks()->get( \KadenceWP\KadenceBlocks\Asset\Asset::class ); // No .asset.php file exists for this path; get_meta() returns the // fallback dependency array and KADENCE_BLOCKS_VERSION instead of failing. $meta = $asset->get_meta( 'dist/legacy-script' ); wp_add_inline_script( 'kb-legacy', sprintf( 'window.KB_LEGACY_VER = %s;', wp_json_encode( $meta['version'] ?? '' ) ) ); ``` -------------------------------- ### GET /kb-design-library/v1/get_connection Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves connection information. ```APIDOC ## GET /kb-design-library/v1/get_connection ### Description Retrieves connection information. ### Method GET ### Endpoint `/kb-design-library/v1/get_connection` ### Authentication Requires `edit_posts` capability. ### Example ```js const connection = await wp.apiFetch({ path: '/kb-design-library/v1/get_connection' }); ``` ### Response Returns connection information. ``` -------------------------------- ### Error handling for POST /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Example try/catch block showing how to handle errors from the optimize endpoint. Lists possible error codes in comments. ```javascript try { const res = await wp.apiFetch({ path: '/kb-optimizer/v1/optimize', method: 'POST', data }); } catch (e) { // e.code is one of: // 'rest_kb_optimizer_create_failed_excluded' // 'rest_kb_optimizer_create_failed_not_published' // 'rest_kb_optimizer_invalid_path' // 'rest_kb_optimizer_create_failed' // 'rest_forbidden' (permission) console.warn(e.message); } ``` -------------------------------- ### Example: conditionally enqueue script with kadence_blocks_is_not_amp() Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/helper-functions.md Example usage of kadence_blocks_is_not_amp() to conditionally enqueue a script only when the request is not an AMP endpoint. ```php if ( kadence_blocks_is_not_amp() ) { wp_enqueue_script( 'my-slider' ); } ``` -------------------------------- ### Typical consumer call to POST /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Example JavaScript using wp.apiFetch to call the optimize endpoint from the editor. Sends post_id, post_path, and results. ```javascript await wp.apiFetch({ path: '/kb-optimizer/v1/optimize', method: 'POST', data: { post_id: wp.data.select('core/editor').getCurrentPostId(), post_path: window.location.pathname, results: analysisResults, }, }); ``` -------------------------------- ### Resolving services from the container Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/app.md Example of using the global accessor to resolve the image downloader and AI cache services from the container. ```php $downloader = kadence_blocks()->get( \KadenceWP\KadenceBlocks\Image_Downloader\Image_Downloader::class ); $ai_cache = kadence_blocks()->get( \KadenceWP\KadenceBlocks\Cache\Ai_Cache::class ); ``` -------------------------------- ### GET /kb-fluentcrm/v1/get Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Proxies to the FluentCRM provider API using stored API keys and returns the provider's payload. ```APIDOC ## GET /kb-fluentcrm/v1/get ### Description Proxies to the FluentCRM provider API using stored API keys and returns the provider's payload. ### Method GET ### Endpoint `/kb-fluentcrm/v1/get` ### Parameters #### Query Parameters - **queryargs** (string) - Required - Query arguments for the FluentCRM API. ### Response #### Success Response (200) - **provider payload** (object) - The response from the FluentCRM API. ``` -------------------------------- ### POST /optimize/posts-metadata Source: https://github.com/stellarwp/kadence-blocks/blob/master/includes/resources/Optimizer/README.md Gets metadata for bulk optimization. ```APIDOC ## POST /wp-json/kb-optimizer/v1/optimize/posts-metadata ### Description Gets metadata for bulk optimization. ### Method POST ### Endpoint /wp-json/kb-optimizer/v1/optimize/posts-metadata ### Parameters #### Request Body - (object) - Required - List of post IDs ### Response #### Success Response (200) - (object) - Metadata for bulk optimization ### Response Example { "data": {} } ``` -------------------------------- ### GET /kb-design-library/v1/get_library Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves the library data. ```APIDOC ## GET /kb-design-library/v1/get_library ### Description Retrieves the library data. ### Method GET ### Endpoint `/kb-design-library/v1/get_library` ### Authentication Requires `edit_posts` capability. ### Example ```js const items = await wp.apiFetch({ path: '/kb-design-library/v1/get_library?context=edit' }); ``` ### Response Returns the library data. ``` -------------------------------- ### GET /kb-design-library/v1/get Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves items from the design library. ```APIDOC ## GET /kb-design-library/v1/get ### Description Retrieves items from the design library. ### Method GET ### Endpoint `/kb-design-library/v1/get` ### Authentication Requires `edit_posts` capability. ### Response Returns the library items. ``` -------------------------------- ### GET /kbp/v1/taxonomies-select Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Retrieves public UI taxonomies for the target post types. ```APIDOC ## GET /kbp/v1/taxonomies-select ### Description Retrieves public UI taxonomies for the target post types. The `source` parameter can be `'all'`, a post type slug, or a post ID. ### Method GET ### Endpoint /kbp/v1/taxonomies-select ### Parameters #### Query Parameters - **source** (string) - Required - Can be `'all'`, a post type slug, or a post ID. Determines the target post types. ### Response #### Success Response (200) - **value** (string) - Taxonomy slug. - **label** (string) - Taxonomy label. #### Response Example ```json [ { "value": "category", "label": "Categories" } ] ``` ``` -------------------------------- ### GET /kb-design-library/v1/get_connection Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Retrieves the Prophecy connection and credits. ```APIDOC ## GET /kb-design-library/v1/get_connection ### Description Retrieves the Prophecy connection and credits. ### Method GET ### Endpoint `/kb-design-library/v1/get_connection` ### Response #### Success Response (200) - **connection** (object) - Prophecy connection details. - **credits** (integer) - Available credits. ``` -------------------------------- ### GET /kb-design-library/v1/get_library_categories Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves library categories. ```APIDOC ## GET /kb-design-library/v1/get_library_categories ### Description Retrieves library categories. ### Method GET ### Endpoint `/kb-design-library/v1/get_library_categories` ### Authentication Requires `edit_posts` capability. ### Response Returns library categories. ``` -------------------------------- ### GET /kb-activecampaign/v1/get Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Proxies to the ActiveCampaign provider API using stored API keys and returns the provider's payload. ```APIDOC ## GET /kb-activecampaign/v1/get ### Description Proxies to the ActiveCampaign provider API using stored API keys and returns the provider's payload. ### Method GET ### Endpoint `/kb-activecampaign/v1/get` ### Parameters #### Query Parameters - **queryargs** (string) - Required - Query arguments for the ActiveCampaign API. ### Response #### Success Response (200) - **provider payload** (object) - The response from the ActiveCampaign API. ``` -------------------------------- ### GET /kb-design-library/v1/get_remaining_jobs Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves remaining jobs. ```APIDOC ## GET /kb-design-library/v1/get_remaining_jobs ### Description Retrieves remaining jobs. ### Method GET ### Endpoint `/kb-design-library/v1/get_remaining_jobs` ### Authentication Requires `edit_posts` capability. ### Response Returns remaining jobs. ``` -------------------------------- ### wp_ajax_kadence_import_get_new_connection_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Gets new connection data. Admin only. ```APIDOC ## wp_ajax_kadence_import_get_new_connection_data ### Description Gets new connection data. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_get_new_connection_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### GET /kb-design-library/v1/get_all_items Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves all items from the design library. ```APIDOC ## GET /kb-design-library/v1/get_all_items ### Description Retrieves all items from the design library. ### Method GET ### Endpoint `/kb-design-library/v1/get_all_items` ### Authentication Requires `edit_posts` capability. ### Response Returns all library items. ``` -------------------------------- ### GET /kb-design-library/v1/get-all-ai Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Retrieves all AI items from the design library. ```APIDOC ## GET /kb-design-library/v1/get-all-ai ### Description Retrieves all AI items from the design library. ### Method GET ### Endpoint `/kb-design-library/v1/get-all-ai` ### Authentication Requires `edit_posts` capability. ### Response Returns all AI library items. ``` -------------------------------- ### GET /kbp/v1/term-select Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Retrieves terms for a given taxonomy. ```APIDOC ## GET /kbp/v1/term-select ### Description Retrieves terms for a given taxonomy. Returns an array of objects with `value` and `label` fields. ### Method GET ### Endpoint /kbp/v1/term-select ### Parameters #### Query Parameters - **source** (string) - Required - Taxonomy slug. - **page** (integer) - Optional - Page number for pagination. - **per_page** (integer) - Optional - Number of items per page. ### Response #### Success Response (200) - **value** (string) - Term value in the format `{taxonomy}|{term_id}`. - **label** (string) - Term name. #### Response Example ```json [ { "value": "category|1", "label": "Uncategorized" } ] ``` ``` -------------------------------- ### GET /optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/includes/resources/Optimizer/README.md Retrieves analysis data for a post. ```APIDOC ## GET /wp-json/kb-optimizer/v1/optimize ### Description Retrieves analysis data for a post. ### Method GET ### Endpoint /wp-json/kb-optimizer/v1/optimize ### Parameters #### Query Parameters - (object) - Required - Post identifier ### Response #### Success Response (200) - (object) - Analysis data ### Response Example { "data": {} } ``` -------------------------------- ### GET /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Reads optimizer data for a given post. Returns 200 with data as WebsiteAnalysis.toArray(). Possible error: rest_kb_optimizer_read_not_found (404). ```APIDOC ## GET /kb-optimizer/v1/optimize ### Description Reads optimizer data for a given post. Returns 200 with data as WebsiteAnalysis.toArray(). Possible error: rest_kb_optimizer_read_not_found (404). ### Method GET ### Endpoint /kb-optimizer/v1/optimize ### Parameters #### Query Parameters - **post_id** (number) - Required - The post ID. - **post_path** (string) - Required - The post path. ### Response #### Success Response (200) - **data** (array) - The WebsiteAnalysis data as an array. ``` -------------------------------- ### GET /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Retrieves the optimization analysis data for a given post. The post path is derived from the post_id parameter. Returns a 404 error if the post cannot be resolved or no stored data exists. ```APIDOC ## GET /kb-optimizer/v1/optimize ### Description Retrieves the optimization analysis data for a given post. The post path is derived from the post_id parameter. Returns a 404 error if the post cannot be resolved or no stored data exists. ### Method GET ### Endpoint /kb-optimizer/v1/optimize ### Parameters #### Query Parameters - **post_id** (integer) - Required - The ID of the post to retrieve optimization data for. - **post_path** (string) - Optional - The path of the post. This is always derived from post_id and not trusted from the client. ### Request Example ```js const res = await wp.apiFetch({ path: `/kb-optimizer/v1/optimize?post_id=${postId}&post_path=${encodeURIComponent(path)}`, method: 'GET', }); ``` ### Response #### Success Response (200) - **data** (object) - The WebsiteAnalysis output containing isStale, desktop, mobile, and images fields. #### Response Example ```json { "data": { "isStale": false, "desktop": { "sections": [], "passed": false, "score": 0, "totalBytes": 0 }, "mobile": { "sections": [], "passed": false, "score": 0, "totalBytes": 0 }, "images": [] } } ``` #### Error Response (404) - **code** (string) - `rest_kb_optimizer_read_not_found` - **message** (string) - Error message indicating the resource was not found. ``` -------------------------------- ### GET /kb-getresponse/v1/get Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Proxies to the GetResponse provider API using stored API keys and returns the provider's payload. ```APIDOC ## GET /kb-getresponse/v1/get ### Description Proxies to the GetResponse provider API using stored API keys and returns the provider's payload. ### Method GET ### Endpoint `/kb-getresponse/v1/get` ### Parameters #### Query Parameters - **endpoint** (string) - Required - Whitelisted to `ALLOWED_ENDPOINTS = ['campaigns','tags','custom-fields']`. ### Response #### Success Response (200) - **provider payload** (object) - The response from the GetResponse API. ``` -------------------------------- ### GET /kbp/v1/post-query Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Query posts for the Posts block. Returns a JSON array of post objects with various fields. ```APIDOC ## GET /kbp/v1/post-query ### Description Query posts for the Posts block. Returns a JSON array of post objects with various fields. ### Method GET ### Endpoint /kbp/v1/post-query ### Parameters #### Query Parameters - **query** (string) - Optional - `'individual'`, `'individual-ordered'`, or any other value → standard query. - **type** (string) - Optional - Post type (validated against `get_allowed_post_types()`). - **multiple** (bool) - Optional - When true, `type_array` is used (commented out in schema but read). - **type_array** (array) - Optional - Post types array. - **include** (array) - Optional - Post IDs to include. - **per_page** (number) - Optional - Default `25`, max 100 (`sanitize_post_perpage`). - **order** (string) - Optional - Query order. - **order_by** (string) - Optional - Query orderby. - **allow_sticky** (bool) - Optional - Sticky allowed (sanitized to `0`/`1`, inverted). - **exclude** (string) - Optional - `'exclude'` → `NOT IN`. - **offset** (number) - Optional - Default `0`. - **post_id** (string) - Optional - Current post ID excluded from results (numeric check). - **custom_tax** (bool) - Optional - Use custom taxonomy. - **tax_type** (string) - Optional - Taxonomy slug. - **category** (string) - Optional - CSV of category IDs (`wp_parse_id_list`). - **tags** (string) - Optional - CSV of tag IDs. ### Request Example ```js const posts = await wp.apiFetch({ path: '/kbp/v1/post-query?type=post&query=standard&per_page=10&order=desc&order_by=date', }); ``` ### Response #### Success Response (200) - **id** (number) - Post ID. - **date** (string) - Post date. - **date_gmt** (string) - Post date GMT. - **modified** (string) - Post modified date. - **modified_gmt** (string) - Post modified date GMT. - **title** (object) - Contains `raw` and `rendered`. - **excerpt** (object) - Contains `raw` and `rendered`. - **type** (string) - Post type. - **slug** (string) - Post slug. - **status** (string) - Post status. - **link** (string) - Post link. - **author** (number) - Author ID. - **featured_media** (number) - Featured media ID. - **featured_image_src_large** (string) - Featured image URL (large). - **author_info** (object) - Contains `display_name` and `author_link`. - **comment_info** (mixed) - Comment info. - **category_info** (mixed) - Category info. - **tag_info** (mixed) - Tag info. - **taxonomy_info** (object) - Object with taxonomy slug keys, each containing an array of `{value, label}` objects. - **kt_archive_item_category_color** (string) - Only when Kadence theme is active. #### Response Example ```json [ { "id": 1, "date": "2023-01-01T00:00:00", "date_gmt": "2023-01-01T00:00:00", "modified": "2023-01-01T00:00:00", "modified_gmt": "2023-01-01T00:00:00", "title": {"raw": "", "rendered": ""}, "excerpt": {"raw": "", "rendered": ""}, "type": "post", "slug": "", "status": "publish", "link": "", "author": 1, "featured_media": 0, "featured_image_src_large": "", "author_info": {"display_name": "", "author_link": ""}, "comment_info": null, "category_info": null, "tag_info": null, "taxonomy_info": {} } ] ``` ### Errors - **403** - Permission callback fails (`current_user_can('edit_posts')` fails). - **false** - When `query` is empty (bail). ``` -------------------------------- ### GET /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-rest.md Retrieves optimizer data for a specific post. This endpoint returns the stored performance analysis results for a given post. ```APIDOC ## GET /kb-optimizer/v1/optimize ### Description Retrieves optimizer data for a specific post. This endpoint returns the stored performance analysis results for a given post. ### Method GET ### Endpoint /kb-optimizer/v1/optimize ### Parameters #### Query Parameters - **post_id** (integer) - Required - The ID of the post to retrieve optimization data for. - **post_path** (string) - Optional - The path of the post. ### Request Example GET /kb-optimizer/v1/optimize?post_id=123 ### Response #### Success Response (200) - **post_id** (integer) - The ID of the post. - **post_path** (string) - The path of the post. - **results** (object) - The stored optimization results. #### Response Example { "post_id": 123, "post_path": "/example-post", "results": {} } ``` -------------------------------- ### Fetch posts with wp.apiFetch Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Use this snippet to query posts via the /kbp/v1/post-query endpoint. The example requests 10 posts of type 'post' in descending date order. The response is a JSON array of post objects with fields like id, title, excerpt, and featured image. ```javascript const posts = await wp.apiFetch({ path: '/kbp/v1/post-query?type=post&query=standard&per_page=10&order=desc&order_by=date', }); ``` -------------------------------- ### Basic usage of App::instance() Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/app.md Shows how to retrieve the application container and resolve a registered service. Assumes the plugin has already initialized the App. ```php use KadenceWP\KadenceBlocks\App; // Retrieve the application container: $app = App::instance(); $container = $app->container(); // Resolve any registered service: $imageDownloader = $container->get( \KadenceWP\KadenceBlocks\Image_Downloader\Image_Downloader::class ); ``` -------------------------------- ### Fetch library and connection via wp.apiFetch Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Use to fetch the library and connection data from editor code via the REST API. The REST controller uses namespace kb-design-library/v1 and rest base get. ```javascript const items = await wp.apiFetch({ path: '/kb-design-library/v1/get_library?context=edit' }); const connection = await wp.apiFetch({ path: '/kb-design-library/v1/get_connection' }); ``` -------------------------------- ### Initialize App with ContainerAdapter Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/app.md Shows how the App is initialized on plugin load from kadence_blocks_init(). Creates a new ContainerAdapter wrapping the DI52 container and passes it to App::instance(). ```php $container = new ContainerAdapter( new \KadenceWP\KadenceBlocks\lucatume\DI52\Container() ); App::instance( $container ); ``` -------------------------------- ### Build CSS with Kadence_Blocks_CSS Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/css.md Shows how to instantiate the CSS class, set a style ID and selector, add properties, and switch media states for tablet. Use this to generate CSS for a block with responsive styles. ```php $css = Kadence_Blocks_CSS::get_instance(); $css->set_style_id( 'kb-rowlayout' . $unique_id ); $css->set_selector( '.kb-rowlayout' . $unique_id ); $css->add_property( 'background-color', '#3182CE' ); $css->add_property( 'padding', '2rem 1rem' ); $css->set_media_state( 'tablet' ); $css->set_selector( '.kb-rowlayout' . $unique_id ); $css->add_property( 'padding', '1rem' ); $css->set_media_state( '' ); ``` -------------------------------- ### Create .env with BUN_AUTH_TOKEN and GITHUB_TOKEN Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Create a .env file in the plugin root with these variables. Bun reads BUN_AUTH_TOKEN for @stellarwp registry authentication; GITHUB_TOKEN authenticates github:stellarwp/... tarball fetches for @kadence/* packages. Do not commit .env. ```plaintext BUN_AUTH_TOKEN=your_token_here GITHUB_TOKEN=your_token_here ``` -------------------------------- ### Remove node_modules before migrating from npm Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Delete the existing node_modules directory before running bun install if you've previously built with npm, so Bun installs cleanly. ```bash rm -rf node_modules ``` -------------------------------- ### wp_ajax_kadence_import_get_prebuilt_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Fetches prebuilt library data. Admin only. ```APIDOC ## wp_ajax_kadence_import_get_prebuilt_data ### Description Fetches prebuilt library data. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_get_prebuilt_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### Hasher error handling example Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/cache.md Example of error handling when hashing null input. Instantiates Hasher with 'xxh128' algorithm and catches InvalidArgumentException with message '$data cannot be null.' ```php use KadenceWP\KadenceBlocks\Hasher; $hasher = new Hasher( 'xxh128' ); try { $hasher->hash( null ); } catch ( InvalidArgumentException $e ) { // '$data cannot be null.' } ``` -------------------------------- ### Basic usage via container Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/image-downloader.md Shows how to retrieve the Image_Downloader from the container and call download with a sample payload. The result is an array of id/url pairs for the downloaded images. ```php use KadenceWP\KadenceBlocks\Image_Downloader\Image_Downloader as KBImageDownloader; $downloader = kadence_blocks()->get( KBImageDownloader::class ); $result = $downloader->download( [ 'collection_slug' => 'my-page', 'image_type' => 'jpg', 'images' => [ [ 'id' => 4497891, 'width' => 1920, 'height' => 1280, 'alt' => 'Mountain landscape', 'url' => 'https://images.pexels.com/photos/4497891/pexels-photo-4497891.jpeg', 'photographer' => 'John Doe', 'photographer_url' => 'https://pexels.com/@johndoe', 'avg_color' => '#4a5a3a', 'sizes' => [ [ 'name' => 'large', 'src' => 'https://images.pexels.com/photos/4497891/pexels-photo-4497891.jpeg?w=1920' ], [ 'name' => 'medium', 'src' => 'https://images.pexels.com/photos/4497891/pexels-photo-4497891.jpeg?w=1024' ], ], ], ], ] ); // $result = [ ['id' => 123, 'url' => 'https://site/wp-content/uploads/...jpg'], ... ] ``` -------------------------------- ### wp_ajax_kadence_import_get_prebuilt_templates_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Fetches prebuilt templates data. Admin only. ```APIDOC ## wp_ajax_kadence_import_get_prebuilt_templates_data ### Description Fetches prebuilt templates data. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_get_prebuilt_templates_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### wp_ajax_kadence_import_get_prebuilt_pages_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Fetches prebuilt pages data. Admin only. ```APIDOC ## wp_ajax_kadence_import_get_prebuilt_pages_data ### Description Fetches prebuilt pages data. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_get_prebuilt_pages_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### download() method parameter and return annotations Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/image-downloader.md Shows the @param and @return annotations for the download method, including the expected image array shape and the return type. Also lists the exceptions thrown. ```php /** * @param array * }> * }> $images * * @return array * @throws ImageDownloadException * @throws Throwable */ ``` -------------------------------- ### POST /kb-lottieanimation/v1/animations Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Creates a `kadence_lottie` post from a provided Lottie animation file. ```APIDOC ## POST /kb-lottieanimation/v1/animations ### Description Creates a `kadence_lottie` post from a provided Lottie animation file. ### Method POST ### Endpoint `/kb-lottieanimation/v1/animations` ### Parameters #### Request Body - **lottieFile** (object) - Required - Must be an array and `json_encode`-able. ### Request Example ```json { "lottieFile": {} } ``` ### Response #### Success Response (200) - **post_id** (integer) - ID of the created `kadence_lottie` post. #### Error Response - **invalid_json** - Returned when the file is missing or invalid. ``` -------------------------------- ### wp_ajax_kadence_import_reload_prebuilt_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Reloads prebuilt library data. Admin only. ```APIDOC ## wp_ajax_kadence_import_reload_prebuilt_data ### Description Reloads prebuilt library data. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_reload_prebuilt_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### Kadence_Blocks_Settings class method list Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/settings.md Shows the full public API of the Kadence_Blocks_Settings singleton class, listing all methods including static get_data_options, AJAX handlers, and settings callbacks. ```php class Kadence_Blocks_Settings { public static function get_instance(); public function __construct(); public function plugin_update_message( $data, $response ); public function exit_interview_args( $default_args ); public function optin_notice_args( $default_args ); public function admin_editor_width(); public function init_post_meta(); public function load_color_palette_editor_settings( $settings ); public function load_color_palette_theme_json( $theme_json ); public function load_color_palette(); public function print_color_palette_css(); public function add_color_palette_css_to_block_editor( array $settings ); public function activation_redirect(); public static function get_data_options( $key ); public function deregister_blocks(); public function settings_user_capabilities(); public function add_network_menu(); public function add_menu(); public function scripts(); public function home_scripts(); public function load_api_settings(); public function load_settings(); public function enabled_editor_width_callback(); public function limited_margins_callback(); public function sidebar_callback(); public function nosidebar_callback(); public function post_default_callback(); public function page_default_callback(); public function load_fonts_local_callback(); public function show_headers_in_admin_bar_callback(); public function maxwidths_callback(); public function fonts_local_callback(); public function admin_bar_callback(); public function validate_options( $input ); public function show_editor_width(); public function home_page(); public function config_page(); public function admin_pro_kadence_notice(); public function blocks_array(); public function ajax_blocks_save_config(); public function ajax_blocks_activate_deactivate(); public function ajax_default_editor_width(); public function settings_link(); public function add_settings_link( $links ); } ``` -------------------------------- ### App class definition Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/app.md The full class definition of KadenceWP\KadenceBlocks\App, including the provider list and method signatures. Shows the singleton pattern and the private constructor. ```php final class App { private static self $instance; private Container $container; /** * @var class-string */ private $providers = [ Log_Provider::class, Database_Provider::class, Asset_Provider::class, Uplink_Provider::class, Harbor_Provider::class, Health_Provider::class, Admin_Provider::class, Image_Downloader_Provider::class, Optimizer_Provider::class, Cache_Provider::class, Shutdown_Provider::class, ]; private function __construct( Container $container ); private function init(): void; // binds Container + ContainerInterface as aliases, binds Dot singleton, registers each provider public static function instance( ?Container $container = null ): App; public function container(): Container; private function __clone() {} public function __wakeup(): void; // throws RuntimeException public function __sleep(): array; // throws RuntimeException } ``` -------------------------------- ### GET /kb-lottieanimation/v1/animations/{id} Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Retrieves the JSON content of a published kadence_lottie post. ```APIDOC ## GET /kb-lottieanimation/v1/animations/{id} ### Description Retrieves the JSON content of a published `kadence_lottie` post. The `id` parameter accepts alphanumeric characters and an optional trailing `.json` extension which is stripped. ### Method GET ### Endpoint /kb-lottieanimation/v1/animations/{id} ### Parameters #### Path Parameters - **id** (string) - Required - Animation ID. Regex: `[\a-zA-Z0-9]+`; trailing `.json` stripped. ### Response #### Success Response (200) Returns the post's JSON content (decoded from `post_content`). #### Response Example ```json { "v": "5.5.7", "meta": {} } ``` ### Error Handling - **404** - `not_found` when post is missing or wrong type/status. - **404** - `invalid_json` when content isn't valid JSON. ``` -------------------------------- ### POST /kb-optimizer/v1/optimize Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Creates an optimizer entry. Returns 201 on success. Possible error codes: rest_kb_optimizer_create_failed_excluded (500), rest_kb_optimizer_create_failed_not_published (500), rest_kb_optimizer_invalid_path (400), rest_kb_optimizer_create_failed (500). ```APIDOC ## POST /kb-optimizer/v1/optimize ### Description Creates an optimizer entry. Returns 201 on success. Possible error codes: rest_kb_optimizer_create_failed_excluded (500), rest_kb_optimizer_create_failed_not_published (500), rest_kb_optimizer_invalid_path (400), rest_kb_optimizer_create_failed (500). ### Method POST ### Endpoint /kb-optimizer/v1/optimize ### Parameters #### Request Body - **post_id** (number) - Required - The post ID. - **post_path** (string) - Required - The post path. - **results** (object) - Required - The optimization results. ### Response #### Success Response (201) No response body details provided. ``` -------------------------------- ### Kadence_Blocks_Prebuilt_Library class definition Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Defines the main class for managing the prebuilt library, including data access, AJAX callbacks, import pipeline, and filesystem/cron methods. The constant CLEANUP_FREQUENCY is set to 'monthly'. ```php class Kadence_Blocks_Prebuilt_Library { const CLEANUP_FREQUENCY = 'monthly'; public static function get_instance(); public function __construct(); // Data access public function get_section_prebuilt_data( $pro_data ); public function get_page_prebuilt_data( $pro_data ); public function get_only_local_template_data( $skip_local = false ); public function get_template_data( $skip_local = false ); public function get_data(); public function get_local_template_data_contents(); public function get_remote_url_contents(); public function local_file_exists(); public function get_local_template_data_path(); public function get_local_template_data_filename(); public function get_connection_data( $skip_local = false ); // AJAX callbacks public function prebuilt_data_ajax_callback(); public function prebuilt_data_reload_ajax_callback(); public function prebuilt_connection_info_ajax_callback(); public function prebuilt_templates_data_ajax_callback(); public function prebuilt_templates_data_reload_ajax_callback(); public function prebuilt_pages_data_ajax_callback(); public function prebuilt_pages_data_reload_ajax_callback(); public function process_data_ajax_callback(); public function process_image_data_ajax_callback(); public function process_pattern_ajax_callback(); public function process_subscribe_ajax_callback(); // Import pipeline public function process_image_content( $content = '', $image_library = '' ); public function process_pattern_content( $content = '' ); public function process_content( $content = '', $import_library = '', $import_type = '', $import_id = '', $import_style = '' ); public function import_image( $image_data ); public function check_for_local_image( $image_data ); public function check_for_image( $link = '' ); public function get_image_info( $images, $target_src ); public function process_individual_import( $content, $import_library, $import_type, $import_id, $import_style ); public function get_importer_files( $slug, $type ); // Filesystem/cron public function schedule_cleanup(); public function add_monthly_to_cron_schedule( $schedules ); public function delete_block_library_folder(); public function get_old_block_library_folder(); public function get_block_library_folder(); public function get_subfolder_name(); public function get_base_path(); public function get_base_url(); } ``` -------------------------------- ### Run production build with bun run build Source: https://github.com/stellarwp/kadence-blocks/blob/master/CONTRIBUTING.md Runs a one-off production build (wp-scripts build + gulp build). ```bash bun run build ``` -------------------------------- ### wp_ajax_kadence_import_process_data Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Processes prebuilt data import. Admin only. ```APIDOC ## wp_ajax_kadence_import_process_data ### Description Processes prebuilt data import. Admin only. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Query Parameters - **action** (string) - Required - Set to `kadence_import_process_data`. ### Response #### Success Response (200) - Response body as defined by the handler. ``` -------------------------------- ### kadence_blocks_get_asset_file() function Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/helper-functions.md Loads the generated asset file for a given relative path (without .asset.php suffix) and returns its dependencies and version. Falls back to a default dependency list and KADENCE_BLOCKS_VERSION if the file does not exist. ```php function kadence_blocks_get_asset_file( $filepath ) { $asset_path = KADENCE_BLOCKS_PATH . $filepath . '.asset.php'; return file_exists( $asset_path ) ? include $asset_path : [ 'dependencies' => [ 'lodash', 'react', 'react-dom', 'wp-block-editor', 'wp-blocks', 'wp-data', 'wp-element', 'wp-i18n', 'wp-polyfill', 'wp-primitives', 'wp-api' ], 'version' => KADENCE_BLOCKS_VERSION, ]; } ``` -------------------------------- ### GET /kb-mailerlite/v1/get Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Proxies to the MailerLite provider API using stored API keys and returns the provider's payload. ```APIDOC ## GET /kb-mailerlite/v1/get ### Description Proxies to the MailerLite provider API using stored API keys and returns the provider's payload. ### Method GET ### Endpoint `/kb-mailerlite/v1/get` ### Parameters #### Query Parameters - **queryargs** (string) - Required - Query arguments for the MailerLite API. ### Response #### Success Response (200) - **provider payload** (object) - The response from the MailerLite API. ``` -------------------------------- ### POST /kb-design-library/v1/handle_event Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/prebuilt-library.md Handles AI events. ```APIDOC ## POST /kb-design-library/v1/handle_event ### Description Handles AI events. ### Method POST ### Endpoint `/kb-design-library/v1/handle_event` ### Authentication Requires `edit_posts` capability. ### Response Returns the event handling result. ``` -------------------------------- ### Hash_Store class Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/optimizer-core.md Defines the Hash_Store class backed by Viewport_Query, providing methods to get, set, and delete hashes for a path and viewport. ```php final class Hash_Store { public function get( Path $path, Viewport $vp ): ?string; public function set( Path $path, Viewport $vp, string $hash ): bool; public function delete( Path $path, Viewport $vp ): bool; } ``` -------------------------------- ### Asset::enqueue_script( string $name, string $path, string $ext = 'js' ): void Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/api-reference/asset.md Enqueues a script in the footer with dependencies and version from the asset meta file. ```APIDOC ## Asset::enqueue_script( string $name, string $path, string $ext = 'js' ): void ### Description Enqueues a script in the footer with dependencies and version from the asset meta file. ### Method enqueue_script ### Parameters - `$name` (string) - Required - Script handle. - `$path` (string) - Required - Relative path to the script, without extension, e.g. `build/settings`. - `$ext` (string) - Optional - Default: `'js'` - File extension without a period. ### Return void ``` -------------------------------- ### POST /wp/v2/kadence_navigation/auto-draft Source: https://github.com/stellarwp/kadence-blocks/blob/master/_autodocs/endpoints.md Creates an auto-draft for the kadence_navigation CPT. Uses standard CPT capabilities and returns the item in context=edit. ```APIDOC ## POST /wp/v2/kadence_navigation/auto-draft ### Description Creates an auto-draft for the kadence_navigation CPT. Uses standard CPT capabilities and returns the item in context=edit. ### Method POST ### Endpoint /wp/v2/kadence_navigation/auto-draft ### Parameters No parameters documented. ### Response #### Success Response (200) No response body details provided. ```