feat: initial ACRIB WordPress deployment
- WordPress 6.9.4 (es_ES) with Kadence theme - Homepage: Hero, La Asociación, Pilares, Beneficios, Eventos, Miembros, Hazte Miembro, Contacto - Brand identity: #13294b navy, #a12932 burgundy, #c69c48 gold - Fonts: Raleway (headings) + Source Sans 3 (body) + Lato (UI) - Plugins: Kadence Blocks, Polylang, Contact Form 7 - Custom CSS with full brand styling and responsive layout - HTTPS enforced via wp-config.php proxy detection
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Header block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Headers container Block for desktop.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Header_Column_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'header-column';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/column/block.json',
|
||||
[
|
||||
'render_callback' => [ $this, 'render_css' ],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$css->set_selector( '.wp-block-kadence-header-column' . $unique_id );
|
||||
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
if( !empty( $block_instance->context['kadence/headerRowLayoutConfig'] ) && $block_instance->context['kadence/headerRowLayoutConfig'] === 'single' && !empty( $attributes['location'] ) && $attributes['location'] !== 'left' && $attributes['location'] !== 'tablet-left' ) {
|
||||
$content = '';
|
||||
}
|
||||
|
||||
if ( ! empty( $attributes['location'] ) && ! in_array( $attributes['location'], ['tablet-center', 'tablet-left', 'tablet-right', 'center-left', 'center', 'center-right' ] ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$classes = [ 'wp-block-kadence-header-column' ];
|
||||
|
||||
if ( ! empty( $attributes['location'] ) ) {
|
||||
$classes[] = 'wp-block-kadence-header-column-' . esc_attr( $attributes['location'] );
|
||||
|
||||
//append a fake column in tablet left and right for more consistent styling compared to desktop
|
||||
if ( $attributes['location'] == 'tablet-left' ) {
|
||||
$content .= '<div class="wp-block-kadence-header-column wp-block-kadence-header-column-center-left"></div>';
|
||||
}
|
||||
if ( $attributes['location'] == 'tablet-right' ) {
|
||||
$content = '<div class="wp-block-kadence-header-column wp-block-kadence-header-column-center-right"></div>' . $content;
|
||||
}
|
||||
}
|
||||
if ( empty( $content ) ) {
|
||||
$classes[] = 'no-content';
|
||||
if ( ! empty( $attributes['location'] ) && ( 'center' === $attributes['location'] || 'tablet-center' === $attributes['location'] ) ) {
|
||||
$classes[] = 'no-content-column-center';
|
||||
}
|
||||
}
|
||||
|
||||
return sprintf( '<div class="%1$s">%2$s</div>', esc_attr( implode( ' ', $classes ) ), $content );
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Header_Column_Block::get_instance();
|
||||
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Header block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Headers container Block for desktop.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Header_Container_Desktop_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'header-container-desktop';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/container-desktop/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$html = '';
|
||||
|
||||
$classes = array(
|
||||
'wp-block-kadence-header-desktop',
|
||||
'kb-header-container',
|
||||
);
|
||||
|
||||
$html .= '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">';
|
||||
$html .= $content;
|
||||
$html .= '</div>';
|
||||
|
||||
return $html; }
|
||||
|
||||
}
|
||||
|
||||
Kadence_Blocks_Header_Container_Desktop_Block::get_instance();
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Header block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Headers container Block for desktop.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Header_Container_Tablet_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'header-container-tablet';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/container-tablet/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$html = '';
|
||||
|
||||
$classes = array(
|
||||
'wp-block-kadence-header-tablet',
|
||||
'kb-header-container',
|
||||
);
|
||||
|
||||
$html .= '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">';
|
||||
$html .= $content;
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Kadence_Blocks_Header_Container_Tablet_Block::get_instance();
|
||||
@@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Header block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Headers container Block for desktop.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Header_Row_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'header-row';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/row/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$layout = ( ! empty( $attributes['layout'] ) ? $attributes['layout'] : 'standard' );
|
||||
$bg = $attributes['background'];
|
||||
$bg_transparent = $attributes['backgroundTransparent'];
|
||||
$sizes = array( 'Desktop', 'Tablet', 'Mobile' );
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
$this->sized_dynamic_styles( $css, $attributes, $unique_id, $size );
|
||||
}
|
||||
$css->set_media_state( 'desktop' );
|
||||
|
||||
// Min Height.
|
||||
$css->set_selector( '.wp-block-kadence-header-row.wp-block-kadence-header-row' . $unique_id . ' .kadence-header-row-inner' );
|
||||
if ( ! empty( $attributes['minHeight'] ) ) {
|
||||
$css->add_property( 'min-height', $attributes['minHeight'] . ( ! empty( $attributes['minHeightUnit'] ) ? $attributes['minHeightUnit'] : 'px' ) );
|
||||
}
|
||||
if ( $css->is_number( $attributes['minHeightTablet'] ) ) {
|
||||
$css->set_media_state( 'tablet' );
|
||||
$css->add_property( 'min-height', $attributes['minHeightTablet'] . ( ! empty( $attributes['minHeightUnit'] ) ? $attributes['minHeightUnit'] : 'px' ) );
|
||||
$css->set_media_state( 'desktop' );
|
||||
}
|
||||
if ( $css->is_number( $attributes['minHeightMobile'] ) ) {
|
||||
$css->set_media_state( 'mobile' );
|
||||
$css->add_property( 'min-height', $attributes['minHeightMobile'] . ( ! empty( $attributes['minHeightUnit'] ) ? $attributes['minHeightUnit'] : 'px' ) );
|
||||
$css->set_media_state( 'desktop' );
|
||||
}
|
||||
if ( ! empty( $attributes['maxWidth'] ) ) {
|
||||
$css->add_property( 'max-width', $attributes['maxWidth'] . ( ! empty( $attributes['maxWidthUnit'] ) ? $attributes['maxWidthUnit'] : 'px' ) );
|
||||
}
|
||||
if ( $css->is_number( $attributes['maxWidthTablet'] ) ) {
|
||||
$css->set_media_state( 'tablet' );
|
||||
$css->add_property( 'max-width', $attributes['maxWidthTablet'] . ( ! empty( $attributes['maxWidthUnit'] ) ? $attributes['maxWidthUnit'] : 'px' ) );
|
||||
$css->set_media_state( 'desktop' );
|
||||
}
|
||||
if ( $css->is_number( $attributes['maxWidthMobile'] ) ) {
|
||||
$css->set_media_state( 'mobile' );
|
||||
$css->add_property( 'max-width', $attributes['maxWidthMobile'] . ( ! empty( $attributes['maxWidthUnit'] ) ? $attributes['maxWidthUnit'] : 'px' ) );
|
||||
$css->set_media_state( 'desktop' );
|
||||
}
|
||||
// Background Variables.
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id );
|
||||
$css->render_background( $bg, $css, '--kb-header-row-bg' );
|
||||
$css->render_background( $bg, $css, '--kb-stuck-header-bg' );
|
||||
$css->render_background( $bg_transparent, $css, '--kb-transparent-header-row-bg' );
|
||||
if ( 'contained' !== $layout ) {
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id . ', .wp-block-kadence-header-row' . $unique_id . '.item-is-stuck.item-is-stuck');
|
||||
$css->render_measure_output( $attributes, 'borderRadius', 'border-radius', array(
|
||||
'desktop_key' => 'borderRadius',
|
||||
'tablet_key' => 'borderRadiusTablet',
|
||||
'mobile_key' => 'borderRadiusMobile',
|
||||
) );
|
||||
$css->render_border_styles( $attributes, 'border', false, array(
|
||||
'desktop_key' => 'border',
|
||||
'tablet_key' => 'borderTablet',
|
||||
'mobile_key' => 'borderMobile',
|
||||
) );
|
||||
}
|
||||
// Container.
|
||||
if ( 'contained' === $layout ) {
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id . ' .kadence-header-row-inner' );
|
||||
$css->render_measure_output( $attributes, 'borderRadius', 'border-radius', array(
|
||||
'desktop_key' => 'borderRadius',
|
||||
'tablet_key' => 'borderRadiusTablet',
|
||||
'mobile_key' => 'borderRadiusMobile',
|
||||
) );
|
||||
$css->render_border_styles( $attributes, 'border', false, array(
|
||||
'desktop_key' => 'border',
|
||||
'tablet_key' => 'borderTablet',
|
||||
'mobile_key' => 'borderMobile',
|
||||
) );
|
||||
}
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id . ' .kadence-header-row-inner' );
|
||||
$css->render_measure_output( $attributes, 'padding', 'padding', array(
|
||||
'desktop_key' => 'padding',
|
||||
'tablet_key' => 'paddingTablet',
|
||||
'mobile_key' => 'paddingMobile',
|
||||
'unit_key' => 'paddingUnit'
|
||||
) );
|
||||
$css->render_measure_output( $attributes, 'margin', 'margin', array(
|
||||
'desktop_key' => 'margin',
|
||||
'tablet_key' => 'marginTablet',
|
||||
'mobile_key' => 'marginMobile',
|
||||
'unit_key' => 'marginUnit'
|
||||
) );
|
||||
|
||||
// Pass down to sections.
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id . ' .wp-block-kadence-header-column, .wp-block-kadence-header-row' . $unique_id . ' .wp-block-kadence-header-section' );
|
||||
// $css->render_row_gap( $attributes, array( 'itemGap', 'itemGapTablet', 'itemGapMobile' ), 'gap', '', 'itemGapUnit' );
|
||||
$css->render_gap( $attributes, 'itemGap', 'gap', 'itemGapUnit', array(
|
||||
'desktop_key' => 'itemGap',
|
||||
'tablet_key' => 'itemGapTablet',
|
||||
'mobile_key' => 'itemGapMobile',
|
||||
) );
|
||||
|
||||
$css->set_media_state( 'desktop' );
|
||||
if ( isset( $attributes['kadenceBlockCSS'] ) && ! empty( $attributes['kadenceBlockCSS'] ) ) {
|
||||
$css->add_css_string( str_replace( 'selector', '.wp-block-kadence-header-row' . $unique_id, $attributes['kadenceBlockCSS'] ) );
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the dynamic styles for a size.
|
||||
*
|
||||
* @param string $size The size.
|
||||
* @return array
|
||||
*/
|
||||
public function sized_dynamic_styles( $css, $attributes, $unique_id, $size = 'Desktop' ) {
|
||||
$sized_attributes = $css->get_sized_attributes_auto( $attributes, $size, false );
|
||||
$sized_attributes_inherit = $css->get_sized_attributes_auto( $attributes, $size );
|
||||
$css->set_media_state( strtolower( $size ) );
|
||||
|
||||
// Pass down to sections.
|
||||
$css->set_selector( '.wp-block-kadence-header-row' . $unique_id . ' .wp-block-kadence-header-column, .wp-block-kadence-header-row' . $unique_id . ' .wp-block-kadence-header-section' );
|
||||
if ( isset( $sized_attributes['vAlign'] ) && $sized_attributes['vAlign'] === 'top' ) {
|
||||
$css->add_property( 'align-items', 'flex-start' );
|
||||
} elseif ( isset( $sized_attributes['vAlign'] ) && $sized_attributes['vAlign'] === 'center' ) {
|
||||
$css->add_property( 'align-items', 'center' );
|
||||
} elseif ( isset( $sized_attributes['vAlign'] ) && $sized_attributes['vAlign'] === 'bottom' ) {
|
||||
$css->add_property( 'align-items', 'flex-end' );
|
||||
}
|
||||
|
||||
$css->set_selector('.wp-block-kadence-header-row' . $unique_id . ' .kadence-header-row-inner');
|
||||
if ($sized_attributes['layoutConfig'] !== 'single') {
|
||||
if ($sized_attributes['sectionPriority'] == 'center') {
|
||||
$css->add_property('grid-template-columns', 'auto minmax(0, 1fr) auto');
|
||||
} else if ($sized_attributes['sectionPriority'] == 'left') {
|
||||
$css->add_property('grid-template-columns', '1fr minmax(0, auto) auto');
|
||||
} else if ($sized_attributes['sectionPriority'] == 'right') {
|
||||
$css->add_property('grid-template-columns', 'auto minmax(0, auto) 1fr');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$html = '';
|
||||
|
||||
// If this row is empty, don't render it
|
||||
if( $this->are_innerblocks_empty( $block_instance ) ) {
|
||||
return $html;
|
||||
}
|
||||
|
||||
$classes = array(
|
||||
'wp-block-kadence-header-row',
|
||||
'wp-block-kadence-header-row' . esc_attr( $unique_id ),
|
||||
);
|
||||
|
||||
if ( ! empty( $attributes['location'] ) ) {
|
||||
$classes[] = 'wp-block-kadence-header-row-' . esc_attr( $attributes['location'] );
|
||||
}
|
||||
if ( ! empty( $attributes['className'] ) ) {
|
||||
$classes[] = $attributes['className'];
|
||||
}
|
||||
$layout = ! empty( $attributes['layout'] ) ? $attributes['layout'] : 'standard';
|
||||
$classes[] = 'kb-header-row-layout-' . esc_attr( $layout );
|
||||
if ( ! empty( $attributes['layoutConfig'] ) ) {
|
||||
$classes[] = 'kb-header-row-layout-config-' . esc_attr( $attributes['layoutConfig'] );
|
||||
}
|
||||
|
||||
$html .= '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">';
|
||||
$html .= '<div class="kadence-header-row-inner">';
|
||||
$html .= $content;
|
||||
$html .= '</div>';
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the innerblocks are empty. We won't render the row if all the innerblocks are empty
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function are_innerblocks_empty( $block_instance ) {
|
||||
$is_empty = true;
|
||||
|
||||
$inner_blocks = $block_instance->parsed_block['innerBlocks'] ?? [];
|
||||
|
||||
foreach( $inner_blocks as $top_level_inner_blocks ) {
|
||||
if ($top_level_inner_blocks['blockName'] === 'kadence/header-column' && !empty($top_level_inner_blocks['innerBlocks'])) {
|
||||
$is_empty = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!empty($top_level_inner_blocks['innerBlocks'])) {
|
||||
foreach ($top_level_inner_blocks['innerBlocks'] as $section_inner_block) {
|
||||
// Check if any 'kadence/header-column' inner block is not empty
|
||||
if ($section_inner_block['blockName'] === 'kadence/header-column' && !empty($section_inner_block['innerBlocks'])) {
|
||||
$is_empty = false;
|
||||
break 2; // Break both loops
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $is_empty;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Kadence_Blocks_Header_Row_Block::get_instance();
|
||||
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Header block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Headers container Block for desktop.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Header_Section_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'header-section';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/section/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$css->set_selector( '.wp-block-kadence-header-desktop' . $unique_id );
|
||||
$css->add_property( 'display', 'block' );
|
||||
|
||||
$css->set_media_state( 'tablet' );
|
||||
$css->add_property( 'display', 'none');
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
|
||||
$html = '';
|
||||
|
||||
$classes = array(
|
||||
'wp-block-kadence-header-section',
|
||||
'wp-block-kadence-header-section' . esc_attr( $unique_id ),
|
||||
);
|
||||
|
||||
$html .= '<div class="' . esc_attr( implode( ' ', $classes ) ) . '">';
|
||||
$html .= $content;
|
||||
$html .= '</div>';
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Kadence_Blocks_Header_Section_Block::get_instance();
|
||||
@@ -0,0 +1,304 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Off Canvas block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Off Canvas block.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Off_Canvas_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'off-canvas';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = false;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/off-canvas/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$sizes = array( 'Desktop', 'Tablet', 'Mobile' );
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
$this->sized_dynamic_styles( $css, $attributes, $unique_id, $size );
|
||||
}
|
||||
$css->set_media_state( 'desktop' );
|
||||
|
||||
// container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-inner-wrap' );
|
||||
$css->render_border_styles( $attributes, 'border', false, array(
|
||||
'desktop_key' => 'border',
|
||||
'tablet_key' => 'borderTablet',
|
||||
'mobile_key' => 'borderMobile',
|
||||
) );
|
||||
$css->render_measure_output( $attributes, 'borderRadius', 'border-radius', array(
|
||||
'desktop_key' => 'borderRadius',
|
||||
'tablet_key' => 'borderRadiusTablet',
|
||||
'mobile_key' => 'borderRadiusMobile',
|
||||
) );
|
||||
|
||||
// inner container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-inner');
|
||||
$css->render_measure_output( $attributes, 'padding', 'padding', array(
|
||||
'desktop_key' => 'padding',
|
||||
'tablet_key' => 'paddingTablet',
|
||||
'mobile_key' => 'paddingMobile',
|
||||
) );
|
||||
|
||||
// For the close icon container styles.
|
||||
// close icon container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close' );
|
||||
$css->render_measure_output(
|
||||
$attributes,
|
||||
'closeIconPadding',
|
||||
'padding',
|
||||
[
|
||||
'desktop_key' => 'closeIconPadding',
|
||||
'tablet_key' => 'closeIconPaddingTablet',
|
||||
'mobile_key' => 'closeIconPaddingMobile',
|
||||
'unit_key' => 'closeIconPaddingUnit',
|
||||
]
|
||||
);
|
||||
$css->render_measure_output( $attributes, 'closeIconMargin', 'margin', array(
|
||||
'desktop_key' => 'closeIconMargin',
|
||||
'tablet_key' => 'closeIconMarginTablet',
|
||||
'mobile_key' => 'closeIconMarginMobile',
|
||||
'unit_key' => 'closeIconMarginUnit',
|
||||
) );
|
||||
$css->render_measure_output( $attributes, 'closeIconBorderRadius', 'border-radius', array(
|
||||
'desktop_key' => 'closeIconBorderRadius',
|
||||
'tablet_key' => 'closeIconBorderRadiusTablet',
|
||||
'mobile_key' => 'closeIconBorderRadiusMobile',
|
||||
) );
|
||||
$css->render_border_styles( $attributes, 'closeIconBorder', false, array(
|
||||
'desktop_key' => 'closeIconBorder',
|
||||
'tablet_key' => 'closeIconBorderTablet',
|
||||
'mobile_key' => 'closeIconBorderMobile',
|
||||
) );
|
||||
|
||||
// Close icon container hover.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close:hover, .wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close:focus-visible' );
|
||||
$css->render_border_styles(
|
||||
$attributes,
|
||||
'closeIconBorderHover',
|
||||
false,
|
||||
[
|
||||
'desktop_key' => 'closeIconBorderHover',
|
||||
'tablet_key' => 'closeIconBorderHoverTablet',
|
||||
'mobile_key' => 'closeIconBorderHoverMobile',
|
||||
]
|
||||
);
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build up the dynamic styles for a size.
|
||||
*
|
||||
* @param string $size The size.
|
||||
* @return array
|
||||
*/
|
||||
public function sized_dynamic_styles( $css, $attributes, $unique_id, $size = 'Desktop' ) {
|
||||
$sized_attributes = $css->get_sized_attributes_auto( $attributes, $size, false );
|
||||
$sized_attributes_inherit = $css->get_sized_attributes_auto( $attributes, $size );
|
||||
|
||||
$css->set_media_state( strtolower( $size ) );
|
||||
|
||||
// Container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-inner-wrap' );
|
||||
if ( empty( $sized_attributes_inherit['widthType'] ) || $sized_attributes_inherit['widthType'] !== 'full' ) {
|
||||
$max_width_unit = ! empty( $attributes['maxWidthUnit'] ) ? $attributes['maxWidthUnit'] : 'px';
|
||||
if ( ! empty( $sized_attributes['maxWidth']) ) {
|
||||
$css->add_property( 'max-width', $sized_attributes['maxWidth'] . $max_width_unit );
|
||||
}
|
||||
} else {
|
||||
$css->add_property( 'max-width', 'initial' );
|
||||
$css->add_property( 'width', '100%' );
|
||||
}
|
||||
|
||||
if ( ! empty( $sized_attributes['backgroundColor'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['backgroundColor'] ) );
|
||||
}
|
||||
|
||||
// Inner container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-inner' );
|
||||
|
||||
if ( ! empty( $sized_attributes['containerMaxWidth'] ) ) {
|
||||
$max_width_unit = ! empty( $sized_attributes['containerMaxWidthUnit'] ) ? $sized_attributes['containerMaxWidthUnit'] : 'px';
|
||||
$css->add_property( 'max-width', $sized_attributes['containerMaxWidth'] . $max_width_unit );
|
||||
}
|
||||
|
||||
// Content area inner alignment.
|
||||
if ( $sized_attributes['hAlign'] == 'center') {
|
||||
$css->add_property( 'align-items', 'center' );
|
||||
$css->add_property( 'margin-left', 'auto' );
|
||||
$css->add_property( 'margin-right', 'auto' );
|
||||
} elseif ( $sized_attributes['hAlign'] == 'right' ) {
|
||||
$css->add_property( 'align-items', 'flex-end' );
|
||||
$css->add_property( 'margin-left', 'auto' );
|
||||
}
|
||||
if ( $sized_attributes['vAlign'] == 'center' ) {
|
||||
$css->add_property( 'justify-content', 'center' );
|
||||
} elseif ( $sized_attributes['vAlign'] == 'bottom' ) {
|
||||
$css->add_property( 'justify-content', 'flex-end' );
|
||||
}
|
||||
|
||||
// Overlay.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas .kb-off-canvas-overlay' . $unique_id );
|
||||
if ( ! empty( $sized_attributes['pageBackgroundColor'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['pageBackgroundColor'] ) );
|
||||
}
|
||||
|
||||
// For the close icon container styles, they need to get applied to the hover state too, due to resets on hover styles in the css
|
||||
// Close Icon container.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close' );
|
||||
if ( ! empty( $sized_attributes['closeIconBackgroundColor'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['closeIconBackgroundColor'] ) );
|
||||
}
|
||||
if ( ! empty( $sized_attributes['closeIconColor'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $sized_attributes['closeIconColor'] ) );
|
||||
}
|
||||
|
||||
// Close Icon container hover.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close:hover, .wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close:focus-visible' );
|
||||
if ( ! empty( $sized_attributes['closeIconBackgroundColorHover'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['closeIconBackgroundColorHover'] ) );
|
||||
}
|
||||
if ( ! empty( $sized_attributes['closeIconColorHover'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $sized_attributes['closeIconColorHover'] ) );
|
||||
}
|
||||
|
||||
// Close Icon.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas' . $unique_id . ' .kb-off-canvas-close svg' );
|
||||
if ( ! empty( $sized_attributes['closeIconSize'] ) ) {
|
||||
$css->add_property( 'width', $sized_attributes['closeIconSize'] . 'px' );
|
||||
$css->add_property( 'height', $sized_attributes['closeIconSize'] . 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$html = '';
|
||||
$overlay = '';
|
||||
$icon = '';
|
||||
$css = Kadence_Blocks_CSS::get_instance();
|
||||
|
||||
if ( ! empty( $attributes['closeIcon'] ) ) {
|
||||
$close_icon = $attributes['closeIcon'];
|
||||
$type = substr( $close_icon, 0, 2 );
|
||||
$line_icon = ( ! empty( $type ) && 'fe' == $type ? true : false );
|
||||
$fill = ( $line_icon ? 'none' : 'currentColor' );
|
||||
$stroke_width = false;
|
||||
if ( $line_icon ) {
|
||||
$stroke_width = ( ! empty( $attributes['closeLineWidth'] ) ? $attributes['closeLineWidth'] : 2 );
|
||||
}
|
||||
$title = '';
|
||||
$hidden = true;
|
||||
$label = ( ! empty( $attributes['closeLabel'] ) ? $attributes['closeLabel'] : esc_attr__( 'Close Menu', 'kadence-blocks' ) );
|
||||
$icon = '<button aria-label="' . esc_attr( $label ) . '" aria-expanded="false" class="kb-off-canvas-close">' . Kadence_Blocks_Svg_Render::render( $close_icon, $fill, $stroke_width, $title, $hidden ) . '</button>';
|
||||
}
|
||||
|
||||
$open_side = $css->get_inherited_value( $attributes['slideFrom'], $attributes['slideFromTablet'], $attributes['slideFromMobile'], 'Desktop' );
|
||||
$open_side_tablet = $css->get_inherited_value( $attributes['slideFrom'], $attributes['slideFromTablet'], $attributes['slideFromMobile'], 'Tablet' );
|
||||
$open_side_mobile = $css->get_inherited_value( $attributes['slideFrom'], $attributes['slideFromTablet'], $attributes['slideFromMobile'], 'Mobile' );
|
||||
$classes = array(
|
||||
'wp-block-kadence-off-canvas',
|
||||
'wp-block-kadence-off-canvas' . $unique_id,
|
||||
'open-' . $open_side,
|
||||
'open-tablet-' . $open_side_tablet,
|
||||
'open-mobile-' . $open_side_mobile,
|
||||
);
|
||||
|
||||
$overlay_classes = array(
|
||||
'kb-off-canvas-overlay',
|
||||
'kb-off-canvas-overlay' . $unique_id,
|
||||
);
|
||||
|
||||
$width_type = $css->get_inherited_value( $attributes['widthType'], $attributes['widthTypeTablet'], $attributes['widthTypeMobile'], 'Desktop' );
|
||||
$width_type_tablet = $css->get_inherited_value( $attributes['widthType'], $attributes['widthTypeTablet'], $attributes['widthTypeMobile'], 'Tablet' );
|
||||
$width_type_mobile = $css->get_inherited_value( $attributes['widthType'], $attributes['widthTypeTablet'], $attributes['widthTypeMobile'], 'Mobile' );
|
||||
if ( ( ! $width_type || $width_type === 'partial' ) || ( ! $width_type_tablet || $width_type_tablet === 'partial' ) || ( ! $width_type_mobile || $width_type_mobile === 'partial' ) ) {
|
||||
$overlay = '<div data-unique-id="' . esc_attr( $unique_id ) . '" class="' . esc_attr( implode( ' ', $overlay_classes ) ) . '"></div>';
|
||||
}
|
||||
|
||||
$wrapper_args = array(
|
||||
'class' => implode( ' ', $classes ),
|
||||
);
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
|
||||
$html .= sprintf( '<div %1$s>%2$s<div class="kb-off-canvas-inner-wrap">%3$s<div class="kb-off-canvas-inner">%4$s</div></div></div>', $wrapper_attributes, $overlay, $icon, $content );
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Off_Canvas_Block::get_instance();
|
||||
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the off canvas trigger.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Off Canvas Trigger.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Off_Canvas_Trigger_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'off-canvas-trigger';
|
||||
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_script = true;
|
||||
/**
|
||||
* Block determines in scripts need to be loaded for block.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $has_style = false;
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/header/children/off-canvas-trigger/block.json',
|
||||
array(
|
||||
'render_callback' => array( $this, 'render_css' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param Kadence_Blocks_CSS $css the css class for blocks.
|
||||
* @param string $unique_id the blocks attr ID.
|
||||
* @param string $unique_style_id the blocks alternate ID for queries.
|
||||
*/
|
||||
public function build_css( $attributes, $css, $unique_id, $unique_style_id ) {
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$sizes = array( 'Desktop', 'Tablet', 'Mobile' );
|
||||
|
||||
foreach ( $sizes as $size ) {
|
||||
$this->sized_dynamic_styles( $css, $attributes, $unique_id, $size );
|
||||
}
|
||||
$css->set_media_state( 'desktop' );
|
||||
|
||||
// For the close icon container styles, they need to get applied to the hover state too, due to resets on hover styles in the css
|
||||
//container
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ', .wp-block-kadence-off-canvas-trigger' . $unique_id . ':hover' );
|
||||
$css->render_measure_output( $attributes, 'padding', 'padding', array(
|
||||
'desktop_key' => 'padding',
|
||||
'tablet_key' => 'paddingTablet',
|
||||
'mobile_key' => 'paddingMobile',
|
||||
) );
|
||||
$css->render_measure_output( $attributes, 'margin', 'margin', array(
|
||||
'desktop_key' => 'margin',
|
||||
'tablet_key' => 'marginTablet',
|
||||
'mobile_key' => 'marginMobile',
|
||||
) );
|
||||
$css->render_measure_output( $attributes, 'borderRadius', 'border-radius', array(
|
||||
'desktop_key' => 'borderRadius',
|
||||
'tablet_key' => 'borderRadiusTablet',
|
||||
'mobile_key' => 'borderRadiusMobile',
|
||||
) );
|
||||
$css->render_border_styles( $attributes, 'border', false, array(
|
||||
'desktop_key' => 'border',
|
||||
'tablet_key' => 'borderTablet',
|
||||
'mobile_key' => 'borderMobile',
|
||||
));
|
||||
|
||||
//container hover
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ':hover' );
|
||||
$css->render_border_styles( $attributes, 'borderHover', false, array(
|
||||
'desktop_key' => 'borderHover',
|
||||
'tablet_key' => 'borderHoverTablet',
|
||||
'mobile_key' => 'borderHoverMobile',
|
||||
) );
|
||||
|
||||
//icon
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ' svg' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build up the dynamic styles for a size.
|
||||
*
|
||||
* @param string $size The size.
|
||||
* @return array
|
||||
*/
|
||||
public function sized_dynamic_styles( $css, $attributes, $unique_id, $size = 'Desktop' ) {
|
||||
$sized_attributes = $css->get_sized_attributes_auto( $attributes, $size, false );
|
||||
$sized_attributes_inherit = $css->get_sized_attributes_auto( $attributes, $size );
|
||||
|
||||
$css->set_media_state( strtolower( $size ) );
|
||||
|
||||
// For the close icon container styles, they need to get applied to the hover state too, due to resets on hover styles in the css
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id. ', .wp-block-kadence-off-canvas-trigger' . $unique_id . ':hover' );
|
||||
if ( ! empty( $sized_attributes['iconBackgroundColor'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['iconBackgroundColor'] ) );
|
||||
}
|
||||
if ( ! empty( $sized_attributes['iconColor'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $sized_attributes['iconColor'] ) );
|
||||
}
|
||||
|
||||
// Hover styles.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ':hover' );
|
||||
if ( ! empty( $sized_attributes['iconBackgroundColorHover'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['iconBackgroundColorHover'] ) );
|
||||
}
|
||||
if ( ! empty( $sized_attributes['iconColorHover'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $sized_attributes['iconColorHover'] ) );
|
||||
}
|
||||
|
||||
// Focus styles - only when aria-expanded is not "false"
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ':focus:not([aria-expanded="false"])' );
|
||||
if ( ! empty( $sized_attributes['iconBackgroundColorHover'] ) ) {
|
||||
$css->add_property( 'background-color', $css->render_color( $sized_attributes['iconBackgroundColorHover'] ) );
|
||||
}
|
||||
if ( ! empty( $sized_attributes['iconColorHover'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $sized_attributes['iconColorHover'] ) );
|
||||
}
|
||||
// Icon styles.
|
||||
$css->set_selector( '.wp-block-kadence-off-canvas-trigger' . $unique_id . ' svg' );
|
||||
if ( ! empty( $sized_attributes['iconSize'] ) ) {
|
||||
$css->add_property( 'width', $sized_attributes['iconSize'] . 'px' );
|
||||
$css->add_property( 'height', $sized_attributes['iconSize'] . 'px' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The innerblocks are stored on the $content variable. We just wrap with our data, if needed
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string Returns the block output.
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
|
||||
$classes = array(
|
||||
'wp-block-kadence-off-canvas-trigger',
|
||||
'wp-block-kadence-off-canvas-trigger' . $unique_id,
|
||||
);
|
||||
$icon = ( ! empty( $attributes['icon'] ) ? $attributes['icon'] : 'fe_menu' );
|
||||
$type = substr( $icon, 0, 2 );
|
||||
$line_icon = ( ! empty( $type ) && 'fe' == $type ? true : false );
|
||||
$fill = ( $line_icon ? 'none' : 'currentColor' );
|
||||
$stroke_width = false;
|
||||
if ( $line_icon ) {
|
||||
$stroke_width = ( ! empty( $attributes['lineWidth'] ) ? $attributes['lineWidth'] : 2 );
|
||||
}
|
||||
$title = '';
|
||||
$hidden = true;
|
||||
$content = Kadence_Blocks_Svg_Render::render( $icon, $fill, $stroke_width, $title, $hidden );
|
||||
$label = ( ! empty( $attributes['label'] ) ? $attributes['label'] : esc_attr__( 'Toggle Menu', 'kadence-blocks' ) );
|
||||
|
||||
$wrapper_args = array(
|
||||
'class' => implode( ' ', $classes ),
|
||||
'aria-label' => $label,
|
||||
'aria-expanded' => 'false',
|
||||
'aria-haspopup' => 'true',
|
||||
'id' => 'kadence-off-canvas-trigger' . $unique_id,
|
||||
);
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
|
||||
return sprintf( '<button %1$s>%2$s</button>', $wrapper_attributes, $content );
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers scripts and styles.
|
||||
*/
|
||||
public function register_scripts() {
|
||||
parent::register_scripts();
|
||||
// If in the backend, bail out.
|
||||
if ( is_admin() ) {
|
||||
return;
|
||||
}
|
||||
if ( apply_filters( 'kadence_blocks_check_if_rest', false ) && kadence_blocks_is_rest() ) {
|
||||
return;
|
||||
}
|
||||
wp_register_script( 'kadence-blocks-' . $this->block_name, KADENCE_BLOCKS_URL . 'includes/assets/js/kb-off-canvas-trigger.min.js', array(), KADENCE_BLOCKS_VERSION, true );
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Off_Canvas_Trigger_Block::get_instance();
|
||||
Reference in New Issue
Block a user