Advertisement
Guenni007

section

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