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,376 @@
|
||||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"title": "Form",
|
||||
"name": "kadence/form",
|
||||
"category": "kadence-blocks",
|
||||
"textdomain": "kadence-blocks",
|
||||
"keywords": ["contact", "marketing", "KB"],
|
||||
"attributes": {
|
||||
"uniqueID": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"postID": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"hAlign": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"fields": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"label": "Name",
|
||||
"showLabel": true,
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"description": "",
|
||||
"rows": 4,
|
||||
"options": [
|
||||
{
|
||||
"value": "",
|
||||
"label": ""
|
||||
}
|
||||
],
|
||||
"multiSelect": false,
|
||||
"inline": false,
|
||||
"showLink": false,
|
||||
"min": "",
|
||||
"max": "",
|
||||
"type": "text",
|
||||
"required": false,
|
||||
"width": ["100", "", ""],
|
||||
"auto": "",
|
||||
"errorMessage": "",
|
||||
"requiredMessage": "",
|
||||
"slug": "",
|
||||
"ariaLabel": ""
|
||||
},
|
||||
{
|
||||
"label": "Email",
|
||||
"showLabel": true,
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"description": "",
|
||||
"rows": 4,
|
||||
"options": [
|
||||
{
|
||||
"value": "",
|
||||
"label": ""
|
||||
}
|
||||
],
|
||||
"multiSelect": false,
|
||||
"inline": false,
|
||||
"showLink": false,
|
||||
"min": "",
|
||||
"max": "",
|
||||
"type": "email",
|
||||
"required": true,
|
||||
"width": ["100", "", ""],
|
||||
"auto": "",
|
||||
"errorMessage": "",
|
||||
"requiredMessage": "",
|
||||
"slug": "",
|
||||
"ariaLabel": ""
|
||||
},
|
||||
{
|
||||
"label": "Message",
|
||||
"showLabel": true,
|
||||
"placeholder": "",
|
||||
"default": "",
|
||||
"description": "",
|
||||
"rows": 4,
|
||||
"options": [
|
||||
{
|
||||
"value": "",
|
||||
"label": ""
|
||||
}
|
||||
],
|
||||
"multiSelect": false,
|
||||
"inline": false,
|
||||
"showLink": false,
|
||||
"min": "",
|
||||
"max": "",
|
||||
"type": "textarea",
|
||||
"required": true,
|
||||
"width": ["100", "", ""],
|
||||
"auto": "",
|
||||
"errorMessage": "",
|
||||
"requiredMessage": "",
|
||||
"slug": "",
|
||||
"ariaLabel": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"messages": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"success": "",
|
||||
"error": "",
|
||||
"required": "",
|
||||
"invalid": "",
|
||||
"recaptchaerror": "",
|
||||
"preError": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"messageFont": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"colorSuccess": "",
|
||||
"colorError": "",
|
||||
"borderSuccess": "",
|
||||
"borderError": "",
|
||||
"backgroundSuccess": "",
|
||||
"backgroundSuccessOpacity": 1,
|
||||
"backgroundError": "",
|
||||
"backgroundErrorOpacity": 1,
|
||||
"borderWidth": ["", "", "", ""],
|
||||
"borderRadius": "",
|
||||
"size": ["", "", ""],
|
||||
"sizeType": "px",
|
||||
"lineHeight": ["", "", ""],
|
||||
"lineType": "px",
|
||||
"letterSpacing": "",
|
||||
"textTransform": "",
|
||||
"family": "",
|
||||
"google": "",
|
||||
"style": "",
|
||||
"weight": "",
|
||||
"variant": "",
|
||||
"subset": "",
|
||||
"loadGoogle": true,
|
||||
"padding": ["", "", "", ""],
|
||||
"margin": ["", "", "", ""]
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"showRequired": true,
|
||||
"size": "standard",
|
||||
"deskPadding": ["", "", "", ""],
|
||||
"tabletPadding": ["", "", "", ""],
|
||||
"mobilePadding": ["", "", "", ""],
|
||||
"color": "",
|
||||
"requiredColor": "",
|
||||
"background": "",
|
||||
"border": "",
|
||||
"backgroundOpacity": 1,
|
||||
"borderOpacity": 1,
|
||||
"borderRadius": "",
|
||||
"borderWidth": ["", "", "", ""],
|
||||
"colorActive": "",
|
||||
"backgroundActive": "",
|
||||
"borderActive": "",
|
||||
"backgroundActiveOpacity": 1,
|
||||
"borderActiveOpacity": 1,
|
||||
"gradient": ["#999999", 1, 0, 100, "linear", 180, "center center"],
|
||||
"gradientActive": ["#777777", 1, 0, 100, "linear", 180, "center center"],
|
||||
"backgroundType": "solid",
|
||||
"backgroundActiveType": "solid",
|
||||
"boxShadow": [false, "#000000", 0.2, 1, 1, 2, 0, false],
|
||||
"boxShadowActive": [false, "#000000", 0.4, 2, 2, 3, 0, false],
|
||||
"fontSize": ["", "", ""],
|
||||
"fontSizeType": "px",
|
||||
"lineHeight": ["", "", ""],
|
||||
"lineType": "px",
|
||||
"rowGap": "",
|
||||
"rowGapType": "px",
|
||||
"gutter": "",
|
||||
"gutterType": "px",
|
||||
"tabletRowGap": "",
|
||||
"mobileRowGap": "",
|
||||
"tabletGutter": "",
|
||||
"mobileGutter": ""
|
||||
}
|
||||
]
|
||||
},
|
||||
"labelFont": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"color": "",
|
||||
"size": ["", "", ""],
|
||||
"sizeType": "px",
|
||||
"lineHeight": ["", "", ""],
|
||||
"lineType": "px",
|
||||
"letterSpacing": "",
|
||||
"textTransform": "",
|
||||
"family": "",
|
||||
"google": "",
|
||||
"style": "",
|
||||
"weight": "",
|
||||
"variant": "",
|
||||
"subset": "",
|
||||
"loadGoogle": true,
|
||||
"padding": ["", "", "", ""],
|
||||
"margin": ["", "", "", ""]
|
||||
}
|
||||
]
|
||||
},
|
||||
"submit": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"label": "",
|
||||
"width": ["100", "", ""],
|
||||
"size": "standard",
|
||||
"widthType": "auto",
|
||||
"fixedWidth": ["", "", ""],
|
||||
"align": ["", "", ""],
|
||||
"deskPadding": ["", "", "", ""],
|
||||
"tabletPadding": ["", "", "", ""],
|
||||
"mobilePadding": ["", "", "", ""],
|
||||
"color": "",
|
||||
"background": "",
|
||||
"border": "",
|
||||
"backgroundOpacity": 1,
|
||||
"borderOpacity": 1,
|
||||
"borderRadius": "",
|
||||
"borderWidth": ["", "", "", ""],
|
||||
"colorHover": "",
|
||||
"backgroundHover": "",
|
||||
"borderHover": "",
|
||||
"backgroundHoverOpacity": 1,
|
||||
"borderHoverOpacity": 1,
|
||||
"icon": "",
|
||||
"iconSide": "right",
|
||||
"iconHover": false,
|
||||
"cssClass": "",
|
||||
"gradient": ["#999999", 1, 0, 100, "linear", 180, "center center"],
|
||||
"gradientHover": ["#777777", 1, 0, 100, "linear", 180, "center center"],
|
||||
"btnStyle": "basic",
|
||||
"btnSize": "standard",
|
||||
"backgroundType": "solid",
|
||||
"backgroundHoverType": "solid",
|
||||
"boxShadow": [false, "#000000", 0.2, 1, 1, 2, 0, false],
|
||||
"boxShadowHover": [false, "#000000", 0.4, 2, 2, 3, 0, false]
|
||||
}
|
||||
]
|
||||
},
|
||||
"submitMargin": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"desk": ["", "", "", ""],
|
||||
"tablet": ["", "", "", ""],
|
||||
"mobile": ["", "", "", ""],
|
||||
"unit": "px",
|
||||
"control": "linked"
|
||||
}
|
||||
]
|
||||
},
|
||||
"submitFont": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"size": ["", "", ""],
|
||||
"sizeType": "px",
|
||||
"lineHeight": ["", "", ""],
|
||||
"lineType": "px",
|
||||
"letterSpacing": "",
|
||||
"textTransform": "",
|
||||
"family": "",
|
||||
"google": "",
|
||||
"style": "",
|
||||
"weight": "",
|
||||
"variant": "",
|
||||
"subset": "",
|
||||
"loadGoogle": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"actions": {
|
||||
"type": "array",
|
||||
"default": ["email"]
|
||||
},
|
||||
"email": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"emailTo": "",
|
||||
"subject": "",
|
||||
"fromEmail": "",
|
||||
"fromName": "",
|
||||
"replyTo": "email_field",
|
||||
"cc": "",
|
||||
"bcc": "",
|
||||
"html": true
|
||||
}
|
||||
]
|
||||
},
|
||||
"redirect": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
},
|
||||
"recaptcha": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"recaptchaVersion": {
|
||||
"type": "string",
|
||||
"default": "v3"
|
||||
},
|
||||
"honeyPot": {
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"mailerlite": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"group": [],
|
||||
"map": []
|
||||
}
|
||||
]
|
||||
},
|
||||
"fluentcrm": {
|
||||
"type": "array",
|
||||
"default": [
|
||||
{
|
||||
"lists": [],
|
||||
"tags": [],
|
||||
"map": [],
|
||||
"doubleOptin": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"containerMarginType": {
|
||||
"type": "string",
|
||||
"default": "px"
|
||||
},
|
||||
"containerMargin": {
|
||||
"type": "array",
|
||||
"default": ["", "", "", ""]
|
||||
},
|
||||
"tabletContainerMargin": {
|
||||
"type": "array",
|
||||
"default": ["", "", "", ""]
|
||||
},
|
||||
"mobileContainerMargin": {
|
||||
"type": "array",
|
||||
"default": ["", "", "", ""]
|
||||
},
|
||||
"submitLabel": {
|
||||
"type": "string",
|
||||
"default": ""
|
||||
}
|
||||
},
|
||||
"supports": {
|
||||
"anchor": true,
|
||||
"align": ["wide", "full"],
|
||||
"ktanimate": true,
|
||||
"ktanimateadd": true,
|
||||
"ktanimatepreview": true,
|
||||
"ktanimateswipe": true
|
||||
},
|
||||
"usesContext": ["postId"]
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Accept Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Accept_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'accept';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'checkbox';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$check_label = $attributes;
|
||||
$check_label['inputName'] = 'cb' . $class_id;
|
||||
|
||||
$inner_content .= '<fieldset class="kb-radio-check-item-wrap" id="' . $this->field_name( $check_label ) . '" data-type="accept" data-required="' . $is_required . '" ' . $this->additional_fieldset_attributes( $attributes ) . '>';
|
||||
$inner_content .= $this->field_legend( $check_label );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$is_checked_from_param = ! empty( $this->get_default( $attributes ) );
|
||||
$is_checked_from_editor = isset( $attributes['isChecked'] ) && true === $attributes['isChecked'] ? true : false;
|
||||
$is_checked = $is_checked_from_editor || $is_checked_from_param;
|
||||
$inner_content .= '<div class="kb-radio-check-item">';
|
||||
$inner_content .= '<input name="' . $this->field_name( $attributes ) . '" id="' . $this->field_id( $attributes ) . '_0"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . $type . '" value="' . esc_attr( $this->get_accept_default( $attributes ) ) . '"' . ( $is_checked ? ' checked' : '' ) . ' data-type="accept" class="kb-field kb-accept-field kb-' . $type . '-field" data-required="' . $is_required . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
$inner_content .= '<label for="' . $this->field_id( $attributes ) . '_0">' . $attributes['description'];
|
||||
if ( ! empty( $attributes['required'] ) && $attributes['required'] && ( empty( $attributes['label'] ) || ( isset( $attributes['showLabel'] ) && ! $attributes['showLabel'] ) ) ) {
|
||||
$inner_content .= '<span class="' . self::REQUIRED_CLASS_NAME . '">*</span>';
|
||||
}
|
||||
$inner_content .= '</label>';
|
||||
|
||||
$inner_content .= '</div>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
$inner_content .= '</fieldset>';
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Accept_Block::get_instance();
|
||||
@@ -0,0 +1,398 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Accordion Block.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Advanced_Form_Input_Block extends Kadence_Blocks_Abstract_Block {
|
||||
|
||||
const HELP_CLASS_NAME = 'kb-adv-form-help';
|
||||
|
||||
const REQUIRED_CLASS_NAME = 'kb-adv-form-required';
|
||||
|
||||
const LABEL_CLASS_NAME = 'kb-adv-form-label';
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = '';
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* On init startup register the block.
|
||||
*/
|
||||
public function on_init() {
|
||||
register_block_type(
|
||||
KADENCE_BLOCKS_PATH . 'dist/blocks/advanced-form/fields/' . $this->block_name . '/block.json',
|
||||
[
|
||||
'render_callback' => [ $this, 'render_css' ],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Class name to list of blocks to render in header.
|
||||
*
|
||||
* @param array $block_class_array the blocks that are registered to be rendered.
|
||||
*/
|
||||
public function add_block_to_post_generate_css( $block_class_array ) {
|
||||
if ( $this->should_register() ) {
|
||||
if ( ! isset( $block_class_array[ $this->namespace . '/advanced-form-' . $this->block_name ] ) ) {
|
||||
$has_input = in_array( $this->block_name, [ 'text', 'email', 'date', 'number', 'telephone', 'time', 'textarea', 'hidden' ], true );
|
||||
$block_class_array[ $this->namespace . '/advanced-form-' . $this->block_name ] = 'Kadence_Blocks_' . str_replace( ' ', '_', ucwords( str_replace( '-', ' ', $this->block_name ) ) ) . ( $has_input ? '_Input' : '' ) . '_Block';
|
||||
}
|
||||
}
|
||||
|
||||
return $block_class_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get default attributes for a block.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function get_block_default_attributes() {
|
||||
$block_name = 'kadence/advanced-form-' . $this->block_name;
|
||||
if ( ! isset( $this->default_attributes_cache[ $block_name ] ) ) {
|
||||
$registry = WP_Block_Type_Registry::get_instance()->get_registered( $block_name );
|
||||
$default_attributes = [];
|
||||
|
||||
if ( $registry && property_exists( $registry, 'attributes' ) && ! empty( $registry->attributes ) ) {
|
||||
foreach ( $registry->attributes as $key => $value ) {
|
||||
if ( isset( $value['default'] ) ) {
|
||||
$default_attributes[ $key ] = $value['default'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->default_attributes_cache[ $block_name ] = $default_attributes;
|
||||
}
|
||||
|
||||
return $this->default_attributes_cache[ $block_name ];
|
||||
}
|
||||
/**
|
||||
* Add help text for given block to the response
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_help_text( $attributes ) {
|
||||
if ( ! empty( $attributes['helpText'] ) ) {
|
||||
$form_id = ! empty( $attributes['formID'] ) ? $attributes['formID'] : '';
|
||||
return '<div class="' . self::HELP_CLASS_NAME . '"' . ( empty( $attributes['ariaDescription'] ) ? ' id="aria-describe' . esc_attr( $form_id ) . esc_attr( $attributes['uniqueID'] ) . '"' : '' ) . '>' . esc_html( $attributes['helpText'] ) . '</div>';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* Add the label to the HTML response if it should be shown
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_label( $attributes ) {
|
||||
$html = '';
|
||||
if ( ! empty( $this->get_label( $attributes ) ) && ( ! isset( $attributes['showLabel'] ) || ( isset( $attributes['showLabel'] ) && $attributes['showLabel'] ) ) ) {
|
||||
$html .= '<label class="' . self::LABEL_CLASS_NAME . '" for="' . esc_attr( $this->field_id( $attributes ) ) . '">' . $this->get_label( $attributes );
|
||||
|
||||
if ( ! empty( $attributes['required'] ) && $attributes['required'] ) {
|
||||
$html .= '<span class="' . self::REQUIRED_CLASS_NAME . '">*</span>';
|
||||
}
|
||||
|
||||
$html .= '</label>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
* Add the label to the HTML response if it should be shown
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_legend( $attributes ) {
|
||||
$html = '';
|
||||
if ( ! empty( $this->get_label( $attributes ) ) && ( ! isset( $attributes['showLabel'] ) || ( isset( $attributes['showLabel'] ) && $attributes['showLabel'] ) ) ) {
|
||||
$html .= '<legend class="' . self::LABEL_CLASS_NAME . '">' . $this->get_label( $attributes );
|
||||
|
||||
if ( ! empty( $attributes['required'] ) && $attributes['required'] ) {
|
||||
$html .= '<span class="' . self::REQUIRED_CLASS_NAME . '">*</span>';
|
||||
}
|
||||
|
||||
$html .= '</legend>';
|
||||
} elseif ( ! empty( $this->get_label( $attributes ) ) ) {
|
||||
$html .= '<legend class="screen-reader-text">' . $this->get_label( $attributes ) . '</legend>';
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
/**
|
||||
* Add the field name to the HTML response.
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_name( $attributes ) {
|
||||
return ! empty( $attributes['inputName'] ) ? $attributes['inputName'] : 'field' . $attributes['uniqueID'];
|
||||
}
|
||||
/**
|
||||
* Add the field name to the HTML response.
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function field_id( $attributes ) {
|
||||
$form_id = ! empty( $attributes['formID'] ) ? $attributes['formID'] : '';
|
||||
return ! empty( $attributes['anchor'] ) ? $attributes['anchor'] : 'field' . $form_id . $attributes['uniqueID'];
|
||||
}
|
||||
/**
|
||||
* Add the field wrapper class ID.
|
||||
*
|
||||
* @param $attributes array
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function class_id( $attributes ) {
|
||||
$form_id = ! empty( $attributes['formID'] ) ? $attributes['formID'] : '';
|
||||
return $form_id . $attributes['uniqueID'];
|
||||
}
|
||||
/**
|
||||
* Generate the aria-describedby attribute
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function field_aria_label( $attributes ) {
|
||||
|
||||
if ( ! empty( $attributes['ariaDescription'] ) ) {
|
||||
$form_id = ! empty( $attributes['formID'] ) ? $attributes['formID'] : '';
|
||||
return '<span id="aria-describe' . esc_attr( $form_id ) . esc_attr( $attributes['uniqueID'] ) . '" class="kb-form-aria-describe screen-reader-text">' . $attributes['ariaDescription'] . '</span>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
/**
|
||||
* Generate the default attribute
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_accept_default( $attributes ) {
|
||||
$default = $this->get_default( $attributes );
|
||||
if ( empty( $default ) ) {
|
||||
return 'accept';
|
||||
}
|
||||
if ( ! empty( $default ) && ( 'true' === $default || true === $default ) ) {
|
||||
return 'accept';
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
/**
|
||||
* Generate the default attribute
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_default( $attributes ) {
|
||||
$default = '';
|
||||
if ( isset( $attributes['defaultValue'] ) && $attributes['defaultValue'] !== '' ) {
|
||||
$default = do_shortcode( $attributes['defaultValue'] );
|
||||
}
|
||||
|
||||
if ( ! empty( $attributes['defaultParameter'] ) ) {
|
||||
if ( isset( $_GET[ $attributes['defaultParameter'] ] ) ) {
|
||||
$default = sanitize_text_field( kadence_blocks_wc_clean( wp_unslash( $_GET[ $attributes['defaultParameter'] ] ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
/**
|
||||
* Generate the aria-describedby attribute
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function aria_described_by( $attributes ) {
|
||||
|
||||
if ( ! empty( $attributes['ariaDescription'] ) || ! empty( $attributes['helpText'] ) ) {
|
||||
$form_id = ! empty( $attributes['formID'] ) ? $attributes['formID'] : '';
|
||||
return ' aria-describedby="aria-describe' . esc_attr( $form_id ) . esc_attr( $attributes['uniqueID'] ) . '"';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the auto complete value
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_auto_complete( $attributes ) {
|
||||
if ( ! empty( $attributes['auto'] ) ) {
|
||||
$value = $attributes['auto'] === 'custom' ? ( ! empty( $attributes['autoCustom'] ) ? $attributes['autoCustom'] : '' ) : $attributes['auto'];
|
||||
return ' autocomplete="' . esc_attr( $value ) . '"';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $block array Attributes for a specific input field
|
||||
* @param $true string Text for HTML if field is required
|
||||
* @param $false string Text for HTML if field is not required
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function is_required( $attributes, $true = 'yes', $false = 'no' ) {
|
||||
if ( ! empty( $attributes['required'] ) && $attributes['required'] ) {
|
||||
return $true;
|
||||
}
|
||||
|
||||
return $false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function a11y_helpers( $attributes ) {
|
||||
$response = '';
|
||||
|
||||
$is_required_bool = $this->is_required( $attributes, true, false );
|
||||
if ( $is_required_bool ) {
|
||||
$response .= 'required aria-required="true"';
|
||||
}
|
||||
|
||||
// if label is hidden and not empty, add as aria-label to input.
|
||||
if ( isset( $attributes['showLabel'] ) && ! $attributes['showLabel'] && ! empty( $attributes['label'] ) ) {
|
||||
if ( ! empty( $response ) ) {
|
||||
$response .= ' ';
|
||||
}
|
||||
$response .= 'aria-label="' . esc_attr( $attributes['label'] ) . '"';
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
/**
|
||||
* Get placeholder text for a given input field
|
||||
*
|
||||
* @param $block array Attributes for a specific input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_placeholder( $attributes ) {
|
||||
if ( isset( $attributes['placeholder'] ) ) {
|
||||
return $attributes['placeholder'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get label for field
|
||||
*
|
||||
* @param $block
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_label( $attributes ) {
|
||||
if ( isset( $attributes['label'] ) ) {
|
||||
return $attributes['label'];
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Option value given attributes for an input field
|
||||
*
|
||||
* @param $attrs array Attributes for a specific input field
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_option_value( $attributes ) {
|
||||
if ( isset( $attributes['value'] ) && $attributes['value'] !== '' ) {
|
||||
return $attributes['value'];
|
||||
}
|
||||
|
||||
return $attributes['label'] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get any additional attributes to be applied to the form <input /> element
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function additional_field_attributes( $attributes ) {
|
||||
$additional_attributes = '';
|
||||
$additional_attributes .= $this->a11y_helpers( $attributes );
|
||||
$additional_attributes .= $this->custom_required_message( $attributes );
|
||||
|
||||
return apply_filters( 'kadence_advanced_form_input_attributes', $additional_attributes, $attributes );
|
||||
}
|
||||
/**
|
||||
* Get any additional attributes to be applied to the form <fieldset /> element
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function additional_fieldset_attributes( $attributes ) {
|
||||
$additional_attributes = '';
|
||||
$additional_attributes .= $this->custom_required_message( $attributes );
|
||||
|
||||
return apply_filters( 'kadence_advanced_form_input_attributes', $additional_attributes, $attributes );
|
||||
}
|
||||
/**
|
||||
* Generates data attribute for the users custom "required" error message
|
||||
*
|
||||
* @param $attributes
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function custom_required_message( $attributes ) {
|
||||
if ( ! empty( $attributes['requiredMessage'] ) ) {
|
||||
return ' data-kb-required-message="' . esc_attr( $attributes['requiredMessage'] ) . '" ';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Captcha Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Captcha_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'captcha';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
if ( ! empty( $attributes['hideRecaptcha'] ) ) {
|
||||
$css->set_selector( '.grecaptcha-badge' );
|
||||
$css->add_property( 'visibility', 'hidden' );
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
|
||||
$captcha_settings = new Kadence_Blocks_Form_Captcha_Settings( $attributes );
|
||||
$this->register_scripts_with_attrs( $attributes, $captcha_settings );
|
||||
|
||||
/* We can't tell captcha type, or key isn't set */
|
||||
if ( ! $captcha_settings->is_valid ) {
|
||||
return '';
|
||||
}
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
|
||||
switch ( $captcha_settings->service ) {
|
||||
case 'googlev2':
|
||||
$inner_content .= $this->render_google_v2( $captcha_settings );
|
||||
break;
|
||||
case 'googlev3':
|
||||
return $this->render_google_v3( $captcha_settings, $unique_id );
|
||||
break;
|
||||
case 'turnstile':
|
||||
$inner_content .= $this->render_turnstile( $captcha_settings );
|
||||
break;
|
||||
case 'hcaptcha':
|
||||
$inner_content .= $this->render_hcaptcha( $captcha_settings );
|
||||
break;
|
||||
}
|
||||
|
||||
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
}
|
||||
|
||||
private function render_google_v2( $captcha_settings ) {
|
||||
|
||||
$recaptcha_v2_script = "var kbOnloadV2Callback = function(){jQuery( '.wp-block-kadence-form' ).find( '.kadence-blocks-g-recaptcha-v2' ).each( function() {grecaptcha.render( jQuery( this ).attr( 'id' ), {'sitekey' : '" . esc_attr( $captcha_settings->public_key ) . "'});});}";
|
||||
wp_add_inline_script( 'kadence-blocks-recaptcha', $recaptcha_v2_script, 'before' );
|
||||
$this->enqueue_script( 'kadence-blocks-recaptcha' );
|
||||
|
||||
return '<div class="g-recaptcha" data-language="' . esc_attr( $captcha_settings->language ) . '" data-size="' . esc_attr( $captcha_settings->size ) . '" data-theme="' . esc_attr( $captcha_settings->theme ) . '" data-sitekey="' . esc_attr( $captcha_settings->public_key ) . '"></div>';
|
||||
}
|
||||
|
||||
private function render_google_v3( $captcha_settings, $unique_id ) {
|
||||
|
||||
$recaptcha_v3_script = "grecaptcha.ready(function () {
|
||||
var kb_recaptcha_inputs = document.getElementsByClassName('kb_recaptcha_response');
|
||||
|
||||
if ( ! kb_recaptcha_inputs.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (var i = 0; i < kb_recaptcha_inputs.length; i++) {
|
||||
const e = i; grecaptcha.execute('" . esc_attr( $captcha_settings->public_key ) . "', { action: 'kb_form' }).then(
|
||||
function (token) {
|
||||
kb_recaptcha_inputs[e].setAttribute('value', token);
|
||||
});
|
||||
}
|
||||
});";
|
||||
wp_add_inline_script( 'kadence-blocks-recaptcha', $recaptcha_v3_script, 'after' );
|
||||
$this->enqueue_script( 'kadence-blocks-recaptcha' );
|
||||
|
||||
$output = '<input type="hidden" name="recaptcha_response" class="kb_recaptcha_response kb_recaptcha_' . esc_attr( $unique_id ) . '" />';
|
||||
|
||||
// Handle Kadence Captcha plugin settings
|
||||
$recaptcha_notice_html = '<span style="max-width: 100%%; font-size: 11px; color: #555; line-height: 1.2; display: block; margin-bottom: 16px; padding: 10px; background: #f2f2f2;" class="kt-recaptcha-branding-string">%s</span>';
|
||||
if ( $captcha_settings->using_kadence_captcha ) {
|
||||
$hide_v3 = $captcha_settings->get_kadence_captcha_stored_value( 'hide_v3_badge', false );
|
||||
$add_notice = $captcha_settings->get_kadence_captcha_stored_value( 'show_v3_notice', false );
|
||||
if ( $hide_v3 && $add_notice ) {
|
||||
$default = __( 'This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply', 'kadence-blocks' );
|
||||
$custom_notice = $captcha_settings->get_kadence_captcha_stored_value( 'v3_notice', $default );
|
||||
|
||||
$output .= sprintf( $recaptcha_notice_html, $custom_notice );
|
||||
}
|
||||
} elseif ( isset( $captcha_settings->hideRecaptcha ) && $captcha_settings->hideRecaptcha &&
|
||||
isset( $captcha_settings->showRecaptchaNotice ) && $captcha_settings->showRecaptchaNotice ) {
|
||||
|
||||
$default = __( 'This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply', 'kadence-blocks' );
|
||||
$custom_notice = isset( $captcha_settings->recaptchaNotice ) && ! empty( $captcha_settings->recaptchaNotice ) ? $captcha_settings->recaptchaNotice : $default;
|
||||
|
||||
$output .= sprintf( $recaptcha_notice_html, $custom_notice );
|
||||
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
private function render_turnstile( $captcha_settings ) {
|
||||
$this->enqueue_script( 'kadence-blocks-turnstile' );
|
||||
|
||||
return '<div class="cf-turnstile" data-language="' . esc_attr( $captcha_settings->language ) . '" data-size="' . esc_attr( $captcha_settings->size ) . '" data-theme="' . esc_attr( $captcha_settings->theme ) . '" data-sitekey="' . esc_attr( $captcha_settings->public_key ) . '"></div>';
|
||||
}
|
||||
|
||||
private function render_hcaptcha( $captcha_settings ) {
|
||||
$this->enqueue_script( 'kadence-blocks-hcaptcha' );
|
||||
|
||||
return '<div class="h-captcha" data-language="' . esc_attr( $captcha_settings->language ) . '" data-size="' . esc_attr( $captcha_settings->size ) . '" data-theme="' . esc_attr( $captcha_settings->theme ) . '" data-sitekey="' . esc_attr( $captcha_settings->public_key ) . '"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers scripts and styles.
|
||||
*/
|
||||
public function register_scripts_with_attrs( $attributes, $captcha_settings ) {
|
||||
// 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-turnstile', 'https://challenges.cloudflare.com/turnstile/v0/api.js', [], null, true );
|
||||
wp_register_script( 'kadence-blocks-hcaptcha', 'https://js.hcaptcha.com/1/api.js', [], null, true );
|
||||
|
||||
$recaptcha_url = 'https://www.google.com/recaptcha/api.js';
|
||||
$recaptcha_net_url = 'https://www.recaptcha.net/recaptcha/api.js';
|
||||
|
||||
if ( $captcha_settings->using_kadence_captcha && $captcha_settings->get_kadence_captcha_stored_value( 'recaptcha_url' ) === 'recaptcha' ) {
|
||||
$recaptcha_url = $recaptcha_net_url;
|
||||
}
|
||||
|
||||
if ( $captcha_settings->language !== false ) {
|
||||
$recaptcha_url = add_query_arg( [ 'hl' => $captcha_settings->language ], $recaptcha_url );
|
||||
}
|
||||
|
||||
if ( $captcha_settings->service === 'googlev3' ) {
|
||||
$recaptcha_url = add_query_arg( [ 'render' => $captcha_settings->public_key ], $recaptcha_url );
|
||||
}
|
||||
|
||||
wp_register_script( 'kadence-blocks-recaptcha', $recaptcha_url, [], null, true );
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Captcha_Block::get_instance();
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Checkbox Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Checkbox_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'checkbox';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$check_label = $attributes;
|
||||
$check_label['inputName'] = 'cb' . $class_id;
|
||||
$inline_class = '';
|
||||
if ( isset( $attributes['inline'] ) && true === $attributes['inline'] ) {
|
||||
$inline_class = ' kb-radio-check-items-inline';
|
||||
}
|
||||
$inner_content .= '<fieldset class="kb-radio-check-item-wrap' . esc_attr( $inline_class ) . '" id="' . esc_attr( $this->field_name( $check_label ) ) . '" data-type="checkbox" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_fieldset_attributes( $attributes ) . '>';
|
||||
$inner_content .= $this->field_legend( $check_label );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
foreach ( $attributes['options'] as $key => $option ) {
|
||||
$id = 'field' . $class_id . '_' . $key;
|
||||
$option_value = $this->get_option_value( $option );
|
||||
$is_checked_from_param = ! empty( $option_value ) && $option_value && in_array( $option_value, explode( ',', $this->get_default( $attributes ) ) );
|
||||
$is_checked_from_editor = ! empty( $option['selected'] );
|
||||
$is_checked = $is_checked_from_editor || $is_checked_from_param;
|
||||
|
||||
$inner_content .= '<div class="kb-radio-check-item">';
|
||||
$inner_content .= '<input class="kb-checkbox-style" type="checkbox" ' . $this->aria_described_by( $attributes ) . ' id="' . esc_attr( $id ) . '" name="' . esc_attr( $this->field_name( $attributes ) ) . '[]"' . ( $is_checked ? ' checked' : '' ) . ' value="' . esc_attr( $option_value ) . '">';
|
||||
|
||||
$inner_content .= '<label for="' . esc_attr( $id ) . '">' . $option['label'] . '</label>';
|
||||
|
||||
$description = [
|
||||
'uniqueID' => $id,
|
||||
'label' => ! empty( $attributes['description'] ) ? ' ' . $attributes['description'] : '',
|
||||
];
|
||||
$inner_content .= $this->field_label( $description );
|
||||
|
||||
$inner_content .= '</div>';
|
||||
}
|
||||
|
||||
$inner_content .= '</fieldset>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Checkbox_Block::get_instance();
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Date Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Date_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'date';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'date';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
if ( ! empty( $attributes['defaultValue'] ) && $attributes['defaultValue'] === 'today' ) {
|
||||
$default_value = wp_date( 'Y-m-d' );
|
||||
} else {
|
||||
$default_value = $this->get_default( $attributes );
|
||||
}
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" value="' . esc_attr( $default_value ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Date_Input_Block::get_instance();
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Email Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
/**
|
||||
* Class to Build the Accordion Block.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Email_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'email';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'email';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-text-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Email_Input_Block::get_instance();
|
||||
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form File Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_File_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'file';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'file';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-file-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$is_multiple = ( isset( $attributes['multiple'] ) && $attributes['multiple'] ? true : false );
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '' . ( $is_multiple ? '[]' : '' ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '' . ( $is_multiple ? ' multiple' : '' ) . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_File_Block::get_instance();
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Hidden Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Hidden_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'hidden';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'hidden';
|
||||
|
||||
$content = '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" />';
|
||||
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Hidden_Input_Block::get_instance();
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Number Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Number_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'number';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'number';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$min = isset( $attributes['minValue'] ) && $attributes['minValue'] !== '' ? ' min="' . esc_attr( $attributes['minValue'] ) . '" ' : '';
|
||||
$max = isset( $attributes['maxValue'] ) && $attributes['maxValue'] !== '' ? ' max="' . esc_attr( $attributes['maxValue'] ) . '" ' : '';
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-text-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$step = '';
|
||||
if ( ! empty( $attributes['allowDecimals'] ) ) {
|
||||
$step = 'step="any"';
|
||||
}
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $min . $max . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . ' ' . $step . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Number_Input_Block::get_instance();
|
||||
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Radio Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Radio_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'radio';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'radio';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
|
||||
$radio_label = $attributes;
|
||||
$radio_label['inputName'] = 'rb' . $class_id;
|
||||
$inline_class = '';
|
||||
if ( isset( $attributes['inline'] ) && true === $attributes['inline'] ) {
|
||||
$inline_class = ' kb-radio-check-items-inline';
|
||||
}
|
||||
$inner_content .= '<fieldset class="kb-radio-check-item-wrap' . esc_attr( $inline_class ) . '" id="' . esc_attr( $this->field_name( $radio_label ) ) . '" data-type="radio" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_fieldset_attributes( $attributes ) . '>';
|
||||
$inner_content .= $this->field_legend( $radio_label );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
foreach ( $attributes['options'] as $key => $option ) {
|
||||
$id = 'field' . $class_id . '_' . $key;
|
||||
$option_value = $this->get_option_value( $option );
|
||||
$is_checked_from_param = ! empty( $option_value ) && $option_value && in_array( $option_value, explode( ',', $this->get_default( $attributes ) ) );
|
||||
$is_checked_from_editor = ! empty( $option['selected'] );
|
||||
$is_checked = $is_checked_from_editor || $is_checked_from_param;
|
||||
|
||||
$inner_content .= '<div class="kb-radio-check-item">';
|
||||
$inner_content .= '<input class="kb-radio-style" type="radio" ' . $this->aria_described_by( $attributes ) . ' id="' . esc_attr( $id ) . '" name="' . esc_attr( $this->field_name( $attributes ) ) . '" ' . ( $is_checked ? 'checked' : '' ) . ' value="' . esc_attr( $option_value ) . '">';
|
||||
|
||||
$inner_content .= '<label for="' . esc_attr( $id ) . '">' . $option['label'] . '</label>';
|
||||
|
||||
$description = [
|
||||
'uniqueID' => $id,
|
||||
'label' => ! empty( $attributes['description'] ) ? ' ' . $attributes['description'] : '',
|
||||
];
|
||||
$inner_content .= $this->field_label( $description );
|
||||
|
||||
$inner_content .= '</div>';
|
||||
}
|
||||
|
||||
$inner_content .= '</fieldset>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Radio_Block::get_instance();
|
||||
@@ -0,0 +1,119 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Select Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Select_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'select';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$is_required = $this->is_required( $attributes, 'required', '' );
|
||||
$is_multiselect = ( isset( $attributes['multiSelect'] ) && $attributes['multiSelect'] === true ) ? 'multiple' : '';
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$default_value = $this->get_default( $attributes );
|
||||
$show_placeholder = true;
|
||||
if ( isset( $attributes['options'] ) && is_array( $attributes['options'] ) ) {
|
||||
foreach ( $attributes['options'] as $option ) {
|
||||
$option_value = $this->get_option_value( $option );
|
||||
if ( $default_value === $option_value ) {
|
||||
$show_placeholder = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$inner_content = '';
|
||||
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
|
||||
$name = $is_multiselect ? $this->field_name( $attributes ) . '[]' : $this->field_name( $attributes );
|
||||
|
||||
$inner_content .= '<select ' . $is_multiselect . ' name="' . esc_attr( $name ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' ' . $this->additional_field_attributes( $attributes ) . '>';
|
||||
if ( ! empty( $attributes['placeholder'] ) && $show_placeholder ) {
|
||||
$inner_content .= '<option value="" disabled selected>' . $attributes['placeholder'] . '</option>';
|
||||
}
|
||||
if ( isset( $attributes['options'] ) && is_array( $attributes['options'] ) ) {
|
||||
foreach ( $attributes['options'] as $option ) {
|
||||
$option_value = $this->get_option_value( $option );
|
||||
$is_selected_from_param = ! empty( $option_value ) && $option_value && in_array( $option_value, explode( ',', $default_value ) );
|
||||
$has_multiple_param_values = count( explode( ',', $default_value ) ) > 1;
|
||||
// if you have multiple values coming in from the default value, then this field must be a multi select to preselect options
|
||||
$selected = ( $has_multiple_param_values && $is_multiselect && $is_selected_from_param ) || ( ! $has_multiple_param_values && $is_selected_from_param );
|
||||
$inner_content .= '<option value="' . esc_attr( $option_value ) . '"' . ( $selected ? ' selected' : '' ) . '>' . $option['label'] . '</option>';
|
||||
}
|
||||
}
|
||||
$inner_content .= '</select>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Select_Block::get_instance();
|
||||
@@ -0,0 +1,268 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Text Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Accordion Block.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Submit_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'submit';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param array $attributes The block attributes.
|
||||
* @param string $unique_id The block unique id.
|
||||
* @param string $content The block content.
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-submit-field', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$classes = [ 'kb-button', 'kt-button', 'button', 'kb-adv-form-submit-button', 'kb-btn' . $class_id ];
|
||||
$classes[] = ! empty( $attributes['sizePreset'] ) ? 'kt-btn-size-' . $attributes['sizePreset'] : 'kt-btn-size-standard';
|
||||
$classes[] = ! empty( $attributes['widthType'] ) ? 'kt-btn-width-type-' . $attributes['widthType'] : 'kt-btn-width-type-auto';
|
||||
$classes[] = ! empty( $attributes['inheritStyles'] ) ? 'kb-btn-global-' . $attributes['inheritStyles'] : 'kb-btn-global-fill';
|
||||
$classes[] = ! empty( $attributes['text'] ) ? 'kt-btn-has-text-true' : 'kt-btn-has-text-false';
|
||||
$classes[] = ! empty( $attributes['icon'] ) ? 'kt-btn-has-svg-true' : 'kt-btn-has-svg-false';
|
||||
if ( ! empty( $attributes['inheritStyles'] ) && 'inherit' === $attributes['inheritStyles'] ) {
|
||||
$classes[] = 'wp-block-button__link';
|
||||
}
|
||||
if ( ! empty( $attributes['className'] ) ) {
|
||||
$wrapper_attributes = str_replace( ' ' . $attributes['className'], '', $wrapper_attributes );
|
||||
$classes[] = $attributes['className'];
|
||||
}
|
||||
$button_args = [
|
||||
'class' => implode( ' ', $classes ),
|
||||
];
|
||||
if ( ! empty( $attributes['anchor'] ) ) {
|
||||
$button_args['id'] = $attributes['anchor'];
|
||||
}
|
||||
$button_args['type'] = 'submit';
|
||||
if ( ! empty( $attributes['label'] ) ) {
|
||||
$button_args['aria-label'] = $attributes['label'];
|
||||
}
|
||||
$button_wrap_attributes = [];
|
||||
foreach ( $button_args as $key => $value ) {
|
||||
$button_wrap_attributes[] = $key . '="' . esc_attr( $value ) . '"';
|
||||
}
|
||||
$button_wrapper_attributes = implode( ' ', $button_wrap_attributes );
|
||||
$text = ! empty( $attributes['text'] ) ? '<span class="kt-btn-inner-text">' . $attributes['text'] . '</span>' : '';
|
||||
$svg_icon = '';
|
||||
if ( ! empty( $attributes['icon'] ) ) {
|
||||
$type = substr( $attributes['icon'], 0, 2 );
|
||||
$line_icon = ( ! empty( $type ) && 'fe' == $type ? true : false );
|
||||
$fill = ( $line_icon ? 'none' : 'currentColor' );
|
||||
$stroke_width = false;
|
||||
|
||||
if ( $line_icon ) {
|
||||
$stroke_width = 2;
|
||||
}
|
||||
$svg_icon = Kadence_Blocks_Svg_Render::render( $attributes['icon'], $fill, $stroke_width );
|
||||
}
|
||||
$icon_left = ! empty( $svg_icon ) && ! empty( $attributes['iconSide'] ) && 'left' === $attributes['iconSide'] ? '<span class="kb-svg-icon-wrap kb-svg-icon-' . esc_attr( $attributes['icon'] ) . ' kt-btn-icon-side-left">' . $svg_icon . '</span>' : '';
|
||||
$icon_right = ! empty( $svg_icon ) && ! empty( $attributes['iconSide'] ) && 'right' === $attributes['iconSide'] ? '<span class="kb-svg-icon-wrap kb-svg-icon-' . esc_attr( $attributes['icon'] ) . ' kt-btn-icon-side-right">' . $svg_icon . '</span>' : '';
|
||||
$html_tag = 'button';
|
||||
$content = sprintf( '<%1$s %2$s>%3$s%4$s%5$s</%1$s>', $html_tag, $button_wrapper_attributes, $icon_left, $text, $icon_right );
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $content );
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
|
||||
$width_type = ! empty( $attributes['widthType'] ) ? $attributes['widthType'] : 'auto';
|
||||
if ( 'fixed' === $width_type ) {
|
||||
$css->set_selector( '.kb-submit-field .kb-btn' . $class_id . '.kb-button, ul.menu .kb-submit-field .kb-btn' . $class_id . '.kb-button' );
|
||||
$css->render_responsive_range( $attributes, 'width', 'width', 'widthUnit' );
|
||||
} else {
|
||||
$css->set_selector( 'ul.menu .kb-submit-field .kb-btn' . $class_id . '.kb-button' );
|
||||
$css->add_property( 'width', 'initial' );
|
||||
}
|
||||
|
||||
if ( $width_type === 'fixed' && ! empty( $attributes['inheritStyles'] ) && 'inherit' === $attributes['inheritStyles'] ) {
|
||||
$css->set_selector( '.kb-submit-field.kb-field' . $class_id );
|
||||
$css->add_property( 'display', 'contents' );
|
||||
}
|
||||
|
||||
$css->set_selector( '.kb-submit-field .kb-btn' . $class_id . '.kb-button' );
|
||||
$bg_type = ! empty( $attributes['backgroundType'] ) ? $attributes['backgroundType'] : 'normal';
|
||||
$bg_hover_type = ! empty( $attributes['backgroundHoverType'] ) ? $attributes['backgroundHoverType'] : 'normal';
|
||||
if ( ! empty( $attributes['color'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $attributes['color'] ) );
|
||||
}
|
||||
if ( 'normal' === $bg_type && ! empty( $attributes['background'] ) ) {
|
||||
$css->add_property( 'background', $css->render_color( $attributes['background'] ) . ( 'gradient' === $bg_hover_type ? ' !important' : '' ) );
|
||||
}
|
||||
if ( 'gradient' === $bg_type && ! empty( $attributes['gradient'] ) ) {
|
||||
$css->add_property( 'background', $attributes['gradient'] . ' !important' );
|
||||
}
|
||||
$css->render_typography( $attributes, 'typography' );
|
||||
$css->render_measure_output(
|
||||
$attributes,
|
||||
'borderRadius',
|
||||
'border-radius',
|
||||
[
|
||||
'unit_key' => 'borderRadiusUnit',
|
||||
]
|
||||
);
|
||||
$css->render_border_styles( $attributes, 'borderStyle', true );
|
||||
$css->render_measure_output( $attributes, 'padding', 'padding', [ 'unit_key' => 'paddingUnit' ] );
|
||||
$css->render_measure_output( $attributes, 'margin', 'margin', [ 'unit_key' => 'marginUnit' ] );
|
||||
if ( isset( $attributes['displayShadow'] ) && true === $attributes['displayShadow'] ) {
|
||||
if ( isset( $attributes['shadow'] ) && is_array( $attributes['shadow'] ) && isset( $attributes['shadow'][0] ) && is_array( $attributes['shadow'][0] ) ) {
|
||||
$css->add_property( 'box-shadow', ( isset( $attributes['shadow'][0]['inset'] ) && true === $attributes['shadow'][0]['inset'] ? 'inset ' : '' ) . ( isset( $attributes['shadow'][0]['hOffset'] ) && is_numeric( $attributes['shadow'][0]['hOffset'] ) ? $attributes['shadow'][0]['hOffset'] : '0' ) . 'px ' . ( isset( $attributes['shadow'][0]['vOffset'] ) && is_numeric( $attributes['shadow'][0]['vOffset'] ) ? $attributes['shadow'][0]['vOffset'] : '0' ) . 'px ' . ( isset( $attributes['shadow'][0]['blur'] ) && is_numeric( $attributes['shadow'][0]['blur'] ) ? $attributes['shadow'][0]['blur'] : '14' ) . 'px ' . ( isset( $attributes['shadow'][0]['spread'] ) && is_numeric( $attributes['shadow'][0]['spread'] ) ? $attributes['shadow'][0]['spread'] : '0' ) . 'px ' . $css->render_color( ( isset( $attributes['shadow'][0]['color'] ) && ! empty( $attributes['shadow'][0]['color'] ) ? $attributes['shadow'][0]['color'] : '#000000' ), ( isset( $attributes['shadow'][0]['opacity'] ) && is_numeric( $attributes['shadow'][0]['opacity'] ) ? $attributes['shadow'][0]['opacity'] : 0.2 ) ) );
|
||||
} else {
|
||||
$css->add_property( 'box-shadow', '1px 1px 2px 0px rgba(0, 0, 0, 0.2)' );
|
||||
}
|
||||
}
|
||||
// Icon.
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button .kb-svg-icon-wrap' );
|
||||
if ( ! empty( $attributes['iconColor'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $attributes['iconColor'] ) );
|
||||
}
|
||||
$css->render_measure_output( $attributes, 'iconPadding', 'padding', [ 'unit_key' => 'iconPaddingUnit' ] );
|
||||
$css->render_responsive_range( $attributes, 'iconSize', 'font-size', 'iconSizeUnit' );
|
||||
// Icon Hover.
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button:hover .kb-svg-icon-wrap, .kb-btn' . $class_id . '.kb-button:focus .kb-svg-icon-wrap' );
|
||||
if ( ! empty( $attributes['iconColorHover'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $attributes['iconColorHover'] ) );
|
||||
}
|
||||
// Hover.
|
||||
$css->set_selector( '.kb-submit-field .kb-btn' . $class_id . '.kb-button:hover, .kb-submit-field .kb-btn' . $class_id . '.kb-button:focus' );
|
||||
if ( ! empty( $attributes['colorHover'] ) ) {
|
||||
$css->add_property( 'color', $css->render_color( $attributes['colorHover'] ) );
|
||||
}
|
||||
if ( 'gradient' !== $bg_type && 'normal' === $bg_hover_type && ! empty( $attributes['backgroundHover'] ) ) {
|
||||
$css->add_property( 'background', $css->render_color( $attributes['backgroundHover'] ) );
|
||||
}
|
||||
$css->render_measure_output( $attributes, 'borderHoverRadius', 'border-radius' );
|
||||
$css->render_border_styles( $attributes, 'borderHoverStyle', true );
|
||||
if ( isset( $attributes['displayHoverShadow'] ) && true === $attributes['displayHoverShadow'] ) {
|
||||
if ( ( 'gradient' === $bg_type || 'gradient' === $bg_hover_type ) && isset( $attributes['shadowHover'][0]['inset'] ) && true === $attributes['shadowHover'][0]['inset'] ) {
|
||||
$css->add_property( 'box-shadow', '0px 0px 0px 0px rgba(0, 0, 0, 0)' );
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button:hover::before' );
|
||||
}
|
||||
if ( isset( $attributes['shadowHover'] ) && is_array( $attributes['shadowHover'] ) && isset( $attributes['shadowHover'][0] ) && is_array( $attributes['shadowHover'][0] ) ) {
|
||||
$css->add_property( 'box-shadow', ( isset( $attributes['shadowHover'][0]['inset'] ) && true === $attributes['shadowHover'][0]['inset'] ? 'inset ' : '' ) . ( isset( $attributes['shadowHover'][0]['hOffset'] ) && is_numeric( $attributes['shadowHover'][0]['hOffset'] ) ? $attributes['shadowHover'][0]['hOffset'] : '0' ) . 'px ' . ( isset( $attributes['shadowHover'][0]['vOffset'] ) && is_numeric( $attributes['shadowHover'][0]['vOffset'] ) ? $attributes['shadowHover'][0]['vOffset'] : '0' ) . 'px ' . ( isset( $attributes['shadowHover'][0]['blur'] ) && is_numeric( $attributes['shadowHover'][0]['blur'] ) ? $attributes['shadowHover'][0]['blur'] : '14' ) . 'px ' . ( isset( $attributes['shadowHover'][0]['spread'] ) && is_numeric( $attributes['shadowHover'][0]['spread'] ) ? $attributes['shadowHover'][0]['spread'] : '0' ) . 'px ' . $css->render_color( ( isset( $attributes['shadowHover'][0]['color'] ) && ! empty( $attributes['shadowHover'][0]['color'] ) ? $attributes['shadowHover'][0]['color'] : '#000000' ), ( isset( $attributes['shadowHover'][0]['opacity'] ) && is_numeric( $attributes['shadowHover'][0]['opacity'] ) ? $attributes['shadowHover'][0]['opacity'] : 0.2 ) ) );
|
||||
} else {
|
||||
$css->add_property( 'box-shadow', '2px 2px 3px 0px rgba(0, 0, 0, 0.4)' );
|
||||
}
|
||||
}
|
||||
// Hover before.
|
||||
if ( 'gradient' === $bg_type && 'normal' === $bg_hover_type && ! empty( $attributes['backgroundHover'] ) ) {
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button:hover::before' );
|
||||
$css->add_property( 'background', $css->render_color( $attributes['backgroundHover'] ) );
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button::before' );
|
||||
$css->add_property( 'transition', 'opacity .3s ease-in-out' );
|
||||
}
|
||||
if ( 'gradient' === $bg_hover_type && ! empty( $attributes['gradientHover'] ) ) {
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button:hover::before, .kb-btn' . $class_id . '.kb-button:focus::before' );
|
||||
$css->add_property( 'background', $attributes['gradientHover'] );
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button::before' );
|
||||
$css->add_property( 'transition', 'opacity .3s ease-in-out' );
|
||||
}
|
||||
// Only Icon.
|
||||
if ( isset( $attributes['onlyIcon'][0] ) && '' !== $attributes['onlyIcon'][0] && true == $attributes['onlyIcon'][0] ) {
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button .kt-btn-inner-text' );
|
||||
$css->add_property( 'display', 'none' );
|
||||
}
|
||||
if ( isset( $attributes['onlyIcon'][1] ) && '' !== $attributes['onlyIcon'][1] ) {
|
||||
$css->set_media_state( 'tablet' );
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button .kt-btn-inner-text' );
|
||||
if ( true == $attributes['onlyIcon'][1] ) {
|
||||
$css->add_property( 'display', 'none' );
|
||||
} elseif ( false == $attributes['onlyIcon'][1] ) {
|
||||
$css->add_property( 'display', 'block' );
|
||||
}
|
||||
}
|
||||
if ( isset( $attributes['onlyIcon'][2] ) && '' !== $attributes['onlyIcon'][2] ) {
|
||||
$css->set_media_state( 'mobile' );
|
||||
$css->set_selector( '.kb-btn' . $class_id . '.kb-button .kt-btn-inner-text' );
|
||||
if ( true == $attributes['onlyIcon'][2] ) {
|
||||
$css->add_property( 'display', 'none' );
|
||||
} elseif ( false == $attributes['onlyIcon'][2] ) {
|
||||
$css->add_property( 'display', 'block' );
|
||||
}
|
||||
}
|
||||
$css->set_media_state( 'desktop' );
|
||||
$css->set_selector( '.kb-submit-field.kb-field' . $class_id );
|
||||
$hAlignKeys = [
|
||||
'hAlign' => 'desktop',
|
||||
'thAlign' => 'tablet',
|
||||
'mhAlign' => 'mobile',
|
||||
];
|
||||
foreach ( $hAlignKeys as $alignKey => $device ) {
|
||||
if ( ! empty( $attributes[ $alignKey ] ) ) {
|
||||
$css->set_media_state( $device );
|
||||
switch ( $attributes[ $alignKey ] ) {
|
||||
case 'left':
|
||||
$css->add_property( 'justify-content', 'flex-start' );
|
||||
break;
|
||||
case 'center':
|
||||
$css->add_property( 'justify-content', 'center' );
|
||||
break;
|
||||
case 'right':
|
||||
$css->add_property( 'justify-content', 'flex-end' );
|
||||
break;
|
||||
}
|
||||
|
||||
$css->set_media_state( 'desktop' );
|
||||
}
|
||||
}
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Submit_Block::get_instance();
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Telephone Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Telephone_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'telephone';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'tel';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-text-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Telephone_Input_Block::get_instance();
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Text Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to Build the Accordion Block.
|
||||
*
|
||||
* @category class
|
||||
*/
|
||||
class Kadence_Blocks_Text_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'text';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'text';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-text-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= '<input name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . esc_attr( $type ) . '" placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Text_Input_Block::get_instance();
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Textarea Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Textarea_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'textarea';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'textarea';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$rows = ! empty( $attributes['rows'] ) ? $attributes['rows'] : 3;
|
||||
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-text-type-input', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
|
||||
$inner_content .= '<textarea name="' . esc_attr( $this->field_name( $attributes ) ) . '" id="' . esc_attr( $this->field_id( $attributes ) ) . '" rows="' . esc_attr( $rows ) . '" ' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' placeholder="' . esc_attr( $this->get_placeholder( $attributes ) ) . '" data-type="' . esc_attr( $type ) . '" class="kb-field kb-' . esc_attr( $type ) . '-field" data-required="' . esc_attr( $is_required ) . '" ' . $this->additional_field_attributes( $attributes ) . '>';
|
||||
$inner_content .= esc_attr( $this->get_default( $attributes ) );
|
||||
$inner_content .= '</textarea>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Textarea_Input_Block::get_instance();
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to Build the Advanced Form Time Input Block.
|
||||
*
|
||||
* @package Kadence Blocks
|
||||
*/
|
||||
|
||||
// Exit if accessed directly.
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
class Kadence_Blocks_Time_Input_Block extends Kadence_Blocks_Advanced_Form_Input_Block {
|
||||
|
||||
/**
|
||||
* Instance of this class
|
||||
*
|
||||
* @var null
|
||||
*/
|
||||
private static $instance = null;
|
||||
|
||||
/**
|
||||
* Block name within this namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $block_name = 'time';
|
||||
|
||||
|
||||
/**
|
||||
* Instance Control
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( is_null( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds CSS for block.
|
||||
*
|
||||
* @param array $attributes the blocks attributes.
|
||||
* @param string $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 ) {
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$css->set_style_id( 'kb-' . $this->block_name . $unique_style_id );
|
||||
$css->set_selector( '.wp-block-kadence-advanced-form .kb-field' . $class_id );
|
||||
|
||||
$css->render_responsive_range( $attributes, 'maxWidth', 'max-width', 'maxWidthUnit' );
|
||||
$css->render_responsive_range( $attributes, 'minWidth', 'min-width', 'minWidthUnit' );
|
||||
|
||||
return $css->css_output();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return dynamically generated HTML for block
|
||||
*
|
||||
* @param $attributes
|
||||
* @param $unique_id
|
||||
* @param $content
|
||||
* @param WP_Block $block_instance The instance of the WP_Block class that represents the block being rendered.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_html( $attributes, $unique_id, $content, $block_instance ) {
|
||||
$type = 'time';
|
||||
$is_required = $this->is_required( $attributes );
|
||||
$class_id = $this->class_id( $attributes );
|
||||
$outer_classes = [ 'kb-adv-form-field', 'kb-adv-form-infield-type-input', 'kb-field' . $class_id ];
|
||||
$wrapper_args = [
|
||||
'class' => implode( ' ', $outer_classes ),
|
||||
];
|
||||
$wrapper_attributes = get_block_wrapper_attributes( $wrapper_args );
|
||||
$inner_content = '';
|
||||
$inner_content .= $this->field_label( $attributes );
|
||||
$inner_content .= $this->field_aria_label( $attributes );
|
||||
$inner_content .= '<input name="' . $this->field_name( $attributes ) . '" id="' . $this->field_id( $attributes ) . '"' . $this->aria_described_by( $attributes ) . ' data-label="' . esc_attr( $this->get_label( $attributes ) ) . '"' . $this->get_auto_complete( $attributes ) . ' type="' . $type . '" value="' . esc_attr( $this->get_default( $attributes ) ) . '" data-type="' . $type . '" class="kb-field kb-' . $type . '-field" data-required="' . $is_required . '" ' . $this->additional_field_attributes( $attributes ) . '/>';
|
||||
|
||||
$inner_content .= $this->field_help_text( $attributes );
|
||||
|
||||
$content = sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $inner_content );
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
Kadence_Blocks_Time_Input_Block::get_instance();
|
||||
Reference in New Issue
Block a user