From c01530f53a5e9ba70b3436858c45c0c273c622a2 Mon Sep 17 00:00:00 2001 From: stiofan Date: Thu, 6 Jun 2024 16:10:01 +0100 Subject: [PATCH] * BS > Modal block added for creating popups - ADDED * Most blocks now show better previews - ADDED * Parent and allowedBlocks params added to some blocks to remove them from main list when they can only be nested - CHANGED * Some blocks such as Navbar will now auto add child element dummy data on insert for faster building - ADDED * Some blocks such as tabs were not working in editor with certain AyeCode UI setting - FIXED --- assets/css/block-editor.css | 2 +- assets/css/block-editor.scss | 11 +- blocks/blocks.js | 1 + ...class-blockstrap-widget-accordion-item.php | 3 +- blocks/class-blockstrap-widget-accordion.php | 4 +- blocks/class-blockstrap-widget-breadcrumb.php | 4 +- blocks/class-blockstrap-widget-button.php | 8 +- blocks/class-blockstrap-widget-container.php | 12 +- blocks/class-blockstrap-widget-gallery.php | 6 +- blocks/class-blockstrap-widget-icon-box.php | 6 +- blocks/class-blockstrap-widget-modal.php | 651 ++ .../class-blockstrap-widget-nav-dropdown.php | 1 + blocks/class-blockstrap-widget-nav-item.php | 27 +- blocks/class-blockstrap-widget-nav.php | 37 +- blocks/class-blockstrap-widget-navbar.php | 17 +- blocks/class-blockstrap-widget-post-info.php | 3 +- blocks/class-blockstrap-widget-rating.php | 8 +- blocks/class-blockstrap-widget-scroll-top.php | 4 +- .../class-blockstrap-widget-shape-divider.php | 8 +- blocks/class-blockstrap-widget-share.php | 5 +- blocks/class-blockstrap-widget-skip-links.php | 6 +- blocks/class-blockstrap-widget-tab.php | 3 +- blocks/class-blockstrap-widget-tabs.php | 5 +- blockstrap-page-builder-blocks.php | 2 +- patterns/footer.php | 8 +- patterns/hero.php | 4 +- patterns/menu.php | 16 +- readme.txt | 13 + .../includes/ayecode-ui-settings.php | 12 +- .../ayecode/wp-super-duper/wp-super-duper.php | 9807 +++++++++-------- 30 files changed, 5736 insertions(+), 4958 deletions(-) create mode 100644 blocks/class-blockstrap-widget-modal.php diff --git a/assets/css/block-editor.css b/assets/css/block-editor.css index f104077..8e7ceac 100644 --- a/assets/css/block-editor.css +++ b/assets/css/block-editor.css @@ -1 +1 @@ -.wp-block-blockstrap-blockstrap-widget-skip-links.bs-skip-links.is-selected{transform:translate(-50%, 0%)}@media (max-width: 840px){.wp-block-blockstrap-blockstrap-widget-navbar.is-selected .wp-block-blockstrap-blockstrap-widget-nav,.wp-block-blockstrap-blockstrap-widget-navbar.has-child-selected .wp-block-blockstrap-blockstrap-widget-nav{display:block !important}.navbar.bg-transparent.navbar-dark{background:#343a40 !important}.navbar.bg-transparent.navbar-light{background:#f8f9fa !important}} +.wp-block-blockstrap-blockstrap-widget-skip-links.bs-skip-links.is-selected{transform:translate(-50%, 0%)}.modal:has(.wp-block-blockstrap-blockstrap-widget-modal.is-selected),.modal:has(.wp-block-blockstrap-blockstrap-widget-modal.has-child-selected){display:block;position:relative;opacity:1 !important}@media (max-width: 840px){.wp-block-blockstrap-blockstrap-widget-navbar.is-selected .wp-block-blockstrap-blockstrap-widget-nav,.wp-block-blockstrap-blockstrap-widget-navbar.has-child-selected .wp-block-blockstrap-blockstrap-widget-nav{display:block !important}.navbar.bg-transparent.navbar-dark{background:#343a40 !important}.navbar.bg-transparent.navbar-light{background:#f8f9fa !important}} diff --git a/assets/css/block-editor.scss b/assets/css/block-editor.scss index 5d850db..7eeda05 100644 --- a/assets/css/block-editor.scss +++ b/assets/css/block-editor.scss @@ -3,6 +3,16 @@ transform: translate(-50%, 0%); } +.modal { + @at-root .modal:has(.wp-block-blockstrap-blockstrap-widget-modal.is-selected), + .modal:has(.wp-block-blockstrap-blockstrap-widget-modal.has-child-selected) { + display: block; + position: relative; + opacity: 1 !important; + } +} + + /* show responsive menu if selected */ @media ( max-width: 840px ) { .wp-block-blockstrap-blockstrap-widget-navbar { @@ -21,4 +31,3 @@ background: #f8f9fa !important; } } - diff --git a/blocks/blocks.js b/blocks/blocks.js index 084f598..840a799 100644 --- a/blocks/blocks.js +++ b/blocks/blocks.js @@ -38,6 +38,7 @@ registerBlockType( 'blockstrap/blockstrap-widget-accordion-item', { title: 'BS > registerBlockType( 'blockstrap/blockstrap-widget-contact', { title: 'BS > Contact Form' } ); registerBlockType( 'blockstrap/blockstrap-widget-rating', { title: 'BS > Rating' } ); registerBlockType( 'blockstrap/blockstrap-widget-scroll-top', { title: 'BS > Scroll Top' } ); +registerBlockType( 'blockstrap/blockstrap-widget-modal', { title: 'BS > Modal' } ); */ diff --git a/blocks/class-blockstrap-widget-accordion-item.php b/blocks/class-blockstrap-widget-accordion-item.php index ce297d4..5b7711b 100644 --- a/blocks/class-blockstrap-widget-accordion-item.php +++ b/blocks/class-blockstrap-widget-accordion-item.php @@ -21,6 +21,7 @@ public function __construct() { 'anchor' => false, 'customClassName' => false, ), + 'parent' => array('blockstrap/blockstrap-widget-accordion'), 'block-output' => array( array( 'element' => 'div', @@ -44,7 +45,7 @@ public function __construct() { array( 'element' => 'div', 'if_className' => 'props.attributes.state === "closed" ? "accordion-collapse collapse" : "accordion-collapse collapse show"', - 'if_x' => '( typeof parentBlocks !== "undefined" && parentBlocks[parentBlocks.length - 1].attributes.anchor ) ? props.setAttributes({parent_anchor: parentBlocks[parentBlocks.length - 1].attributes.anchor}) : ""', // required + 'if_x' => '( typeof parentBlocks !== "undefined" && parentBlocks[parentBlocks.length - 1]?.attributes?.length && parentBlocks[parentBlocks.length - 1].attributes.anchor ) ? props.setAttributes({parent_anchor: parentBlocks[parentBlocks.length - 1].attributes.anchor}) : ""', // required 'if_id' => '"collapse-"+props.attributes.anchor', 'if_"aria-labelledby"' => '"heading-"+props.attributes.anchor', 'if_"data-bs-parent"' => 'props.attributes.parent_anchor ? "#"+props.attributes.parent_anchor : ""', diff --git a/blocks/class-blockstrap-widget-accordion.php b/blocks/class-blockstrap-widget-accordion.php index f6d920d..1aa08e0 100644 --- a/blocks/class-blockstrap-widget-accordion.php +++ b/blocks/class-blockstrap-widget-accordion.php @@ -11,7 +11,8 @@ class BlockStrap_Widget_Accordion extends WP_Super_Duper */ public function __construct() { - $aui_settings = is_admin() ? get_option('ayecode-ui-settings') : []; + $aui_settings = is_admin() ? get_option( 'ayecode-ui-settings', array()) : array(); + $aui_settings = apply_filters( 'ayecode-ui-settings', $aui_settings, array(), array() ); $bs5 = ! empty($aui_settings['bs_ver']) && '5' === $aui_settings['bs_ver'] ? 'bs-' : ''; $options = [ @@ -25,6 +26,7 @@ public function __construct() 'block-category' => 'layout', 'block-keywords' => "['accordion','list','content']", 'block-supports' => ['customClassName' => false], + 'allowed-blocks' => array('blockstrap/blockstrap-widget-accordion-item'), 'block-output' => [ [ 'element' => 'innerBlocksProps', diff --git a/blocks/class-blockstrap-widget-breadcrumb.php b/blocks/class-blockstrap-widget-breadcrumb.php index 9e99ead..67464d6 100644 --- a/blocks/class-blockstrap-widget-breadcrumb.php +++ b/blocks/class-blockstrap-widget-breadcrumb.php @@ -33,9 +33,7 @@ className: '', 'description' => esc_html__( 'A bootstrap breadcrumb output.', 'blockstrap-page-builder-blocks' ), ), 'example' => array( - 'attributes' => array( - 'after_text' => 'Earth', - ), + 'viewportWidth' => 300 ), 'no_wrap' => true, 'block_group_tabs' => array( diff --git a/blocks/class-blockstrap-widget-button.php b/blocks/class-blockstrap-widget-button.php index 3b39412..65f60f1 100644 --- a/blocks/class-blockstrap-widget-button.php +++ b/blocks/class-blockstrap-widget-button.php @@ -33,9 +33,7 @@ className: '', 'description' => esc_html__( 'A bootstrap button, badge or iconbox.', 'blockstrap-page-builder-blocks' ), ), 'example' => array( - 'attributes' => array( - 'after_text' => 'Earth', - ), + 'viewportWidth' => 200 ), 'no_wrap' => true, 'block_group_tabs' => array( @@ -132,7 +130,7 @@ public function set_arguments() { 'type' => 'text', 'title' => __( 'Custom URL', 'blockstrap-page-builder-blocks' ), 'desc' => __( 'Add custom link URL', 'blockstrap-page-builder-blocks' ), - 'placeholder' => __( 'https://example.com', 'blockstrap-page-builder-blocks' ), + 'placeholder' => __( 'https://example.com or #contact-form', 'blockstrap-page-builder-blocks' ), 'default' => '', 'desc_tip' => true, 'group' => __( 'Link', 'blockstrap-page-builder-blocks' ), @@ -141,7 +139,7 @@ public function set_arguments() { $arguments['lightbox_notice'] = array( 'type' => 'notice', - 'desc' => __( 'Enter the BS > Contact form ID prefixed by a `#` eg: #contact-form', 'blockstrap-page-builder-blocks' ), + 'desc' => __( 'Enter the BS > Contact or BS > Modal form ID prefixed by a `#` eg: #contact-form', 'blockstrap-page-builder-blocks' ), 'status' => 'info', 'group' => __( 'Link', 'blockstrap-page-builder-blocks' ), 'element_require' => '[%type%]=="lightbox"', diff --git a/blocks/class-blockstrap-widget-container.php b/blocks/class-blockstrap-widget-container.php index 945aa81..49db752 100644 --- a/blocks/class-blockstrap-widget-container.php +++ b/blocks/class-blockstrap-widget-container.php @@ -65,9 +65,15 @@ public function __construct() { 'description' => esc_html__( 'A container for content', 'blockstrap-page-builder-blocks' ), ), 'example' => array( - 'attributes' => array( - 'after_text' => 'Earth', - ), + 'viewportWidth' => 300, + 'innerBlocks' => array( + array( + 'name' => 'core/paragraph', + 'attributes' => array( + 'content' => esc_html__( 'A container for content', 'blockstrap-page-builder-blocks' ), + ) + ) + ) ), 'no_wrap' => true, 'block_group_tabs' => array( diff --git a/blocks/class-blockstrap-widget-gallery.php b/blocks/class-blockstrap-widget-gallery.php index e405bfc..32faf06 100644 --- a/blocks/class-blockstrap-widget-gallery.php +++ b/blocks/class-blockstrap-widget-gallery.php @@ -30,11 +30,7 @@ public function __construct() { 'classname' => 'bs-image', 'description' => esc_html__( 'An image gallery.', 'blockstrap-page-builder-blocks' ), ), - 'example' => array( - 'attributes' => array( - 'after_text' => 'Earth', - ), - ), + 'example' => false, 'no_wrap' => true, 'block_group_tabs' => array( 'content' => array( diff --git a/blocks/class-blockstrap-widget-icon-box.php b/blocks/class-blockstrap-widget-icon-box.php index 763ac51..36b95a5 100644 --- a/blocks/class-blockstrap-widget-icon-box.php +++ b/blocks/class-blockstrap-widget-icon-box.php @@ -34,8 +34,12 @@ className: '', ), 'example' => array( 'attributes' => array( - 'after_text' => 'Earth', + 'icon_class' => 'fas fa-ship', + 'icon_type' => 'iconbox-translucent', + 'iconbox_size' => 'medium', + 'icon_color' => 'success', ), + 'viewportWidth' => 300 ), 'no_wrap' => true, 'block_group_tabs' => array( diff --git a/blocks/class-blockstrap-widget-modal.php b/blocks/class-blockstrap-widget-modal.php new file mode 100644 index 0000000..271c2e7 --- /dev/null +++ b/blocks/class-blockstrap-widget-modal.php @@ -0,0 +1,651 @@ + 'blockstrap', + 'output_types' => [ + 'block', + 'shortcode', + ], + 'nested-block' => true, + 'block-icon' => 'fas fa-square', + 'block-category' => 'layout', + 'block-keywords' => "['modal','popup','lightbox']", + 'block-supports' => ['customClassName' => false], + 'block-output' => [ + [ + 'element' => 'BlocksProps', + 'blockProps' => array( + 'if_className' => 'bs_build_modal_button_class(props.attributes)', + ), + 'inner_element' => 'button', +// setTimeout(function() { window.dispatchEvent(new Event('resize')); }, 1000);" +// 'if_onclick' => 'alert(1)',//'setTimeout(function() { window.dispatchEvent(new Event("resize")); }, 1000);', + '"data-bs-togglex"' => 'modal', + 'if_"data-bs-target"' => 'props.attributes.anchor ? "#" + props.attributes.anchor : "#" + props.attributes.styleid', + 'if_content' => 'props.attributes.button_text', + 'element_require' => '[%open_with%]==""', + ], + [ + 'element' => 'BlocksProps', + 'blockProps' => array( + 'className' => 'alert alert-info', + ), + 'inner_element' => 'div', + 'if_content' => '"Modal Placeholder for #" + bs_build_modal_id(props.attributes)', + 'element_require' => '[%open_with%]=="external"', + ], + array( + 'element' => 'div', + 'if_id' => 'props.attributes.anchor ? props.attributes.anchor : props.attributes.styleid', + 'if_class' => 'props.attributes.animation && props.attributes.animation === "no" ? "modal" : "modal fade"', + 'tabindex' => '-1', + 'if_"data-bs-backdrop"' => 'props.attributes.static_backdrop && props.attributes.static_backdrop == "yes" ? "static" : "true"', + 'if_"data-bs-keyboard"' => 'props.attributes.static_backdrop && props.attributes.static_backdrop == "yes" ? "false" : "true"', + array( + 'element' => 'div', + 'if_class' => '"modal-dialog " + bs_build_modal_dialog_class(props.attributes)', + array( + 'element' => 'div', + 'if_class' => '"modal-content overflow-hidden " [%WrapClass%]', + 'style' => '{[%WrapStyle%]}', + array( + 'element' => 'div', + 'if_class' => '"modal-header " + bs_build_modal_header_class(props.attributes)', + array( + 'element' => 'h1', + 'if_class' => '"modal-title " + bs_build_modal_title_class(props.attributes)', + 'if_content' => 'props.attributes.header_title', + ), + array( + 'element' => 'button', + 'if_class' => 'props.attributes.close_icon=="hide" ? "d-none" : "btn-close bg-white"', + '"data-bs-dismiss"' => 'modal', + '"aria-label"' => 'Close', + ), + + ), + array( + 'element' => 'div', + 'if_class' => '"modal-body " + bs_build_modal_body_class(props.attributes)', + array( + 'element' => 'innerBlocksProps', + 'blockProps' => array( + ), + 'innerBlocksProps' => array( + 'orientation' => 'vertical', + ), + + ), + ) + + ) + ), + + ), + ], + 'example' => array( + 'viewportWidth' => 200 + ), + 'block-wrap' => '', + 'block-api-version' => 3, // this is needed to make the block selectable in the editor if not using innerBlockProps https://wordpress.stackexchange.com/questions/384004/cant-select-my-block-by-clicking-on-it + 'class_name' => __CLASS__, + 'base_id' => 'bs_modal', + 'name' => __('BS > Modal', 'blockstrap-page-builder-blocks'), + 'widget_ops' => [ + 'classname' => 'bs-modal', + 'description' => esc_html__('A Bootstrap Modal builder', 'blockstrap-page-builder-blocks'), + ], + 'no_wrap' => true, + 'block_group_tabs' => [ + 'content' => array( + 'groups' => array( + __( 'Modal', 'blockstrap-page-builder-blocks' ), + __( 'Header', 'blockstrap-page-builder-blocks' ), + __( 'Body', 'blockstrap-page-builder-blocks' ), + __( 'Footer', 'blockstrap-page-builder-blocks' ), + ), + 'tab' => array( + 'title' => __( 'Content', 'blockstrap-page-builder-blocks' ), + 'key' => 'bs_tab_content', + 'tabs_open' => true, + 'open' => true, + 'class' => 'text-center flex-fill d-flex justify-content-center', + ), + ), + 'styles' => [ + 'groups' => [ + __('Button', 'blockstrap-page-builder-blocks'), + __('Modal Header', 'blockstrap-page-builder-blocks'), + __('Modal Body', 'blockstrap-page-builder-blocks'), + ], + 'tab' => [ + 'title' => __('Styles', 'blockstrap-page-builder-blocks'), + 'key' => 'bs_tab_styles', + 'tabs_open' => true, + 'open' => true, + 'class' => 'text-center flex-fill d-flex justify-content-center', + ], + ], + 'advanced' => [ + 'groups' => [ + __('Wrapper Styles', 'blockstrap-page-builder-blocks'), + __('Advanced', 'blockstrap-page-builder-blocks'), + ], + 'tab' => [ + 'title' => __('Advanced', 'blockstrap-page-builder-blocks'), + 'key' => 'bs_tab_advanced', + 'tabs_open' => true, + 'open' => true, + 'class' => 'text-center flex-fill d-flex justify-content-center', + ], + ], + ], + ]; + + parent::__construct($options); + + }//end __construct() + + + /** + * Set the arguments later. + * + * @return array + */ + public function set_arguments() + { + $arguments = []; + + $arguments['footer_notice'] = [ + 'type' => 'notice', + 'desc' => __('Place in the theme footer to be able to open on any page.', 'blockstrap-page-builder-blocks'), + 'status' => 'info', + // 'warning' | 'success' | 'error' | 'info' + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + 'element_require' => '[%open_with%]=="external"', + ]; + + $arguments['open_with'] = [ + 'type' => 'select', + 'title' => __('Open with', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('Button', 'blockstrap-page-builder-blocks'), + 'external' => __('Another Element', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc_tip' => true, + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['anchor'] = [ + 'type' => 'text', + 'title' => __('Modal ID', 'blockstrap-page-builder-blocks'), + 'default' => '', +// 'custom_attributes' => array( +//// 'pattern' => '[A-Za-z0-9_\-\.]+', +// 'onkeyup' => "alert(1)", +// ), + 'desc' => __('Enter an ID with no spaces, only dashes allowed, eg: contact-form', 'blockstrap-page-builder-blocks'), + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + 'element_require' => '[%open_with%]=="external"', + ]; + + $arguments['anchor_notice'] = [ + 'type' => 'notice', + 'desc' => __('The Modal ID can be used by other blocks to open the Modal, BS > Button or BS > Nav item', 'blockstrap-page-builder-blocks'), + 'status' => 'error', + // 'warning' | 'success' | 'error' | 'info' + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + 'element_require' => '[%open_with%]=="external"', + ]; + + $arguments['button_text'] = [ + 'type' => 'text', + 'title' => __('Button text', 'blockstrap-page-builder-blocks'), + 'placeholder' => __('Open Popup', 'blockstrap-page-builder-blocks'), + 'default' => __('Open Modal', 'blockstrap-page-builder-blocks'), + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['size'] = [ + 'type' => 'select', + 'title' => __('Size', 'blockstrap-page-builder-blocks'), + 'options' => [ + 'sm' => __('Small', 'blockstrap-page-builder-blocks'), + '' => __('Default', 'blockstrap-page-builder-blocks'), + 'lg' => __('Large', 'blockstrap-page-builder-blocks'), + 'xl' => __('Extra Large', 'blockstrap-page-builder-blocks'), + '100' => __('100% Width', 'blockstrap-page-builder-blocks'), + 'fullscreen' => __('Full Screen', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc_tip' => true, + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['modal_position'] = [ + 'type' => 'select', + 'title' => __('Vertical Position', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('Top', 'blockstrap-page-builder-blocks'), + 'center' => __('Centered', 'blockstrap-page-builder-blocks'), + ], + 'default' => 'center', + 'desc_tip' => true, + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['animation'] = [ + 'type' => 'select', + 'title' => __('Fade-in Animation', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('Yes', 'blockstrap-page-builder-blocks'), + 'no' => __('no', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc_tip' => true, + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['static_backdrop'] = [ + 'type' => 'select', + 'title' => __('Static Backdrop', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('No', 'blockstrap-page-builder-blocks'), + 'yes' => __('Yes', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc' => __('Prevents modal close on clicks outside modal and on keyboard Esc', 'blockstrap-page-builder-blocks'), + 'desc_tip' => true, + 'group' => __('Modal', 'blockstrap-page-builder-blocks'), + ]; + + + + + // Header + + $arguments['header_hide'] = [ + 'type' => 'select', + 'title' => __('Header', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('Show', 'blockstrap-page-builder-blocks'), + 'hide' => __('Hide', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc_tip' => true, + 'group' => __('Header', 'blockstrap-page-builder-blocks'), + ]; + + $arguments['header_title'] = [ + 'type' => 'text', + 'title' => __('Header title', 'blockstrap-page-builder-blocks'), + 'placeholder' => __('Popup title', 'blockstrap-page-builder-blocks'), + 'default' => __('Modal title', 'blockstrap-page-builder-blocks'), + 'group' => __('Header', 'blockstrap-page-builder-blocks'), + ]; + + + $arguments['close_icon'] = [ + 'type' => 'select', + 'title' => __('Close Icon', 'blockstrap-page-builder-blocks'), + 'options' => [ + '' => __('Show', 'blockstrap-page-builder-blocks'), + 'hide' => __('Hide', 'blockstrap-page-builder-blocks'), + ], + 'default' => '', + 'desc_tip' => true, + 'group' => __('Header', 'blockstrap-page-builder-blocks'), + ]; + + // STYLES + + // Button Styles + // button styles + $arguments['link_type'] = array( + 'type' => 'select', + 'title' => __( 'Link style', 'blockstrap-page-builder-blocks' ), + 'options' => array( + 'btn' => __( 'Button', 'blockstrap-page-builder-blocks' ), + 'btn-round' => __( 'Button rounded', 'blockstrap-page-builder-blocks' ), + 'iconbox-fill' => __( 'Iconbox filled', 'blockstrap-page-builder-blocks' ), + ), + 'default' => 'btn', + 'desc_tip' => true, + 'group' => __( 'Button', 'blockstrap-page-builder-blocks' ), + ); + + $arguments['link_size'] = array( + 'type' => 'select', + 'title' => __( 'Size', 'blockstrap-page-builder-blocks' ), + 'options' => array( + '' => __( 'Default', 'blockstrap-page-builder-blocks' ), + 'small' => __( 'Small', 'blockstrap-page-builder-blocks' ), + 'medium' => __( 'Medium', 'blockstrap-page-builder-blocks' ), + 'large' => __( 'Large', 'blockstrap-page-builder-blocks' ), + ), + 'default' => '', + 'desc_tip' => true, + 'group' => __( 'Button', 'blockstrap-page-builder-blocks' ), + 'element_require' => '[%link_type%]!="badge" && [%link_type%]!="badge-pill"', + ); + + + $arguments = $arguments + sd_get_background_inputs( + 'link_bg', + array( + 'title' => __( 'Color', 'blockstrap-page-builder-blocks' ), + 'group' => __( 'Button', 'blockstrap-page-builder-blocks' ), + 'element_require' => '[%link_type%]!="iconbox"', + 'default' => 'primary', + ), + false, + false, + false, + true + ); + + + // Header + + + + $arguments['header_text_color'] = sd_get_text_color_input( 'text_color', array( + 'group' => __( 'Modal Header', 'blockstrap-page-builder-blocks' ), + )); + + // font size + $arguments['header_font_size'] = sd_get_font_size_input( 'font_size', array( + 'group' => __( 'Modal Header', 'blockstrap-page-builder-blocks' ), + 'default' => 'fs-5', + )); + + // font size + $arguments['header_font_weight'] = sd_get_font_weight_input('font_weight', array( + 'group' => __( 'Modal Header', 'blockstrap-page-builder-blocks' ), + )); + + + // background + $arguments = $arguments + sd_get_background_inputs( + 'header_bg', + array('group' => __('Modal Header', 'blockstrap-page-builder-blocks')), + array('group' => __('Modal Header', 'blockstrap-page-builder-blocks')), + array('group' => __('Modal Header', 'blockstrap-page-builder-blocks')), + false + ); + + + // Modal Content + // background + $arguments = $arguments + sd_get_background_inputs( + 'body_bg', + array('group' => __('Modal Body', 'blockstrap-page-builder-blocks')), + array('group' => __('Modal Body', 'blockstrap-page-builder-blocks')), + array('group' => __('Modal Body', 'blockstrap-page-builder-blocks')), + false + ); + + + // padding + $arguments['body_pt'] = sd_get_padding_input('pt', array('group' => __('Modal Body', 'blockstrap-page-builder-blocks') ) ); + $arguments['body_pr'] = sd_get_padding_input('pr', array('group' => __('Modal Body', 'blockstrap-page-builder-blocks') ) ); + $arguments['body_pb'] = sd_get_padding_input('pb', array('group' => __('Modal Body', 'blockstrap-page-builder-blocks') )); + $arguments['body_pl'] = sd_get_padding_input('pl', array('group' => __('Modal Body', 'blockstrap-page-builder-blocks') ) ); + + + // border + $arguments['border'] = sd_get_border_input('border'); + $arguments['rounded'] = sd_get_border_input('rounded'); + $arguments['rounded_size'] = sd_get_border_input('rounded_size'); + + // shadow + $arguments['shadow'] = sd_get_shadow_input('shadow'); + + // block visibility conditions + $arguments['visibility_conditions'] = sd_get_visibility_conditions_input(); + + $arguments['css_class'] = sd_get_class_input(); + + // advanced +// $arguments['anchor'] = sd_get_anchor_input(); + + $arguments['styleid'] = array( + 'type' => 'hidden', + 'title' => __( 'Style ID', 'blockstrap-page-builder-blocks' ), + 'desc_tip' => true, + 'group' => __( 'Advanced', 'blockstrap-page-builder-blocks' ), + ); + + if (function_exists('sd_get_custom_name_input')) { + $arguments['metadata_name'] = sd_get_custom_name_input(); + } + + return $arguments; + + }//end set_arguments() + + + /** + * This is the output function for the widget, shortcode and block (front end). + * + * @param array $args The arguments values. + * @param array $widget_args The widget arguments when used. + * @param string $content The shortcode content argument. + * + * @return string + */ + public function output($args=[], $widget_args=[], $content='') + { + global $bs_modal_content,$bs_modal_header_count; + + if (!$bs_modal_header_count) { + $bs_modal_header_count = 0; + } + + // we add the x so it will not open popup in editor, then we remove it here so on frontend it will + $content = str_replace('data-bs-togglex', 'onclick="setTimeout(function() { window.dispatchEvent(new Event(\'resize\')); }, 200);" data-bs-toggle', $content); + + // Maybe remove the placeholder div + if ($content) { + // Define the pattern to match the first div with the specific classes + $pattern = '/
.*?<\/div>/s'; + + // Replace the first occurrence of the pattern with an empty string + $content = preg_replace($pattern, '', $content, 1); + } + + + // + // Regex to match the first top-level button + $buttonRegex = '/]*\sdata-bs-target="[^"]*"[^>]*>(.*?)<\/button>/is'; + + + // Initialize variables + $buttonHtml = ''; + $bs_modal_content[$bs_modal_header_count] = $content; + + // Find the first top-level button and separate it from the content + if (preg_match($buttonRegex, $content, $matches)) { + $buttonHtml = $matches[0]; + // Remove the button from the remaining content + $bs_modal_content[$bs_modal_header_count] = preg_replace($buttonRegex, '', $content, 1); + } + + // add the modal HTML to the footer, this needs to work for multiple instances + add_action('wp_footer', function() { + global $bs_modal_content,$bs_modal_header_count; + if ($bs_modal_header_count) { + foreach ($bs_modal_content as $content) { + echo $content; + } + $bs_modal_header_count = 0; // reset the + } + }); + + $bs_modal_header_count++; + + return $buttonHtml; + + }//end output() + + public function block_global_js() { + ob_start(); + if ( false ) { + ?> + [/bs_nav] +
[/bs_nav] - [bs_nav anchor='main-nav' inside_navbar='1' container='' flex_direction='' nav_style='' flex_justify_content='' flex_justify_content_md='' flex_justify_content_lg='' nav_fill='' font_size='0' font_size_custom='' bg='' mt='' mr='auto' mb='' ml='auto' mt_md='' mr_md='' mb_md='' ml_md='' mt_lg='' mr_lg='0' mb_lg='' ml_lg='' pt='' pr='' pb='' pl='' pt_md='' pr_md='' pb_md='' pl_md='' pt_lg='' pr_lg='' pb_lg='' pl_lg='' border='' rounded='' rounded_size='lg' shadow='' width='w-100' css_class='' ][/bs_nav] Rating Add a start rating icons to your posts. (can also be used to output GeoDirectory post ratings) +### BS > Scroll Top +Add a button to the page so users can scroll back to the top of the page easily. + +### BS > Modal +Add a modal (popup) to the page containing any content. + ## Get BlockStrap Today! Take your WordPress site to the next level with the BlockStrap plugin. Experience the power of Bootstrap in your WordPress block editor today! @@ -167,6 +173,13 @@ Automatic updates should work seamlessly. We always suggest you backup your webs == Changelog == += 0.1.17 = +* BS > Modal block added for creating popups - ADDED +* Most blocks now show better previews - ADDED +* Parent and allowedBlocks params added to some blocks to remove them from main list when they can only be nested - CHANGED +* Some blocks such as Navbar will now auto add child element dummy data on insert for faster building - ADDED +* Some blocks such as tabs were not working in editor with certain AyeCode UI setting - FIXED + = 0.1.16 = * Nav item can show class in name for UWP login in/out - FIXED * Accordion block now has option to enable FAQ Schema - ADDED diff --git a/vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php b/vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php index 441f619..3b6fca1 100644 --- a/vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php +++ b/vendor/ayecode/wp-ayecode-ui/includes/ayecode-ui-settings.php @@ -529,7 +529,7 @@ public function enqueue_style() { .bs-tooltip-top .arrow{ margin-left:0px; } - + .custom-switch input[type=checkbox]{ display:none; } @@ -1443,7 +1443,7 @@ public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex // buttons $output .= $prefix . ' .btn-'.esc_attr($type).'{'; - $output .= ' + $output .= ' --bs-btn-bg: '.esc_attr($color_code).'; --bs-btn-border-color: '.esc_attr($color_code).'; --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); @@ -1465,7 +1465,7 @@ public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex // buttons outline $output .= $prefix . ' .btn-outline-'.esc_attr($type).'{'; - $output .= ' + $output .= ' --bs-btn-color: '.esc_attr($color_code).'; --bs-btn-border-color: '.esc_attr($color_code).'; --bs-btn-hover-bg: rgba(var(--bs-'.esc_attr($type).'-rgb), .9); @@ -1488,7 +1488,7 @@ public static function css_overwrite_bs5($type,$color_code,$compatibility, $hex // button hover $output .= $prefix . ' .btn-'.esc_attr($type).':hover{'; - $output .= ' + $output .= ' box-shadow: 0 0.25rem 0.25rem 0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb), .1), 0 0.375rem 0.75rem -0.125rem rgb(var(--bs-'.esc_attr($type).'-rgb) , .4); } '; @@ -2793,7 +2793,7 @@ function aui_cf_field_apply_rules($el) { found = true; } } - + if (found) { $keys[condition.key][index] = true; } else { @@ -3122,4 +3122,4 @@ function aui_cf_field_hide_element($el) { * Run the class if found. */ AyeCode_UI_Settings::instance(); -} \ No newline at end of file +} diff --git a/vendor/ayecode/wp-super-duper/wp-super-duper.php b/vendor/ayecode/wp-super-duper/wp-super-duper.php index 6f50d16..cdbf328 100644 --- a/vendor/ayecode/wp-super-duper/wp-super-duper.php +++ b/vendor/ayecode/wp-super-duper/wp-super-duper.php @@ -1,2602 +1,2629 @@ $options['name'], - 'class_name' => $options['class_name'], - 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() - ); - $this->base_id = $options['base_id']; - // lets filter the options before we do anything - $options = apply_filters( "wp_super_duper_options", $options ); - $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); - $options = $this->add_name_from_key( $options ); - $this->options = $options; - - $this->base_id = $options['base_id']; - $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); - - // nested blocks can't work as a widget - if(!empty($this->options['nested-block'])){ - if(empty($this->options['output_types'])){ - $this->options['output_types'] = array('shortcode','block'); - }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { - unset($this->options['output_types'][$key]); - } - } - - // init parent - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ - parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); - } - - - if ( isset( $options['class_name'] ) ) { - // register widget - $this->class_name = $options['class_name']; - - // register shortcode, this needs to be done even for blocks and widgets - $this->register_shortcode(); - - - // Fusion Builder (avada) support - if ( function_exists( 'fusion_builder_map' ) ) { - add_action( 'init', array( $this, 'register_fusion_element' ) ); - } - - // register block - if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ - add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); - } - } - - // add the CSS and JS we need ONCE - global $sd_widget_scripts; - - if ( ! $sd_widget_scripts ) { - wp_add_inline_script( 'admin-widgets', $this->widget_js() ); - wp_add_inline_script( 'customize-controls', $this->widget_js() ); - wp_add_inline_style( 'widgets', $this->widget_css() ); - - // maybe add elementor editor styles - add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); - - $sd_widget_scripts = true; - - // add shortcode insert button once - add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); - // generatepress theme sections compatibility - if ( function_exists( 'generate_sections_sections_metabox' ) ) { - add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); - } - /* Load script on Divi theme builder page */ - if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { - add_thickbox(); - add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); - } - - if ( $this->is_preview() ) { - add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); - // this makes the insert button work for elementor - add_action( 'elementor/editor/after_enqueue_scripts', array( - $this, - 'shortcode_insert_button_script' - ) ); // for elementor - } - // this makes the insert button work for cornerstone - add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); - - add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); - add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); - - // add generator text to head - add_action( 'admin_head', array( $this, 'generator' ), 99 ); - add_action( 'wp_head', array( $this, 'generator' ), 99 ); - } - - do_action( 'wp_super_duper_widget_init', $options, $this ); - } - - /** - * The register widget function - * @return void - */ - public function _register() { - if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ - parent::_register(); - } - } - - /** - * Add our widget CSS to elementor editor. - */ - public function elementor_editor_styles() { - wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); - } - - public function register_fusion_element() { - - $options = $this->options; - - if ( $this->base_id ) { - - $params = $this->get_fusion_params(); - - $args = array( - 'name' => $options['name'], - 'shortcode' => $this->base_id, - 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', - 'allow_generator' => true, - ); - - if ( ! empty( $params ) ) { - $args['params'] = $params; - } - - fusion_builder_map( $args ); - } - - } - - public function get_fusion_params() { - $params = array(); - $arguments = $this->get_arguments(); - - if ( ! empty( $arguments ) ) { - foreach ( $arguments as $key => $val ) { - $param = array(); - // type - $param['type'] = str_replace( - array( - "text", - "number", - "email", - "color", - "checkbox" - ), - array( - "textfield", - "textfield", - "textfield", - "colorpicker", - "select", - - ), - $val['type'] ); - - // multiselect - if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { - $param['type'] = 'multiple_select'; - $param['multiple'] = true; - } - - // heading - $param['heading'] = isset( $val['title'] ) ? $val['title'] : ''; - - // description - $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; - - // param_name - $param['param_name'] = $key; - - // Default - $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; - - // Group - if ( isset( $val['group'] ) ) { - $param['group'] = $val['group']; - } - - // value - if ( $val['type'] == 'checkbox' ) { - if ( isset( $val['default'] ) && $val['default'] == '0' ) { - unset( $param['default'] ); - } - $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) ); - } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { - $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); - } else { - $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; - } - - // setup the param - $params[] = $param; - - } - } - - - return $params; - } - - /** - * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder - */ - public static function maybe_cornerstone_builder() { - if ( did_action( 'cornerstone_before_boot_app' ) ) { - self::shortcode_insert_button_script(); - } - } - - /** - * A function to ge the shortcode builder picker html. - * - * @param string $editor_id - * - * @return string - */ - public static function get_picker( $editor_id = '' ) { - - ob_start(); - if ( isset( $_POST['editor_id'] ) ) { - $editor_id = esc_attr( $_POST['editor_id'] ); - } elseif ( isset( $_REQUEST['et_fb'] ) ) { - $editor_id = 'main_content_content_vb_tiny_mce'; - } - - global $sd_widgets; + define( 'SUPER_DUPER_VER', '1.1.42' ); + + /** + * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress. + * + * Should not be called direct but extended instead. + * + * Class WP_Super_Duper + * @since 1.0.16 change log moved to file change-log.txt - CHANGED + * @ver 1.1.1 + */ + class WP_Super_Duper extends WP_Widget { + + public $version = SUPER_DUPER_VER; + public $font_awesome_icon_version = "5.11.2"; + public $block_code; + public $options; + public $base_id; + public $settings_hash; + public $arguments = array(); + public $instance = array(); + private $class_name; + + /** + * The relative url to the current folder. + * + * @var string + */ + public $url = ''; + + /** + * Take the array options and use them to build. + */ + public function __construct( $options ) { + global $sd_widgets; + + $sd_widgets[ $options['base_id'] ] = array( + 'name' => $options['name'], + 'class_name' => $options['class_name'], + 'output_types' => !empty($options['output_types']) ? $options['output_types'] : array() + ); + $this->base_id = $options['base_id']; + // lets filter the options before we do anything + $options = apply_filters( "wp_super_duper_options", $options ); + $options = apply_filters( "wp_super_duper_options_{$this->base_id}", $options ); + $options = $this->add_name_from_key( $options ); + $this->options = $options; + + $this->base_id = $options['base_id']; + $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array(); + + // nested blocks can't work as a widget + if(!empty($this->options['nested-block'])){ + if(empty($this->options['output_types'])){ + $this->options['output_types'] = array('shortcode','block'); + }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) { + unset($this->options['output_types'][$key]); + } + } + + // init parent + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ + parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] ); + } + + + if ( isset( $options['class_name'] ) ) { + // register widget + $this->class_name = $options['class_name']; + + // register shortcode, this needs to be done even for blocks and widgets + $this->register_shortcode(); + + + // Fusion Builder (avada) support + if ( function_exists( 'fusion_builder_map' ) ) { + add_action( 'init', array( $this, 'register_fusion_element' ) ); + } + + // register block + if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){ + add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) ); + } + } + + // add the CSS and JS we need ONCE + global $sd_widget_scripts; + + if ( ! $sd_widget_scripts ) { + wp_add_inline_script( 'admin-widgets', $this->widget_js() ); + wp_add_inline_script( 'customize-controls', $this->widget_js() ); + wp_add_inline_style( 'widgets', $this->widget_css() ); + + // maybe add elementor editor styles + add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) ); + + $sd_widget_scripts = true; + + // add shortcode insert button once + add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) ); + // generatepress theme sections compatibility + if ( function_exists( 'generate_sections_sections_metabox' ) ) { + add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) ); + } + /* Load script on Divi theme builder page */ + if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { + add_thickbox(); + add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) ); + } + + if ( $this->is_preview() ) { + add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) ); + // this makes the insert button work for elementor + add_action( 'elementor/editor/after_enqueue_scripts', array( + $this, + 'shortcode_insert_button_script' + ) ); // for elementor + } + // this makes the insert button work for cornerstone + add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) ); + + add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) ); + add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) ); + + // add generator text to head + add_action( 'admin_head', array( $this, 'generator' ), 99 ); + add_action( 'wp_head', array( $this, 'generator' ), 99 ); + } + + do_action( 'wp_super_duper_widget_init', $options, $this ); + } + + /** + * The register widget function + * @return void + */ + public function _register() { + if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){ + parent::_register(); + } + } + + /** + * Add our widget CSS to elementor editor. + */ + public function elementor_editor_styles() { + wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) ); + } + + public function register_fusion_element() { + + $options = $this->options; + + if ( $this->base_id ) { + + $params = $this->get_fusion_params(); + + $args = array( + 'name' => $options['name'], + 'shortcode' => $this->base_id, + 'icon' => $options['block-icon'] ? $options['block-icon'] : 'far fa-square', + 'allow_generator' => true, + ); + + if ( ! empty( $params ) ) { + $args['params'] = $params; + } + + fusion_builder_map( $args ); + } + + } + + public function get_fusion_params() { + $params = array(); + $arguments = $this->get_arguments(); + + if ( ! empty( $arguments ) ) { + foreach ( $arguments as $key => $val ) { + $param = array(); + // type + $param['type'] = str_replace( + array( + "text", + "number", + "email", + "color", + "checkbox" + ), + array( + "textfield", + "textfield", + "textfield", + "colorpicker", + "select", + + ), + $val['type'] ); + + // multiselect + if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) { + $param['type'] = 'multiple_select'; + $param['multiple'] = true; + } + + // heading + $param['heading'] = isset( $val['title'] ) ? $val['title'] : ''; + + // description + $param['description'] = isset( $val['desc'] ) ? $val['desc'] : ''; + + // param_name + $param['param_name'] = $key; + + // Default + $param['default'] = isset( $val['default'] ) ? $val['default'] : ''; + + // Group + if ( isset( $val['group'] ) ) { + $param['group'] = $val['group']; + } + + // value + if ( $val['type'] == 'checkbox' ) { + if ( isset( $val['default'] ) && $val['default'] == '0' ) { + unset( $param['default'] ); + } + $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) ); + } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) { + $param['value'] = isset( $val['options'] ) ? $val['options'] : array(); + } else { + $param['value'] = isset( $val['default'] ) ? $val['default'] : ''; + } + + // setup the param + $params[] = $param; + + } + } + + + return $params; + } + + /** + * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder + */ + public static function maybe_cornerstone_builder() { + if ( did_action( 'cornerstone_before_boot_app' ) ) { + self::shortcode_insert_button_script(); + } + } + + /** + * A function to ge the shortcode builder picker html. + * + * @param string $editor_id + * + * @return string + */ + public static function get_picker( $editor_id = '' ) { + + ob_start(); + if ( isset( $_POST['editor_id'] ) ) { + $editor_id = esc_attr( $_POST['editor_id'] ); + } elseif ( isset( $_REQUEST['et_fb'] ) ) { + $editor_id = 'main_content_content_vb_tiny_mce'; + } + + global $sd_widgets; // print_r($sd_widgets);exit; - ?> - -
- '; - echo ""; - foreach ( $sd_widgets as $shortcode => $class ) { - if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; } - echo ""; - } - echo ""; - - } - ?> -
- -
- -
- -
- - - - -
-
- version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />'; - } - - /** - * Get widget settings. - * - * @since 1.0.0 - */ - public static function get_widget_settings() { - global $sd_widgets; - - $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : ''; - if ( ! $shortcode ) { - wp_die(); - } - $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : ''; - if ( ! $widget_args ) { - wp_die(); - } - $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : ''; - if ( ! $class_name ) { - wp_die(); - } - - // invoke an instance method - $widget = new $class_name; - - ob_start(); - $widget->form( array() ); - $form = ob_get_clean(); - echo "
" . $form . "
"; - echo ""; - echo ""; - ?> - '; - } - - echo self::shortcode_button( 'this', 'true' ); - - // see opening note - if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { - echo ''; // end #insert-media-button - } - - // Add separate script for generatepress theme sections - if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { - } else { - self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); - } - - $shortcode_insert_button_once = true; - } - - /** - * Gets the shortcode insert button html. - * - * @param string $id - * @param string $search_for_id - * - * @return mixed - */ - public static function shortcode_button( $id = '', $search_for_id = '' ) { - ob_start(); - ?> - - );" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" - class="thickbox button super-duper-content-open" title="Add Shortcode"> - - - - - - - - tags for code highlighting, so we strip them from the output. - */ - - return str_replace( array( - '' - ), '', $output ); - } - - /** - * Output the JS and CSS for the shortcode insert button. - * - * @param string $editor_id - * @param string $insert_shortcode_function - * - *@since 1.0.6 - * - */ - public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { - ?> - - " . self::siteorigin_js() . ""; - } - ?> - "; + ?> + '; + } + + echo self::shortcode_button( 'this', 'true' ); + + // see opening note + if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) { + echo ''; // end #insert-media-button + } + + // Add separate script for generatepress theme sections + if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) { + } else { + self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function ); + } + + $shortcode_insert_button_once = true; + } + + /** + * Gets the shortcode insert button html. + * + * @param string $id + * @param string $search_for_id + * + * @return mixed + */ + public static function shortcode_button( $id = '', $search_for_id = '' ) { + ob_start(); + ?> + + );" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed" + class="thickbox button super-duper-content-open" title="Add Shortcode"> + + + + + + + + tags for code highlighting, so we strip them from the output. + */ + + return str_replace( array( + '' + ), '', $output ); + } + + /** + * Output the JS and CSS for the shortcode insert button. + * + * @param string $editor_id + * @param string $insert_shortcode_function + * + *@since 1.0.6 + * + */ + public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) { + ?> + + " . self::siteorigin_js() . ""; + } + ?> + - - - tags for code highlighting, so we strip them from the output. - */ - - return str_replace( array( - '' - ), '', $output ); - } - - /** - * Gets some JS for the widgets screen. - * - * @return mixed - */ - public function widget_js() { - ob_start(); - ?> - - tags for code highlighting, so we strip them from the output. - */ - - return str_replace( array( - '' - ), '', $output ); - } - - - /** - * Set the name from the argument key. - * - * @param $options - * - * @return mixed - */ - private function add_name_from_key( $options, $arguments = false ) { - if ( ! empty( $options['arguments'] ) ) { - foreach ( $options['arguments'] as $key => $val ) { - $options['arguments'][ $key ]['name'] = $key; - } - } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { - foreach ( $options as $key => $val ) { - $options[ $key ]['name'] = $key; - } - } - - return $options; - } - - /** - * Register the parent shortcode. - * - * @since 1.0.0 - */ - public function register_shortcode() { - add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); - add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); - } - - /** - * Render the shortcode via ajax so we can return it to Gutenberg. - * - * @since 1.0.0 - */ - public function render_shortcode() { - check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); - if ( ! current_user_can( 'manage_options' ) ) { - wp_die(); - } - - // we might need the $post value here so lets set it. - if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { - $post_obj = get_post( absint( $_POST['post_id'] ) ); - if ( ! empty( $post_obj ) && empty( $post ) ) { - global $post; - $post = $post_obj; - } - } - - if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { - $is_preview = $this->is_preview(); - $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); - $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); - $attributes = ''; - if ( ! empty( $attributes_array ) ) { - foreach ( $attributes_array as $key => $value ) { - if ( is_array( $value ) ) { - $value = implode( ",", $value ); - } - - if ( ! empty( $value ) ) { - $value = wp_unslash( $value ); - - // Encode [ and ]. - if ( $is_preview ) { - $value = $this->encode_shortcodes( $value ); - } - } - $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' "; - } - } - - $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]"; - - $content = do_shortcode( $shortcode ); - - // Decode [ and ]. - if ( ! empty( $content ) && $is_preview ) { - $content = $this->decode_shortcodes( $content ); - } - - echo $content; - } - wp_die(); - } - - /** - * Output the shortcode. - * - * @param array $args - * @param string $content - * - * @return string - */ - public function shortcode_output( $args = array(), $content = '' ) { - $_instance = $args; - - $args = $this->argument_values( $args ); - - // add extra argument so we know its a output to gutenberg - //$args - $args = $this->string_to_bool( $args ); - - // if we have a enclosed shortcode we add it to the special `html` argument - if ( ! empty( $content ) ) { - $args['html'] = $content; - } - - if ( ! $this->is_preview() ) { - /** - * Filters the settings for a particular widget args. - * - * @param array $args The current widget instance's settings. - * @param WP_Super_Duper $widget The current widget settings. - * @param array $_instance An array of default widget arguments. - * - *@since 1.0.28 - * - */ - $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); - - if ( ! is_array( $args ) ) { - return $args; - } - } - - $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; - $class .= " sdel-".$this->get_instance_hash(); - - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); - - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); - - $shortcode_args = array(); - $output = ''; - $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; - if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { - $no_wrap = true; - } - $main_content = $this->output( $args, $shortcode_args, $content ); - if ( $main_content && ! $no_wrap ) { - // wrap the shortcode in a div with the same class as the widget - $output .= '
'; - if ( ! empty( $args['title'] ) ) { - // if its a shortcode and there is a title try to grab the title wrappers - $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); - if ( empty( $instance ) ) { - global $wp_registered_sidebars; - if ( ! empty( $wp_registered_sidebars ) ) { - foreach ( $wp_registered_sidebars as $sidebar ) { - if ( ! empty( $sidebar['before_title'] ) ) { - $shortcode_args['before_title'] = $sidebar['before_title']; - $shortcode_args['after_title'] = $sidebar['after_title']; - break; - } - } - } - } - $output .= $this->output_title( $shortcode_args, $args ); - } - $output .= $main_content; - $output .= '
'; - } elseif ( $main_content && $no_wrap ) { - $output .= $main_content; - } - - // if preview show a placeholder if empty - if ( $this->is_preview() && $output == '' ) { - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); - } - - return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); - } - - /** - * Placeholder text to show if output is empty and we are on a preview/builder page. - * - * @param string $name - * - * @return string - */ - public function preview_placeholder_text( $name = '' ) { - return "
" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "
"; - } - - /** - * Sometimes booleans values can be turned to strings, so we fix that. - * - * @param $options - * - * @return mixed - */ - public function string_to_bool( $options ) { - // convert bool strings to booleans - foreach ( $options as $key => $val ) { - if ( $val == 'false' ) { - $options[ $key ] = false; - } elseif ( $val == 'true' ) { - $options[ $key ] = true; - } - } - - return $options; - } - - /** - * Get the argument values that are also filterable. - * - * @param $instance - * - * @return array - *@since 1.0.12 Don't set checkbox default value if the value is empty. - * - */ - public function argument_values( $instance ) { - $argument_values = array(); - - // set widget instance - $this->instance = $instance; - - if ( empty( $this->arguments ) ) { - $this->arguments = $this->get_arguments(); - } - - if ( ! empty( $this->arguments ) ) { - foreach ( $this->arguments as $key => $args ) { - // set the input name from the key - $args['name'] = $key; - // - $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; - if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { - // don't set default for an empty checkbox - } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { - $argument_values[ $key ] = $args['default']; - } - } - } - - return $argument_values; - } - - /** - * Set arguments in super duper. - * - * @return array Set arguments. - *@since 1.0.0 - * - */ - public function set_arguments() { - return $this->arguments; - } - - /** - * Get arguments in super duper. - * - * @return array Get arguments. - *@since 1.0.0 - * - */ - public function get_arguments() { - if ( empty( $this->arguments ) ) { - $this->arguments = $this->set_arguments(); - } - - $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); - $this->arguments = $this->add_name_from_key( $this->arguments, true ); - - return $this->arguments; - } - - /** - * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. - * - * @param array $args - * @param array $widget_args - * @param string $content - */ - public function output( $args = array(), $widget_args = array(), $content = '' ) { - - } - - /** - * Add the dynamic block code inline when the wp-block in enqueued. - */ - public function register_block() { - wp_add_inline_script( 'wp-blocks', $this->block() ); - if ( class_exists( 'SiteOrigin_Panels' ) ) { - wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); - } - } - - /** - * Check if we need to show advanced options. - * - * @return bool - */ - public function block_show_advanced() { - - $show = false; - $arguments = $this->get_arguments(); - - if ( ! empty( $arguments ) ) { - foreach ( $arguments as $argument ) { - if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { - $show = true; - break; // no need to continue if we know we have it - } - } - } - - return $show; - } - - /** - * Get the url path to the current folder. - * - * @return string - */ - public function get_url() { - $url = $this->url; - - if ( ! $url ) { - $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); - $content_url = untrailingslashit( WP_CONTENT_URL ); - - // Replace http:// to https://. - if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { - $content_url = str_replace( 'http://', 'https://', $content_url ); - } - - // Check if we are inside a plugin - $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); - $url = str_replace( $content_dir, $content_url, $file_dir ); - $url = trailingslashit( $url ); - $this->url = $url; - } - - return $url; - } - - /** - * Get the url path to the current folder. - * - * @return string - */ - public function get_url_old() { - - $url = $this->url; - - if ( ! $url ) { - // check if we are inside a plugin - $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); - - $dir_parts = explode( "/wp-content/", $file_dir ); - $url_parts = explode( "/wp-content/", plugins_url() ); - - if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { - $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); - $this->url = $url; - } - } - - - return $url; - } - - /** - * Generate the block icon. - * - * Enables the use of Font Awesome icons. - * - * @note xlink:href is actually deprecated but href is not supported by all so we use both. - * - * @param $icon - * - * @return string - *@since 1.1.0 - */ - public function get_block_icon( $icon ) { - - // check if we have a Font Awesome icon - $fa_type = ''; - if ( substr( $icon, 0, 7 ) === "fas fa-" ) { - $fa_type = 'solid'; - } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { - $fa_type = 'regular'; - } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { - $fa_type = 'brands'; - } else { - $icon = "'" . $icon . "'"; - } - - // set the icon if we found one - if ( $fa_type ) { - $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); - $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; - } - - return $icon; - } - - public function group_arguments( $arguments ) { - if ( ! empty( $arguments ) ) { - $temp_arguments = array(); - $general = __( "General", 'ayecode-connect' ); - $add_sections = false; - foreach ( $arguments as $key => $args ) { - if ( isset( $args['group'] ) ) { - $temp_arguments[ $args['group'] ][ $key ] = $args; - $add_sections = true; - } else { - $temp_arguments[ $general ][ $key ] = $args; - } - } - - // only add sections if more than one - if ( $add_sections ) { - $arguments = $temp_arguments; - } - } - - return $arguments; - } - - /** - * Parse used group tabs. - * - * @since 1.1.17 - */ - public function group_block_tabs( $tabs, $arguments ) { - if ( ! empty( $tabs ) && ! empty( $arguments ) ) { - $has_sections = false; - - foreach ( $this->arguments as $key => $args ) { - if ( isset( $args['group'] ) ) { - $has_sections = true; - break; - } - } - - if ( ! $has_sections ) { - return $tabs; - } - - $new_tabs = array(); - - foreach ( $tabs as $tab_key => $tab ) { - $new_groups = array(); - - if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) { - foreach ( $tab['groups'] as $group ) { - if ( isset( $arguments[ $group ] ) ) { - $new_groups[] = $group; - } - } - } - - if ( ! empty( $new_groups ) ) { - $tab['groups'] = $new_groups; - - $new_tabs[ $tab_key ] = $tab; - } - } - - $tabs = $new_tabs; - } - - return $tabs; - } - - /** - * Output the JS for building the dynamic Guntenberg block. - * - * @return mixed - *@since 1.0.9 Save numbers as numbers and not strings. - * @since 1.1.0 Font Awesome classes can be used for icons. - * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. - */ - public function block() { - global $sd_is_js_functions_loaded, $aui_bs5; - - $show_advanced = $this->block_show_advanced(); - - ob_start(); - ?> - + + + tags for code highlighting, so we strip them from the output. + */ + + return str_replace( array( + '' + ), '', $output ); + } + + /** + * Gets some JS for the widgets screen. + * + * @return mixed + */ + public function widget_js() { + ob_start(); + ?> + + tags for code highlighting, so we strip them from the output. + */ + + return str_replace( array( + '' + ), '', $output ); + } + + + /** + * Set the name from the argument key. + * + * @param $options + * + * @return mixed + */ + private function add_name_from_key( $options, $arguments = false ) { + if ( ! empty( $options['arguments'] ) ) { + foreach ( $options['arguments'] as $key => $val ) { + $options['arguments'][ $key ]['name'] = $key; + } + } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) { + foreach ( $options as $key => $val ) { + $options[ $key ]['name'] = $key; + } + } + + return $options; + } + + /** + * Register the parent shortcode. + * + * @since 1.0.0 + */ + public function register_shortcode() { + add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) ); + add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) ); + } + + /** + * Render the shortcode via ajax so we can return it to Gutenberg. + * + * @since 1.0.0 + */ + public function render_shortcode() { + check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true ); + if ( ! current_user_can( 'manage_options' ) ) { + wp_die(); + } + + // we might need the $post value here so lets set it. + if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) { + $post_obj = get_post( absint( $_POST['post_id'] ) ); + if ( ! empty( $post_obj ) && empty( $post ) ) { + global $post; + $post = $post_obj; + } + } + + if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) { + $is_preview = $this->is_preview(); + $shortcode_name = sanitize_title_with_dashes( $_POST['shortcode'] ); + $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array(); + $attributes = ''; + if ( ! empty( $attributes_array ) ) { + foreach ( $attributes_array as $key => $value ) { + if ( is_array( $value ) ) { + $value = implode( ",", $value ); + } + + if ( ! empty( $value ) ) { + $value = wp_unslash( $value ); + + // Encode [ and ]. + if ( $is_preview ) { + $value = $this->encode_shortcodes( $value ); + } + } + $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' "; + } + } + + $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]"; + + $content = do_shortcode( $shortcode ); + + // Decode [ and ]. + if ( ! empty( $content ) && $is_preview ) { + $content = $this->decode_shortcodes( $content ); + } + + echo $content; + } + wp_die(); + } + + /** + * Output the shortcode. + * + * @param array $args + * @param string $content + * + * @return string + */ + public function shortcode_output( $args = array(), $content = '' ) { + $_instance = $args; + + $args = $this->argument_values( $args ); + + // add extra argument so we know its a output to gutenberg + //$args + $args = $this->string_to_bool( $args ); + + // if we have a enclosed shortcode we add it to the special `html` argument + if ( ! empty( $content ) ) { + $args['html'] = $content; + } + + if ( ! $this->is_preview() ) { + /** + * Filters the settings for a particular widget args. + * + * @param array $args The current widget instance's settings. + * @param WP_Super_Duper $widget The current widget settings. + * @param array $_instance An array of default widget arguments. + * + *@since 1.0.28 + * + */ + $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance ); + + if ( ! is_array( $args ) ) { + return $args; + } + } + + $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : ''; + $class .= " sdel-".$this->get_instance_hash(); + + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); + + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); + + $shortcode_args = array(); + $output = ''; + $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false; + if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) { + $no_wrap = true; + } + $main_content = $this->output( $args, $shortcode_args, $content ); + if ( $main_content && ! $no_wrap ) { + // wrap the shortcode in a div with the same class as the widget + $output .= '
'; + if ( ! empty( $args['title'] ) ) { + // if its a shortcode and there is a title try to grab the title wrappers + $shortcode_args = array( 'before_title' => '', 'after_title' => '' ); + if ( empty( $instance ) ) { + global $wp_registered_sidebars; + if ( ! empty( $wp_registered_sidebars ) ) { + foreach ( $wp_registered_sidebars as $sidebar ) { + if ( ! empty( $sidebar['before_title'] ) ) { + $shortcode_args['before_title'] = $sidebar['before_title']; + $shortcode_args['after_title'] = $sidebar['after_title']; + break; + } + } + } + } + $output .= $this->output_title( $shortcode_args, $args ); + } + $output .= $main_content; + $output .= '
'; + } elseif ( $main_content && $no_wrap ) { + $output .= $main_content; + } + + // if preview show a placeholder if empty + if ( $this->is_preview() && $output == '' ) { + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); + } + + return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this ); + } + + /** + * Placeholder text to show if output is empty and we are on a preview/builder page. + * + * @param string $name + * + * @return string + */ + public function preview_placeholder_text( $name = '' ) { + return "
" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "
"; + } + + /** + * Sometimes booleans values can be turned to strings, so we fix that. + * + * @param $options + * + * @return mixed + */ + public function string_to_bool( $options ) { + // convert bool strings to booleans + foreach ( $options as $key => $val ) { + if ( $val == 'false' ) { + $options[ $key ] = false; + } elseif ( $val == 'true' ) { + $options[ $key ] = true; + } + } + + return $options; + } + + /** + * Get the argument values that are also filterable. + * + * @param $instance + * + * @return array + *@since 1.0.12 Don't set checkbox default value if the value is empty. + * + */ + public function argument_values( $instance ) { + $argument_values = array(); + + // set widget instance + $this->instance = $instance; + + if ( empty( $this->arguments ) ) { + $this->arguments = $this->get_arguments(); + } + + if ( ! empty( $this->arguments ) ) { + foreach ( $this->arguments as $key => $args ) { + // set the input name from the key + $args['name'] = $key; + // + $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : ''; + if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) { + // don't set default for an empty checkbox + } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) { + $argument_values[ $key ] = $args['default']; + } + } + } + + return $argument_values; + } + + /** + * Set arguments in super duper. + * + * @return array Set arguments. + *@since 1.0.0 + * + */ + public function set_arguments() { + return $this->arguments; + } + + /** + * Get arguments in super duper. + * + * @return array Get arguments. + *@since 1.0.0 + * + */ + public function get_arguments() { + if ( empty( $this->arguments ) ) { + $this->arguments = $this->set_arguments(); + } + + $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance ); + $this->arguments = $this->add_name_from_key( $this->arguments, true ); + + return $this->arguments; + } + + /** + * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class. + * + * @param array $args + * @param array $widget_args + * @param string $content + */ + public function output( $args = array(), $widget_args = array(), $content = '' ) { + + } + + /** + * Add the dynamic block code inline when the wp-block in enqueued. + */ + public function register_block() { + wp_add_inline_script( 'wp-blocks', $this->block() ); + if ( class_exists( 'SiteOrigin_Panels' ) ) { + wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() ); + } + } + + /** + * Check if we need to show advanced options. + * + * @return bool + */ + public function block_show_advanced() { + + $show = false; + $arguments = $this->get_arguments(); + + if ( ! empty( $arguments ) ) { + foreach ( $arguments as $argument ) { + if ( isset( $argument['advanced'] ) && $argument['advanced'] ) { + $show = true; + break; // no need to continue if we know we have it + } + } + } + + return $show; + } + + /** + * Get the url path to the current folder. + * + * @return string + */ + public function get_url() { + $url = $this->url; + + if ( ! $url ) { + $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) ); + $content_url = untrailingslashit( WP_CONTENT_URL ); + + // Replace http:// to https://. + if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) { + $content_url = str_replace( 'http://', 'https://', $content_url ); + } + + // Check if we are inside a plugin + $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) ); + $url = str_replace( $content_dir, $content_url, $file_dir ); + $url = trailingslashit( $url ); + $this->url = $url; + } + + return $url; + } + + /** + * Get the url path to the current folder. + * + * @return string + */ + public function get_url_old() { + + $url = $this->url; + + if ( ! $url ) { + // check if we are inside a plugin + $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) ); + + $dir_parts = explode( "/wp-content/", $file_dir ); + $url_parts = explode( "/wp-content/", plugins_url() ); + + if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) { + $url = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] ); + $this->url = $url; + } + } + + + return $url; + } + + /** + * Generate the block icon. + * + * Enables the use of Font Awesome icons. + * + * @note xlink:href is actually deprecated but href is not supported by all so we use both. + * + * @param $icon + * + * @return string + *@since 1.1.0 + */ + public function get_block_icon( $icon ) { + + // check if we have a Font Awesome icon + $fa_type = ''; + if ( substr( $icon, 0, 7 ) === "fas fa-" ) { + $fa_type = 'solid'; + } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) { + $fa_type = 'regular'; + } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) { + $fa_type = 'brands'; + } else { + $icon = "'" . $icon . "'"; + } + + // set the icon if we found one + if ( $fa_type ) { + $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon ); + $icon = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))"; + } + + return $icon; + } + + public function group_arguments( $arguments ) { + if ( ! empty( $arguments ) ) { + $temp_arguments = array(); + $general = __( "General", 'ayecode-connect' ); + $add_sections = false; + foreach ( $arguments as $key => $args ) { + if ( isset( $args['group'] ) ) { + $temp_arguments[ $args['group'] ][ $key ] = $args; + $add_sections = true; + } else { + $temp_arguments[ $general ][ $key ] = $args; + } + } + + // only add sections if more than one + if ( $add_sections ) { + $arguments = $temp_arguments; + } + } + + return $arguments; + } + + /** + * Parse used group tabs. + * + * @since 1.1.17 + */ + public function group_block_tabs( $tabs, $arguments ) { + if ( ! empty( $tabs ) && ! empty( $arguments ) ) { + $has_sections = false; + + foreach ( $this->arguments as $key => $args ) { + if ( isset( $args['group'] ) ) { + $has_sections = true; + break; + } + } + + if ( ! $has_sections ) { + return $tabs; + } + + $new_tabs = array(); + + foreach ( $tabs as $tab_key => $tab ) { + $new_groups = array(); + + if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) { + foreach ( $tab['groups'] as $group ) { + if ( isset( $arguments[ $group ] ) ) { + $new_groups[] = $group; + } + } + } + + if ( ! empty( $new_groups ) ) { + $tab['groups'] = $new_groups; + + $new_tabs[ $tab_key ] = $tab; + } + } + + $tabs = $new_tabs; + } + + return $tabs; + } + + /** + * Output the JS for building the dynamic Guntenberg block. + * + * @return mixed + *@since 1.0.9 Save numbers as numbers and not strings. + * @since 1.1.0 Font Awesome classes can be used for icons. + * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap. + */ + public function block() { + global $sd_is_js_functions_loaded, $aui_bs5; + + $show_advanced = $this->block_show_advanced(); + + ob_start(); + ?> + - tags for code highlighting, so we strip them from the output. - */ - - return str_replace( array( - '' - ), '', $output ); - } - - - - public function block_row_start($key, $args){ - - // check for row - if(!empty($args['row'])){ - - if(!empty($args['row']['open'])){ - - // element require - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; - $device_type_icon = ''; - if($device_type=='Desktop'){ - $device_type_icon = ''; - }elseif($device_type=='Tablet'){ - $device_type_icon = ''; - }elseif($device_type=='Mobile'){ - $device_type_icon = ''; - } - echo $element_require; - echo $device_type_require; - - if(false){?> + tags for code highlighting, so we strip them from the output. + */ + + return str_replace( array( + '' + ), '', $output ); + } + + + + public function block_row_start($key, $args){ + + // check for row + if(!empty($args['row'])){ + + if(!empty($args['row']['open'])){ + + // element require + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; + $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; + $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; + $device_type_icon = ''; + if($device_type=='Desktop'){ + $device_type_icon = ''; + }elseif($device_type=='Tablet'){ + $device_type_icon = ''; + }elseif($device_type=='Mobile'){ + $device_type_icon = ''; + } + echo $element_require; + echo $device_type_require; + + if(false){?>array_to_attributes( $args['custom_attributes'] ) : ''; - $options = ''; - $extra = ''; - $require = ''; - $inside_elements = ''; - $after_elements = ''; - - // `content` is a protected and special argument - if ( $key == 'content' ) { - return; - } - - $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; - $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; - $device_type_icon = ''; - if($device_type=='Desktop'){ - $device_type_icon = ''; - }elseif($device_type=='Tablet'){ - $device_type_icon = ''; - }elseif($device_type=='Mobile'){ - $device_type_icon = ''; - } - - // icon - $icon = ''; - if( !empty( $args['icon'] ) ){ - $icon .= "el('div', {"; - $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; - $icon .= "className: 'text-center',"; - $icon .= "title: '".addslashes( $args['title'] )."',"; - $icon .= "}),"; - - // blank title as its added to the icon. - $args['title'] = ''; - } - - // require advanced - $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; - - // element require - $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; - - - $onchange = "props.setAttributes({ $key: $key } )"; - $onchangecomplete = ""; - $value = "props.attributes.$key"; - $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); - if ( in_array( $args['type'], $text_type ) ) { - $type = 'TextControl'; - // Save numbers as numbers and not strings - if ( $args['type'] == 'number' ) { - $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; - } - - if (substr($key, 0, 9 ) === 'metadata_') { - $real_key = str_replace('metadata_','', $key ); - $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )"; - $value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''"; - } - } + el('hr', {className: 'm-0'}), el( + wp.components.TabPanel, + { + activeClass: 'is-active', + className: 'btn-groupx', + initialTabName: '', + tabs: [ + + array_to_attributes( $args['custom_attributes'] ) : ''; + $options = ''; + $extra = ''; + $require = ''; + $inside_elements = ''; + $after_elements = ''; + + // `content` is a protected and special argument + if ( $key == 'content' ) { + return; + } + + $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : ''; + $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : ''; + $device_type_icon = ''; + if($device_type=='Desktop'){ + $device_type_icon = ''; + }elseif($device_type=='Tablet'){ + $device_type_icon = ''; + }elseif($device_type=='Mobile'){ + $device_type_icon = ''; + } + + // icon + $icon = ''; + if( !empty( $args['icon'] ) ){ + $icon .= "el('div', {"; + $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},"; + $icon .= "className: 'text-center',"; + $icon .= "title: '".addslashes( $args['title'] )."',"; + $icon .= "}),"; + + // blank title as its added to the icon. + $args['title'] = ''; + } + + // require advanced + $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : ""; + + // element require + $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : ""; + + + $onchange = "props.setAttributes({ $key: $key } )"; + $onchangecomplete = ""; + $value = "props.attributes.$key"; + $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' ); + if ( in_array( $args['type'], $text_type ) ) { + $type = 'TextControl'; + // Save numbers as numbers and not strings + if ( $args['type'] == 'number' ) { + $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )"; + } + + if (substr($key, 0, 9 ) === 'metadata_') { + $real_key = str_replace('metadata_','', $key ); + $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )"; + $value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''"; + } + } // else if ( $args['type'] == 'popup' ) { // $type = 'TextControl'; // $args['type'] == 'text'; @@ -3473,139 +3500,139 @@ public function build_block_arguments( $key, $args ) { // // $value = "props.attributes.$key ? props.attributes.$key : ''"; // } - else if ( $args['type'] == 'styleid' ) { - $type = 'TextControl'; - $args['type'] == 'text'; - // Save numbers as numbers and not strings - $value = "props.attributes.$key ? props.attributes.$key : ''"; - }else if ( $args['type'] == 'notice' ) { - - $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; - $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; - - $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; - echo $notice_message ? $element_require . $notice : ''; - return; - } - /* - * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout - elseif($args['type']=='tabs'){ - ?> - el( - wp.components.TabPanel, - { - activeClass: 'active-tab', - initialTabName: deviceType, - tabs: [ - { - name: 'Desktop', - title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), - className: 'tab-one' + deviceType == 'Desktop' ? ' active-tab' : '', - content: el('div', {dangerouslySetInnerHTML: {__html: 'ddd'}}) - }, - { - name: 'Tablet', - title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), - className: 'tab-two' + deviceType == 'Tablet' ? ' active-tab' : '', - content: el('div', {dangerouslySetInnerHTML: {__html: 'ttt'}}) - }, - { - name: 'Mobile', - title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), - className: 'tab-two' + deviceType == 'Mobile' ? ' active-tab' : '', - content: el('div', {dangerouslySetInnerHTML: {__html: 'mmm'}}) - }, - ], - }, - ( tab ) => { + else if ( $args['type'] == 'styleid' ) { + $type = 'TextControl'; + $args['type'] == 'text'; + // Save numbers as numbers and not strings + $value = "props.attributes.$key ? props.attributes.$key : ''"; + }else if ( $args['type'] == 'notice' ) { + + $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : ''; + $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info'; + + $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),"; + echo $notice_message ? $element_require . $notice : ''; + return; + } + /* + * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout + elseif($args['type']=='tabs'){ + ?> + el( + wp.components.TabPanel, + { + activeClass: 'active-tab', + initialTabName: deviceType, + tabs: [ + { + name: 'Desktop', + title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), + className: 'tab-one' + deviceType == 'Desktop' ? ' active-tab' : '', + content: el('div', {dangerouslySetInnerHTML: {__html: 'ddd'}}) + }, + { + name: 'Tablet', + title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), + className: 'tab-two' + deviceType == 'Tablet' ? ' active-tab' : '', + content: el('div', {dangerouslySetInnerHTML: {__html: 'ttt'}}) + }, + { + name: 'Mobile', + title: el('div', {dangerouslySetInnerHTML: {__html: ''}}), + className: 'tab-two' + deviceType == 'Mobile' ? ' active-tab' : '', + content: el('div', {dangerouslySetInnerHTML: {__html: 'mmm'}}) + }, + ], + }, + ( tab ) => { // @todo https://github.com/WordPress/gutenberg/issues/39248 - if(tab.name=='Desktop'){ - wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Desktop'); + if(tab.name=='Desktop'){ + wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Desktop'); wp.data.select('core/edit-post').__experimentalGetPreviewDeviceType(); - }else if(tab.name=='Tablet'){ - wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Tablet'); + }else if(tab.name=='Tablet'){ + wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Tablet'); wp.data.select('core/edit-post').__experimentalGetPreviewDeviceType(); - }else if(tab.name=='Mobile'){ - wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Mobile'); + }else if(tab.name=='Mobile'){ + wp.data.dispatch('core/edit-post').__experimentalSetPreviewDeviceType('Mobile'); wp.data.select('core/edit-post').__experimentalGetPreviewDeviceType(); - } + } - return tab.content; + return tab.content; - } - ), + } + ), - = 0 ? props.attributes.{$key}_xy : {x: 0.5,y: 0.5,}, + $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key || props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{ + url: props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4=' : props.attributes.$key, + value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy : {x: 0.5,y: 0.5,}, // value: props.attributes.{$key}_xy, - onChange: function(focalPoint){ - console.log(props.attributes); - return props.setAttributes({ - {$key}_xy: focalPoint - }); - }, - // @todo for some reason this does not work as expected. + onChange: function(focalPoint){ + console.log(props.attributes); + return props.setAttributes({ + {$key}_xy: focalPoint + }); + }, + // @todo for some reason this does not work as expected. // onDrag: function(focalPointTemp){ // return props.setAttributes({ // {$key}_xy: focalPointTemp @@ -3613,165 +3640,165 @@ className: 'tab-two' + deviceType == 'Mobile' ? ' active-tab' : '', // } - }), "; - - - $value = '""'; - $type = 'MediaUpload'; - $extra .= "onSelect: function(media){ - return props.setAttributes({ - $key: media.url, - {$key}_id: media.id - }); - },"; - $extra .= "type: 'image',"; - $extra .= "render: function (obj) { - return el( 'div',{}, - ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-primary is-smallx', - onClick: obj.open - }, - 'Upload Image' - ), - $img_preview - props.attributes.$key && el( wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-secondary is-small', - style: {margin:'8px 0',display: 'block'}, - onClick: function(){ - return props.setAttributes({ - $key: '', - {$key}_id: '' - }); - } - }, - props.attributes.$key? 'Clear' : '' - ) - ) - - - - }"; - $onchange = ""; - - //$inside_elements = ",el('div',{},'file upload')"; - } else if ( $args['type'] == 'images' ) { - $img_preview = "props.attributes.$key && (function() { - let uploads = JSON.parse('['+props.attributes.$key+']'); - let images = []; - uploads.map((upload, index) => ( - images.push( el('div',{ className: 'col p-2', draggable: 'true', 'data-index': index }, - el('img', { - src: (upload.sizes && upload.sizes.thumbnail ? upload.sizes.thumbnail.url : upload.url), - style: { maxWidth:'100%', background: '#ccc', pointerEvents:'none' } - }), - el('i',{ - className: 'fas fa-times-circle text-danger position-absolute ml-n2 mt-n1 bg-white rounded-circle c-pointer', - onClick: function() { - aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) { - if (confirmed) { - let new_uploads = JSON.parse('['+props.attributes.$key+']'); - new_uploads.splice(index, 1); - return props.setAttributes({ {$key}: JSON.stringify( new_uploads ).replace('[','').replace(']','') }); - } - }); - }}, - '') - )) - )); - return images; + }), "; + + + $value = '""'; + $type = 'MediaUpload'; + $extra .= "onSelect: function(media){ + return props.setAttributes({ + $key: media.url, + {$key}_id: media.id + }); + },"; + $extra .= "type: 'image',"; + $extra .= "render: function (obj) { + return el( 'div',{}, + ( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-primary is-smallx', + onClick: obj.open + }, + 'Upload Image' + ), + $img_preview + props.attributes.$key && el( wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-secondary is-small', + style: {margin:'8px 0',display: 'block'}, + onClick: function(){ + return props.setAttributes({ + $key: '', + {$key}_id: '' + }); + } + }, + props.attributes.$key? 'Clear' : '' + ) + ) + + + + }"; + $onchange = ""; + + //$inside_elements = ",el('div',{},'file upload')"; + } else if ( $args['type'] == 'images' ) { + $img_preview = "props.attributes.$key && (function() { + let uploads = JSON.parse('['+props.attributes.$key+']'); + let images = []; + uploads.map((upload, index) => ( + images.push( el('div',{ className: 'col p-2', draggable: 'true', 'data-index': index }, + el('img', { + src: (upload.sizes && upload.sizes.thumbnail ? upload.sizes.thumbnail.url : upload.url), + style: { maxWidth:'100%', background: '#ccc', pointerEvents:'none' } + }), + el('i',{ + className: 'fas fa-times-circle text-danger position-absolute ml-n2 mt-n1 bg-white rounded-circle c-pointer', + onClick: function() { + aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) { + if (confirmed) { + let new_uploads = JSON.parse('['+props.attributes.$key+']'); + new_uploads.splice(index, 1); + return props.setAttributes({ {$key}: JSON.stringify( new_uploads ).replace('[','').replace(']','') }); + } + }); + }}, + '') + )) + )); + return images; })(),"; - $value = '""'; - $type = 'MediaUpload'; - $extra .= "onSelect: function(media){ - let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; - if(media.length){ - for (var i=0; i < media.length; i++) { - slim_images.push({id: media[i].id, caption: media[i].caption, description: media[i].description,title: media[i].title,alt: media[i].alt,sizes: media[i].sizes, url: media[i].url}); - } - } - var slimImagesV = JSON.stringify(slim_images); - if (slimImagesV) { - slimImagesV = slimImagesV.replace('[','').replace(']','').replace(/'/g, '''); - } - return props.setAttributes({ $key: slimImagesV}); + $value = '""'; + $type = 'MediaUpload'; + $extra .= "onSelect: function(media){ + let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : []; + if(media.length){ + for (var i=0; i < media.length; i++) { + slim_images.push({id: media[i].id, caption: media[i].caption, description: media[i].description,title: media[i].title,alt: media[i].alt,sizes: media[i].sizes, url: media[i].url}); + } + } + var slimImagesV = JSON.stringify(slim_images); + if (slimImagesV) { + slimImagesV = slimImagesV.replace('[','').replace(']','').replace(/'/g, '''); + } + return props.setAttributes({ $key: slimImagesV}); },"; - $extra .= "type: 'image',"; - $extra .= "multiple: true,"; - $extra .= "render: function (obj) { - /* Init the sort */ - enableDragSort('sd-sortable'); - return el( 'div',{}, - el( wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-primary is-smallx', - onClick: obj.open - }, - 'Upload Images' - ), - el('div',{ - className: 'row row-cols-3 px-2 sd-sortable', - 'data-field':'$key' - }, - $img_preview - ), - props.attributes.$key && el( wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-secondary is-small', - style: {margin:'8px 0'}, - onClick: function(){ - return props.setAttributes({ $key: '' }); - } - }, - props.attributes.$key ? 'Clear All' : '' - ) - ) + $extra .= "type: 'image',"; + $extra .= "multiple: true,"; + $extra .= "render: function (obj) { + /* Init the sort */ + enableDragSort('sd-sortable'); + return el( 'div',{}, + el( wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-primary is-smallx', + onClick: obj.open + }, + 'Upload Images' + ), + el('div',{ + className: 'row row-cols-3 px-2 sd-sortable', + 'data-field':'$key' + }, + $img_preview + ), + props.attributes.$key && el( wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-secondary is-small', + style: {margin:'8px 0'}, + onClick: function(){ + return props.setAttributes({ $key: '' }); + } + }, + props.attributes.$key ? 'Clear All' : '' + ) + ) }"; - $onchange = ""; - - //$inside_elements = ",el('div',{},'file upload')"; - } - elseif ( $args['type'] == 'checkbox' ) { - $type = 'CheckboxControl'; - $extra .= "checked: props.attributes.$key,"; - $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; - } elseif ( $args['type'] == 'textarea' ) { - $type = 'TextareaControl'; - - } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { - $type = 'SelectControl'; - - if($args['name'] == 'category' && !empty($args['post_type_linked'])){ - $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; - }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ - $options .= "options: sort_by_".str_replace("-","_", $this->id).","; - }else { - - if ( ! empty( $args['options'] ) ) { - $options .= "options: ["; - foreach ( $args['options'] as $option_val => $option_label ) { - $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },"; - } - $options .= "],"; - } - } - if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 - $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; - } - - if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ - $after_elements .= "props.attributes.$key && el( wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-secondary is-small', - style: {margin:'-8px 0 8px 0',display: 'block'}, - onClick: function(){ - return props.setAttributes({ - $key: '', - }); - } - }, - 'Clear' - ),"; - } - } elseif ( $args['type'] == 'tagselect' ) { + $onchange = ""; + + //$inside_elements = ",el('div',{},'file upload')"; + } + elseif ( $args['type'] == 'checkbox' ) { + $type = 'CheckboxControl'; + $extra .= "checked: props.attributes.$key,"; + $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )"; + } elseif ( $args['type'] == 'textarea' ) { + $type = 'TextareaControl'; + + } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) { + $type = 'SelectControl'; + + if($args['name'] == 'category' && !empty($args['post_type_linked'])){ + $options .= "options: taxonomies_".str_replace("-","_", $this->id).","; + }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){ + $options .= "options: sort_by_".str_replace("-","_", $this->id).","; + }else { + + if ( ! empty( $args['options'] ) ) { + $options .= "options: ["; + foreach ( $args['options'] as $option_val => $option_label ) { + $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },"; + } + $options .= "],"; + } + } + if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550 + $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, '; + } + + if($args['type'] == 'multiselect' || ( isset( $args['multiple'] ) && $args['multiple'] ) ){ + $after_elements .= "props.attributes.$key && el( wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-secondary is-small', + style: {margin:'-8px 0 8px 0',display: 'block'}, + onClick: function(){ + return props.setAttributes({ + $key: '', + }); + } + }, + 'Clear' + ),"; + } + } elseif ( $args['type'] == 'tagselect' ) { // $type = 'FormTokenField'; // // if ( ! empty( $args['options'] ) ) { @@ -3806,1324 +3833,1324 @@ className: 'components-button components-circular-option-picker__clear is-second // $value = "[]"; // $extra .= ' __experimentalExpandOnFocus: true,'; - } else if ( $args['type'] == 'alignment' ) { - $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example - } else if ( $args['type'] == 'margins' ) { - - } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) { - $type = 'TextControl'; - $value = "(props.attributes.$key ? props.attributes.$key : '')"; - $args['type'] = 'text'; - $options .= 'disabled:true,'; - $bsvc_title = esc_attr( addslashes( $args['title'] ) ); - $bsvc_body = $this->block_visibility_fields( $args ); - // @TODO reset button - $bsvc_footer = ''; - $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, { - className: 'components-button components-circular-option-picker__clear is-primary is-smallx', - onClick: function() { - var sValue = props.attributes." . $key . "; - var oValue; - try {oValue = JSON.parse(sValue);} catch(err) {} - jQuery(document).off('show.bs.modal', '.bs-vc-modal').on('show.bs.modal', '.bs-vc-modal', function (e) { - if (e.target && jQuery(e.target).hasClass('bs-vc-modal')) { - sd_block_visibility_render_fields(oValue); - if (!jQuery('.bs-vc-modal-form .bs-vc-rule-sets .bs-vc-rule').length) { - jQuery('.bs-vc-modal-form .bs-vc-add-rule').trigger('click'); - } - if(typeof aui_init_select2 == 'function') { - aui_init_select2(); - } - jQuery('.bs-vc-modal-form').trigger('change'); - } - }); - aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', ''); - jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) { - props.setAttributes({" . $key . ": e.target.value}); - }); - } - }, - '" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "' - ) ),"; - } else { - return;// if we have not implemented the control then don't break the JS. - } - - // color input does not show the labels so we add them - if($args['type']=='color'){ - // add show only if advanced - echo $require_advanced; - // add setting require if defined - echo $element_require; - echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; - } - - // add show only if advanced - echo $require_advanced; - // add setting require if defined - echo $element_require; - echo $device_type_require; - - // icon - echo $icon; - ?> - el( , { - label: el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: ''}}),deviceType == '' && el('span',{dangerouslySetInnerHTML: {__html: ''},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}))'', - help: , - value: , - - - - - - - - onChange: function ( ) { - - } - - } ), - $val ) { - if(is_array($val)){ - $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; - }else{ - $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; - } - } - - } - - return $attributes; - } - - - - /** - * A self looping function to create the output for JS block elements. - * - * This is what is output in the WP Editor visual view. - * - * @param $args - */ - public function block_element( $args, $save = false ) { - - - if ( ! empty( $args ) ) { - foreach ( $args as $element => $new_args ) { - - if ( is_array( $new_args ) ) { // its an element - - - if ( isset( $new_args['element'] ) ) { - - if ( isset( $new_args['element_require'] ) ) { - echo str_replace( array( - "'+", - "+'" - ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; - unset( $new_args['element_require'] ); - } - - if($new_args['element']=='InnerBlocks'){ - echo "\n el( InnerBlocks, {"; - }elseif($new_args['element']=='innerBlocksProps'){ - $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; - // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; + } else if ( $args['type'] == 'alignment' ) { + $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example + } else if ( $args['type'] == 'margins' ) { + + } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) { + $type = 'TextControl'; + $value = "(props.attributes.$key ? props.attributes.$key : '')"; + $args['type'] = 'text'; + $options .= 'disabled:true,'; + $bsvc_title = esc_attr( addslashes( $args['title'] ) ); + $bsvc_body = $this->block_visibility_fields( $args ); + // @TODO reset button + $bsvc_footer = ''; + $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, { + className: 'components-button components-circular-option-picker__clear is-primary is-smallx', + onClick: function() { + var sValue = props.attributes." . $key . "; + var oValue; + try {oValue = JSON.parse(sValue);} catch(err) {} + jQuery(document).off('show.bs.modal', '.bs-vc-modal').on('show.bs.modal', '.bs-vc-modal', function (e) { + if (e.target && jQuery(e.target).hasClass('bs-vc-modal')) { + sd_block_visibility_render_fields(oValue); + if (!jQuery('.bs-vc-modal-form .bs-vc-rule-sets .bs-vc-rule').length) { + jQuery('.bs-vc-modal-form .bs-vc-add-rule').trigger('click'); + } + if(typeof aui_init_select2 == 'function') { + aui_init_select2(); + } + jQuery('.bs-vc-modal-form').trigger('change'); + } + }); + aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', ''); + jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) { + props.setAttributes({" . $key . ": e.target.value}); + }); + } + }, + '" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "' + ) ),"; + } else { + return;// if we have not implemented the control then don't break the JS. + } + + // color input does not show the labels so we add them + if($args['type']=='color'){ + // add show only if advanced + echo $require_advanced; + // add setting require if defined + echo $element_require; + echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),"; + } + + // add show only if advanced + echo $require_advanced; + // add setting require if defined + echo $element_require; + echo $device_type_require; + + // icon + echo $icon; + ?> + el( , { + label: el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: ''}}),deviceType == '' && el('span',{dangerouslySetInnerHTML: {__html: ''},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}}))'', + help: , + value: , + + + + + + + + onChange: function ( ) { + + } + + } ), + $val ) { + if(is_array($val)){ + $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},'; + }else{ + $attributes .= $html ? " $key='$val' " : "'$key': '$val',"; + } + } + + } + + return $attributes; + } + + + + /** + * A self looping function to create the output for JS block elements. + * + * This is what is output in the WP Editor visual view. + * + * @param $args + */ + public function block_element( $args, $save = false ) { + + + if ( ! empty( $args ) ) { + foreach ( $args as $element => $new_args ) { + + if ( is_array( $new_args ) ) { // its an element + + + if ( isset( $new_args['element'] ) ) { + + if ( isset( $new_args['element_require'] ) ) { + echo str_replace( array( + "'+", + "+'" + ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " && "; + unset( $new_args['element_require'] ); + } + + if($new_args['element']=='InnerBlocks'){ + echo "\n el( InnerBlocks, {"; + }elseif($new_args['element']=='innerBlocksProps'){ + $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div'; + // echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {"; // echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; - echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; - echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; - - echo "} ), {"; - echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; - // echo '###'; - - // echo '###'; - }elseif($new_args['element']=='BlocksProps'){ - - if ( isset($new_args['if_inner_element']) ) { - $element = $new_args['if_inner_element']; - }else { - $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; - } - - unset($new_args['inner_element']); - echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; - echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; - - - // echo "} ),"; - - }else{ - echo "\n el( '" . $new_args['element'] . "', {"; - } - - - // get the attributes - foreach ( $new_args as $new_key => $new_value ) { - - - if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { - // do nothing - } else { - echo $this->block_element( array( $new_key => $new_value ),$save ); - } - } - - echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes - - // get the content - $first_item = 0; - foreach ( $new_args as $new_key => $new_value ) { - if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { - - if ( $new_key === 'content' ) { - echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; - }else if ( $new_key === 'if_content' ) { - echo $this->block_props_replace( $new_value ); - } - - if ( is_array( $new_value ) ) { - - if ( isset( $new_value['element_require'] ) ) { - echo str_replace( array( - "'+", - "+'" - ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; - unset( $new_value['element_require'] ); - } - - if ( isset( $new_value['element_repeat'] ) ) { - $x = 1; - while ( $x <= absint( $new_value['element_repeat'] ) ) { - $this->block_element( array( '' => $new_value ),$save ); - $x ++; - } - } else { - $this->block_element( array( '' => $new_value ),$save ); - } - } - $first_item ++; - } - } - - if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ - echo "))";// end content - }else{ - echo ")";// end content - } - - - echo ", \n"; - - } - } else { - - if ( substr( $element, 0, 3 ) === "if_" ) { - $extra = ''; - if( strpos($new_args, '[%WrapClass%]') !== false ){ - $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); - $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); - } - echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; - } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { - $new_args = str_replace('[%WrapStyle%]','',$new_args); - echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; + echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( "; + echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {"; + echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; + + echo "} ), {"; + echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : ''; + // echo '###'; + + // echo '###'; + }elseif($new_args['element']=='BlocksProps'){ + + if ( isset($new_args['if_inner_element']) ) { + $element = $new_args['if_inner_element']; + }else { + $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'"; + } + + unset($new_args['inner_element']); + echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {"; + echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : ''; + + + // echo "} ),"; + + }else{ + echo "\n el( '" . $new_args['element'] . "', {"; + } + + + // get the attributes + foreach ( $new_args as $new_key => $new_value ) { + + + if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) { + // do nothing + } else { + echo $this->block_element( array( $new_key => $new_value ),$save ); + } + } + + echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes + + // get the content + $first_item = 0; + foreach ( $new_args as $new_key => $new_value ) { + if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) { + + if ( $new_key === 'content' ) { + echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'"; + }else if ( $new_key === 'if_content' ) { + echo $this->block_props_replace( $new_value ); + } + + if ( is_array( $new_value ) ) { + + if ( isset( $new_value['element_require'] ) ) { + echo str_replace( array( + "'+", + "+'" + ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " && "; + unset( $new_value['element_require'] ); + } + + if ( isset( $new_value['element_repeat'] ) ) { + $x = 1; + while ( $x <= absint( $new_value['element_repeat'] ) ) { + $this->block_element( array( '' => $new_value ),$save ); + $x ++; + } + } else { + $this->block_element( array( '' => $new_value ),$save ); + } + } + $first_item ++; + } + } + + if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){ + echo "))";// end content + }else{ + echo ")";// end content + } + + + echo ", \n"; + + } + } else { + + if ( substr( $element, 0, 3 ) === "if_" ) { + $extra = ''; + if( strpos($new_args, '[%WrapClass%]') !== false ){ + $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args); + $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args); + } + echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ","; + } elseif ( $element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false ) { + $new_args = str_replace('[%WrapStyle%]','',$new_args); + echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },"; // echo $element . ": " . $this->block_props_replace( $new_args ) . ","; - } elseif ( $element == 'style' ) { - echo $element . ": " . $this->block_props_replace( $new_args ) . ","; - } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { - $new_args = str_replace('[%WrapClass%]','',$new_args); - echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; - } elseif ( $element == 'template' && $new_args ) { - echo $element . ": $new_args,"; - } else { - echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; - } - - } - } - } - } - - /** - * Replace block attributes placeholders with the proper naming. - * - * @param $string - * - * @return mixed - */ - public function block_props_replace( $string, $no_wrap = false ) { - if ( $no_wrap ) { - $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string ); - } else { - $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string ); - } - - return $string; - } - - /** - * Outputs the content of the widget - * - * @param array $args - * @param array $instance - */ - public function widget( $args, $instance ) { - if ( ! is_array( $args ) ) { - $args = array(); - } - - // Get the filtered values - $argument_values = $this->argument_values( $instance ); - $argument_values = $this->string_to_bool( $argument_values ); - $output = $this->output( $argument_values, $args ); - - $no_wrap = false; - if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { - $no_wrap = true; - } - - ob_start(); - if ( $output && ! $no_wrap ) { - - $class_original = $this->options['widget_ops']['classname']; - $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); - - // Before widget - $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : ''; - $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget; - $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); - $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); - - // After widget - $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : ''; - $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); - $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); - - echo $before_widget; - // elementor strips the widget wrapping div so we check for and add it back if needed - if ( $this->is_elementor_widget_output() ) { - // Filter class & attrs for elementor widget output. - $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); - $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); - - $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); - $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); - - echo ""; - } - echo $this->output_title( $args, $instance ); - echo $output; - if ( $this->is_elementor_widget_output() ) { - echo ""; - } - echo $after_widget; - } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty - $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); - echo $output; - } elseif ( $output && $no_wrap ) { - echo $output; - } - $output = ob_get_clean(); - - $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); - - echo $output; - } - - /** - * Tests if the current output is inside a elementor container. - * - * @return bool - *@since 1.0.4 - */ - public function is_elementor_widget_output() { - $result = false; - if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a elementor preview. - * - * @return bool - *@since 1.0.4 - */ - public function is_elementor_preview() { - $result = false; - if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a Divi preview. - * - * @return bool - *@since 1.0.6 - */ - public function is_divi_preview() { - $result = false; - if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a Beaver builder preview. - * - * @return bool - *@since 1.0.6 - */ - public function is_beaver_preview() { - $result = false; - if ( isset( $_REQUEST['fl_builder'] ) ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a siteorigin builder preview. - * - * @return bool - *@since 1.0.6 - */ - public function is_siteorigin_preview() { - $result = false; - if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a cornerstone builder preview. - * - * @return bool - *@since 1.0.8 - */ - public function is_cornerstone_preview() { - $result = false; - if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a fusion builder preview. - * - * @return bool - *@since 1.1.0 - */ - public function is_fusion_preview() { - $result = false; - if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { - $result = true; - } - - return $result; - } - - /** - * Tests if the current output is inside a Oxygen builder preview. - * - * @return bool - *@since 1.0.18 - */ - public function is_oxygen_preview() { - $result = false; - if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { - $result = true; - } - - return $result; - } - - /** - * Check for Kallyas theme Zion builder preview. - * - * @since 1.1.22 - * - * @return bool True when preview page otherwise false. - */ - public function is_kallyas_zion_preview() { - $result = false; - - if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { - $result = true; - } - - return $result; - } - - /** - * Check for Bricks theme builder preview. - * - * @since 1.1.31 - * - * @return bool True when preview page otherwise false. - */ - public function is_bricks_preview() { - $result = false; - - if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { - $result = true; - } - - return $result; - } - - /** - * General function to check if we are in a preview situation. - * - * @return bool - *@since 1.0.6 - */ - public function is_preview() { - $preview = false; - if ( $this->is_divi_preview() ) { - $preview = true; - } elseif ( $this->is_elementor_preview() ) { - $preview = true; - } elseif ( $this->is_beaver_preview() ) { - $preview = true; - } elseif ( $this->is_siteorigin_preview() ) { - $preview = true; - } elseif ( $this->is_cornerstone_preview() ) { - $preview = true; - } elseif ( $this->is_fusion_preview() ) { - $preview = true; - } elseif ( $this->is_oxygen_preview() ) { - $preview = true; - } elseif( $this->is_kallyas_zion_preview() ) { - $preview = true; - } elseif( $this->is_block_content_call() ) { - $preview = true; - } elseif( $this->is_bricks_preview() ) { - $preview = true; - } - - return $preview; - } - - /** - * Output the super title. - * - * @param $args - * @param array $instance - * - * @return string - */ - public function output_title( $args, $instance = array() ) { - $output = ''; - if ( ! empty( $instance['title'] ) ) { - /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ - $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); - - if(empty($instance['widget_title_tag'])){ - $output = $args['before_title'] . $title . $args['after_title']; - }else{ - $title_tag = esc_attr( $instance['widget_title_tag'] ); - - // classes - $title_classes = array(); - $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; - $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; - - $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; - $output = "<$title_tag class='$class' >$title"; - } - - } - - return $output; - } - - /** - * Outputs the options form inputs for the widget. - * - * @param array $instance The widget options. - */ - public function form( $instance ) { - - // set widget instance - $this->instance = $instance; - - // set it as a SD widget - echo $this->widget_advanced_toggle(); - - echo "

" . esc_attr( $this->options['widget_ops']['description'] ) . "

"; - $arguments_raw = $this->get_arguments(); - - if ( is_array( $arguments_raw ) ) { - - $arguments = $this->group_arguments( $arguments_raw ); - - // Do we have sections? - $has_sections = $arguments == $arguments_raw ? false : true; - - - if ( $has_sections ) { - $panel_count = 0; - foreach ( $arguments as $key => $args ) { - - ?> - - " . esc_attr( $key ) . " "; - echo "
"; - - foreach ( $args as $k => $a ) { - - $this->widget_inputs_row_start($k, $a); - $this->widget_inputs( $a, $instance ); - $this->widget_inputs_row_end($k, $a); - - } - - echo "
"; - - $panel_count ++; - - } - } else { - foreach ( $arguments as $key => $args ) { - $this->widget_inputs_row_start($key, $args); - $this->widget_inputs( $args, $instance ); - $this->widget_inputs_row_end($key, $args); - } - } - - } - } - - public function widget_inputs_row_start( $key, $args ) { - if ( ! empty( $args['row'] ) ) { - // Maybe open - if ( ! empty( $args['row']['open'] ) ) { - ?> -
' data-element_require='convert_element_require( $args['row']['element_require'] ) : '' ); ?>'> - - - - -
'> -
- "; - } else { - echo "
"; - } - } - } - - public function widget_inputs_row_end( $key, $args ) { - if ( ! empty( $args['row'] ) ) { - // Maybe close - if ( ! empty( $args['row']['close'] ) ) { - echo "
"; - } - echo "
"; - } - } - - /** - * Get the hidden input that when added makes the advanced button show on widget settings. - * - * @return string - */ - public function widget_advanced_toggle() { - - $output = ''; - if ( $this->block_show_advanced() ) { - $val = 1; - } else { - $val = 0; - } - - $output .= ""; - - return $output; - } - - /** - * Convert require element. - * - * @param string $input Input element. - * - * @return string $output - *@since 1.0.0 - * - */ - public function convert_element_require( $input ) { - $input = str_replace( "'", '"', $input );// we only want double quotes - - $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( - "jQuery(form).find('[data-argument=\"", - "\"]').find('input,select,textarea').val()", - "\"]').find('input:checked').val()" - ), $input ) ); - - return $output; - } - - /** - * Builds the inputs for the widget options. - * - * @param $args - * @param $instance - */ - public function widget_inputs( $args, $instance ) { - - $class = ""; - $element_require = ""; - $custom_attributes = ""; - - // get value - if ( isset( $instance[ $args['name'] ] ) ) { - $value = $instance[ $args['name'] ]; - } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { - $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); - } else { - $value = ''; - } - - // get placeholder - if ( ! empty( $args['placeholder'] ) ) { - $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; - } else { - $placeholder = ''; - } - - // get if advanced - if ( isset( $args['advanced'] ) && $args['advanced'] ) { - $class .= " sd-advanced-setting "; - } - - // element_require - if ( isset( $args['element_require'] ) && $args['element_require'] ) { - $element_require = $args['element_require']; - } - - // custom_attributes - if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { - $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); - } - - // before wrapper - ?> -

' data-element_require='convert_element_require( $element_require );} ?>'> - - - class="widefat" id="get_field_id( $args['name'] ) ); ?>" name="get_field_name( $args['name'] ) ); ?>" type="" value=""> - - - - - class="widefat" id="get_field_id( $args['name'] ) ); ?>" name="get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1"> - - - - - - -

'; - }elseif($icon=='box-right'){ - return ''; - }elseif($icon=='box-bottom'){ - return ''; - }elseif($icon=='box-left'){ - return ''; - } - } - - /** - * Get the widget input description html. - * - * @param $args - * - * @return string - * @todo, need to make its own tooltip script - */ - public function widget_field_desc( $args ) { - - $description = ''; - if ( isset( $args['desc'] ) && $args['desc'] ) { - if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { - $description = $this->desc_tip( $args['desc'] ); - } else { - $description = '' . wp_kses_post( $args['desc'] ) . ''; - } - } - - return $description; - } - - /** - * Get the widget input title html. - * - * @param $args - * - * @return string - */ - public function widget_field_title( $args ) { - $title = ''; - - if ( isset( $args['title'] ) && $args['title'] ) { - if ( ! empty( $args['device_type'] ) ) { - $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title. - } - - if ( isset( $args['icon'] ) && $args['icon'] ) { - $title = self::get_widget_icon( $args['icon'], $args['title'] ); - } else { - $title = esc_attr( $args['title'] ); - } - } - - return $title; - } - - /** - * Get the tool tip html. - * - * @param $tip - * @param bool $allow_html - * - * @return string - */ - function desc_tip( $tip, $allow_html = false ) { - if ( $allow_html ) { - $tip = $this->sanitize_tooltip( $tip ); - } else { - $tip = esc_attr( $tip ); - } - - return ''; - } - - /** - * Sanitize a string destined to be a tooltip. - * - * @param string $var - * - * @return string - */ - public function sanitize_tooltip( $var ) { - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( - 'br' => array(), - 'em' => array(), - 'strong' => array(), - 'small' => array(), - 'span' => array(), - 'ul' => array(), - 'li' => array(), - 'ol' => array(), - 'p' => array(), - ) ) ); - } - - /** - * Processing widget options on save - * - * @param array $new_instance The new options - * @param array $old_instance The previous options - * - * @return array - * @todo we should add some sanitation here. - */ - public function update( $new_instance, $old_instance ) { - - //save the widget - $instance = array_merge( (array) $old_instance, (array) $new_instance ); - - // set widget instance - $this->instance = $instance; - - if ( empty( $this->arguments ) ) { - $this->get_arguments(); - } - - // check for checkboxes - if ( ! empty( $this->arguments ) ) { - foreach ( $this->arguments as $argument ) { - if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { - $instance[ $argument['name'] ] = '0'; - } - } - } - - return $instance; - } - - /** - * Checks if the current call is a ajax call to get the block content. - * - * This can be used in your widget to return different content as the block content. - * - * @return bool - *@since 1.0.3 - */ - public function is_block_content_call() { - $result = false; - if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { - $result = true; - } - - return $result; - } - - /** - * Get an instance hash that will be unique to the type and settings. - * - * @return string - *@since 1.0.20 - */ - public function get_instance_hash(){ - $instance_string = $this->base_id.serialize($this->instance); - return hash('crc32b',$instance_string); - } - - /** - * Generate and return inline styles from CSS rules that will match the unique class of the instance. - * - * @param array $rules - * - * @return string - *@since 1.0.20 - */ - public function get_instance_style($rules = array()){ - $css = ''; - - if(!empty($rules)){ - $rules = array_unique($rules); - $instance_hash = $this->get_instance_hash(); - $css .= ""; - } - - return $css; - } - - /** - * Encode shortcodes tags. - * - * @param string $content Content to search for shortcode tags. - * + } elseif ( $element == 'style' ) { + echo $element . ": " . $this->block_props_replace( $new_args ) . ","; + } elseif ( ( $element == 'class' || $element == 'className' ) && strpos($new_args, '[%WrapClass%]') !== false ) { + $new_args = str_replace('[%WrapClass%]','',$new_args); + echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),"; + } elseif ( $element == 'template' && $new_args ) { + echo $element . ": $new_args,"; + } else { + echo $element . ": '" . $this->block_props_replace( $new_args ) . "',"; + } + + } + } + } + } + + /** + * Replace block attributes placeholders with the proper naming. + * + * @param $string + * + * @return mixed + */ + public function block_props_replace( $string, $no_wrap = false ) { + if ( $no_wrap ) { + $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string ); + } else { + $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string ); + } + + return $string; + } + + /** + * Outputs the content of the widget + * + * @param array $args + * @param array $instance + */ + public function widget( $args, $instance ) { + if ( ! is_array( $args ) ) { + $args = array(); + } + + // Get the filtered values + $argument_values = $this->argument_values( $instance ); + $argument_values = $this->string_to_bool( $argument_values ); + $output = $this->output( $argument_values, $args ); + + $no_wrap = false; + if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) { + $no_wrap = true; + } + + ob_start(); + if ( $output && ! $no_wrap ) { + + $class_original = $this->options['widget_ops']['classname']; + $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash(); + + // Before widget + $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : ''; + $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget; + $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this ); + $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this ); + + // After widget + $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : ''; + $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this ); + $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this ); + + echo $before_widget; + // elementor strips the widget wrapping div so we check for and add it back if needed + if ( $this->is_elementor_widget_output() ) { + // Filter class & attrs for elementor widget output. + $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this ); + $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this ); + + $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this ); + $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this ); + + echo ""; + } + echo $this->output_title( $args, $instance ); + echo $output; + if ( $this->is_elementor_widget_output() ) { + echo ""; + } + echo $after_widget; + } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty + $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" ); + echo $output; + } elseif ( $output && $no_wrap ) { + echo $output; + } + $output = ob_get_clean(); + + $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this ); + + echo $output; + } + + /** + * Tests if the current output is inside a elementor container. + * + * @return bool + *@since 1.0.4 + */ + public function is_elementor_widget_output() { + $result = false; + if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a elementor preview. + * + * @return bool + *@since 1.0.4 + */ + public function is_elementor_preview() { + $result = false; + if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a Divi preview. + * + * @return bool + *@since 1.0.6 + */ + public function is_divi_preview() { + $result = false; + if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a Beaver builder preview. + * + * @return bool + *@since 1.0.6 + */ + public function is_beaver_preview() { + $result = false; + if ( isset( $_REQUEST['fl_builder'] ) ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a siteorigin builder preview. + * + * @return bool + *@since 1.0.6 + */ + public function is_siteorigin_preview() { + $result = false; + if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a cornerstone builder preview. + * + * @return bool + *@since 1.0.8 + */ + public function is_cornerstone_preview() { + $result = false; + if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a fusion builder preview. + * + * @return bool + *@since 1.1.0 + */ + public function is_fusion_preview() { + $result = false; + if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) { + $result = true; + } + + return $result; + } + + /** + * Tests if the current output is inside a Oxygen builder preview. + * + * @return bool + *@since 1.0.18 + */ + public function is_oxygen_preview() { + $result = false; + if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) { + $result = true; + } + + return $result; + } + + /** + * Check for Kallyas theme Zion builder preview. + * + * @since 1.1.22 + * + * @return bool True when preview page otherwise false. + */ + public function is_kallyas_zion_preview() { + $result = false; + + if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) { + $result = true; + } + + return $result; + } + + /** + * Check for Bricks theme builder preview. + * + * @since 1.1.31 + * + * @return bool True when preview page otherwise false. + */ + public function is_bricks_preview() { + $result = false; + + if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) { + $result = true; + } + + return $result; + } + + /** + * General function to check if we are in a preview situation. + * + * @return bool + *@since 1.0.6 + */ + public function is_preview() { + $preview = false; + if ( $this->is_divi_preview() ) { + $preview = true; + } elseif ( $this->is_elementor_preview() ) { + $preview = true; + } elseif ( $this->is_beaver_preview() ) { + $preview = true; + } elseif ( $this->is_siteorigin_preview() ) { + $preview = true; + } elseif ( $this->is_cornerstone_preview() ) { + $preview = true; + } elseif ( $this->is_fusion_preview() ) { + $preview = true; + } elseif ( $this->is_oxygen_preview() ) { + $preview = true; + } elseif( $this->is_kallyas_zion_preview() ) { + $preview = true; + } elseif( $this->is_block_content_call() ) { + $preview = true; + } elseif( $this->is_bricks_preview() ) { + $preview = true; + } + + return $preview; + } + + /** + * Output the super title. + * + * @param $args + * @param array $instance + * + * @return string + */ + public function output_title( $args, $instance = array() ) { + $output = ''; + if ( ! empty( $instance['title'] ) ) { + /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ + $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); + + if(empty($instance['widget_title_tag'])){ + $output = $args['before_title'] . $title . $args['after_title']; + }else{ + $title_tag = esc_attr( $instance['widget_title_tag'] ); + + // classes + $title_classes = array(); + $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : ''; + $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : ''; + + $class = !empty( $title_classes ) ? implode(" ",$title_classes) : ''; + $output = "<$title_tag class='$class' >$title"; + } + + } + + return $output; + } + + /** + * Outputs the options form inputs for the widget. + * + * @param array $instance The widget options. + */ + public function form( $instance ) { + + // set widget instance + $this->instance = $instance; + + // set it as a SD widget + echo $this->widget_advanced_toggle(); + + echo "

" . esc_attr( $this->options['widget_ops']['description'] ) . "

"; + $arguments_raw = $this->get_arguments(); + + if ( is_array( $arguments_raw ) ) { + + $arguments = $this->group_arguments( $arguments_raw ); + + // Do we have sections? + $has_sections = $arguments == $arguments_raw ? false : true; + + + if ( $has_sections ) { + $panel_count = 0; + foreach ( $arguments as $key => $args ) { + + ?> + + " . esc_attr( $key ) . " "; + echo "
"; + + foreach ( $args as $k => $a ) { + + $this->widget_inputs_row_start($k, $a); + $this->widget_inputs( $a, $instance ); + $this->widget_inputs_row_end($k, $a); + + } + + echo "
"; + + $panel_count ++; + + } + } else { + foreach ( $arguments as $key => $args ) { + $this->widget_inputs_row_start($key, $args); + $this->widget_inputs( $args, $instance ); + $this->widget_inputs_row_end($key, $args); + } + } + + } + } + + public function widget_inputs_row_start( $key, $args ) { + if ( ! empty( $args['row'] ) ) { + // Maybe open + if ( ! empty( $args['row']['open'] ) ) { + ?> +
' data-element_require='convert_element_require( $args['row']['element_require'] ) : '' ); ?>'> + + + + +
'> +
+ "; + } else { + echo "
"; + } + } + } + + public function widget_inputs_row_end( $key, $args ) { + if ( ! empty( $args['row'] ) ) { + // Maybe close + if ( ! empty( $args['row']['close'] ) ) { + echo "
"; + } + echo "
"; + } + } + + /** + * Get the hidden input that when added makes the advanced button show on widget settings. + * + * @return string + */ + public function widget_advanced_toggle() { + + $output = ''; + if ( $this->block_show_advanced() ) { + $val = 1; + } else { + $val = 0; + } + + $output .= ""; + + return $output; + } + + /** + * Convert require element. + * + * @param string $input Input element. + * + * @return string $output + *@since 1.0.0 + * + */ + public function convert_element_require( $input ) { + $input = str_replace( "'", '"', $input );// we only want double quotes + + $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array( + "jQuery(form).find('[data-argument=\"", + "\"]').find('input,select,textarea').val()", + "\"]').find('input:checked').val()" + ), $input ) ); + + return $output; + } + + /** + * Builds the inputs for the widget options. + * + * @param $args + * @param $instance + */ + public function widget_inputs( $args, $instance ) { + + $class = ""; + $element_require = ""; + $custom_attributes = ""; + + // get value + if ( isset( $instance[ $args['name'] ] ) ) { + $value = $instance[ $args['name'] ]; + } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) { + $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] ); + } else { + $value = ''; + } + + // get placeholder + if ( ! empty( $args['placeholder'] ) ) { + $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'"; + } else { + $placeholder = ''; + } + + // get if advanced + if ( isset( $args['advanced'] ) && $args['advanced'] ) { + $class .= " sd-advanced-setting "; + } + + // element_require + if ( isset( $args['element_require'] ) && $args['element_require'] ) { + $element_require = $args['element_require']; + } + + // custom_attributes + if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) { + $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true ); + } + + // before wrapper + ?> +

' data-element_require='convert_element_require( $element_require );} ?>'> + + + class="widefat" id="get_field_id( $args['name'] ) ); ?>" name="get_field_name( $args['name'] ) ); ?>" type="" value=""> + + + + + class="widefat" id="get_field_id( $args['name'] ) ); ?>" name="get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1"> + + + + + + +

'; + }elseif($icon=='box-right'){ + return ''; + }elseif($icon=='box-bottom'){ + return ''; + }elseif($icon=='box-left'){ + return ''; + } + } + + /** + * Get the widget input description html. + * + * @param $args + * + * @return string + * @todo, need to make its own tooltip script + */ + public function widget_field_desc( $args ) { + + $description = ''; + if ( isset( $args['desc'] ) && $args['desc'] ) { + if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) { + $description = $this->desc_tip( $args['desc'] ); + } else { + $description = '' . wp_kses_post( $args['desc'] ) . ''; + } + } + + return $description; + } + + /** + * Get the widget input title html. + * + * @param $args + * + * @return string + */ + public function widget_field_title( $args ) { + $title = ''; + + if ( isset( $args['title'] ) && $args['title'] ) { + if ( ! empty( $args['device_type'] ) ) { + $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title. + } + + if ( isset( $args['icon'] ) && $args['icon'] ) { + $title = self::get_widget_icon( $args['icon'], $args['title'] ); + } else { + $title = esc_attr( $args['title'] ); + } + } + + return $title; + } + + /** + * Get the tool tip html. + * + * @param $tip + * @param bool $allow_html + * + * @return string + */ + function desc_tip( $tip, $allow_html = false ) { + if ( $allow_html ) { + $tip = $this->sanitize_tooltip( $tip ); + } else { + $tip = esc_attr( $tip ); + } + + return ''; + } + + /** + * Sanitize a string destined to be a tooltip. + * + * @param string $var + * + * @return string + */ + public function sanitize_tooltip( $var ) { + return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( + 'br' => array(), + 'em' => array(), + 'strong' => array(), + 'small' => array(), + 'span' => array(), + 'ul' => array(), + 'li' => array(), + 'ol' => array(), + 'p' => array(), + ) ) ); + } + + /** + * Processing widget options on save + * + * @param array $new_instance The new options + * @param array $old_instance The previous options + * + * @return array + * @todo we should add some sanitation here. + */ + public function update( $new_instance, $old_instance ) { + + //save the widget + $instance = array_merge( (array) $old_instance, (array) $new_instance ); + + // set widget instance + $this->instance = $instance; + + if ( empty( $this->arguments ) ) { + $this->get_arguments(); + } + + // check for checkboxes + if ( ! empty( $this->arguments ) ) { + foreach ( $this->arguments as $argument ) { + if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) { + $instance[ $argument['name'] ] = '0'; + } + } + } + + return $instance; + } + + /** + * Checks if the current call is a ajax call to get the block content. + * + * This can be used in your widget to return different content as the block content. + * + * @return bool + *@since 1.0.3 + */ + public function is_block_content_call() { + $result = false; + if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) { + $result = true; + } + + return $result; + } + + /** + * Get an instance hash that will be unique to the type and settings. + * + * @return string + *@since 1.0.20 + */ + public function get_instance_hash(){ + $instance_string = $this->base_id.serialize($this->instance); + return hash('crc32b',$instance_string); + } + + /** + * Generate and return inline styles from CSS rules that will match the unique class of the instance. + * + * @param array $rules + * + * @return string + *@since 1.0.20 + */ + public function get_instance_style($rules = array()){ + $css = ''; + + if(!empty($rules)){ + $rules = array_unique($rules); + $instance_hash = $this->get_instance_hash(); + $css .= ""; + } + + return $css; + } + + /** + * Encode shortcodes tags. + * + * @param string $content Content to search for shortcode tags. + * *@return string Content with shortcode tags removed. - *@since 1.0.28 - * - */ - public function encode_shortcodes( $content ) { - // Avoids existing encoded tags. - $trans = array( - '[' => '[', - ']' => ']', - '&#91;' => '[', - '&#93;' => ']', - '<' => '&0lt;', - '>' => '&0gt;', - '&lt;' => '&0lt;', - '&gt;' => '&0gt;', - ); - - $content = strtr( $content, $trans ); - - $trans = array( - '[' => '[', - ']' => ']', - '<' => '<', - '>' => '>', - '"' => '"', - "'" => ''', - ); - - $content = strtr( $content, $trans ); - - return $content; - } - - /** - * Remove encoded shortcod tags. - * - * @param string $content Content to search for shortcode tags. - * + *@since 1.0.28 + * + */ + public function encode_shortcodes( $content ) { + // Avoids existing encoded tags. + $trans = array( + '[' => '[', + ']' => ']', + '&#91;' => '[', + '&#93;' => ']', + '<' => '&0lt;', + '>' => '&0gt;', + '&lt;' => '&0lt;', + '&gt;' => '&0gt;', + ); + + $content = strtr( $content, $trans ); + + $trans = array( + '[' => '[', + ']' => ']', + '<' => '<', + '>' => '>', + '"' => '"', + "'" => ''', + ); + + $content = strtr( $content, $trans ); + + return $content; + } + + /** + * Remove encoded shortcod tags. + * + * @param string $content Content to search for shortcode tags. + * *@return string Content with decoded shortcode tags. - *@since 1.0.28 - * - */ - public function decode_shortcodes( $content ) { - $trans = array( - '[' => '[', - ']' => ']', - '&#91;' => '[', - '&#93;' => ']', - '<' => '<', - '>' => '>', - '&lt;' => '<', - '&gt;' => '>', - '"' => '"', - ''' => "'", - ); - - $content = strtr( $content, $trans ); - - $trans = array( - '[' => '[', - ']' => ']', - '&#091;' => '[', - '&#093;' => ']', - '&0lt;' => '<', - '&0gt;' => '>', - '&0lt;' => '<', - '&0gt;' => '>', - ); - - $content = strtr( $content, $trans ); - - return $content; - } - - public function block_visibility_fields( $args ) { - $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : ''; - $content = '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= aui()->select( - array( - 'id' => 'bsvc_rule_BSVCINDEX', - 'name' => 'bsvc_rule_BSVCINDEX', - 'label' => __( 'Rule', 'ayecode-connect' ), - 'placeholder' => __( 'Select Rule...', 'ayecode-connect' ), - 'class' => 'bsvc_rule form-select-sm no-select2 mw-100', - 'options' => sd_visibility_rules_options(), - 'default' => '', - 'value' => '', - 'label_type' => '', - 'select2' => false, - 'input_group_left' => __( 'Rule:', 'ayecode-connect' ), - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= '
'; - - if ( class_exists( 'GeoDirectory' ) ) { - $content .= '
'; - - $content .= aui()->select( - array( - 'id' => 'bsvc_gd_field_BSVCINDEX', - 'name' => 'bsvc_gd_field_BSVCINDEX', - 'label' => __( 'FIELD', 'ayecode-connect' ), - 'placeholder' => __( 'FIELD', 'ayecode-connect' ), - 'class' => 'bsvc_gd_field form-select-sm no-select2 mw-100', - 'options' => sd_visibility_gd_field_options(), - 'default' => '', - 'value' => '', - 'label_type' => '', - 'select2' => false, - 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= '
'; - $content .= '
'; - - $content .= aui()->select( - array( - 'id' => 'bsvc_gd_field_condition_BSVCINDEX', - 'name' => 'bsvc_gd_field_condition_BSVCINDEX', - 'label' => __( 'CONDITION', 'ayecode-connect' ), - 'placeholder' => __( 'CONDITION', 'ayecode-connect' ), - 'class' => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100', - 'options' => sd_visibility_field_condition_options(), - 'default' => '', - 'value' => '', - 'label_type' => '', - 'select2' => false, - 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= '
'; - $content .= '
'; - - $content .= aui()->input( - array( - 'type' => 'text', - 'id' => 'bsvc_gd_field_search_BSVCINDEX', - 'name' => 'bsvc_gd_field_search_BSVCINDEX', - 'label' => __( 'VALUE TO MATCH', 'ayecode-connect' ), - 'class' => 'bsvc_gd_field_search form-control-sm', - 'placeholder' => __( 'VALUE TO MATCH', 'ayecode-connect' ), - 'label_type' => '', - 'value' => '', - 'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")' - ) - ); - - $content .= '
'; - } - - $content .= '
'; - - $content .= '
'; - $role_options = sd_user_roles_options(); - - $role_option_i = 0; - foreach ( $role_options as $role_option_key => $role_option_name ) { - $role_option_i++; - - $content .= '
'; - $content .= aui()->input( - array( - 'id' => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i, - 'name' => 'bsvc_user_roles_BSVCINDEX[]', - 'type' => 'checkbox', - 'label' => $role_option_name, - 'label_type' => 'hidden', - 'class' => 'bsvc_user_roles', - 'value' => $role_option_key, - 'switch' => 'md', - 'no_wrap' => true - ) - ); - $content .= '
'; - } - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= '
'; - $content .= aui()->select( - array( - 'id' => 'bsvc_output', - 'name' => 'bsvc_output', - 'label' => __( 'What should happen if rules met.', 'ayecode-connect' ), - 'placeholder' => __( 'Default Output', 'ayecode-connect' ), - 'class' => 'bsvc_output form-select-sm no-select2 mw-100', - 'options' => sd_visibility_output_options(), - 'default' => '', - 'value' => '', - 'label_type' => 'top', - 'select2' => false, - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= '
'; - - $content .= aui()->select( - array( - 'id' => 'bsvc_page', - 'name' => 'bsvc_page', - 'label' => __( 'Page Content', 'ayecode-connect' ), - 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), - 'class' => 'bsvc_page form-select-sm no-select2 mw-100', - 'options' => sd_template_page_options(), - 'default' => '', - 'value' => '', - 'label_type' => 'top', - 'select2' => false, - 'element_require' => '[%bsvc_output%]=="page"' - ) - ); - - $content .= aui()->select( - array( - 'id' => 'bsvc_tmpl_part', - 'name' => 'bsvc_tmpl_part', - 'label' => __( 'Template Part', 'ayecode-connect' ), - 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), - 'class' => 'bsvc_tmpl_part form-select-sm no-select2 mw-100', - 'options' => sd_template_part_options(), - 'default' => '', - 'value' => '', - 'label_type' => 'top', - 'select2' => false, - 'element_require' => '[%bsvc_output%]=="template_part"', - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= aui()->select( - array( - 'id' => 'bsvc_message_type', - 'name' => 'bsvc_message_type', - 'label' => __( 'Custom Message Type', 'ayecode-connect' ), - 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), - 'class' => 'bsvc_message_type form-select-sm no-select2 mw-100', - 'options' => sd_aui_colors(), - 'default' => '', - 'value' => '', - 'label_type' => 'top', - 'select2' => false, - 'element_require' => '[%bsvc_output%]=="message"', - 'extra_attributes' => array( - 'data-minimum-results-for-search' => '-1' - ) - ) - ); - - $content .= '
'; - - $content .= aui()->input( - array( - 'type' => 'text', - 'id' => 'bsvc_message', - 'name' => 'bsvc_message', - 'label' => '', - 'class' => 'bsvc_message form-control-sm', - 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), - 'label_type' => '', - 'value' => '', - 'form_group_class' => ' ', - 'element_require' => '[%bsvc_output%]=="message"', - ) - ); - - $content .= '
'; - - return $content; - } - } + *@since 1.0.28 + * + */ + public function decode_shortcodes( $content ) { + $trans = array( + '[' => '[', + ']' => ']', + '&#91;' => '[', + '&#93;' => ']', + '<' => '<', + '>' => '>', + '&lt;' => '<', + '&gt;' => '>', + '"' => '"', + ''' => "'", + ); + + $content = strtr( $content, $trans ); + + $trans = array( + '[' => '[', + ']' => ']', + '&#091;' => '[', + '&#093;' => ']', + '&0lt;' => '<', + '&0gt;' => '>', + '&0lt;' => '<', + '&0gt;' => '>', + ); + + $content = strtr( $content, $trans ); + + return $content; + } + + public function block_visibility_fields( $args ) { + $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : ''; + $content = '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= aui()->select( + array( + 'id' => 'bsvc_rule_BSVCINDEX', + 'name' => 'bsvc_rule_BSVCINDEX', + 'label' => __( 'Rule', 'ayecode-connect' ), + 'placeholder' => __( 'Select Rule...', 'ayecode-connect' ), + 'class' => 'bsvc_rule form-select-sm no-select2 mw-100', + 'options' => sd_visibility_rules_options(), + 'default' => '', + 'value' => '', + 'label_type' => '', + 'select2' => false, + 'input_group_left' => __( 'Rule:', 'ayecode-connect' ), + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= '
'; + + if ( class_exists( 'GeoDirectory' ) ) { + $content .= '
'; + + $content .= aui()->select( + array( + 'id' => 'bsvc_gd_field_BSVCINDEX', + 'name' => 'bsvc_gd_field_BSVCINDEX', + 'label' => __( 'FIELD', 'ayecode-connect' ), + 'placeholder' => __( 'FIELD', 'ayecode-connect' ), + 'class' => 'bsvc_gd_field form-select-sm no-select2 mw-100', + 'options' => sd_visibility_gd_field_options(), + 'default' => '', + 'value' => '', + 'label_type' => '', + 'select2' => false, + 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= '
'; + $content .= '
'; + + $content .= aui()->select( + array( + 'id' => 'bsvc_gd_field_condition_BSVCINDEX', + 'name' => 'bsvc_gd_field_condition_BSVCINDEX', + 'label' => __( 'CONDITION', 'ayecode-connect' ), + 'placeholder' => __( 'CONDITION', 'ayecode-connect' ), + 'class' => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100', + 'options' => sd_visibility_field_condition_options(), + 'default' => '', + 'value' => '', + 'label_type' => '', + 'select2' => false, + 'element_require' => '[%bsvc_rule_BSVCINDEX%]=="gd_field"', + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= '
'; + $content .= '
'; + + $content .= aui()->input( + array( + 'type' => 'text', + 'id' => 'bsvc_gd_field_search_BSVCINDEX', + 'name' => 'bsvc_gd_field_search_BSVCINDEX', + 'label' => __( 'VALUE TO MATCH', 'ayecode-connect' ), + 'class' => 'bsvc_gd_field_search form-control-sm', + 'placeholder' => __( 'VALUE TO MATCH', 'ayecode-connect' ), + 'label_type' => '', + 'value' => '', + 'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")' + ) + ); + + $content .= '
'; + } + + $content .= '
'; + + $content .= '
'; + $role_options = sd_user_roles_options(); + + $role_option_i = 0; + foreach ( $role_options as $role_option_key => $role_option_name ) { + $role_option_i++; + + $content .= '
'; + $content .= aui()->input( + array( + 'id' => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i, + 'name' => 'bsvc_user_roles_BSVCINDEX[]', + 'type' => 'checkbox', + 'label' => $role_option_name, + 'label_type' => 'hidden', + 'class' => 'bsvc_user_roles', + 'value' => $role_option_key, + 'switch' => 'md', + 'no_wrap' => true + ) + ); + $content .= '
'; + } + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= '
'; + $content .= aui()->select( + array( + 'id' => 'bsvc_output', + 'name' => 'bsvc_output', + 'label' => __( 'What should happen if rules met.', 'ayecode-connect' ), + 'placeholder' => __( 'Default Output', 'ayecode-connect' ), + 'class' => 'bsvc_output form-select-sm no-select2 mw-100', + 'options' => sd_visibility_output_options(), + 'default' => '', + 'value' => '', + 'label_type' => 'top', + 'select2' => false, + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= '
'; + + $content .= aui()->select( + array( + 'id' => 'bsvc_page', + 'name' => 'bsvc_page', + 'label' => __( 'Page Content', 'ayecode-connect' ), + 'placeholder' => __( 'Select Page ID...', 'ayecode-connect' ), + 'class' => 'bsvc_page form-select-sm no-select2 mw-100', + 'options' => sd_template_page_options(), + 'default' => '', + 'value' => '', + 'label_type' => 'top', + 'select2' => false, + 'element_require' => '[%bsvc_output%]=="page"' + ) + ); + + $content .= aui()->select( + array( + 'id' => 'bsvc_tmpl_part', + 'name' => 'bsvc_tmpl_part', + 'label' => __( 'Template Part', 'ayecode-connect' ), + 'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ), + 'class' => 'bsvc_tmpl_part form-select-sm no-select2 mw-100', + 'options' => sd_template_part_options(), + 'default' => '', + 'value' => '', + 'label_type' => 'top', + 'select2' => false, + 'element_require' => '[%bsvc_output%]=="template_part"', + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= aui()->select( + array( + 'id' => 'bsvc_message_type', + 'name' => 'bsvc_message_type', + 'label' => __( 'Custom Message Type', 'ayecode-connect' ), + 'placeholder' => __( 'Default (none)', 'ayecode-connect' ), + 'class' => 'bsvc_message_type form-select-sm no-select2 mw-100', + 'options' => sd_aui_colors(), + 'default' => '', + 'value' => '', + 'label_type' => 'top', + 'select2' => false, + 'element_require' => '[%bsvc_output%]=="message"', + 'extra_attributes' => array( + 'data-minimum-results-for-search' => '-1' + ) + ) + ); + + $content .= '
'; + + $content .= aui()->input( + array( + 'type' => 'text', + 'id' => 'bsvc_message', + 'name' => 'bsvc_message', + 'label' => '', + 'class' => 'bsvc_message form-control-sm', + 'placeholder' => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ), + 'label_type' => '', + 'value' => '', + 'form_group_class' => ' ', + 'element_require' => '[%bsvc_output%]=="message"', + ) + ); + + $content .= '
'; + + return $content; + } + } }