### Action Run Method - Success Example Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md The run method is called on form submission. This example shows a successful response after logging submission data to a file. ```php /** * Log the form submission to a file * * @param array $form * @param array $settings * @param array $extra * @return array success or error message */ public function run($form, $settings, $extra) { try { $this->writeToFile($extra['formId'], $extra['fields']); } catch(Exception $e) { return ['type' => 'error', 'message' => $e->getMessage()]; } return ['type' => 'success', 'message' => 'Submission logged to file']; } ``` -------------------------------- ### Action Run Method - Success Response Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md Example of a success response from the run method, indicating the form submission was processed correctly. ```php public function run($form, $settings, $extra) { ... return ['type' => 'success', 'message' => 'Submission logged to file']; } ``` -------------------------------- ### Action Run Method - Error Response Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md Example of an error response from the run method, returning an error type and message if an exception occurs during processing. ```php public function run($form, $settings, $extra) { ... return ['type' => 'error', 'message' => 'Could not write to file']; } ``` -------------------------------- ### Register Multiple Instances of a Dynamic Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md This script registers multiple instances of the `MyDynamicField` class. It iterates through an array of field configurations, creating a new `MyDynamicField` object for each and registering it using `Breakdance\DynamicData\registerField`. Ensure Breakdance is installed and available before registering. ```php // register-fields.php included by your plugin add_action('init', function() { // fail if Breakdance is not installed and available if (!function_exists('\Breakdance\DynamicData\registerField') || !class_exists('\Breakdance\DynamicData\Field')) { return; } require_once('my-dynamic-field.php'); $myFields = [[ 'label' => 'My Field One', 'slug' => 'my_field_slug_one', 'group' => 'My Plugin', ],[ 'label' => 'My Field Two', 'slug' => 'my_field_slug_two', 'group' => 'My Plugin', ]]; // loop through fields array and register fields foreach ($myFields as $fieldData) { \Breakdance\DynamicData\registerField(new MyField($fieldData)); } }); ``` -------------------------------- ### Register Element Display Condition Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/conditions/readme.md Register a custom condition for controlling element visibility. This example shows how to define a condition with a dropdown of selectable values and a callback function to evaluate the condition. ```php add_action( 'breakdance_register_template_types_and_conditions', function() { \Breakdance\ConditionsAPI\register( [ 'supports' => ['element_display'], 'slug' => 'unique-prefix-my-condition', // MUST BE UNIQUE 'label' => 'My Condition', 'category' => 'My Category', 'operands' => ['equals', 'not equals'], // providing a dropdown of values is optional. if 'values' is not provided, a text input will be provided instead of a dropdown 'values' => function() { return [ [ 'label' => 'Item Group Title', 'items' => [ [ 'text' => 'Item 1', 'value' => 'item-1' ], [ 'text' => 'Item 2', 'value' => 'item-2' ] ] ], [ 'label' => 'Item Group Title 2', 'items' => [ [ 'text' => 'Another Item', 'value' => 'another-item' ], [ 'text' => 'Different Item', 'value' => 'different-item' ] ] ] ]; }, /* when specifying possible values for a dropdown, you can optionally make the dropdown a multiselect */ 'allowMultiselect' => true, /* this function will be called to evaluate the condition if it returns true, the element will be shown if it returns false, the element will be hidden */ 'callback' => function(string $operand, $value) { $myVal = 'item-1'; // usually, you'd get $myVal from somewhere, i.e. global $post; $myVal = $post->ID; /* if allowMultiselect is false, $value will be a string. use it like so: if ($operand === 'equals') { return $myVal === $value; } if ($operand === 'not equals') { return $myVal !== $value; } */ /* in our example, allowMultiselect is true, which means $value will be an array of strings */ if ($operand === 'equals') { return in_array($myVal, $value); } if ($operand === 'not equals') { return !in_array($myVal, $value); } return false; }, ] ); } ); ``` -------------------------------- ### Access Breakdance Menu Instance Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Get the Breakdance Menu instance from its HTMLElement after the page has loaded. This is the entry point for interacting with the menu's API. ```javascript const menu = document.querySelector('.breakdance-menu').bdMenu; ``` -------------------------------- ### Append Dependencies with breakdance_append_dependencies Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md The `breakdance_append_dependencies` filter allows you to modify or remove dependencies that will be appended to the document. The example logs the dependencies. ```php add_filter("breakdance_append_dependencies", function ($dependenciesToAppend) { // you could use this to modify or remove dependencies echo "
";
    print_r($dependenciesToAppend);
    echo "
"; return $dependenciesToAppend; }); ``` -------------------------------- ### Get Currently Open Dropdown API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Retrieves the currently open dropdown element. Returns null if no dropdown is active. ```typescript getOpenDropdown() => DropdownElement | null ``` -------------------------------- ### Modify Query Builder Input with breakdance_query_builder_input_query Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md The `breakdance_query_builder_input_query` filter allows modification of the query builder input. This example demonstrates enabling FacetWP for custom queries, handling both string and array query formats. ```php add_filter('breakdance_query_builder_input_query', '\Breakdance\Integrations\FacetWp\enableFacetWpForCustomQueries'); function enableFacetWpForCustomQueries($query) { if (is_string($query)) { return $query . "&facetwp=true"; } else { $query['facetwp'] = true; return $query; } } ``` -------------------------------- ### Register or Filter Fonts with breakdance_register_font Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md Use the `breakdance_register_font` filter to control which fonts are registered within Breakdance. This example shows how to disable all Google Fonts. ```php add_filter("breakdance_register_font", function ($font) { // disable all Google Fonts $isGoogleFont = !!$font['dependencies']['googleFonts']; if ($isGoogleFont) { return false; } return $font; }); ``` -------------------------------- ### Modify Element Classnames with breakdance_element_classnames_for_html_class_attribute Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md Use the `breakdance_element_classnames_for_html_class_attribute` filter to add custom class names to the HTML class attribute of elements. This example adds 'another-class'. ```php add_filter("breakdance_element_classnames_for_html_class_attribute", function ($classNames) { $classNames[] = 'another-class'; return $classNames; }); ``` -------------------------------- ### Register Custom Dynamic Data Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Register a custom dynamic data field class with Breakdance. It's recommended to call this from within a WordPress 'init' action to avoid file loading race conditions. Ensure Breakdance is installed and the necessary functions/classes exist before attempting registration. ```php add_action('init', function() { // Check if Breakdance is installed and class/function exists if (!function_exists('\Breakdance\DynamicData\registerField') || !class_exists('\Breakdance\DynamicData\Field')) { return; } \Breakdance\DynamicData\registerField(new MyField()); }) ``` -------------------------------- ### Hook: breakdance_form_start Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/forms.md Use this hook to add content before the form begins. It receives form settings as an argument. ```php add_action('breakdance_form_start', function ($settings) { echo "

{$settings['form']['form_name']}

"; }); ``` -------------------------------- ### Replay Animations on the Entire Website Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/animations/readme.md Dispatch a global event to replay entrance animations across the entire website. This is useful for re-engaging all animations simultaneously. ```javascript const event = new Event("breakdance_play_animations", { bubbles: true }); document.dispatchEvent(event); ``` -------------------------------- ### isDesktop Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is currently displaying its desktop version. ```APIDOC ## isDesktop ### Description Determines if the menu is currently displaying its desktop version. ### Method JavaScript Method ### Response #### Success Response (200) - **boolean** - True if the menu is in desktop view, false otherwise. ``` -------------------------------- ### Create a Custom Oembed Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Implement a custom OembedField for video content. The handler must return an OembedData object with at least $embedUrl, $type, and $provider properties. ```php use Breakdance\DynamicData\OembedField; use Breakdance\DynamicData\OembedData; class MyDynamicField extends OembedField { /** * @return string */ public function label() { return 'Dynamic Video'; } /** * @return string */ public function category() { return 'My Plugin'; } /** * @return string */ public function slug() { return 'my_plugin_video'; } /** * @param array $attributes */ public function handler($attributes): OembedData { // retrieve the video from your plugin or application $videoData = get_the_video_data(); // create a new OembedData object $oembedData = new OembedData; $oembedData->title = $videoData['title']; $oembedData->provider = 'video'; $oembedData->embedUrl = $videoData['url']; $oembedData->thumbnail = $videoData['thumbnail']; $oembedData->format = 'video/mp4'; $oembedData->type = 'video'; // or using the helper $oembedData = OembedData::fromOembedUrl('https://www.youtube.com/watch?v=dQw4w9WgXcQ'); return $oembedData; } } ``` -------------------------------- ### Replay Animations on a Specific Element Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/animations/readme.md Use this to replay entrance animations on a single, specific element. Ensure the element is queryable and exists in the DOM. ```javascript const panel = document.querySelector('.bde-accordion__panel'); const event = new Event("breakdance_play_animations", { bubbles: true }); panel.dispatchEvent(event); ``` -------------------------------- ### Check Desktop View API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is currently displaying its desktop version. ```typescript isDesktop() => boolean ``` -------------------------------- ### Use OpenRouter with Claude 3.5 Sonnet Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/ai-endpoints.md Configure Breakdance AI to use a specific model from an alternative provider like OpenRouter. Ensure the model string is correct and that you have the necessary credits with the provider. ```php function override_breakdance_ai_model($model_version, $model) { $model_version = 'anthropic/claude-3.5-sonnet'; return $model_version; } add_filter('breakdance_ai_model', 'override_breakdance_ai_model', 10, 2); ``` -------------------------------- ### Create a Custom Gallery Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Implement a custom GalleryField to return multiple images for slideshows or galleries. Ensure the handler returns a GalleryData object with an array of ImageData objects. ```php use Breakdance\DynamicData\GalleryField; use Breakdance\DynamicData\GalleryData; class MyDynamicField extends GalleryField { /** * @return string */ public function label() { return 'Dynamic Gallery'; } /** * @return string */ public function category() { return 'My Plugin'; } /** * @return string */ public function slug() { return 'my_plugin_gallery'; } /** * @param array $attributes */ public function handler($attributes): GalleryData { // fetch IDs for images attached to the current post $attachedImages = get_attached_media('image', get_the_ID()); $gallery = new GalleryData(); // map WordPress attachments to ImageData $gallery->images = array_map(static function($attachment) { return ImageData::fromAttachmentId($attachment->ID); }, $attachedImages); return $gallery; } } ``` -------------------------------- ### Control Dropdown Menus Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Use the menu instance to open, close, or close all dropdown menus. Ensure the correct HTMLElement for the dropdown is passed to the respective methods. ```javascript const dropdown = document.querySelector('.bde-menu-dropdown-72-105 .breakdance-dropdown'); menu.openDropdown(dropdown); menu.closeDropdown(dropdown); menu.closeAll(); ``` -------------------------------- ### Register a New Reusable Dependency Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/reusable-dependencies/readme.md Use the 'breakdance_reusable_dependencies_urls' action hook to register a new reusable dependency with a specific script URL. Replace 'bootstrap' with your desired dependency name. ```php add_action('breakdance_reusable_dependencies_urls', function ($urls) { $urls['bootstrap'] = 'https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.2.3/js/bootstrap.min.js'; return $urls; }); ``` -------------------------------- ### Implement Field Label Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The label method must return a string to identify the field in the Dynamic Data Field selection window. ```php /** * @return string */ public function label() { return 'My Dynamic Field'; } ``` -------------------------------- ### Action Name Method Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md Implement the name method to return a string identifying the action in the Form Builder. ```php /** * @return string */ public function name() { return 'My Action'; } ``` -------------------------------- ### Registering a Form Action Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md Register a custom action class with Breakdance using the registerAction helper, preferably within a WordPress init action to avoid race conditions. ```php // register-actions.php included by your plugin add_action('init', function() { // fail if Breakdance is not installed and available if (!function_exists('\Breakdance\Forms\Actions\registerAction') || !class_exists('\Breakdance\Forms\Actions\Action')) { return; } require_once('my-action.php'); \Breakdance\Forms\Actions\registerAction(new MyAction()); }); ``` -------------------------------- ### Action Slug Method Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/form-actions/readme.md Implement the slug method to return a unique string identifier for the form action, recommended to be prefixed. ```php /** * @return string */ public function slug() { return 'my_plugin_form_action'; } ``` -------------------------------- ### Implement Unique Field Slug Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The slug method must return a unique string to identify the field handler for output. Prefixing the slug is recommended. ```php /** * @return string */ public function slug() { return 'my_plugin_field'; } ``` -------------------------------- ### openDropdown Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Opens a specific dropdown menu. It closes all other dropdowns except the one specified. This method works on both desktop and mobile views. ```APIDOC ## openDropdown ### Description Opens a specific dropdown menu. It closes all other dropdowns except the one specified. This method works on both desktop and mobile views. ### Method JavaScript Method ### Parameters #### Path Parameters - **node** (HTMLElement) - Required - The dropdown element to open. ### Response #### Success Response This method does not return a value. ``` -------------------------------- ### Hook: breakdance_form_before_footer Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/forms.md Use this hook to inject content just before the form's footer section. It receives the form settings. ```php add_action('breakdance_form_before_footer', function ($settings) { echo '
'; }); ``` -------------------------------- ### Implement Field Category Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The category method must return a string to group the fields in the Dynamic Data Field selection window. ```php /** * @return string */ public function category() { return 'My Plugin'; } ``` -------------------------------- ### isVertical Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is configured to be displayed vertically. ```APIDOC ## isVertical ### Description Determines if the menu is configured to be displayed vertically. ### Method JavaScript Method ### Response #### Success Response (200) - **boolean** - True if the menu is displayed vertically, false otherwise. ``` -------------------------------- ### Toggle Mobile Menu API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Toggles the mobile menu's visibility. The returned promise resolves upon completion of the animation. ```typescript toggleMobileMenu() => Promise ``` -------------------------------- ### Create a Custom String Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Extends StringField to create a custom dynamic string data field. Implement label, category, slug, and handler methods. The handler must return a StringData object. ```php use Breakdance\DynamicData\StringField; use Breakdance\DynamicData\StringData; class MyDynamicField extends StringField { /** * @return string */ public function label() { return 'Dynamic String'; } /** * @return string */ public function category() { return 'My Plugin'; } /** * @return string */ public function slug() { return 'my_plugin_string'; } /** * array $attributes */ public function handler($attributes): StringData { return StringData::fromString('some string value'); } } ``` -------------------------------- ### Define a Reusable Dynamic Field Class Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Create a custom field class extending `StringField`. This class defines the behavior and metadata for a dynamic field. It uses `$fieldData` to customize properties like label, slug, and group for each instance. ```php // MyDynamicField.php use Breakdance\DynamicData\StringField; use Breakdance\DynamicData\StringData; class MyDynamicField extends \Breakdance\DynamicData\StringField { protected array $fieldData; /** *@return string */ public function __construct($fieldData) { $this->fieldData = $fieldData; } /** * @return string */ public function label() { return $this->fieldData['label']; } /** * @return string */ public function category() { return 'My Plugin'; } /** * @return string */ public function subcategory() { return $this->fieldData['group']; } /** * @return string */ public function slug() { return 'my_plugin_field_' . $this->fieldData['slug']; } /** * @return string */ public function handler($attributes): StringData { $value = (string) get_the_field_value($this->fieldData['slug']); return StringData::fromString($value); } } ``` -------------------------------- ### Check Mobile View API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is currently displaying its mobile version. ```typescript isMobile() => boolean ``` -------------------------------- ### Implement Optional Subcategory Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The subcategory method can be implemented to further group dynamic fields within the dialog. ```php /** *@return string */ public function subcategory() { return 'My dynamic field subcategory'; } ``` -------------------------------- ### Create a Custom Image Field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md Extends ImageField to create a custom dynamic image data field. The handler must return an ImageData object with required properties like url and sizes. ```php use Breakdance\DynamicData\ImageField; use Breakdance\DynamicData\ImageData; class MyDynamicField extends ImageField { /** * @return string */ public function label() { return 'Dynamic Image'; } /** * @return string */ public function category() { return 'My Plugin'; } /** * @return string */ public function slug() { return 'my_plugin_image'; } /** * @param array $attributes */ public function handler($attributes): ImageData { // build from attachment data $attachmentData = wp_prepare_attachment_for_js($attachmentId); $imageData = new ImageData; $imageData->id = (string) $attachmentData['id']; $imageData->filename = $attachmentData['filename']; $imageData->alt = $attachmentData['alt']; $imageData->caption = $attachmentData['caption']; $imageData->url = $attachmentData['url']; $imageData->type = $attachmentData['type']; $imageData->mime = $attachmentData['mime']; $imageData->sizes = $attachmentData['sizes']; // or using the helper $imageData = ImageData::fromAttachmentId($attachmentId); return $imageData; } } ``` -------------------------------- ### Implement Field Handler Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The handler method accepts an array of attributes and returns a data object matching the parent field type. ```php /** * @param array $attributes */ public function handler($attributes): StringData { return StringData::fromString('My Dynamic Field Output'); } ``` -------------------------------- ### Toggle Mobile Menu Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Toggle the visibility of the mobile menu. This action returns a promise that resolves when the animation is complete. ```javascript menu.toggleMobileMenu(); ``` -------------------------------- ### Implement Return Types Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/dynamic-data/readme.md The returnTypes method determines which elements will display in the dialog for the selected element. It should return an array of strings. ```php /** *@return string */ public function returnTypes() { return ['string']; } ``` -------------------------------- ### isMobile Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is currently displaying its mobile version. ```APIDOC ## isMobile ### Description Determines if the menu is currently displaying its mobile version. ### Method JavaScript Method ### Response #### Success Response (200) - **boolean** - True if the menu is in mobile view, false otherwise. ``` -------------------------------- ### getOpenDropdown Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Retrieves the currently open dropdown element. Returns null if no dropdown is currently open. ```APIDOC ## getOpenDropdown ### Description Retrieves the currently open dropdown element. Returns null if no dropdown is currently open. ### Method JavaScript Method ### Response #### Success Response (200) - **DropdownElement** (HTMLElement | null) - The currently open dropdown element, or null if none is open. ``` -------------------------------- ### closeAll Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Closes all currently open dropdown menus associated with the Breakdance Menu instance. ```APIDOC ## closeAll ### Description Closes all currently open dropdown menus associated with the Breakdance Menu instance. ### Method JavaScript Method ### Response #### Success Response This method does not return a value. ``` -------------------------------- ### Open Dropdown API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Opens a specific dropdown menu. This method also ensures all other dropdowns are closed. It is effective on both desktop and mobile views. ```typescript openDropdown(node: HTMLElement) ``` -------------------------------- ### Change OpenAI Model to gpt-4 Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/ai-endpoints.md Use the `breakdance_ai_model` filter to specify a different OpenAI model. This filter allows you to override the default model version. ```php function override_breakdance_ai_model($model_version, $model) { return 'gpt-4'; } add_filter('breakdance_ai_model', 'override_breakdance_ai_model', 10, 2); ``` -------------------------------- ### Reset Entrance Animations Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/animations/readme.md Reset entrance animations to their initial hidden state for a specific element. This allows animations to play again when the element re-enters the viewport. ```javascript const panel = document.querySelector('.bde-accordion__panel'); const event = new Event("breakdance_reset_animations", { bubbles: true }); panel.dispatchEvent(event); ``` -------------------------------- ### Perform Actions After Saving with breakdance_after_save_document Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md The `breakdance_after_save_document` action hook is triggered after a post or document has been successfully saved in Breakdance. It provides the post ID. ```php add_action("breakdance_after_save_document", function ($postId) { // the save button in Breakdance was clicked and the post was saved }); ``` -------------------------------- ### toggleMobileMenu Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Toggles the visibility of the mobile menu. This method returns a Promise that resolves once the mobile menu animation has completed. ```APIDOC ## toggleMobileMenu ### Description Toggles the visibility of the mobile menu. This method returns a Promise that resolves once the mobile menu animation has completed. ### Method JavaScript Method ### Response #### Success Response - **Promise** - A promise that resolves when the animation is finished. ``` -------------------------------- ### Check Vertical Display API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Determines if the menu is configured to be displayed vertically. ```typescript isVertical() => boolean ``` -------------------------------- ### Set OpenRouter API Endpoint Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/ai-endpoints.md Use the `breakdance_ai_api_endpoint` filter to change the AI provider's URL. This is necessary when using services like OpenRouter instead of the default OpenAI endpoint. ```php function override_breakdance_ai_endpoint($url) { $url = 'https://openrouter.ai/api'; return $url; } add_filter('breakdance_ai_api_endpoint', 'override_breakdance_ai_endpoint'); ``` -------------------------------- ### Hook: breakdance_form_before_field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/forms.md Insert content immediately before a form field is rendered. This hook receives the field data and form settings. ```php add_action('breakdance_form_before_field', function ($field, $settings) { echo 'The field below is ' . ($field['advanced']['required'] ? '' : 'not') . ' required.'; }, 10, 2); ``` -------------------------------- ### Hook: breakdance_form_end Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/forms.md Add content at the very end of the form. This hook is passed the form settings. ```php add_action('breakdance_form_end', function ($settings) { echo '
By submitting this form you agree to the terms of service.
'; }); ``` -------------------------------- ### Filter Singular Content with breakdance_singular_content Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/other.md Use the `breakdance_singular_content` filter to modify the content before it's rendered. This can be used for conditional display or authorization checks. ```php add_filter("breakdance_singular_content", function ($content) { if ($something) { return $content; } else { return "not authorized"; } }); ``` -------------------------------- ### Add Custom Shape Divider Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/shape-dividers.md Use the 'breakdance_shape_dividers' filter to add your own custom SVG shape dividers. The SVG content should be loaded from a file. ```php add_filter('breakdance_shape_dividers', function ($dividers) { $myDivider = [ 'text' => 'My Divider', 'value' => file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . "my-divider.svg") ]; $dividers[] = $myDivider; return $dividers; }); ``` -------------------------------- ### refreshDropdowns Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Refreshes all dropdown menus. This action recalculates the width of the open dropdown and aligns each dropdown element with the menu's container. ```APIDOC ## refreshDropdowns ### Description Refreshes all dropdown menus. This action recalculates the width of the open dropdown and aligns each dropdown element with the menu's container. ### Method JavaScript Method ### Response #### Success Response This method does not return a value. ``` -------------------------------- ### Refresh Dropdowns API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Recalculates dropdown widths and aligns them with the menu container. This ensures proper display and positioning of all dropdowns. ```typescript refreshDropdowns() ``` -------------------------------- ### Hook: breakdance_form_after_field Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/forms.md Add content directly after a form field has been rendered. It provides access to field details and form settings. ```php add_action('breakdance_form_after_field', function ($field, $settings) { echo "Type: {$field['type']} / ID: {$field['advanced']['id']}"; }, 10, 2); ``` -------------------------------- ### Close All Dropdowns API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Closes all currently open dropdown menus simultaneously. ```typescript closeAll() ``` -------------------------------- ### Change GSAP Version Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/reusable-dependencies/readme.md Modify the global GSAP version loaded by Breakdance by updating the script URL in the 'breakdance_reusable_dependencies_urls' hook. Ensure ScrollTrigger version is also updated to match. ```php add_action('breakdance_reusable_dependencies_urls', function ($urls) { $urls['gsap'] = 'https://cdnjs.cloudflare.com/ajax/libs/gsap/3.8.0/gsap.min.js'; return $urls; }); ``` -------------------------------- ### Close Dropdown API Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Closes a specific dropdown menu. This method accepts an HTMLElement and works across different screen sizes, including mobile. ```typescript closeDropdown(node: HTMLElement) ``` -------------------------------- ### closeDropdown Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/menu/readme.md Closes a specific dropdown menu. It takes an HTMLElement representing the dropdown to be closed. This method is functional on mobile as well. ```APIDOC ## closeDropdown ### Description Closes a specific dropdown menu. It takes an HTMLElement representing the dropdown to be closed. This method is functional on mobile as well. ### Method JavaScript Method ### Parameters #### Path Parameters - **node** (HTMLElement) - Required - The dropdown element to close. ### Response #### Success Response This method does not return a value. ``` -------------------------------- ### Disable Breakdance AI Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/ai-endpoints.md Use the `breakdance_ai_enabled` filter to completely disable the Breakdance AI assistant within the Breakdance interface. This hook returns `false` to disable the feature. ```php add_filter('breakdance_ai_enabled', '__return_false'); ``` -------------------------------- ### Disable Editor Saving for Specific Users Source: https://github.com/soflyy/breakdance-developer-docs/blob/master/hooks/editor-save-actions.md This PHP snippet demonstrates how to disable saving of global settings, design presets, custom selectors, and AI settings in the Breakdance editor for all users except those with a specific user ID. It uses the `get_current_user_id()` function to check the user's ID and returns `false` to prevent saving if the ID does not match the allowed ID. ```php function disable_saving_for_other_users($allow_save) { $user_id = get_current_user_id(); // Get the current user's ID if ($user_id != 69420) { return false; // Disable saving if the user ID is not 69420 } return $allow_save; // Allow saving otherwise } // Apply the filter to each saving function add_filter('breakdance_save_global_settings', 'disable_saving_for_other_users'); add_filter('breakdance_save_presets', 'disable_saving_for_other_users'); add_filter('breakdance_save_selectors', 'disable_saving_for_other_users'); add_filter('breakdance_save_ai_settings', 'disable_saving_for_other_users'); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.