Advertisement
Guenni007

section

Mar 29th, 2021 (edited)
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 52.05 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Color Section
  4.  *
  5.  * Shortcode creates a section with unique background image and colors for better content sepearation
  6.  */
  7.  
  8.  // Don't load directly
  9. if ( ! defined('ABSPATH') ) { die('-1'); }
  10.  
  11.  
  12.  
  13. if ( ! class_exists( 'avia_sc_section' ) )
  14. {
  15.     class avia_sc_section extends aviaShortcodeTemplate
  16.     {
  17.  
  18.         static $section_count = 0;
  19.         static $add_to_closing = '';
  20.         static $close_overlay = '';
  21.  
  22.  
  23.         /**
  24.          * Create the config array for the shortcode button
  25.          */
  26.         function shortcode_insert_button()
  27.         {
  28.             $this->config['version']        = '1.0';
  29.             $this->config['is_fullwidth']   = 'yes';
  30.             $this->config['type']           = 'layout';
  31.             $this->config['self_closing']   = 'no';
  32.             $this->config['contains_text']  = 'no';
  33.             $this->config['base_element']   = 'yes';
  34.  
  35.             $this->config['name']           = __( 'Color Section', 'avia_framework' );
  36.             $this->config['icon']           = AviaBuilder::$path['imagesURL'] . 'sc-section.png';
  37.             $this->config['tab']            = __( 'Layout Elements', 'avia_framework' );
  38.             $this->config['order']          = 20;
  39.             $this->config['shortcode']      = 'av_section';
  40.             $this->config['html_renderer']  = false;
  41.             $this->config['tinyMCE']        = array( 'disable' => 'true' );
  42.             $this->config['tooltip']        = __('Creates a section with unique background image and colors', 'avia_framework' );
  43.             $this->config['drag-level']     = 1;
  44.             $this->config['drop-level']     = 1;
  45.             $this->config['preview']        = false;
  46.  
  47.             $this->config['id_name']        = 'id';
  48.             $this->config['id_show']        = 'always';             //  we use original code - not $meta
  49.             $this->config['aria_label']     = 'yes';
  50.         }
  51.        
  52.         /**
  53.          * Popup Elements
  54.          *
  55.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  56.          * opens a modal window that allows to edit the element properties
  57.          *
  58.          * @return void
  59.          */
  60.         function popup_elements()
  61.         {
  62.             $this->elements = array(
  63.                
  64.                 array(
  65.                         'type'  => 'tab_container',
  66.                         'nodescription' => true
  67.                     ),
  68.                        
  69.                 array(
  70.                         'type'  => 'tab',
  71.                         'name'  => __( 'Layout' , 'avia_framework' ),
  72.                         'nodescription' => true
  73.                     ),
  74.                
  75.                     array(
  76.                             'type'          => 'template',
  77.                             'template_id'   => 'toggle_container',
  78.                             'templates_include' => array(
  79.                                                     $this->popup_key( 'layout_section_height' ),
  80.                                                     $this->popup_key( 'layout_margin_padding' )
  81.                                                 ),
  82.                             'nodescription' => true
  83.                         ),
  84.                
  85.                 array(
  86.                         'type'  => 'tab_close',
  87.                         'nodescription' => true
  88.                     ),
  89.                
  90.                 array(
  91.                         'type'  => 'tab',
  92.                         'name'  => __( 'Styling', 'avia_framework' ),
  93.                         'nodescription' => true
  94.                     ),
  95.                
  96.                     array(
  97.                             'type'          => 'template',
  98.                             'template_id'   => 'toggle_container',
  99.                             'templates_include' => array(
  100.                                                     $this->popup_key( 'styling_background_colors' ),
  101.                                                     $this->popup_key( 'styling_background_image' ),
  102.                                                     $this->popup_key( 'styling_background_video' ),
  103.                                                     $this->popup_key( 'styling_background_overlay' ),
  104.                                                     $this->popup_key( 'styling_section_dividers' ),
  105.                                                     $this->popup_key( 'styling_borders' ),
  106.                                                     $this->popup_key( 'styling_arrow' )
  107.                                                 ),
  108.                             'nodescription' => true
  109.                         ),
  110.                
  111.                 array(
  112.                         'type'  => 'tab_close',
  113.                         'nodescription' => true
  114.                     ),
  115.                
  116.                 array(
  117.                         'type'  => 'tab',
  118.                         'name'  => __( 'Advanced', 'avia_framework' ),
  119.                         'nodescription' => true
  120.                     ),
  121.                
  122.                     array(
  123.                             'type'  => 'toggle_container',
  124.                             'nodescription' => true
  125.                         ),
  126.                
  127.                         array( 
  128.                                 'type'          => 'template',
  129.                                 'template_id'   => 'screen_options_toggle',
  130.                                 'lockable'      => true
  131.                             ),
  132.                
  133.                         array( 
  134.                                 'type'          => 'template',
  135.                                 'template_id'   => 'developer_options_toggle',
  136.                                 'args'          => array( 'sc' => $this )
  137.                             ),
  138.                
  139.                     array(
  140.                             'type'  => 'toggle_container_close',
  141.                             'nodescription' => true
  142.                         ),
  143.                
  144.                 array(
  145.                         'type'  => 'tab_close',
  146.                         'nodescription' => true
  147.                     ),
  148.                
  149.                 array( 
  150.                         'type'          => 'template',
  151.                         'template_id'   => 'element_template_selection_tab',
  152.                         'args'          => array( 'sc' => $this )
  153.                     ),
  154.  
  155.                 array(
  156.                         'type'  => 'tab_container_close',
  157.                         'nodescription' => true
  158.                     ),
  159.                
  160.                
  161.                
  162.                 array( 
  163.                         'id'    => 'av_element_hidden_in_editor',
  164.                         'type'  => 'hidden',
  165.                         'std'   => '0'
  166.                     ),
  167.                 );
  168.            
  169.         }
  170.        
  171.         /**
  172.          * Create and register templates for easier maintainance
  173.          *
  174.          * @since 4.6.4
  175.          */
  176.         protected function register_dynamic_templates()
  177.         {
  178.             global $avia_config;
  179.            
  180.             /**
  181.              * Layout Tab
  182.              * ===========
  183.              */
  184.            
  185.             $c = array(
  186.                         array(
  187.                             'name'  => __( 'Section Minimum Height','avia_framework' ),
  188.                             'id'    => 'min_height',
  189.                             'desc'  => __( 'Define a minimum height for the section. Content within the section will be centered vertically within the section', 'avia_framework' ),
  190.                             'type'  => 'select',
  191.                             'std'   => '',
  192.                             'lockable'  => true,
  193.                             'subtype'   => array(  
  194.                                             __( 'No minimum height, use content within section to define Section height', 'avia_framework' )    => '',
  195.                                             __( 'At least 100&percnt; of Browser Window height', 'avia_framework' )                 => '100',
  196.                                             __( 'At least 75&percnt; of Browser Window height', 'avia_framework' )                  => '75',
  197.                                             __( 'At least 50&percnt; of Browser Window height', 'avia_framework' )                  => '50',
  198.                                             __( 'At least 25&percnt; of Browser Window height', 'avia_framework' )                  => '25',
  199.                                             __( 'Custom height in &percnt; based on browser windows height', 'avia_framework' )     => 'percent',
  200.                                             __( 'Custom height in pixel', 'avia_framework' )                                        => 'custom',
  201.                                         )
  202.                         ),
  203.                                            
  204.                         array( 
  205.                             'name'  => __( 'Section minimum custom height in &percnt;', 'avia_framework' ),
  206.                             'desc'  => __( 'Define a minimum height for the section in &percnt; based on the browser windows height', 'avia_framework' ),
  207.                             'id'    => 'min_height_pc',
  208.                             'type'  => 'select',
  209.                             'std'   => '25',
  210.                             'lockable'  => true,
  211.                             'required'  => array( 'min_height', 'equals', 'percent' ),
  212.                             'subtype'   => AviaHtmlHelper::number_array( 1, 99, 1 )
  213.                         ),
  214.                                                
  215.                         array( 
  216.                             'name'  => __( 'Section custom height', 'avia_framework' ),
  217.                             'desc'  => __( 'Define a minimum height for the section. Use a pixel value. eg: 500px', 'avia_framework' ) ,
  218.                             'id'    => 'min_height_px',
  219.                             'type'  => 'input',
  220.                             'std'   => '500px',
  221.                             'lockable'  => true,
  222.                             'required'  => array( 'min_height', 'equals', 'custom' ),
  223.                         )              
  224.                 );
  225.            
  226.             $template = array(
  227.                             array( 
  228.                                 'type'          => 'template',
  229.                                 'template_id'   => 'toggle',
  230.                                 'title'         => __( 'Section Height', 'avia_framework' ),
  231.                                 'content'       => $c
  232.                             ),
  233.                     );
  234.            
  235.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_section_height' ), $template );
  236.  
  237.            
  238.             $c = array(
  239.                         array(
  240.                             'name'  => __( 'Section Padding', 'avia_framework' ),
  241.                             'id'    => 'padding',
  242.                             'desc'  => __( 'Define the sections top and bottom padding', 'avia_framework' ),
  243.                             'type'  => 'select',
  244.                             'std'   => 'default',
  245.                             'lockable'  => true,
  246.                             'subtype'   => array(  
  247.                                             __( 'No Padding', 'avia_framework' )        => 'no-padding',
  248.                                             __( 'Small Padding', 'avia_framework' )     => 'small',
  249.                                             __( 'Default Padding', 'avia_framework' )   => 'default',
  250.                                             __( 'Large Padding', 'avia_framework' )     => 'large',
  251.                                             __( 'Huge Padding', 'avia_framework' )      => 'huge',
  252.                                         )
  253.                         ),
  254.                                                    
  255.                         array(
  256.                             'name'  => __( 'Custom top and bottom margin', 'avia_framework' ),
  257.                             'desc'  => __( 'If checked allows you to set a custom top and bottom margin. Otherwise the margin is calculated by the theme based on surrounding elements', 'avia_framework' ),
  258.                             'id'    => 'margin',
  259.                             'type'  => 'checkbox',
  260.                             'std'   => '',
  261.                             'lockable'  => true,
  262.                         ),
  263.                                
  264.                         array(
  265.                             'name'  => __( 'Custom top and bottom margin', 'avia_framework' ),
  266.                             'desc'  => __( 'Set a custom top or bottom margin. Both pixel and &percnt; based values are accepted. eg: 30px, 5&percnt;', 'avia_framework' ),
  267.                             'id'    => 'custom_margin',
  268.                             'type'  => 'multi_input',
  269.                             'sync'  => true,                           
  270.                             'std'   => '0px',                          
  271.                             'lockable'  => true,
  272.                             'required' => array( 'margin', 'not','' ),
  273.                             'multi'     => array(
  274.                                                 'top'       => __( 'Margin-Top', 'avia_framework' ),
  275.                                                 'bottom'    => __( 'Margin-Bottom', 'avia_framework' ),
  276.                                             )
  277.                         )
  278.                                    
  279.                 );
  280.            
  281.             $template = array(
  282.                             array( 
  283.                                 'type'          => 'template',
  284.                                 'template_id'   => 'toggle',
  285.                                 'title'         => __( 'Margin and Padding', 'avia_framework' ),
  286.                                 'content'       => $c
  287.                             ),
  288.                     );
  289.            
  290.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_margin_padding' ), $template );
  291.            
  292.             /**
  293.              * Styling Tab
  294.              * ===========
  295.              */
  296.            
  297.             $c = array(
  298.                         array(
  299.                             'name'  => __( 'Section Colors', 'avia_framework' ),
  300.                             'desc'  => __( 'The section will use the color scheme you select. Color schemes are defined on your styling page', 'avia_framework' ) .
  301.                                        '<br/><a target="_blank" href="' . admin_url( 'admin.php?page=avia#goto_styling' ) . '">' . __( '(Show Styling Page)', 'avia_framework' ) . '</a>',
  302.                             'id'    => 'color',
  303.                             'type'  => 'select',
  304.                             'std'   => 'main_color',
  305.                             'lockable'  => true,
  306.                             'subtype'   =>  array_flip( $avia_config['color_sets'] )
  307.                         ),
  308.                                
  309.                         array(
  310.                             'name'  => __( 'Background', 'avia_framework' ),
  311.                             'desc'  => __( 'Select the type of background for the column.', 'avia_framework' ),
  312.                             'id'    => 'background',
  313.                             'type'  => 'select',
  314.                             'std'   => 'bg_color',
  315.                             'lockable'  => true,
  316.                             'subtype'   => array(
  317.                                                 __( 'Background Color', 'avia_framework' )      => 'bg_color',
  318.                                                 __( 'Background Gradient', 'avia_framework' )   => 'bg_gradient',
  319.                                             )
  320.                         ),
  321.                                
  322.                         array(
  323.                             'name'  => __( 'Custom Background Color', 'avia_framework' ),
  324.                             'desc'  => __( 'Select a custom background color for this cell here. Leave empty for default color', 'avia_framework' ),
  325.                             'id'    => 'custom_bg',
  326.                             'type'  => 'colorpicker',
  327.                             'rgba'  => true,
  328.                             'std'   => '',
  329.                             'lockable'  => true,
  330.                             'required'  => array( 'background', 'equals', 'bg_color' )
  331.                         ),
  332.                                
  333.                         array(
  334.                             'name'  => __( 'Background Gradient Color 1', 'avia_framework' ),
  335.                             'desc'  => __( 'Select the first color for the gradient.', 'avia_framework' ),
  336.                             'id'    => 'background_gradient_color1',
  337.                             'type'  => 'colorpicker',
  338.                             'rgba'  => true,
  339.                             'std'   => '',
  340.                             'container_class' => 'av_third av_third_first',
  341.                             'lockable'  => true,
  342.                             'required'  => array( 'background', 'equals', 'bg_gradient' )
  343.                         ),
  344.                
  345.                         array(
  346.                             'name'  => __( 'Background Gradient Color 2', 'avia_framework' ),
  347.                             'desc'  => __( 'Select the second color for the gradient.', 'avia_framework' ),
  348.                             'id'    => 'background_gradient_color2',
  349.                             'type'  => 'colorpicker',
  350.                             'rgba'  => true,
  351.                             'std'   => '',
  352.                             'container_class' => 'av_third',
  353.                             'lockable'  => true,
  354.                             'required' => array( 'background', 'equals', 'bg_gradient' )
  355.                         ),
  356.                                
  357.                         array(
  358.                             'name'  => __( 'Background Gradient Direction','avia_framework' ),
  359.                             'desc'  => __( 'Define the gradient direction', 'avia_framework' ),
  360.                             'id'    => 'background_gradient_direction',
  361.                             'type'  => 'select',
  362.                             'std'   => 'vertical',
  363.                             'container_class' => 'av_third',
  364.                             'lockable'  => true,
  365.                             'required'  => array( 'background', 'equals', 'bg_gradient' ),
  366.                             'subtype'   => array(
  367.                                                 __( 'Vertical', 'avia_framework' )      => 'vertical',
  368.                                                 __( 'Horizontal', 'avia_framework' )    => 'horizontal',
  369.                                                 __( 'Radial', 'avia_framework' )        => 'radial',
  370.                                                 __( 'Diagonal Top Left to Bottom Right', 'avia_framework' ) => 'diagonal_tb',
  371.                                                 __( 'Diagonal Bottom Left to Top Right', 'avia_framework' ) => 'diagonal_bt',
  372.                                             )
  373.                         )
  374.                
  375.                 );
  376.            
  377.             $template = array(
  378.                             array( 
  379.                                 'type'          => 'template',
  380.                                 'template_id'   => 'toggle',
  381.                                 'title'         => __( 'Background Colors', 'avia_framework' ),
  382.                                 'content'       => $c
  383.                             ),
  384.                     );
  385.            
  386.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background_colors' ), $template );
  387.            
  388.             $c = array(
  389.                         array(
  390.                             'name'      => __( 'Custom Background Image', 'avia_framework' ),
  391.                             'desc'      => __( 'Either upload a new, or choose an existing image from your media library. Leave empty if you want to use the background image of the color scheme defined above', 'avia_framework' ),
  392.                             'id'        => 'src',
  393.                             'type'      => 'image',
  394.                             'title'     => __( 'Insert Image', 'avia_framework' ),
  395.                             'button'    => __( 'Insert', 'avia_framework' ),
  396.                             'std'       => '',
  397.                             'lockable'  => true,
  398.                             'locked'    => array( 'src', 'attachment', 'attachment_size' )
  399.                         ),
  400.                                    
  401.                         array(
  402.                             'name'  => __( 'Background Attachment', 'avia_framework' ),
  403.                             'desc'  => __( 'Background can either scroll with the page, be fixed or scroll with a parallax motion', 'avia_framework' ),
  404.                             'id'    => 'attach',
  405.                             'type'  => 'select',
  406.                             'std'   => 'scroll',
  407.                             'lockable'  => true,
  408.                             'required'  => array( 'src', 'not', '' ),
  409.                             'subtype'   => array(
  410.                                             __( 'Scroll', 'avia_framework' )    => 'scroll',
  411.                                             __( 'Fixed', 'avia_framework' )     => 'fixed',
  412.                                             __( 'Parallax', 'avia_framework' )  => 'parallax'
  413.                                         )
  414.                         ),
  415.                
  416.                         array(
  417.                             'type'          => 'template',
  418.                             'template_id'   => 'background_image_position',
  419.                             'args'          => array(
  420.                                                     'id_pos'        => 'position',
  421.                                                     'id_repeat'     => 'repeat'
  422.                                                 ),
  423.                             'lockable'      => true
  424.                         )              
  425.                 );
  426.            
  427.             $template = array(
  428.                             array( 
  429.                                 'type'          => 'template',
  430.                                 'template_id'   => 'toggle',
  431.                                 'title'         => __( 'Background Image', 'avia_framework' ),
  432.                                 'content'       => $c
  433.                             ),
  434.                     );
  435.            
  436.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background_image' ), $template );
  437.  
  438.            
  439.             $c = array(
  440.                         array( 
  441.                             'name'  => __( 'Background Video', 'avia_framework' ),
  442.                             'desc'  => __( 'You can also place a video as background for your section. Enter the URL to the Video. Currently supported are Youtube, Vimeo and direct linking of web-video files (mp4, webm, ogv)', 'avia_framework' ) . '<br/><br/>' .
  443.                                 __( 'Working examples Youtube & Vimeo:', 'avia_framework' ) . '<br/>
  444.                                 <strong>http://vimeo.com/1084537</strong><br/>
  445.                                 <strong>http://www.youtube.com/watch?v=5guMumPFBag</strong><br/><br/>',
  446.                             'id'    => 'video',
  447.                             'type'  => 'input',
  448.                             'std'   => '',
  449.                             'lockable'  => true
  450.                         ),
  451.                                                    
  452.                         array( 
  453.                             'name'  => __( 'Video Aspect Ratio', 'avia_framework' ),
  454.                             'desc'  => __( 'In order to calculate the correct height and width for the video slide you need to enter a aspect ratio (width:height). usually: 16:9 or 4:3.', 'avia_framework' ) . '<br/>' . __( 'If left empty 16:9 will be used', 'avia_framework' ) ,
  455.                             'id'    => 'video_ratio',
  456.                             'type'  => 'input',
  457.                             'std'   => '16:9',
  458.                             'lockable'  => true,
  459.                             'required'  => array( 'video', 'not', '' ),
  460.                         ),
  461.                                                
  462.                         array( 
  463.                             'name'  => __( 'Hide video on Mobile Devices?', 'avia_framework' ),
  464.                             'desc'  => __( 'You can choose to hide the video entirely on Mobile devices and instead display the Section Background image', 'avia_framework' ) . '<br/><small>' . __( "Most mobile devices can't autoplay videos to prevent bandwidth problems for the user", 'avia_framework' ) . '</small>' ,
  465.                             'id'    => 'video_mobile_disabled',
  466.                             'type'  => 'checkbox',
  467.                             'std'   => '',
  468.                             'lockable'  => true,
  469.                             'required'  => array( 'video', 'not', '' ),
  470.                         )
  471.                 );
  472.            
  473.             $template = array(
  474.                             array( 
  475.                                 'type'          => 'template',
  476.                                 'template_id'   => 'toggle',
  477.                                 'title'         => __( 'Background Video', 'avia_framework' ),
  478.                                 'content'       => $c
  479.                             ),
  480.                     );
  481.            
  482.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background_video' ), $template );
  483.            
  484.             $c = array(
  485.                         array( 
  486.                             'name'  => __( 'Enable Overlay?', 'avia_framework' ),
  487.                             'desc'  => __( 'Check if you want to display a transparent color and/or pattern overlay above your section background image/video', 'avia_framework' ),
  488.                             'id'    => 'overlay_enable',
  489.                             'type'  => 'checkbox',
  490.                             'std'   => '',
  491.                             'lockable'  => true,
  492.                         ),
  493.                                            
  494.                         array(
  495.                             'name'  => __( 'Overlay Opacity', 'avia_framework' ),
  496.                             'desc'  => __( 'Set the opacity of your overlay: 0.1 is barely visible, 1.0 is opaque ', 'avia_framework' ),
  497.                             'id'    => 'overlay_opacity',
  498.                             'type'  => 'select',
  499.                             'std'   => '0.5',
  500.                             'lockable'  => true,
  501.                             'required'  => array( 'overlay_enable', 'not', '' ),
  502.                             'subtype'   => array(  
  503.                                             __( '0.1', 'avia_framework' )   => '0.1',
  504.                                             __( '0.2', 'avia_framework' )   => '0.2',
  505.                                             __( '0.3', 'avia_framework' )   => '0.3',
  506.                                             __( '0.4', 'avia_framework' )   => '0.4',
  507.                                             __( '0.5', 'avia_framework' )   => '0.5',
  508.                                             __( '0.6', 'avia_framework' )   => '0.6',
  509.                                             __( '0.7', 'avia_framework' )   => '0.7',
  510.                                             __( '0.8', 'avia_framework' )   => '0.8',
  511.                                             __( '0.9', 'avia_framework' )   => '0.9',
  512.                                             __( '1.0', 'avia_framework' )   => '1',
  513.                                         )
  514.                         ),
  515.                                                
  516.                         array(
  517.                             'name'  => __( 'Overlay Color', 'avia_framework' ),
  518.                             'desc'  => __( 'Select a custom color for your overlay here. Leave empty if you want no color overlay', 'avia_framework' ),
  519.                             'id'    => 'overlay_color',
  520.                             'type'  => 'colorpicker',
  521.                             'std'   => '',
  522.                             'lockable'  => true,
  523.                             'required'  => array( 'overlay_enable', 'not', '' )                        
  524.                         ),
  525.                                            
  526.                         array(
  527.                             'name'      => __( 'Background Image', 'avia_framework' ),
  528.                             'desc'      => __( 'Select an existing or upload a new background image', 'avia_framework' ),
  529.                             'id'        => 'overlay_pattern',
  530.                             'type'      => 'select',
  531.                             'std'       => '',
  532.                             'folder'    => 'images/background-images/',
  533.                             'folderlabel'   => '',
  534.                             'group'     => __( 'Select predefined pattern', 'avia_framework' ),
  535.                             'exclude'   => array( 'fullsize-', 'gradient' ),
  536.                             'lockable'  => true,
  537.                             'required'  => array( 'overlay_enable', 'not', '' ),
  538.                             'subtype'   => array(
  539.                                                 __( 'No Background Image', 'avia_framework' )   => '',
  540.                                                 __( 'Upload custom image', 'avia_framework' )   => 'custom'
  541.                                             )
  542.                         ),
  543.  
  544.                         array(
  545.                             'name'      => __( 'Custom Pattern', 'avia_framework' ),
  546.                             'desc'      => __( 'Upload your own seamless pattern', 'avia_framework' ),
  547.                             'id'        => 'overlay_custom_pattern',
  548.                             'type'      => 'image',
  549.                             'fetch'     => 'url',
  550.                             'secondary_img' => true,
  551.                             'title'     => __( 'Insert Pattern', 'avia_framework' ),
  552.                             'button'    => __( 'Insert', 'avia_framework' ),
  553.                             'std'       => '',
  554.                             'lockable'  => true,
  555.                             'required'  => array( 'overlay_pattern', 'equals', 'custom' )
  556.                         ),
  557.                
  558.                 );
  559.            
  560.             $template = array(
  561.                             array( 
  562.                                 'type'          => 'template',
  563.                                 'template_id'   => 'toggle',
  564.                                 'title'         => __( 'Background Overlay', 'avia_framework' ),
  565.                                 'content'       => $c
  566.                             ),
  567.                     );
  568.            
  569.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background_overlay' ), $template );
  570.  
  571.  
  572. // here comes the new divider project
  573.  
  574.             $c = array(
  575.                         array(
  576.                             'name'      => __( 'Top Divider', 'avia_framework' ),
  577.                             'desc'      => __( 'Insert a Divider on top of the color-section', 'avia_framework' ),
  578.                             'id'        => 'divider_on_top',
  579.                             'type'      => 'image',
  580.                             'fetch'     => 'url',
  581.                             'secondary_img' => true,
  582.                             'title'     => __( 'Insert Divider', 'avia_framework' ),
  583.                             'button'    => __( 'Insert', 'avia_framework' ),
  584.                             'std'       => '',
  585.                             'lockable'  => true
  586.                         ),
  587.  
  588.  
  589.                         array(
  590.                             'name'  => __( 'Top Divider Layer Position', 'avia_framework' ),
  591.                             'desc'  => __( 'Layer Position of the inserted svg', 'avia_framework' ),
  592.                             'id'    => 'divider_on_top_layer',
  593.                             'type'  => 'select',
  594.                             'std'   => 'front',
  595.                             'lockable'  => true,
  596.                             'required'  => array( 'divider_on_top', 'not', '' ),
  597.                             'subtype'   => array(
  598.                                             __( 'infront', 'avia_framework' )    => 'front',
  599.                                             __( 'behind', 'avia_framework' ) => 'behind'
  600.                                         )
  601.                         ),
  602.  
  603.                        
  604.  
  605.                         array(
  606.                             'name'      => __( 'Bottom Divider', 'avia_framework' ),
  607.                             'desc'      => __( 'Insert a Divider on bottom of the color-section', 'avia_framework' ),
  608.                             'id'        => 'divider_on_bottom',
  609.                             'type'      => 'image',
  610.                             'fetch'     => 'url',
  611.                             'secondary_img' => true,
  612.                             'title'     => __( 'Insert Divider', 'avia_framework' ),
  613.                             'button'    => __( 'Insert', 'avia_framework' ),
  614.                             'std'       => '',
  615.                             'lockable'  => true
  616.                         ),
  617.  
  618.                         array(
  619.                             'name'  => __( 'Bottom Divider Layer Position', 'avia_framework' ),
  620.                             'desc'  => __( 'Layer Position of the inserted svg', 'avia_framework' ),
  621.                             'id'    => 'divider_on_bottom_layer',
  622.                             'type'  => 'select',
  623.                             'std'   => 'front',
  624.                             'lockable'  => true,
  625.                             'required'  => array( 'divider_on_bottom', 'not', '' ),
  626.                             'subtype'   => array(
  627.                                             __( 'infront', 'avia_framework' )    => 'front',
  628.                                             __( 'behind', 'avia_framework' ) => 'behind'
  629.                                         )
  630.                         ),                     
  631.                 );
  632.  
  633.             $template = array(
  634.                             array( 
  635.                                 'type'          => 'template',
  636.                                 'template_id'   => 'toggle',
  637.                                 'title'         => __( 'Divider Image', 'avia_framework' ),
  638.                                 'content'       => $c
  639.                             ),
  640.                     );
  641.  
  642.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_section_dividers' ), $template );
  643.  
  644. // end of the arrays
  645.  
  646.            
  647.             $c = array(
  648.                         array(
  649.                             'name'  => __( 'Section Top Border Styling', 'avia_framework' ),
  650.                             'desc'  => __( 'Choose a border styling for the top of your section', 'avia_framework' ),
  651.                             'id'    => 'shadow',
  652.                             'type'  => 'select',
  653.                             'std'   => 'no-border-styling',
  654.                             'lockable'  => true,
  655.                             'subtype'   => array(
  656.                                             __( 'Display a simple 1px top border', 'avia_framework' )   => 'no-shadow',  
  657.                                             __( 'Display a small styling shadow at the top of the section', 'avia_framework' )  => 'shadow',
  658.                                             __( 'No border styling', 'avia_framework' ) => 'no-border-styling',
  659.                                         )
  660.                         ),
  661.  
  662.                         array(
  663.                             'name'  => __( 'Section Bottom Border Styling', 'avia_framework' ),
  664.                             'desc'  => __( 'Choose a border styling for the bottom of your section', 'avia_framework' ),
  665.                             'id'    => 'bottom_border',
  666.                             'type'  => 'select',
  667.                             'std'   => 'no-border-styling',
  668.                             'lockable'  => true,
  669.                             'subtype'   => array(  
  670.                                             __( 'No border styling', 'avia_framework' ) => 'no-border-styling',
  671.                                             __( 'Display a small arrow that points down to the next section', 'avia_framework' )    => 'border-extra-arrow-down',
  672.                                             __( 'Diagonal section border', 'avia_framework' )   => 'border-extra-diagonal',
  673.                                         )
  674.                         ),
  675.  
  676.                         array(
  677.                             'name'      => __( 'Diagonal Border: Color', 'avia_framework' ),
  678.                             'desc'      => __( 'Select a custom background color for your Section border here.', 'avia_framework' ),
  679.                             'id'        => 'bottom_border_diagonal_color',
  680.                             'type'      => 'colorpicker',
  681.                             'std'       => '#333333',
  682.                             'container_class'   => 'av_third av_third_first',
  683.                             'lockable'  => true,
  684.                             'required'  => array( 'bottom_border', 'contains', 'diagonal' )
  685.                         ),
  686.                                            
  687.                         array(
  688.                             'name'  => __( 'Diagonal Border: Direction','avia_framework' ),
  689.                             'desc'  => __( 'Set the direction of the diagonal border', 'avia_framework' ),
  690.                             'id'    => 'bottom_border_diagonal_direction',
  691.                             'type'  => 'select',
  692.                             'std'   => '',
  693.                             'container_class'   => 'av_third',
  694.                             'lockable'  => true,
  695.                             'required'  => array( 'bottom_border', 'contains', 'diagonal' ),
  696.                             'subtype'   => array(
  697.                                             __( 'Slanting from left to right', 'avia_framework' )   => '',
  698.                                             __( 'Slanting from right to left', 'avia_framework' )   => 'border-extra-diagonal-inverse'
  699.                                         )
  700.                         ),
  701.  
  702.                         array(
  703.                             'name'  => __( 'Diagonal Border Box Style', 'avia_framework' ),
  704.                             'desc'  => __( 'Set the style shadow of the border', 'avia_framework' ),
  705.                             'id'    => 'bottom_border_style',
  706.                             'type'  => 'select',
  707.                             'std'   => '',
  708.                             'container_class'   => 'av_third',
  709.                             'lockable'  => true,
  710.                             'required'  => array( 'bottom_border', 'contains', 'diagonal' ),
  711.                             'subtype'   => array(
  712.                                             __( 'Minimal', 'avia_framework' )       => '',
  713.                                             __( 'Box shadow', 'avia_framework' )    => 'diagonal-box-shadow'
  714.                                         )
  715.                         )
  716.                
  717.                 );
  718.            
  719.             $template = array(
  720.                             array( 
  721.                                 'type'          => 'template',
  722.                                 'template_id'   => 'toggle',
  723.                                 'title'         => __( 'Borders', 'avia_framework' ),
  724.                                 'content'       => $c
  725.                             ),
  726.                     );
  727.            
  728.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_borders' ), $template );
  729.            
  730.             $c = array(
  731.                         array(
  732.                             'name'  => __( 'Display a scroll down arrow', 'avia_framework' ),
  733.                             'desc'  => __( 'Check if you want to show a button at the bottom of the section that takes the user to the next section by scrolling down', 'avia_framework' ) ,
  734.                             'id'    => 'scroll_down',
  735.                             'type'  => 'checkbox',
  736.                             'std'   => '',
  737.                             'lockable'  => true
  738.                         ),
  739.  
  740.                         array(
  741.                             'name'  => __( 'Custom Arrow Color', 'avia_framework' ),
  742.                             'desc'  => __( 'Select a custom arrow color. Leave empty if you want to use the default arrow color and style', 'avia_framework' ),
  743.                             'id'    => 'custom_arrow_bg',
  744.                             'type'  => 'colorpicker',
  745.                             'std'   => '',
  746.                             'lockable'  => true,
  747.                             'required'  => array( 'scroll_down', 'not', '' ),
  748.                         )      
  749.                 );
  750.            
  751.             $template = array(
  752.                             array( 
  753.                                 'type'          => 'template',
  754.                                 'template_id'   => 'toggle',
  755.                                 'title'         => __( 'Scroll Down Arrow', 'avia_framework' ),
  756.                                 'content'       => $c
  757.                             ),
  758.                     );
  759.            
  760.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_arrow' ), $template );
  761.            
  762.         }
  763.  
  764.  
  765.         /**
  766.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  767.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  768.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  769.          *
  770.          *
  771.          * @param array $params this array holds the default values for $content and $args.
  772.          * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  773.          */
  774.         function editor_element( $params )
  775.         {
  776.             $default = array();
  777.             $locked = array();
  778.             $attr = $params['args'];
  779.             $content = $params['content'];
  780.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked, $content );
  781.            
  782.             $args = $attr;          //      =>  extract( $params );
  783.             $data = isset( $params['data'] ) && is_array( $params['data'] ) ? $params['data'] : array();
  784.             $data_locked = array();
  785.  
  786.             $extraClass = isset( $args['element_template'] ) && $args['element_template'] > 0 ? ' element_template_selected' : '  no_element_template';
  787.             $name = $this->config['shortcode'];
  788.             $data['shortcodehandler']   = $this->config['shortcode'];
  789.             $data['modal_title']        = $this->config['name'];
  790.             $data['modal_ajax_hook']    = $this->config['shortcode'];
  791.             $data['dragdrop-level']     = $this->config['drag-level'];
  792.             $data['allowed-shortcodes'] = $this->config['shortcode'];
  793.             $data['base_shortcode']     = $this->config['shortcode'];
  794.             $data['element_title']      = $this->config['name'];
  795.             $data['element_tooltip']    = $this->config['tooltip'];
  796.             $data['preview']            = ! empty( $this->config['preview'] ) ? $this->config['preview'] : 0;
  797.  
  798.             $title_id = ! empty( $args['id'] ) ? ': ' . ucfirst( $args['id'] ) : '';
  799.            
  800.             foreach( $locked as $key => $value )
  801.             {
  802.                 $data_locked[ 'locked_' . $key ] = $value;
  803.             }
  804.  
  805.             // add background color or gradient to indicator
  806.             $el_bg = '';
  807.  
  808.             if( empty( $args['background'] ) || ( $args['background'] == 'bg_color' ) )
  809.             {
  810.                 $el_bg = ! empty( $args['custom_bg'] ) ? " background:{$args['custom_bg']};" : '';
  811.             }
  812.             else
  813.             {
  814.                 if( $args['background_gradient_color1'] && $args['background_gradient_color2'] )
  815.                 {
  816.                     $el_bg = "background:linear-gradient({$args['background_gradient_color1']},{$args['background_gradient_color2']});";
  817.                 }
  818.             }
  819.  
  820.             $hidden_el_active = ! empty( $args['av_element_hidden_in_editor'] ) ? 'av-layout-element-closed' : '';
  821.  
  822.             if( ! empty( $this->config['modal_on_load'] ) )
  823.             {
  824.                 $data['modal_on_load']  = $this->config['modal_on_load'];
  825.             }
  826.            
  827.             $data_locked['initial_el_bg'] = $el_bg;
  828.             $data_locked['initial_layout_element_bg'] = $this->get_bg_string( $args );
  829.  
  830.             $dataString = AviaHelper::create_data_string( $data );
  831.             $dataStringLocked = AviaHelper::create_data_string( $data_locked );
  832.  
  833.             $output  = "<div class='avia_layout_section {$hidden_el_active} {$extraClass} avia_pop_class avia-no-visual-updates {$name} av_drag' {$dataString}>";
  834.  
  835.             $output .=      '<div class="avia_data_locked_container" ' . $dataStringLocked . ' data-update_element_template="yes"></div>';
  836.            
  837.             $output .=      "<div class='avia_sorthandle menu-item-handle'>";
  838.             $output .=          "<span class='avia-element-title'>";
  839.             $output .=              "<span class='avia-element-bg-color' style='{$el_bg}'></span>";
  840.             $output .=              $this->config['name'];
  841.             $output .=              "<span class='avia-element-title-id'>{$title_id}</span>";
  842.             $output .=          '</span>';
  843. //          $output .=          "<a class='avia-new-target'  href='#new-target' title='" . __( 'Move Section','avia_framework' ) . "'>+</a>";
  844.             $output .=          "<a class='avia-delete'  href='#delete' title='" . __( 'Delete Section', 'avia_framework' ) . "'>x</a>";
  845.             $output .=          "<a class='avia-toggle-visibility'  href='#toggle' title='" . __( 'Show/Hide Section', 'avia_framework' ) . "'></a>";
  846.  
  847.             if( ! empty( $this->config['popup_editor'] ) )
  848.             {
  849.                 $output .=      "<a class='avia-edit-element'  href='#edit-element' title='" . __( 'Edit Section', 'avia_framework' ) . "'>edit</a>";
  850.             }
  851.            
  852.             $output .=          "<a class='avia-save-element'  href='#save-element' title='" . __( 'Save Element as Template','avia_framework' ) . "'>+</a>";
  853.             $output .= "        <a class='avia-clone'  href='#clone' title='" . __( 'Clone Section', 'avia_framework' ) . "' >" . __( 'Clone Section', 'avia_framework' ) . '</a>';
  854.             $output .=      '</div>';
  855.             $output .=      "<div class='avia_inner_shortcode avia_connect_sort av_drop' data-dragdrop-level='{$this->config['drop-level']}'>";
  856.             $output .=          "<textarea data-name='text-shortcode' cols='20' rows='4'>" . ShortcodeHelper::create_shortcode_by_array( $name, $content, $params['args'] ) . '</textarea>';
  857.            
  858.             if( $content )
  859.             {
  860.                 $content = $this->builder->do_shortcode_backend( $content );
  861.             }
  862.            
  863.             $output .=          $content;
  864.             $output .=      '</div>';
  865.                
  866.             $output .=      "<div class='avia-layout-element-bg' style='{$data_locked['initial_layout_element_bg']}'></div>";
  867.  
  868.             $output .=      "<a class='avia-layout-element-hidden' href='#'>" . __( 'Section content hidden. Click here to show it', 'avia_framework' ) . '</a>';
  869.            
  870.             $output .= '</div>';
  871.  
  872.             return $output;
  873.         }
  874.            
  875.                
  876.         /**
  877.          * Frontend Shortcode Handler
  878.          *
  879.          * @param array $atts array of attributes
  880.          * @param string $content text within enclosing form of shortcode element
  881.          * @param string $shortcodename the shortcode found, when == callback name
  882.          * @return string $output returns the modified html string
  883.          */
  884.         function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  885.         {
  886.             global $avia_config;
  887.            
  888.             $default = array(
  889.                         'src'               => '',
  890.                         'position'          => 'top left',
  891.                         'repeat'            => 'no-repeat',
  892.                         'attach'            => 'scroll',
  893.                         'color'             => 'main_color',
  894.                         'background'        => '',
  895.                         'custom_bg'         => '',
  896.                         'background_gradient_color1'        => '',
  897.                         'background_gradient_color2'        => '',
  898.                         'background_gradient_direction'     => '',
  899.                         'padding'           => 'default' ,
  900.                         'margin'            => '',
  901.                         'custom_margin'     => '',
  902.                         'shadow'            => 'shadow',
  903.                         'id'                => '',
  904.                         'min_height'        => '',
  905.                         'min_height_pc'     => 25,
  906.                         'min_height_px'     => '',
  907.                         'video'             => '',
  908.                         'video_ratio'       =>' 16:9',
  909.                         'video_mobile_disabled'         =>'',
  910.                         'custom_markup'     => '',
  911.                         'attachment'        => '',
  912.                         'attachment_size'   => '',
  913.                         'bottom_border'     => '',
  914.                         'overlay_enable'    => '',
  915.                         'overlay_opacity'   => '',
  916.                         'overlay_color'     => '',
  917.                         'overlay_pattern'   => '',
  918.                         'overlay_custom_pattern' => '',
  919.                         'divider_on_top'    => '',
  920.                         'divider_on_top_layer' => 'front',
  921.                         'divider_on_bottom' => '',
  922.                         'divider_on_bottom_layer' => 'front',
  923.                         'scroll_down'       => '',
  924.                         'bottom_border_diagonal_color'      => '',
  925.                         'bottom_border_diagonal_direction'  => '',
  926.                         'bottom_border_style'               => '',
  927.                         'custom_arrow_bg'                   => ''
  928.                     );
  929.            
  930.             //  we skip $content override as we only allow styling of section to be locked
  931.             $locked = array();
  932.             Avia_Element_Templates()->set_locked_attributes( $atts, $this, $shortcodename, $default, $locked );
  933.             Avia_Element_Templates()->add_template_class( $meta, $atts, $default );
  934.  
  935.             extract( AviaHelper::av_mobile_sizes( $atts ) ); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  936.            
  937.             $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  938.            
  939.             if( 'percent' == $atts['min_height'] )
  940.             {
  941.                 $atts['min_height'] = $atts['min_height_pc'];
  942.             }
  943.            
  944.             extract( $atts );
  945.            
  946.             avia_sc_section::$section_count ++;
  947.                
  948.             $output      = '';
  949.             $class       = "avia-section {$color} avia-section-{$padding} avia-{$shadow} ";
  950.             $background  = '';
  951.             $src         = '';
  952.             $params = array();
  953.  
  954.             $params['id'] = AviaHelper::save_string( $id, '-', 'av_section_' . avia_sc_section::$section_count );
  955.             $params['custom_markup'] = $meta['custom_markup'];
  956.             $params['aria_label'] = $meta['aria_label'];
  957.             $params['attach'] = '';
  958.  
  959.             if( ! empty( $attachment ) && ! empty( $attachment_size ) )
  960.             {
  961.                 /**
  962.                  * Allows e.g. WPML to reroute to translated image
  963.                  */
  964.                 $posts = get_posts( array(
  965.                                         'include'           => $attachment,
  966.                                         'post_status'       => 'inherit',
  967.                                         'post_type'         => 'attachment',
  968.                                         'post_mime_type'    => 'image',
  969.                                         'order'             => 'ASC',
  970.                                         'orderby'           => 'post__in' )
  971.                                     );
  972.  
  973.                 if( is_array( $posts ) && ! empty( $posts ) )
  974.                 {
  975.                     $attachment_entry = $posts[0];
  976.  
  977.                     $src = wp_get_attachment_image_src( $attachment_entry->ID, $attachment_size );
  978.                     $src = !empty($src[0]) ? $src[0] : '';
  979.                 }
  980.             }
  981.             else
  982.             {
  983.                 $attachment = false;
  984.             }
  985.  
  986.  
  987.             // background gradient
  988.             $gradient_val = '';
  989.  
  990.             if( $atts['background'] == 'bg_gradient' )
  991.             {
  992.                 if ( $atts['background_gradient_color1'] && $atts['background_gradient_color2'])
  993.                 {
  994.  
  995.                     switch ( $atts['background_gradient_direction'] )
  996.                     {
  997.                         case 'vertical':
  998.                             $gradient_val .= 'linear-gradient(';
  999.                             break;
  1000.                         case 'horizontal':
  1001.                             $gradient_val .= 'linear-gradient(to right,';
  1002.                             break;
  1003.                         case 'radial':
  1004.                             $gradient_val .= 'radial-gradient(';
  1005.                             break;
  1006.                         case 'diagonal_tb':
  1007.                             $gradient_val .= 'linear-gradient(to bottom right,';
  1008.                             break;
  1009.                         case 'diagonal_bt':
  1010.                             $gradient_val .= 'linear-gradient(45deg,';
  1011.                             break;
  1012.                     }
  1013.  
  1014.                     $gradient_val .= $atts['background_gradient_color1'].','.$atts['background_gradient_color2'].')';
  1015.  
  1016.                     // Fallback background color for IE9
  1017.                     if( $custom_bg == '' )
  1018.                     {
  1019.                         $background .= "background-color: {$atts['background_gradient_color1']};";
  1020.                     }
  1021.                 }
  1022.             }
  1023.  
  1024.                
  1025.             if( $custom_bg != '' )
  1026.             {
  1027.                  $background .= "background-color: {$custom_bg}; ";
  1028.             }
  1029.  
  1030.             /*set background image*/
  1031.             if( $src != '' )
  1032.             {
  1033.                 if( $repeat == 'stretch' )
  1034.                 {
  1035.                     $background .= 'background-repeat: no-repeat; ';
  1036.                     $class .= ' avia-full-stretch';
  1037.                 }
  1038.                 else if( $repeat == 'contain' )
  1039.                 {
  1040.                     $background .= 'background-repeat: no-repeat; ';
  1041.                     $class .= ' avia-full-contain';
  1042.                 }
  1043.                 else
  1044.                 {
  1045.                     $background .= "background-repeat: {$repeat}; ";
  1046.                 }
  1047.  
  1048.                  $background .= "background-image: url({$src})";
  1049.                  if( $gradient_val !== '' )
  1050.                  {
  1051.                      $background .= ", {$gradient_val}";
  1052.                  }
  1053.  
  1054.                  $background .= ';';
  1055.                  $background .= $attach == 'parallax' ? 'background-attachment: scroll; ' : "background-attachment: {$attach}; ";
  1056.                  $background .= "background-position: {$position}; ";
  1057.  
  1058.  
  1059.  
  1060.                 if( $attach == 'parallax' )
  1061.                 {
  1062.                     $attachment_class = '';
  1063.                     if($repeat == 'stretch' || $repeat == 'no-repeat' ){ $attachment_class .= ' avia-full-stretch'; }
  1064.                     if($repeat == 'contain'  ){ $attachment_class .= ' avia-full-contain'; }
  1065.  
  1066.                     $class .= ' av-parallax-section';
  1067.                     $speed = apply_filters( 'avf_parallax_speed', '0.3', $params['id'] );
  1068.                     $params['attach'] .= "<div class='av-parallax' data-avia-parallax-ratio='{$speed}' >";
  1069.                     $params['attach'] .= "<div class='av-parallax-inner {$color} {$attachment_class}' style = '{$background}' >";
  1070.                     $params['attach'] .= '</div>';
  1071.                     $params['attach'] .= '</div>';
  1072.                     $background = '';
  1073.                 }
  1074.  
  1075.  
  1076.                 $params['data'] = "data-section-bg-repeat='{$repeat}'";
  1077.  
  1078.             }
  1079.  
  1080.             else if( ! empty( $gradient_val ) )
  1081.             {
  1082.                 $attach = 'scroll';
  1083.                 if( $gradient_val !== '' )
  1084.                 {
  1085.                     $background .= "background-image: {$gradient_val};";
  1086.                 }
  1087.             }
  1088.  
  1089.                
  1090.             if( $custom_bg != '' && $background == '' )
  1091.             {
  1092.                  $background .= "background-color: {$custom_bg}; ";
  1093.             }
  1094.  
  1095.             /* custom margin */
  1096.             if( ! empty( $atts['margin'] ) )
  1097.             {
  1098.                 $explode_custom_margin = explode( ',', $atts['custom_margin'] );
  1099.                 if( count( $explode_custom_margin ) > 1 )
  1100.                 {
  1101.                     $atts['margin-top'] = $explode_custom_margin['0'];
  1102.                     $atts['margin-bottom'] = $explode_custom_margin['1'];
  1103.                 }
  1104.                 else
  1105.                 {
  1106.                     $atts['margin-top'] = $atts['custom_margin'];
  1107.                     $atts['margin-bottom'] = $atts['custom_margin'];
  1108.                 }
  1109.             }
  1110.  
  1111.             $custom_margin_style = '';
  1112.             $custom_margin_style .= AviaHelper::style_string( $atts, 'margin-top' );
  1113.             $custom_margin_style .= AviaHelper::style_string( $atts, 'margin-bottom' );
  1114.  
  1115.  
  1116.             /*check/create overlay*/
  1117.             $overlay    = '';
  1118.             $pre_wrap   = "<div class='av-section-color-overlay-wrap'>" ;
  1119.             if( ! empty( $overlay_enable ) )
  1120.             {
  1121.                 $overlay_src = '';
  1122.                 $overlay = "opacity: {$overlay_opacity}; ";
  1123.  
  1124.                 if( ! empty( $overlay_color ) )
  1125.                 {
  1126.                     $overlay .= "background-color: {$overlay_color}; ";
  1127.                 }
  1128.  
  1129.                 if( ! empty( $overlay_pattern ) )
  1130.                 {
  1131.                     if( $overlay_pattern == 'custom' )
  1132.                     {
  1133.                         $overlay_src = $overlay_custom_pattern;
  1134.                     }
  1135.                     else
  1136.                     {
  1137.                         $overlay_src = str_replace( '{{AVIA_BASE_URL}}', AVIA_BASE_URL, $overlay_pattern );
  1138.                     }
  1139.                 }
  1140.  
  1141.                 if( ! empty( $overlay_src ) )
  1142.                 {
  1143.                     $overlay .= "background-image: url({$overlay_src}); background-repeat: repeat;";
  1144.                 }
  1145.  
  1146.                 $overlay = "<div class='av-section-color-overlay' style='{$overlay}'></div>";
  1147.                 $class .= ' av-section-color-overlay-active';
  1148.  
  1149.                 $params['attach'] .= $pre_wrap . $overlay;
  1150.  
  1151.             }
  1152.  
  1153.             if( ! empty( $scroll_down ) )
  1154.             {  
  1155.                 $arrow_style = '';
  1156.                 $arrow_class = '';
  1157.  
  1158.                 if( ! $overlay )
  1159.                 {
  1160.                     $params['attach'] .= $pre_wrap;
  1161.                 }
  1162.  
  1163.                 if( ! empty( $custom_arrow_bg ) )
  1164.                 {
  1165.                     $arrow_style = "style='color: {$custom_arrow_bg};'";
  1166.                     $arrow_class = " av-custom-scroll-down-color";
  1167.                 }
  1168.  
  1169.                 $params['attach'] .= "<a href='#next-section' title='' class='scroll-down-link {$arrow_class}' {$arrow_style} " . av_icon_string( 'scrolldown' ) . '></a>';
  1170.             }
  1171.  
  1172.                
  1173.             $class .= " avia-bg-style-{$attach}";
  1174.             $params['class'] = $class . ' ' . $meta['el_class'] . ' ' . $av_display_classes;
  1175.             $params['bg'] = $background;
  1176.             $params['divider_on_top'] = $divider_on_top;
  1177.             $params['divider_on_top_layer'] = $divider_on_top_layer;
  1178.             $params['divider_on_bottom'] = $divider_on_bottom;
  1179.             $params['divider_on_bottom_layer'] = $divider_on_bottom_layer;
  1180.             $params['custom_margin'] = $custom_margin_style;
  1181.             $params['min_height'] = $min_height;
  1182.             $params['min_height_px'] = $min_height_px;
  1183.             $params['video'] = $video;
  1184.             $params['video_ratio'] = $video_ratio;
  1185.             $params['video_mobile_disabled'] = $video_mobile_disabled;
  1186.                
  1187.             if( isset( $meta['index'] ) && $meta['index'] >= 0 )
  1188.             {
  1189.                 if( $meta['index'] == 0 )              
  1190.                 {
  1191.                     $params['main_container'] = true;
  1192.                 }
  1193.  
  1194.                 if( $meta['index'] == 0 || ( isset( $meta['siblings']['prev']['tag'] ) && in_array( $meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section ) ) )
  1195.                 {
  1196.                     $params['close'] = false;
  1197.                 }
  1198.             }
  1199.                
  1200.             if( $bottom_border == 'border-extra-arrow-down' )
  1201.             {
  1202.                 $params['class'] .= ' av-arrow-down-section';
  1203.             }
  1204.  
  1205.             $avia_config['layout_container'] = 'section';
  1206.  
  1207.             $output .= avia_new_section( $params );
  1208.             $output .=  ShortcodeHelper::avia_remove_autop( $content, true ) ;
  1209.  
  1210.             /*set extra arrow element*/
  1211.             if( strpos( $bottom_border, 'border-extra' ) !== false )
  1212.             {
  1213.                 $backgroundEl = '';
  1214.                 $backgroundElColor = ! empty( $custom_bg ) ? $custom_bg : $avia_config['backend_colors']['color_set'][ $color ]['bg'];
  1215.  
  1216.                 if( strpos( $bottom_border, 'diagonal') !== false )
  1217.                 {
  1218.                     // bottom_border_diagonal_direction // bottom_border_diagonal_color
  1219.                     $backgroundElColor = '#333333';
  1220.                     if( isset( $bottom_border_diagonal_color ) )
  1221.                     {
  1222.                         $backgroundElColor = $bottom_border_diagonal_color;
  1223.                     }
  1224.  
  1225.                     $bottom_border .= ' ' . $bottom_border_diagonal_direction . ' ' . $bottom_border_style;
  1226.                 }
  1227.  
  1228.                 if( $backgroundElColor )
  1229.                 {
  1230.                     $backgroundEl = " style='background-color:{$backgroundElColor};' ";
  1231.                 }
  1232.  
  1233.                 avia_sc_section::$add_to_closing = "<div class='av-extra-border-element {$bottom_border}'><div class='av-extra-border-outer'><div class='av-extra-border-inner' {$backgroundEl}></div></div></div>";
  1234.             }
  1235.             else
  1236.             {
  1237.                 avia_sc_section::$add_to_closing = '';
  1238.             }
  1239.  
  1240.                
  1241.             //next section needs an extra closing tag if overlay with wrapper was added:
  1242.             if( $overlay || ! empty( $scroll_down ) )
  1243.             {
  1244.                 avia_sc_section::$close_overlay = '</div>';
  1245.             }
  1246.             else
  1247.             {
  1248.                 avia_sc_section::$close_overlay = '';
  1249.             }
  1250.                
  1251.             //if the next tag is a section dont create a new section from this shortcode
  1252.             if( ! empty( $meta['siblings']['next']['tag'] ) && in_array( $meta['siblings']['next']['tag'], AviaBuilder::$full_el ) )
  1253.             {
  1254.                 $skipSecond = true;
  1255.             }
  1256.  
  1257.             //if there is no next element dont create a new section. if we got a sidebar always create a next section at the bottom
  1258.             if( empty( $meta['siblings']['next']['tag'] ) && ! avia_has_sidebar() )
  1259.             {
  1260.                 $skipSecond = true;
  1261.             }
  1262.  
  1263.             if( empty( $skipSecond ) )
  1264.             {
  1265.                 $new_params['id'] = 'after_section_' . avia_sc_section::$section_count;
  1266.                 $output .= avia_new_section( $new_params );
  1267.             }
  1268.  
  1269.             unset( $avia_config['layout_container'] );
  1270.            
  1271.             return $output;
  1272.         }
  1273.            
  1274.         /**
  1275.          *
  1276.          * @param array $args
  1277.          * @return string
  1278.          */
  1279.         protected function get_bg_string( array $args )
  1280.         {
  1281.             $style = '';
  1282.  
  1283.             if( ! empty( $args['attachment'] ) )
  1284.             {
  1285.                 $image = false;
  1286.                 $src = wp_get_attachment_image_src( $args['attachment'], $args['attachment_size'] );
  1287.                 if( ! empty( $src[0] ) )
  1288.                 {
  1289.                     $image = $src[0];
  1290.                 }
  1291.  
  1292.                 if( $image )
  1293.                 {
  1294. //                  $bg = ! empty( $args['custom_bg'] ) ? $args['custom_bg'] : 'transparent';
  1295.                     $bg = 'transparent';
  1296.                     $pos = ! empty( $args['position'] ) ? $args['position'] : 'center center';
  1297.                     $repeat = ! empty( $args['repeat'] ) ? $args['repeat'] : 'no-repeat';
  1298.                     $extra = '';
  1299.  
  1300.                     if( $repeat == 'stretch' )
  1301.                     {
  1302.                         $repeat = 'no-repeat';
  1303.                         $extra = 'background-size: cover;';
  1304.                     }
  1305.  
  1306.                     if( $repeat == 'contain' )
  1307.                     {
  1308.                         $repeat = 'no-repeat';
  1309.                         $extra = 'background-size: contain;';
  1310.                     }
  1311.  
  1312.                     $style = "background: $bg url($image) $repeat $pos; $extra";
  1313.                 }
  1314.             }
  1315.  
  1316.             return $style;
  1317.         }
  1318.     }
  1319. }
  1320.  
  1321.  
  1322.  
  1323. if( ! function_exists( 'avia_new_section' ) )
  1324. {
  1325.     function avia_new_section( $params = array() )
  1326.     {
  1327.         global $avia_section_markup, $avia_config;
  1328.        
  1329.         $defaults = array( 
  1330.                         'class'             => 'main_color',
  1331.                         'bg'                => '',
  1332.                         'divider_on_top'    => '',
  1333.                         'divider_on_top_layer' => 'front',
  1334.                         'divider_on_bottom' => '',
  1335.                         'divider_on_bottom_layer' => 'front',
  1336.                         'custom_margin'     => '',
  1337.                         'close'             => true,
  1338.                         'open'              => true,
  1339.                         'open_structure'    => true,
  1340.                         'open_color_wrap'   => true,
  1341.                         'data'              => '',
  1342.                         'style'             => '',
  1343.                         'id'                => '',
  1344.                         'main_container'    => false,
  1345.                         'min_height'        => '',
  1346.                         'min_height_px'     => '',
  1347.                         'video'             => '',
  1348.                         'video_ratio'       => '16:9',
  1349.                         'video_mobile_disabled' => '',
  1350.                         'attach'            => '',
  1351.                         'before_new'        => '',
  1352.                         'custom_markup'     => '',
  1353.                         'aria_label'        => ''           //  set to true to force id as label
  1354.                     );
  1355.        
  1356.        
  1357.        
  1358.         $defaults = array_merge( $defaults, $params );
  1359.        
  1360.         extract( $defaults );
  1361.  
  1362.         $post_class = '';
  1363.         $output     = '';
  1364.         $bg_slider  = '';
  1365.         $container_style = '';
  1366.         $id_val = $id;
  1367.        
  1368.         $id = ! empty( $id_val ) ? "id='{$id_val}'" : '';
  1369.                
  1370.         if( ! empty( $aria_label ) || ! empty( $id_val ) )
  1371.         {
  1372.             if( true === $aria_label )
  1373.             {
  1374.                 $label = $id_val;
  1375.             }
  1376.             else if ( ! empty( $aria_label ) )
  1377.             {
  1378.                 $label = $aria_label;
  1379.             }
  1380.             else
  1381.             {
  1382.                 $label = '';
  1383.             }
  1384.            
  1385.             $aria_label = ! empty( $label ) ? "aria-label='{$label}'" : '';
  1386.         }
  1387.         else
  1388.         {
  1389.             $aria_label = '';
  1390.         }
  1391.    
  1392.        
  1393.         //close old content structure. only necessary when previous element was a section. other fullwidth elements dont need this
  1394.         if( $close )
  1395.         {
  1396.             $cm = avia_section_close_markup();
  1397.            
  1398.             $output .= "</div></div>{$cm}</div>" . avia_sc_section::$add_to_closing . avia_sc_section::$close_overlay . '</div>';
  1399.             avia_sc_section::$add_to_closing = '';
  1400.             avia_sc_section::$close_overlay = '';
  1401.         }
  1402.        
  1403.         //start new
  1404.         if( $open )
  1405.         {  
  1406.             if( function_exists('avia_get_the_id') )
  1407.             {
  1408.                 $post_class = 'post-entry-' . avia_get_the_id();
  1409.             }
  1410.    
  1411.             if( $open_color_wrap )
  1412.             {
  1413.            
  1414.                 if( ! empty( $min_height ) )
  1415.                 {
  1416.                     $class .= " av-minimum-height av-minimum-height-{$min_height} ";
  1417.                    
  1418.                     if( is_numeric( $min_height ) )
  1419.                     {
  1420.                         $data .= " data-av_minimum_height_pc='{$min_height}'";
  1421.                     }
  1422.                    
  1423.                     if( $min_height == 'custom' && $min_height_px != '' )
  1424.                     {
  1425.                         $min_height_px      = (int) $min_height_px;
  1426.                         $container_style    = "style='height:{$min_height_px}px'";
  1427.                     }
  1428.                 }
  1429.                
  1430.                 if( ! empty( $video ) )
  1431.                 {
  1432.                     $slide = array(
  1433.                                 'shortcode' => 'av_slideshow',  
  1434.                                 'content'   => '',
  1435.                                 'attr'      => array(  
  1436.                                                     'id'                => '',
  1437.                                                     'video'             => $video ,
  1438.                                                     'slide_type'        => 'video',
  1439.                                                     'video_mute'        => true,
  1440.                                                     'video_loop'        => true,
  1441.                                                     'video_ratio'       => $video_ratio,
  1442.                                                     'video_controls'    => 'disabled',
  1443.                                                     'video_section_bg'  => true,
  1444.                                                     'video_format'      => '',
  1445.                                                     'video_mobile'      => '',
  1446.                                                     'video_mobile_disabled' => $video_mobile_disabled
  1447.                                                 )  
  1448.                                 );
  1449.                    
  1450.                    
  1451.                     $bg_slider = new avia_slideshow( array( 'content' => array( $slide ) ) );
  1452.                     $bg_slider->set_extra_class( 'av-section-video-bg' );
  1453.                     $class .= ' av-section-with-video-bg';
  1454.                     $class .= ! empty( $video_mobile_disabled ) ? ' av-section-mobile-video-disabled' : '';
  1455.                     $data .= " data-section-video-ratio='{$video_ratio}'";
  1456.                    
  1457.                 }
  1458.                
  1459.                 $output .= $before_new;
  1460.  
  1461.                
  1462.                 //fix version 4.5.1 by Kriesi
  1463.                 //we cant just overwrite style since it might be passed by a function. eg the menu element passes z-index. need to merge the style strings
  1464.                
  1465.                 $extra_style = "{$bg} {$custom_margin}";
  1466.                 $style = trim($style);
  1467.                 if( empty( $style ) )
  1468.                 {
  1469.                     $style = "style='{$extra_style}' ";
  1470.                 }
  1471.                 else
  1472.                 {
  1473.                     $style = str_replace( "style='", "style='{$extra_style} ", $style );
  1474.                     $style = str_replace( 'style="', 'style="' . $extra_style . ' ', $style );
  1475.                 }
  1476.  
  1477.                 if( $class == 'main_color' )
  1478.                 {
  1479.                     $class .= ' av_default_container_wrap';
  1480.                 }
  1481.  
  1482. //  dividers
  1483.  
  1484.                 if( ! empty( $divider_on_top ) )
  1485.                 {
  1486.                     $class .= " avia-divider-top top-{$divider_on_top_layer}";
  1487.                     $data .= " data-divider_on_top='{$divider_on_top}'";           
  1488.                 }
  1489.  
  1490.                 if( ! empty( $divider_on_bottom ) )
  1491.                 {
  1492.                     $class .= " avia-divider-bottom bottom-{$divider_on_bottom_layer}";
  1493.                     $data .= " data-divider_on_bottom='{$divider_on_bottom}'";
  1494.                 }
  1495. //  end dividers
  1496.                
  1497.                 $output .= "<div {$id} {$aria_label} class='{$class} container_wrap " . avia_layout_class( 'main' , false ) . "' {$style} {$data} >";
  1498.                 $output .= ! empty( $bg_slider ) ? $bg_slider->html() : '';
  1499.                 $output .= $attach;
  1500.                
  1501.                 $output .= apply_filters( 'avf_section_container_add', '', $defaults );
  1502.             }
  1503.    
  1504.            
  1505.             //this applies only for sections. other fullwidth elements dont need the container for centering
  1506.             if( $open_structure )
  1507.             {
  1508.                 if( ! empty( $main_container ) )
  1509.                 {
  1510.                     $markup = 'main ' . avia_markup_helper( array( 'context' => 'content', 'echo' => false, 'custom_markup' => $custom_markup ) );
  1511.                     $avia_section_markup = 'main';
  1512.                 }
  1513.                 else
  1514.                 {
  1515.                     $markup = 'div';  
  1516.                 }
  1517.  
  1518.                 $output .= "<div class='container' {$container_style}>";
  1519.                 $output .= "<{$markup} class='template-page content  " . avia_layout_class( 'content', false ) . " units'>";
  1520.                 $output .= "<div class='post-entry post-entry-type-page {$post_class}'>";
  1521.                 $output .= "<div class='entry-content-wrapper clearfix'>";
  1522.             }
  1523.         }
  1524.         return $output;
  1525.    
  1526.     }
  1527. }
  1528.  
  1529.  
  1530.  
  1531. if( ! function_exists( 'avia_section_close_markup' ) )
  1532. {
  1533.     function avia_section_close_markup()
  1534.     {
  1535.         global $avia_section_markup, $avia_config;
  1536.        
  1537.         if( ! empty( $avia_section_markup ) )
  1538.         {
  1539.             $avia_section_markup = false;
  1540.             $close_markup = '</main><!-- close content main element -->';
  1541.            
  1542.         }
  1543.         else
  1544.         {
  1545.             $close_markup = '</div><!-- close content main div -->';
  1546.         }
  1547.        
  1548.         return $close_markup;
  1549.     }
  1550. }
  1551.  
  1552. if( ! function_exists( 'avia_section_after_element_content' ) )
  1553. {
  1554.     function avia_section_after_element_content( $meta, $second_id = '', $skipSecond = false, $extra = '' )
  1555.     {
  1556.        
  1557.         $output = '</div>'; //close section
  1558.         $output .= $extra;
  1559.                    
  1560.         //if the next tag is a section dont create a new section from this shortcode
  1561.         if( ! empty( $meta['siblings']['next']['tag'] ) && in_array( $meta['siblings']['next']['tag'], AviaBuilder::$full_el ) )
  1562.         {
  1563.             $skipSecond = true;
  1564.         }
  1565.    
  1566.         //if there is no next element dont create a new section.
  1567.         if( empty( $meta['siblings']['next']['tag'] ) )
  1568.         {
  1569.             $skipSecond = true;
  1570.         }
  1571.        
  1572.         if( empty( $skipSecond ) )
  1573.         {
  1574.             $output .= avia_new_section(array('close'=>false, 'id' => $second_id));
  1575.         }
  1576.        
  1577.         return $output;
  1578.     }
  1579. }
  1580.  
  1581.  
  1582.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement