This commit is contained in:
2026-07-02 15:54:39 -06:00
commit 9883323161
17470 changed files with 4470592 additions and 0 deletions
@@ -0,0 +1,61 @@
<?php
/**
* Handles the Tab Item block.
*
* @package GenerateBlocksPro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Tabs menu block class.
*/
class GenerateBlocks_Block_Tab_Item extends GenerateBlocks_Block {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
protected static $block_ids = [];
/**
* Store our block name.
*
* @var string $block_name The block name.
*/
public static $block_name = 'generateblocks-pro/tab-item';
/**
* Render the Element block.
*
* @param array $attributes The block attributes.
* @param string $block_content The block content.
* @param array $block The block.
*/
public static function render_block( $attributes, $block_content, $block ) {
// Add styles to this block if needed.
$block_content = generateblocks_maybe_add_block_css(
$block_content,
[
'class_name' => __CLASS__,
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);
if ( $attributes['tabItemOpen'] ) {
$processor = class_exists( 'WP_HTML_Tag_Processor' )
? new WP_HTML_Tag_Processor( $block_content )
: false;
if ( $processor && $processor->next_tag( $attributes['tagName'] ?? 'div' ) ) {
$processor->add_class( 'gb-tabs__item-open' );
$block_content = $processor->get_updated_html();
}
}
return $block_content;
}
}
@@ -0,0 +1,50 @@
<?php
/**
* Handles the Tab Items block.
*
* @package GenerateBlocksPro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Tabs menu block class.
*/
class GenerateBlocks_Block_Tab_Items extends GenerateBlocks_Block {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
protected static $block_ids = [];
/**
* Store our block name.
*
* @var string $block_name The block name.
*/
public static $block_name = 'generateblocks-pro/tab-items';
/**
* Render the Element block.
*
* @param array $attributes The block attributes.
* @param string $block_content The block content.
* @param array $block The block.
*/
public static function render_block( $attributes, $block_content, $block ) {
// Add styles to this block if needed.
$block_content = generateblocks_maybe_add_block_css(
$block_content,
[
'class_name' => __CLASS__,
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);
return $block_content;
}
}
@@ -0,0 +1,82 @@
<?php
/**
* Handles the Tab Menu Item block.
*
* @package GenerateBlocksPro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Tabs menu block class.
*/
class GenerateBlocks_Block_Tab_Menu_Item extends GenerateBlocks_Block {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
protected static $block_ids = [];
/**
* Store our block name.
*
* @var string $block_name The block name.
*/
public static $block_name = 'generateblocks-pro/tab-menu-item';
/**
* Render the Element block.
*
* @param array $attributes The block attributes.
* @param string $block_content The block content.
* @param array $block The block.
*/
public static function render_block( $attributes, $block_content, $block ) {
// Add styles to this block if needed.
$block_content = generateblocks_maybe_add_block_css(
$block_content,
[
'class_name' => __CLASS__,
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);
if ( ! class_exists( 'WP_HTML_Tag_Processor' ) ) {
return $block_content;
}
$processor = new WP_HTML_Tag_Processor( $block_content );
$tag_name = $attributes['tagName'] ?? 'div';
$main_tag = $processor->next_tag( $tag_name );
$updated_html = false;
if ( $processor && $main_tag ) {
if ( $attributes['tabItemOpen'] ) {
$processor->add_class( 'gb-block-is-current' );
$updated_html = true;
}
if ( 'div' === $tag_name ) {
if ( ! $processor->get_attribute( 'tabindex' ) ) {
$processor->set_attribute( 'tabindex', '0' );
}
if ( ! $processor->get_attribute( 'role' ) ) {
$processor->set_attribute( 'role', 'button' );
}
$updated_html = true;
}
if ( $updated_html ) {
$block_content = $processor->get_updated_html();
}
}
return $block_content;
}
}
@@ -0,0 +1,50 @@
<?php
/**
* Handles the Tabs Menu block.
*
* @package GenerateBlocksPro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Tabs menu block class.
*/
class GenerateBlocks_Block_Tabs_Menu extends GenerateBlocks_Block {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
protected static $block_ids = [];
/**
* Store our block name.
*
* @var string $block_name The block name.
*/
public static $block_name = 'generateblocks-pro/tabs-menu';
/**
* Render the Element block.
*
* @param array $attributes The block attributes.
* @param string $block_content The block content.
* @param array $block The block.
*/
public static function render_block( $attributes, $block_content, $block ) {
// Add styles to this block if needed.
$block_content = generateblocks_maybe_add_block_css(
$block_content,
[
'class_name' => __CLASS__,
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);
return $block_content;
}
}
@@ -0,0 +1,91 @@
<?php
/**
* Handles the Tabs block.
*
* @package GenerateBlocksPro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Tabs block class.
*/
class GenerateBlocks_Block_Tabs extends GenerateBlocks_Block {
/**
* Keep track of all blocks of this type on the page.
*
* @var array $block_ids The current block id.
*/
protected static $block_ids = [];
/**
* Store our block name.
*
* @var string $block_name The block name.
*/
public static $block_name = 'generateblocks-pro/tabs';
/**
* Render the Element block.
*
* @param array $attributes The block attributes.
* @param string $block_content The block content.
* @param array $block The block.
*/
public static function render_block( $attributes, $block_content, $block ) {
// Add styles to this block if needed.
$block_content = generateblocks_maybe_add_block_css(
$block_content,
[
'class_name' => __CLASS__,
'attributes' => $attributes,
'block_ids' => self::$block_ids,
]
);
if ( ! wp_style_is( 'generateblocks-tabs', 'enqueued' ) ) {
self::enqueue_style();
}
if ( ! wp_script_is( 'generateblocks-tabs', 'enqueued' ) ) {
self::enqueue_assets();
}
return $block_content;
}
/**
* Enqueue block styles.
*/
private static function enqueue_style() {
wp_enqueue_style(
'generateblocks-tabs',
GENERATEBLOCKS_PRO_DIR_URL . 'dist/blocks/tabs/tabs.css',
[],
GENERATEBLOCKS_PRO_VERSION
);
}
/**
* Enqueue block scripts.
*/
private static function enqueue_scripts() {
wp_enqueue_script(
'generateblocks-tabs',
GENERATEBLOCKS_PRO_DIR_URL . 'dist/tabs.js',
[],
GENERATEBLOCKS_PRO_VERSION,
true
);
}
/**
* Enqueue block assets.
*/
public static function enqueue_assets() {
self::enqueue_scripts();
self::enqueue_style();
}
}
@@ -0,0 +1,36 @@
<?php
/**
* Handles the accordion block.
*
* @package GenerateBlocks Pro
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
require_once 'class-tabs.php';
require_once 'class-tabs-menu.php';
require_once 'class-tab-menu-item.php';
require_once 'class-tab-items.php';
require_once 'class-tab-item.php';
add_filter( 'block_editor_settings_all', 'generateblocks_pro_tabs_block_editor_settings', 20 );
/**
* Add block editor settings for the tabs block.
*
* @param array $settings The block editor settings.
*/
function generateblocks_pro_tabs_block_editor_settings( $settings ) {
$blocks_to_reset = [
'.editor-styles-wrapper .wp-block-generateblocks-pro-tabs',
'.editor-styles-wrapper .wp-block-generateblocks-pro-tabs-menu',
'.editor-styles-wrapper .wp-block-generateblocks-pro-tab-menu-item',
'.editor-styles-wrapper .wp-block-generateblocks-pro-tab-items',
'.editor-styles-wrapper .wp-block-generateblocks-pro-tab-item',
];
$css = implode( ',', $blocks_to_reset ) . ' {max-width:unset;margin:0}';
$settings['styles'][] = [ 'css' => $css ];
return $settings;
}