config['version'] = '1.0';
$this->config['self_closing'] = 'no';
$this->config['name'] = __( 'Fullwidth Sub Menu', 'avia_framework' );
$this->config['tab'] = __( 'Content Elements', 'avia_framework' );
$this->config['icon'] = AviaBuilder::$path['imagesURL'] . 'sc-submenu.png';
$this->config['order'] = 30;
$this->config['target'] = 'avia-target-insert';
$this->config['shortcode'] = 'av_submenu';
$this->config['shortcode_nested'] = array( 'av_submenu_item' );
$this->config['tooltip'] = __( 'Display a sub menu', 'avia_framework' );
$this->config['tinyMCE'] = array( 'disable' => 'true' );
$this->config['drag-level'] = 1;
$this->config['preview'] = false;
$this->config['disabling_allowed'] = true;
}
function extra_assets()
{
//load css
wp_enqueue_style( 'avia-module-menu', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/menu/menu.css', array( 'avia-layout' ), false );
//load js
wp_enqueue_script( 'avia-module-menu', AviaBuilder::$path['pluginUrlRoot'] . 'avia-shortcodes/menu/menu.js', array( 'avia-shortcodes' ), false, true );
}
/**
* Popup Elements
*
* If this function is defined in a child class the element automatically gets an edit button, that, when pressed
* opens a modal window that allows to edit the element properties
*
* @return void
*/
function popup_elements()
{
$this->elements = array(
//Opening for all tabs
array(
'type' => 'tab_container',
'nodescription' => true
),
//Opening for the first tab: Content
array(
'type' => 'tab',
'name' => __( 'Content', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'content_menus' ),
'nodescription' => true
),
array(
'type' => 'tab_close',
'nodescription' => true
),
//Opening for the first tab: Styling
array(
'type' => 'tab',
'name' => __( 'Styling', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'styling_colors' ),
'nodescription' => true
),
array(
'type' => 'tab_close',
'nodescription' => true
),
//Opening for the second tab: Advanced
array(
'type' => 'tab',
'name' => __( 'Advanced', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'advanced_responsive' ),
'nodescription' => true
),
//Opening of the Developer Tab
array(
'type' => 'toggle_container',
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => 'developer_options_toggle',
'args' => array( 'sc' => $this )
),
array(
'type' => 'toggle_container_close',
'nodescription' => true
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab_container_close',
'nodescription' => true
)
);
}
/**
* Create and register templates for easier maintainance
*
* @since 4.6.4
*/
protected function register_dynamic_templates()
{
global $avia_config;
$this->register_modal_group_templates();
/**
* Content Tab
* ===========
*/
$menus = array();
if( ! empty( $_POST ) && ! empty( $_POST['action'] ) && $_POST['action'] == 'avia_ajax_av_submenu' )
{
$menus = AviaHelper::list_menus();
}
$c = array(
array(
'name' => __( 'Which kind of menu do you want to display','avia_framework' ),
'desc' => __( 'Either use an existing menu, built in Appearance -> Menus or create a simple custom menu here', 'avia_framework' ),
'id' => 'which_menu',
'type' => 'select',
'std' => 'center',
'subtype' => array(
__( 'Use existing menu', 'avia_framework' ) => '',
__( 'Build simple custom menu', 'avia_framework' ) => 'custom',
)
),
array(
'name' => __( 'Select menu to display', 'avia_framework' ),
'desc' => __( 'You can create new menus in ', 'avia_framework' ) . "" . __( 'Appearance -> Menus', 'avia_framework' ) . '
' . __( 'Please note that Mega Menus are not supported for this element ', 'avia_framework' ),
'id' => 'menu',
'type' => 'select',
'std' => '',
'required' => array( 'which_menu', 'not', 'custom' ),
'subtype' => $menus
),
array(
'name' => __( 'Add/Edit submenu item text', 'avia_framework' ),
'desc' => __( 'Here you can add, remove and edit the submenu item text', 'avia_framework' ),
'type' => 'modal_group',
'id' => 'content',
'required' => array( 'which_menu', 'equals', 'custom' ),
'modal_title' => __( 'Edit Text Element', 'avia_framework' ),
'std' => array(
array( 'title' => __( 'Menu Item 1', 'avia_framework' ) ),
array( 'title' => __( 'Menu Item 2', 'avia_framework' ) ),
),
'subelements' => $this->create_modal()
),
array(
'name' => __( 'Menu Position', 'avia_framework' ),
'desc' => __( 'Aligns the menu either to the left, the right or centers it', 'avia_framework' ),
'id' => 'position',
'type' => 'select',
'std' => 'center',
'subtype' => array(
__( 'Left', 'avia_framework' ) => 'left',
__( 'Center', 'avia_framework' ) => 'center',
__( 'Right', 'avia_framework' ) => 'right',
)
),
array(
'name' => __( 'Sticky Submenu', 'avia_framework' ),
'desc' => __( 'If checked the menu will stick at the top of the page once it touches it. This option is ignored when burger menu icon is shown.', 'avia_framework' ),
'id' => 'sticky',
'std' => 'true',
'type' => 'checkbox'
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'content_menus' ), $c );
/**
* Styling Tab
* ===========
*/
$desc = __('The menu will use the color scheme you select. Color schemes are defined on your styling page', 'avia_framework' );
$desc .= '
';
$desc .= __( '(Show Styling Page)', 'avia_framework' ) . '';
$c = array(
array(
'name' => __( 'Menu Colors', 'avia_framework' ),
'id' => 'color',
'desc' => $desc,
'type' => 'select',
'std' => 'main_color',
'subtype' => array_flip( $avia_config['color_sets'] )
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $c );
/**
* Advanced Tab
* ============
*/
$c = array(
array(
'name' => __( 'Mobile Menu Display','avia_framework' ),
'desc' => __( 'How do you want to display the menu on mobile devices','avia_framework' ),
'id' => 'mobile',
'type' => 'select',
'std' => 'disabled',
'subtype' => array(
__( 'Display full menu (works best if you only got a few menu items)', 'avia_framework' ) => 'disabled',
__( 'Display a button to open menu (works best for menus with a lot of menu items)', 'avia_framework' ) => 'active',
)
),
array(
'name' => __( 'Screenwidth for burger menu button', 'avia_framework' ),
'desc' => __( 'Select the maximum screenwidth to use a burger menu button instead of full menu. Above that the full menu is displayed', 'avia_framework' ),
'id' => 'mobile_switch',
'type' => 'select',
'std' => 'av-switch-768',
'required' => array( 'mobile', 'equals', 'active' ),
'subtype' => array(
__( 'Switch at 990px (tablet landscape)','avia_framework' ) => 'av-switch-990',
__( 'Switch at 768px (tablet portrait)','avia_framework' ) => 'av-switch-768',
__( 'Switch at 480px (smartphone portrait)','avia_framework' ) => 'av-switch-480',
)
),
array(
'name' => __( 'Hide Mobile Menu Submenu Items', 'avia_framework'),
'desc' => __( 'By default all menu items of the mobile menu are visible. If you activate this option they will be hidden and a user needs to click on the parent menu item to display the submenus', 'avia_framework'),
'id' => 'mobile_submenu',
'required' => array( 'mobile', 'equals', 'active' ),
'type' => 'checkbox',
'std' => ''
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_responsive' ), $c );
}
/**
* Creates the modal popup for a single entry
*
* @since 4.6.4
* @return array
*/
protected function create_modal()
{
$elements = array(
array(
'type' => 'tab_container',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Content', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'modal_content_menu' )
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Styling', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'modal_styling_style' )
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab',
'name' => __( 'Advanced', 'avia_framework' ),
'nodescription' => true
),
array(
'type' => 'template',
'template_id' => $this->popup_key( 'modal_advanced_link' )
),
array(
'type' => 'tab_close',
'nodescription' => true
),
array(
'type' => 'tab_container_close',
'nodescription' => true
)
);
return $elements;
}
/**
* Register all templates for the modal group popup
*
* @since 4.6.4
*/
protected function register_modal_group_templates()
{
/**
* Content Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Menu Text', 'avia_framework' ),
'desc' => __( 'Enter the menu text here', 'avia_framework' ) ,
'id' => 'title',
'std' => '',
'type' => 'input'
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_content_menu' ), $c );
/**
* Styling Tab
* ===========
*/
$c = array(
array(
'name' => __( 'Style', 'avia_framework' ),
'desc' => __( 'Select the styling of your menu item', 'avia_framework' ),
'id' => 'button_style',
'type' => 'select',
'std' => '',
'subtype' => array(
__( 'Default Style', 'avia_framework' ) => '',
__( 'Button Style (Colored)', 'avia_framework' ) => 'av-menu-button av-menu-button-colored',
__( 'Button Style (Bordered)', 'avia_framework' ) => 'av-menu-button av-menu-button-bordered',
),
)
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_styling_style' ), $c );
/**
* Advanced Tab
* ===========
*/
$c = array(
array(
'type' => 'template',
'template_id' => 'linkpicker_toggle',
'name' => __( 'Menu Link?', 'avia_framework' ),
'desc' => __( 'Apply a link to the menu text?', 'avia_framework' ),
'subtypes' => array( 'manually', 'single', 'taxonomy' ),
'no_toggle' => true
),
);
AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'modal_advanced_link' ), $c );
}
/**
* Editor Sub Element - this function defines the visual appearance of an element that is displayed within a modal window and on click opens its own modal window
* Works in the same way as Editor Element
* @param array $params this array holds the default values for $content and $args.
* @return $params the return array usually holds an innerHtml key that holds item specific markup.
*/
function editor_sub_element( $params )
{
$template = $this->update_template( 'title', '{{title}}' );
$params['innerHtml'] = '';
$params['innerHtml'] .= "