Guenni007

grid_row

Sep 1st, 2025 (edited)
379
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 32.14 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Grid Row
  4.  *
  5.  * Shortcode which adds multiple Grid Rows below each other to create advanced grid layouts. Cells can be styled individually
  6.  * added dividers options by Guenni007
  7.  */
  8.  
  9.  // Don't load directly
  10. if( ! defined( 'ABSPATH' ) ) { die( '-1' ); }
  11.  
  12.  
  13. if( ! class_exists( 'avia_sc_grid_row', false ) )
  14. {
  15.   // if you like to use both integrations: for grid-row element and for Grid-Cells
  16.   // then you had to download both files for your child-theme shortcodes folder https://pastebin.com/Raw6vXEp
  17.  
  18.   include_once( 'cell.php' );  
  19.  
  20.   // only if you need the grid-row dividers - then comment out that line on top: include_once( 'cell.php' );
  21.   // and activate the next line by removing: //
  22.   // include_once( get_template_directory() . '/config-templatebuilder/avia-shortcodes/grid_row/cell.php');
  23.  
  24.     class avia_sc_grid_row extends aviaShortcodeTemplate
  25.     {
  26.  
  27.         /**
  28.          *
  29.          * @var int
  30.          */
  31.         static $count = 0;
  32.  
  33.         /**
  34.          * Create the config array for the shortcode grid row
  35.          */
  36.         protected function shortcode_insert_button()
  37.         {
  38.             $this->config['version']            = '1.0';
  39.             $this->config['is_fullwidth']       = 'yes';
  40. //          $this->config['base_element']       = 'yes';
  41.             $this->config['type']               = 'layout';
  42.             $this->config['self_closing']       = 'no';
  43.             $this->config['contains_text']      = 'no';
  44.             $this->config['layout_children']    = array(
  45.                                                         'av_cell_one_full',
  46.                                                         'av_cell_one_half',
  47.                                                         'av_cell_one_third',
  48.                                                         'av_cell_one_fourth',
  49.                                                         'av_cell_one_fifth',
  50.                                                         'av_cell_two_third',
  51.                                                         'av_cell_three_fourth',
  52.                                                         'av_cell_two_fifth',
  53.                                                         'av_cell_three_fifth',
  54.                                                         'av_cell_four_fifth'
  55.                                                     );
  56.  
  57.  
  58.             $this->config['name']               = __( 'Grid Row', 'avia_framework' );
  59.             $this->config['icon']               = AviaBuilder::$path['imagesURL'] . 'sc-layout_row.png';
  60.             $this->config['tab']                = __( 'Layout Elements', 'avia_framework' );
  61.             $this->config['order']              = 15;
  62.             $this->config['shortcode']          = 'av_layout_row';
  63.             $this->config['html_renderer']      = false;
  64.             $this->config['tinyMCE']            = array( 'disable' => 'true' );
  65.             $this->config['tooltip']            = __( 'Add multiple Grid Rows below each other to create advanced grid layouts. Cells can be styled individually', 'avia_framework' );
  66.             $this->config['drag-level']         = 1;
  67.             $this->config['drop-level']         = 100;
  68.             $this->config['disabling_allowed']  = false;
  69.  
  70.             $this->config['id_name']            = 'id';
  71.             $this->config['id_show']            = 'always';             //  we use original code - not $meta
  72.             $this->config['aria_label']         = 'yes';
  73.         }
  74.  
  75.         protected function extra_assets()
  76.         {
  77.             $ver = Avia_Builder()->get_theme_version();
  78.             $min_css = avia_minify_extension( 'css' );
  79.  
  80.             //load css
  81.             wp_enqueue_style( 'avia-module-gridrow', AviaBuilder::$path['pluginUrlRoot'] . "avia-shortcodes/grid_row/grid_row{$min_css}.css", array( 'avia-layout' ), $ver );
  82.         }
  83.  
  84.         /**
  85.          * Popup Elements
  86.          *
  87.          * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  88.          * opens a modal window that allows to edit the element properties
  89.          *
  90.          * @return void
  91.          */
  92.         protected function popup_elements()
  93.         {
  94.  
  95.             $this->elements = array(
  96.  
  97.                 array(
  98.                         'type'  => 'tab_container',
  99.                         'nodescription' => true
  100.                     ),
  101.  
  102.                 array(
  103.                         'type'  => 'tab',
  104.                         'name'  => __( 'Layout', 'avia_framework' ),
  105.                         'nodescription' => true
  106.                     ),
  107.  
  108.                     array(
  109.                             'type'          => 'template',
  110.                             'template_id'   => 'toggle_container',
  111.                             'templates_include' => array(
  112.                                                     $this->popup_key( 'layout_height' ),
  113.                                                     $this->popup_key( 'layout_borders' ),
  114.                           $this->popup_key( 'layout_svg_dividers' ),
  115.                                                     'fold_unfold_container_toggle'
  116.                                                 ),
  117.                             'nodescription' => true
  118.                         ),
  119.  
  120.                 array(
  121.                         'type'  => 'tab_close',
  122.                         'nodescription' => true
  123.                     ),
  124.  
  125.                 array(
  126.                         'type'  => 'tab',
  127.                         'name'  => __( 'Styling', 'avia_framework' ),
  128.                         'nodescription' => true
  129.                     ),
  130.  
  131.                     array(
  132.                             'type'          => 'template',
  133.                             'template_id'   => 'toggle_container',
  134.                             'templates_include' => array(
  135.                                                     $this->popup_key( 'styling_colors' ),
  136.                                                     'fold_styling_toggle'
  137.                                                 ),
  138.                             'nodescription' => true
  139.                         ),
  140.  
  141.                 array(
  142.                         'type'  => 'tab_close',
  143.                         'nodescription' => true
  144.                     ),
  145.  
  146.                 array(
  147.                         'type'  => 'tab',
  148.                         'name'  => __( 'Advanced', 'avia_framework' ),
  149.                         'nodescription' => true
  150.                     ),
  151.  
  152.                     array(
  153.                             'type'  => 'toggle_container',
  154.                             'nodescription' => true
  155.                         ),
  156.  
  157.                         array(
  158.                                 'type'          => 'template',
  159.                                 'template_id'   => 'fold_animation_toggle',
  160.                                 'lockable'      => true
  161.                             ),
  162.  
  163.                         array(
  164.                                 'type'              => 'template',
  165.                                 'template_id'       => 'screen_options_toggle',
  166.                                 'lockable'          => true,
  167.                                 'templates_include' => array(
  168.                                                     $this->popup_key( 'advanced_mobile' ),
  169.                                                     'screen_options_visibility'
  170.                                                 )
  171.                             ),
  172.  
  173.                         array(
  174.                                 'type'          => 'template',
  175.                                 'template_id'   => 'developer_options_toggle',
  176.                                 'args'          => array( 'sc' => $this )
  177.                             ),
  178.  
  179.                     array(
  180.                             'type'  => 'toggle_container_close',
  181.                             'nodescription' => true
  182.                         ),
  183.  
  184.                 array(
  185.                         'type'  => 'tab_close',
  186.                         'nodescription' => true
  187.                     ),
  188.  
  189.                 array(
  190.                         'type'          => 'template',
  191.                         'template_id'   => 'element_template_selection_tab',
  192.                         'args'          => array( 'sc'  => $this )
  193.                     ),
  194.  
  195.                 array(
  196.                         'id'    => 'av_element_hidden_in_editor',
  197.                         'type'  => 'hidden',
  198.                         'std'   => '0'
  199.                     ),
  200.  
  201.                 array(
  202.                         'type'  => 'tab_container_close',
  203.                         'nodescription' => true
  204.                     )
  205.  
  206.             );
  207.         }
  208.  
  209.         /**
  210.          * Create and register templates for easier maintainance
  211.          *
  212.          * @since 4.6.4
  213.          */
  214.         protected function register_dynamic_templates()
  215.         {
  216.             global $avia_config;
  217.  
  218.             /**
  219.              * Layout Tab
  220.              * ===========
  221.              */
  222.  
  223.             $c = array(
  224.                          array(
  225.                             'name'      => __( 'Grid Row Minimum Height', 'avia_framework' ),
  226.                             'desc'      => __( 'Define a minimum height for the grid row.', 'avia_framework' ),
  227.                             'id'        => 'min_height_percent',
  228.                             'type'      => 'select',
  229.                             'std'       => '',
  230.                             'lockable'  => true,
  231.                             'subtype'   => array(
  232.                                                 __( 'At least 100&percnt; of browser window height', 'avia_framework' )                     => '100',
  233.                                                 __( 'At least 75&percnt; of browser window height', 'avia_framework' )                      => '75',
  234.                                                 __( 'At least 50&percnt; of browser window height', 'avia_framework' )                      => '50',
  235.                                                 __( 'At least 25&percnt; of browser window height', 'avia_framework' )                      => '25',
  236.                                                 __( 'Minimum custom height in &percnt; based on browser windows height', 'avia_framework' ) => 'percent',
  237.                                                 __( 'Minimum custom height in pixel', 'avia_framework' )                                    => '',
  238.                                             )
  239.                         ),
  240.  
  241.                         array(
  242.                             'name'      => __( 'Grid Row Minimum Custom Height In &percnt;', 'avia_framework' ),
  243.                             'desc'      => __( 'Define a minimum height for the gridrow in &percnt; based on the browser windows height', 'avia_framework' ),
  244.                             'id'        => 'min_height_pc',
  245.                             'type'      => 'select',
  246.                             'std'       => '25',
  247.                             'lockable'  => true,
  248.                             'required'  => array( 'min_height_percent', 'equals', 'percent' ),
  249.                             'subtype'   => AviaHtmlHelper::number_array( 1, 99, 1 )
  250.                         ),
  251.  
  252.                         array(
  253.                             'name'      => __( 'Grid Row Minimum Custom Height In px', 'avia_framework' ),
  254.                             'desc'      => __( 'Set the minimum height of all the cells in pixel. eg:400px', 'avia_framework' ),
  255.                             'id'        => 'min_height',
  256.                             'type'      => 'input',
  257.                             'std'       => '0',
  258.                             'lockable'  => true,
  259.                             'required'  => array( 'min_height_percent', 'equals', '' )
  260.                         )
  261.  
  262.                 );
  263.  
  264.             $template = array(
  265.                             array(
  266.                                 'type'          => 'template',
  267.                                 'template_id'   => 'toggle',
  268.                                 'title'         => __( 'Grid Row Height', 'avia_framework' ),
  269.                                 'content'       => $c
  270.                             ),
  271.                     );
  272.  
  273.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_height' ), $template, true );
  274.  
  275.             $c = array(
  276.                         array(
  277.                             'name'  => __( 'Grid Borders', 'avia_framework' ),
  278.                             'desc'  => __( 'Choose if your layout grid should display any border', 'avia_framework' ),
  279.                             'id'    => 'border',
  280.                             'type'  => 'select',
  281.                             'std'   => '',
  282.                             'lockable'  => true,
  283.                             'subtype'   => array(
  284.                                                 __( 'No Borders', 'avia_framework' )                => '',
  285.                                                 __( 'Borders on top and bottom', 'avia_framework' ) => 'av-border-top-bottom',
  286.                                                 __( 'Borders between cells', 'avia_framework' )     => 'av-border-cells',
  287.                                                 __( 'Borders on top and bottom and between cells', 'avia_framework' )   => 'av-border-top-bottom av-border-cells',
  288.                                             )
  289.                         )
  290.  
  291.                 );
  292.  
  293.             $template = array(
  294.                             array(
  295.                                 'type'          => 'template',
  296.                                 'template_id'   => 'toggle',
  297.                                 'title'         => __( 'Borders', 'avia_framework' ),
  298.                                 'content'       => $c
  299.                             ),
  300.                     );
  301.  
  302.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_borders' ), $template, true );
  303.  
  304.       $template = array(
  305.               array(
  306.                 'type'      => 'template',
  307.                 'template_id' => 'svg_divider_toggle',
  308.                 'lockable'    => true
  309.               )
  310.           );
  311.  
  312.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_svg_dividers' ), $template );
  313.  
  314.             /**
  315.              * Styling Tab
  316.              * ===========
  317.              */
  318.  
  319.             $desc  = __( 'The section will use the color scheme you select. Color schemes are defined on your styling page', 'avia_framework' );
  320.             $desc .= '<br/><a target="_blank" href="' . admin_url( 'admin.php?page=avia#goto_styling' ) . '">';
  321.             $desc .= __( '(Show Styling Page)', 'avia_framework' ) . '</a>';
  322.  
  323.             $c = array(
  324.                         array(
  325.                             'name'  => __( 'Section Colors', 'avia_framework' ),
  326.                             'desc'  => $desc,
  327.                             'id'    => 'color',
  328.                             'type'  => 'select',
  329.                             'std'   => 'main_color',
  330.                             'lockable'  => true,
  331.                             'subtype'   =>  array_flip( $avia_config['color_sets'] )
  332.                         )
  333.                 );
  334.  
  335.             $template = array(
  336.                             array(
  337.                                 'type'          => 'template',
  338.                                 'template_id'   => 'toggle',
  339.                                 'title'         => __( 'Colors', 'avia_framework' ),
  340.                                 'content'       => $c
  341.                             ),
  342.                     );
  343.  
  344.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_colors' ), $template, true );
  345.  
  346.             /**
  347.              * Advanced Tab
  348.              * =============
  349.              */
  350.  
  351.             $desc  = __( 'Select order of cells when switched to fullwidth. Individual position must be set in &quot;Advanced Tab -&gt; Responsive Toggle&quot;.', 'avia_framework' ) . '<br /><br />';
  352.             $desc .= '<strong>' . __( ' This is currently a beta feature (added 4.8.7)', 'avia_framework' ) . '</strong>';
  353.  
  354.             $c = array(
  355.                         array(
  356.                             'name'      => __( 'Mobile Behaviour', 'avia_framework' ),
  357.                             'desc'      => __( 'Choose how the cells inside the grid should behave on mobile devices and small screens', 'avia_framework' ),
  358.                             'id'        => 'mobile',
  359.                             'type'      => 'select',
  360.                             'std'       => 'av-flex-cells',
  361.                             'lockable'  => true,
  362.                             'subtype'   => array(
  363.                                                 __( 'Default: Each cell is displayed on its own', 'avia_framework' )                    => 'av-flex-cells',
  364.                                                 __( 'Cells appear beside each other, just like on large screens', 'avia_framework' )    => 'av-fixed-cells',
  365.                                             )
  366.                         ),
  367.  
  368.                         array(
  369.                             'name'      => __( 'Mobile Breaking Point', 'avia_framework' ),
  370.                             'desc'      => __( 'Set the screen width when cells in this row should switch to full width', 'avia_framework' ),
  371.                             'type'      => 'heading',
  372.                             'required'  => array( 'mobile', 'not', 'av-fixed-cells' ),
  373.                             'description_class' => 'av-builder-note av-neutral'
  374.                         ),
  375.  
  376.                         array(
  377.                             'name'      => __( 'Fullwidth Break Point', 'avia_framework' ),
  378.                             'desc'      => __( 'The cells in this row will switch to fullwidth at this screen width ', 'avia_framework' ),
  379.                             'id'        => 'mobile_breaking',
  380.                             'type'      => 'select',
  381.                             'std'       => '',
  382.                             'lockable'  => true,
  383.                             'required'  => array( 'mobile', 'not', 'av-fixed-cells' ),
  384.                             'subtype'   => array(
  385.                                                 __( 'On mobile devices (at a screen width of 767px or lower)', 'avia_framework' )   => '',
  386.                                                 __( 'On tablets (at a screen width of 989px or lower)', 'avia_framework' )          => 'av-break-at-tablet',
  387.                                             )
  388.                         ),
  389.  
  390.                         array(
  391.                             'name'      => __( 'Column Behaviour When Fullwidth', 'avia_framework' ),
  392.                             'desc'      => $desc,
  393.                             'id'        => 'mobile_column_order',
  394.                             'type'      => 'select',
  395.                             'std'       => '',
  396.                             'lockable'  => true,
  397.                             'required'  => array( 'mobile', 'not', 'av-fixed-cells' ),
  398.                             'subtype'   => array(
  399.                                                 __( 'Same order as defined for desktop', 'avia_framework' )             => '',
  400.                                                 __( 'Reverse order', 'avia_framework' )                                 => 'reverse',
  401.                                                 __( 'Individually select position for each column', 'avia_framework' )  => 'individual',
  402.                                             )
  403.                         )
  404.  
  405.                 );
  406.  
  407.             AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_mobile' ), $c, true );
  408.  
  409.         }
  410.  
  411.         /**
  412.          * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  413.          * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  414.          * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  415.          *
  416.          * @param array $params         holds the default values for $content and $args.
  417.          * @return array                usually holds an innerHtml key that holds item specific markup.
  418.          */
  419.         public function editor_element( $params )
  420.         {
  421. /*
  422.             $params['content'] = trim($params['content']);
  423.             if(empty($params['content'])) $params['content'] = '[av_cell_one_half first][/av_cell_one_half] [av_cell_one_half][/av_cell_one_half]';
  424. */
  425.  
  426.             $default = array();
  427.             $locked = array();
  428.             $attr = $params['args'];
  429.             $content = $params['content'];
  430.  
  431.             Avia_Element_Templates()->set_locked_attributes( $attr, $this, $this->config['shortcode'], $default, $locked, $content );
  432.  
  433.             $args = $attr;      //  => extract( $params );
  434.  
  435.             $name = $this->config['shortcode'];
  436.             $data['shortcodehandler'] = $this->config['shortcode'];
  437.             $data['modal_title'] = $this->config['name'];
  438.             $data['modal_ajax_hook'] = $this->config['shortcode'];
  439.             $data['dragdrop-level'] = $this->config['drag-level'];
  440.             $data['allowed-shortcodes'] = $this->config['shortcode'];
  441.  
  442.             if( ! empty( $this->config['modal_on_load'] ) )
  443.             {
  444.                 $data['modal_on_load']  = $this->config['modal_on_load'];
  445.             }
  446.  
  447.             $dataString  = AviaHelper::create_data_string( $data );
  448.  
  449.             if( $content )
  450.             {
  451.                 $final_content = $this->builder->do_shortcode_backend( $content );
  452.                 $text_area = ShortcodeHelper::create_shortcode_by_array( $name, $content, $args );
  453.             }
  454.             else if( Avia_Element_Templates()->is_edit_element_page() )
  455.             {
  456.                 $cell = new avia_sc_cell( $this->builder );
  457.  
  458.                 $params = array(
  459.                             'content' => '',
  460.                             'args' => array(),
  461.                             'data' => ''
  462.                         );
  463.  
  464.                 $final_content = $cell->editor_element( $params );
  465.  
  466.                 $text_area = ShortcodeHelper::create_shortcode_by_array( $name, '[av_cell_one_full][/av_cell_one_full]', $args );
  467.             }
  468.             else
  469.             {
  470.                 $cell = new avia_sc_cell_one_half( $this->builder );
  471.  
  472.                 $params = array(
  473.                             'content' => '',
  474.                             'args' => array(),
  475.                             'data' => ''
  476.                         );
  477.  
  478.                 $final_content  = $cell->editor_element( $params );
  479.                 $final_content .= $cell->editor_element( $params );
  480.  
  481.                 $text_area = ShortcodeHelper::create_shortcode_by_array( $name, '[av_cell_one_half][/av_cell_one_half] [av_cell_one_half][/av_cell_one_half]', $args );
  482.             }
  483.  
  484.             $title_id = ! empty( $args['id'] ) ? ': ' . ucfirst( $args['id'] ) : '';
  485.             $hidden_el_active = ! empty( $args['av_element_hidden_in_editor'] ) ? 'av-layout-element-closed' : '';
  486.  
  487.  
  488.             $output  = "<div class='avia_layout_row {$hidden_el_active} avia_layout_section avia_pop_class avia-no-visual-updates {$name} av_drag' {$dataString}>";
  489.             $output .=      "<div class='avia_sorthandle menu-item-handle'>";
  490.             $output .=          "<span class='avia-element-title'>{$this->config['name']}<span class='avia-element-title-id'>{$title_id}</span></span>";
  491.             $output .=          "<a class='avia-delete'  href='#delete' title='" . __( 'Delete Row', 'avia_framework' ) . "'>x</a>";
  492.             $output .=          "<a class='avia-toggle-visibility'  href='#toggle' title='" . __( 'Show/Hide Section', 'avia_framework' ) . "'></a>";
  493.  
  494.             if( ! empty( $this->config['popup_editor'] ) )
  495.             {
  496.                 $output .=      "<a class='avia-edit-element'  href='#edit-element' title='" . __( 'Edit Row', 'avia_framework' ) . "'>" . __( 'edit', 'avia_framework' ) . '</a>';
  497.             }
  498.  
  499.             $output .=          "<a class='avia-save-element'  href='#save-element' title='" . __( 'Save Element as Template', 'avia_framework' ) . "'>+</a>";
  500.             $output .=          "<a class='avia-clone'  href='#clone' title='" . __( 'Clone Row', 'avia_framework' ) . "' >" . __( 'Clone Row', 'avia_framework' ) . '</a>';
  501.             $output .=      '</div>';
  502.             $output .=      "<div class='avia_inner_shortcode avia_connect_sort av_drop' data-dragdrop-level='{$this->config['drop-level']}'>";
  503.             $output .=          "<textarea data-name='text-shortcode' cols='20' rows='4'>{$text_area}</textarea>";
  504.             $output .=          $final_content;
  505.             $output .=      '</div>';
  506.             $output .=      "<a class='avia-layout-element-hidden' href='#'>" . __( 'Grid Row content hidden. Click here to show it', 'avia_framework' ) . '</a>';
  507.             $output .=      '<div class="avia-cell-layout-buttons">';
  508.             $output .=          "<a class='avia-set-cell-size avia-add'  href='#set-size' title='" . __( 'Set Cell Size', 'avia_framework' ) . "'>" . __( 'Set Cell Size', 'avia_framework' ) . '</a>';
  509.             $output .=          "<a class='avia-add-cell avia-add'  href='#add-cell' title='" . __( 'Add Cell', 'avia_framework' ) . "'>" . __( 'Add Cell', 'avia_framework' ) . '</a>';
  510.             $output .=      '</div>';
  511.             $output .= '</div>';
  512.  
  513.             return $output;
  514.         }
  515.  
  516.         /**
  517.          * Create custom stylings
  518.          *
  519.          * @since 4.8.7
  520.          * @param array $args
  521.          * @return array
  522.          */
  523.         protected function get_element_styles( array $args )
  524.         {
  525.             $result = parent::get_element_styles( $args );
  526.  
  527.             extract( $result );
  528.  
  529.             $default = array(
  530.                         'color'                 => 'main_color',
  531.                         'border'                => '',
  532.                         'min_height'            => '0',
  533.                         'min_height_percent'    => '',
  534.                         'min_height_pc'         => 25,
  535.                         'mobile'                => 'av-flex-cells',
  536.                         'mobile_breaking'       => '',
  537.                         'mobile_column_order'   => '',
  538.                         'id'                    => '',
  539.             'svg_dividers'   => ''
  540.                     );
  541.  
  542.             $default = $this->sync_sc_defaults_array( $default, 'no_modal_item', 'no_content' );
  543.  
  544.             $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  545.  
  546.             if( 'percent' == $atts['min_height_percent'] )
  547.             {
  548.                 $atts['min_height_percent'] = $atts['min_height_pc'];
  549.             }
  550.  
  551.             if( empty( $atts['fold_height'] ) )
  552.             {
  553.                 $atts['fold_height'] = 80;
  554.             }
  555.  
  556.             /**
  557.              * Removed option, allows to place top of folded container from screen top when top of container unvisible
  558.              *
  559.              * @since 5.6
  560.              * @param int $avf_fold_top_offset
  561.              * @param array $atts
  562.              * @param aviaShortcodeTemplate $this
  563.              * @return int
  564.              */
  565.             $atts['fold_top_offset'] = apply_filters( 'avf_fold_top_offset', 50, $atts, $this );
  566.  
  567.             $atts['fold_element_class'] = "av-fold-grid-{$element_id}";
  568.  
  569.             //  make global for content inside
  570.             avia_sc_cell::$attr = $atts;
  571.  
  572.             $element_styling->create_callback_styles( $atts );
  573.  
  574.  
  575.             $classes = array(
  576.                         'av-layout-grid-container',
  577.                         $element_id,
  578.                         'entry-content-wrapper',
  579.                         $atts['color'],
  580.                         $atts['border'],
  581.                         $atts['mobile'],
  582.                         $atts['mobile_breaking'],
  583.                     );
  584.  
  585.             $element_styling->add_classes( 'section', $classes );
  586.             $element_styling->add_classes_from_array( 'section', $meta, 'el_class' );
  587.  
  588.             if( $atts['mobile_column_order'] != '' )
  589.             {
  590.                 $element_styling->add_classes( 'section', 'av-grid-order-' . $atts['mobile_column_order'] );
  591.             }
  592.  
  593.             if( $atts['min_height_percent'] != '' )
  594.             {
  595.                 $element_styling->add_classes( 'section', array(
  596.                                                     'av-cell-min-height',
  597.                                                     'av-cell-min-height-' . $atts['min_height_percent']
  598.                                                 ) );
  599.             }
  600.  
  601.             if( isset( $meta['index'] ) && $meta['index'] > 0 )
  602.             {
  603.                 $element_styling->add_classes( 'section', 'grid-row-not-first' );
  604.             }
  605.  
  606.  
  607. //  SVG Dividers
  608.       $element_styling->add_classes( 'divider-top', array( 'avia-divider-svg', 'avia-divider-svg-' . $atts['svg_div_top'] ) );
  609.       $element_styling->add_classes( 'divider-bottom', array( 'avia-divider-svg', 'avia-divider-svg-' . $atts['svg_div_bottom'] ) );
  610.  
  611.       $element_styling->add_callback_styles( 'divider-top-svg', array( 'svg_div_top_svg', 'svg_div_top_color' ) );
  612.       $element_styling->add_callback_styles( 'divider-bottom-svg', array( 'svg_div_bottom_svg', 'svg_div_bottom_color' ) );
  613.  
  614.       $element_styling->add_callback_classes( 'divider-top', array( 'svg_div_top' ) );
  615.       $element_styling->add_callback_classes( 'divider-bottom', array( 'svg_div_bottom' ) );
  616.  
  617.  
  618.  
  619.       //  z-index
  620.       if( $element_styling->add_responsive_styles( 'section-outer', 'css_position', $atts, $this ) > 0 )
  621.       {
  622.         $element_styling->add_responsive_styles( 'section-outer-curtain', 'css_position', $atts, $this );
  623.  
  624.         $element_styling->add_classes( 'section-outer', array( 'av-custom-positioned' ) );
  625.         //  needed to allow z-index because by default static
  626.         $element_styling->add_styles( 'section-outer', array( 'position' => 'relative' ) );
  627.       }
  628.  
  629.  
  630.  
  631.  
  632.             if( ! empty( $atts['fold_type'] ) )
  633.             {
  634.                 $f_classes = array(
  635.                             $atts['fold_type'],
  636.                             'avia-fold-grid-row-wrap',
  637.                             'avia-fold-init',
  638.                             $atts['fold_element_class'],
  639.                             $atts['fold_text_style'],
  640.                             empty( $atts['fold_btn_align'] ) ? 'align-left' : $atts['fold_btn_align']
  641.                         );
  642.  
  643.                 $element_styling->add_classes( 'fold-section', $f_classes );
  644.  
  645.                 if( $atts['fold_text_style'] == '' )
  646.                 {
  647.                     $element_styling->add_styles( 'fold-button', array( 'color' => $atts['fold_text_color'] ) );
  648.                 }
  649.  
  650.                 if( $atts['fold_text_style'] != '' && $atts['fold_btn_color'] == 'custom' )
  651.                 {
  652.                     $element_styling->add_styles( 'fold-button', array(
  653.                                                     'background-color'  => $atts['fold_btn_bg_color'],
  654.                                                     'color'             => $atts['fold_btn_font_color'],
  655.                                                 ) );
  656.                 }
  657.  
  658.                 $element_styling->add_responsive_font_sizes( 'fold-button', 'size-btn-text', $atts, $this );
  659.  
  660.                 if( ! empty( $atts['fold_overlay_color'] ) )
  661.                 {
  662.                     $bg_rgb = avia_backend_hex_to_rgb_array( $atts['fold_overlay_color'] );
  663.  
  664.                     $element_styling->add_styles( 'fold-unfold-after', array(
  665.                                                     'background'    => "linear-gradient( to bottom, rgba({$bg_rgb[0]},{$bg_rgb[1]},{$bg_rgb[2]},0), rgba({$bg_rgb[0]},{$bg_rgb[1]},{$bg_rgb[2]},1) )"
  666.                                                 ) );
  667.                 }
  668.  
  669.                 $element_styling->add_styles( 'fold-unfold', array( 'max-height' => $atts['fold_height'] . 'px' ) );
  670.  
  671.                 if( ! empty( $atts['fold_timer'] ) )
  672.                 {
  673.                     $rules = $element_styling->transition_duration_rules( $atts['fold_timer'] );
  674.  
  675.                     $element_styling->add_styles( 'fold-unfold', $rules );
  676.                     $element_styling->add_styles( 'fold-unfold-after', $rules );
  677.                 }
  678.  
  679.                 $element_styling->add_styles( 'fold-unfold-folded-after', array( 'z-index' => $atts['z_index_fold'] ) );
  680.  
  681.                 //  prepare attributes for frontend
  682.                 $element_styling->add_data_attributes( 'fold-section', array(
  683.                                                 'type'      => $atts['fold_type'],
  684.                                                 'height'    => $atts['fold_height'],
  685.                                                 'more'      => $atts['fold_more'],
  686.                                                 'less'      => $atts['fold_less'],
  687.                                                 'context'   => __CLASS__
  688.                                             ) );
  689.             }
  690.  
  691.  
  692.             $selectors = array(
  693.                         'section'                   => ".av-layout-grid-container.{$element_id}",
  694.  
  695.             'divider-top-div'     => ".av-layout-grid-container.{$element_id} .avia-divider-svg-top",
  696.             'divider-bottom-div'  => ".av-layout-grid-container.{$element_id} .avia-divider-svg-bottom",
  697.             'divider-top-svg'     => ".av-layout-grid-container.{$element_id} .avia-divider-svg-top svg",
  698.             'divider-bottom-svg'  => ".av-layout-grid-container.{$element_id} .avia-divider-svg-bottom svg",
  699.  
  700.  
  701.                         'fold-section'              => ".avia-fold-unfold-section.{$atts['fold_element_class']}",
  702.                         'fold-unfold'               => ".avia-fold-unfold-section.{$atts['fold_element_class']} .av-fold-unfold-container",
  703.                         'fold-unfold-after'         => "#top .avia-fold-unfold-section.{$atts['fold_element_class']} .av-fold-unfold-container:after",
  704.                         'fold-unfold-folded-after'  => ".avia-fold-unfold-section.{$atts['fold_element_class']} .av-fold-unfold-container.folded::after",
  705.                         'fold-button'               => "#top .avia-fold-unfold-section.{$atts['fold_element_class']} .av-fold-button-container"
  706.                     );
  707.  
  708.             $element_styling->add_selectors( $selectors );
  709.  
  710.  
  711.             $result['default'] = $default;
  712.             $result['atts'] = $atts;
  713.             $result['content'] = $content;
  714.             $result['element_styling'] = $element_styling;
  715.  
  716.             return $result;
  717.         }
  718.  
  719.  
  720.         /**
  721.      * Returns the modal popups svg divider preview windows in $svg_list
  722.      *
  723.      * @since 4.8.4
  724.      * @param array $args
  725.      * @param array $svg_list
  726.      * @return array
  727.      */
  728.     public function build_svg_divider_preview( array $args, array $svg_list )
  729.     {
  730.       //  clear content and not needed settings - we only need minimal stylings
  731.       $args['content'] = '';
  732.       unset( $args['atts']['content'] );
  733.  
  734. //      $args['atts']['padding'] = '';
  735.       $args['atts']['custom_margin'] = '';
  736.  
  737.  
  738.       $result = $this->get_element_styles( $args );
  739.  
  740.       extract( $result );
  741.  
  742.       $dummy_text = __( 'Grid Cell Content to demonstrate &quot;Bring To Front&quot; option', 'avia_framework' );
  743.  
  744.       foreach( $svg_list as $id => $info )
  745.       {
  746.         $svg_height = $atts[ $id . '_height' ];
  747.         $svg_max_height = $atts[ $id . '_max_height' ];
  748.  
  749.         if( ! is_numeric( $svg_height ) )
  750.         {
  751.           $svg_height = is_numeric( $svg_max_height ) ? $svg_max_height : 100;
  752.         }
  753.  
  754.         $dummy_dist = $svg_height > 30 ? 20 : 5;
  755.         $dummy_height = $svg_height + 20;
  756.  
  757.         $style_col = array(
  758.                 'height'  => max( $svg_height + 120, 150 ) . 'px'
  759.               );
  760.  
  761.         $style_dummy = array(
  762.                 'height'      => $dummy_height . 'px',
  763.                 'line-height' => $dummy_height . 'px',
  764.                 'display'     => 'flex',
  765.                 'flex-flow'   => 'row nowrap',
  766.                 'justify-content' => 'space-between',
  767.               );
  768.  
  769.         $style_dummy_cell = array(
  770.                 'border'      =>  '1px solid #666',
  771.                 'flex'        =>  '1 1 50%',
  772.               );
  773.  
  774.         if( 'top' == $info['location'] )
  775.         {
  776.           $class = 'av-top-divider';
  777.           $element_styling->add_styles( 'preview-column-top', $style_col );
  778.           $element_styling->add_styles( 'preview-dummy-top', array( 'top' => $dummy_dist . 'px' ) );
  779.           $element_styling->add_styles( 'preview-dummy-top', $style_dummy );
  780.           $element_styling->add_styles( 'preview-dummy-top-cell', $style_dummy_cell );
  781.         }
  782.         else
  783.         {
  784.           $class = 'av-bottom-divider';
  785.           $element_styling->add_styles( 'preview-column-bottom', $style_col );
  786.           $element_styling->add_styles( 'preview-dummy-bottom', array( 'bottom' => $dummy_dist . 'px' ) );
  787.           $element_styling->add_styles( 'preview-dummy-bottom', $style_dummy );
  788.           $element_styling->add_styles( 'preview-dummy-bottom-cell', $style_dummy_cell );
  789.         }
  790.  
  791.         $selectors = array(
  792.                 'preview-column-top'  => ".av-layout-grid-container.{$element_id}.av-top-divider",
  793.                 'preview-column-bottom' => ".av-layout-grid-container.{$element_id}.av-bottom-divider",
  794.                 'preview-dummy-top'   => ".av-layout-grid-container.{$element_id}.av-top-divider .av-dummy-text",
  795.                 'preview-dummy-bottom'  => ".av-layout-grid-container.{$element_id}.av-bottom-divider .av-dummy-text",
  796.                 'preview-dummy-top-cell'   => ".av-layout-grid-container.{$element_id}.av-top-divider .av-dummy-text div",
  797.                 'preview-dummy-bottom-cell'   => ".av-layout-grid-container.{$element_id}.av-bottom-divider .av-dummy-text div",
  798.               );
  799.  
  800.  
  801.         $element_styling->add_selectors( $selectors );
  802.  
  803.         $style_tag = $element_styling->get_style_tag( $element_id );
  804.  
  805.         $html  = '';
  806.         $html .= $style_tag;
  807.         $html .= "<div class='svg-shape-container av-layout-grid-container {$element_id} {$class}'>";
  808.  
  809.         if( ! empty( $atts[ $id ] ) )
  810.         {
  811.           $html .= AviaSvgShapes()->get_svg_dividers( $atts, $element_styling, $info['location'] );
  812.         }
  813.  
  814.         $html .=    '<div class="av-dummy-text">';
  815.         $html .=      '<div><p>' . esc_html( $dummy_text ) . '</p></div>';
  816.         $html .=      '<div><p>' . esc_html( $dummy_text ) . '</p></div>';
  817.         $html .=    '</div>';
  818.  
  819.         $html .= '</div>';
  820.  
  821.         $svg_list[ $id ]['html'] = $html;
  822.       }
  823.  
  824.  
  825.       return $svg_list;
  826.     }
  827.  
  828.  
  829.         /**
  830.          * Frontend Shortcode Handler
  831.          *
  832.          * @param array $atts array of attributes
  833.          * @param string $content text within enclosing form of shortcode element
  834.          * @param string $shortcodename the shortcode found, when == callback name
  835.          * @return string $output returns the modified html string
  836.          */
  837.         public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '' )
  838.         {
  839.             $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) );
  840.  
  841.             extract( $result );
  842.             extract( $atts );
  843.  
  844.             avia_sc_grid_row::$count++;
  845.  
  846.             $params = array();
  847.  
  848.             $params['open_structure'] = false;
  849.             $params['id'] = AviaHelper::save_string( $id, '-', 'av-layout-grid-' . avia_sc_grid_row::$count );
  850.             $params['custom_markup'] = $meta['custom_markup'];
  851.             $params['aria_label'] = $meta['aria_label'];
  852.             $params['data'] = '';
  853.  
  854.             if( $min_height_percent != '' )
  855.             {
  856.                 $params['data'] .= " data-av_minimum_height_pc='{$min_height_percent}'";
  857.             }
  858.  
  859.             //we dont need a closing structure if the element is the first one or if a previous fullwidth element was displayed before
  860.             if( isset($meta['index'] ) && $meta['index'] == 0)
  861.             {
  862.                 $params['close'] = false;
  863.             }
  864.  
  865.             if( ! empty( $meta['siblings']['prev']['tag'] ) && in_array( $meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section ) )
  866.             {
  867.                 $params['close'] = false;
  868.             }
  869.  
  870.             $params['class']  = $element_styling->get_class_string( 'section' );
  871.             $params['class'] .= ' ' . $element_styling->responsive_classes_string( 'hide_element', $atts );
  872.  
  873.       $params['svg_dividers'] = AviaSvgShapes()->get_svg_dividers( $atts, $element_styling );
  874.  
  875.             //  execute content
  876.             $cells_content = ShortcodeHelper::avia_remove_autop( $content, true );
  877.  
  878.             if( $fold_type != '' )
  879.             {
  880.                 $hide = $element_styling->responsive_classes_string( 'hide_element', $atts );
  881.                 $fold_section_class = $element_styling->get_class_string( 'fold-section' );
  882.                 $fold_section_data = $element_styling->get_data_attributes_json_string( 'fold-section', 'fold_unfold' );
  883.                
  884.                 $args = [
  885.                         'atts'          => $atts,
  886.                         'wrapper_class' => "av-grid-row-fold-btn-wrap av-fold-btn-padding {$hide}",
  887.                         'context'       => __CLASS__
  888.                     ];
  889.  
  890.                 $params['before_new']  =    "<div id='{$params['id']}-fold-unfold' class='avia-fold-unfold-section {$fold_section_class} {$atts['color']}' {$fold_section_data}>";
  891.                 $params['before_new'] .=        '<div class="av-fold-unfold-container folded"></div>';
  892.                 $params['before_new'] .=        aviaFrontTemplates::fold_unfold_button( $args );
  893.                 $params['before_new'] .=    '</div>';
  894.             }
  895.  
  896.             $style_tag = $element_styling->get_style_tag( $element_id );
  897.  
  898.             $output  = '';
  899.             $output .= $style_tag;
  900.  
  901.             $output .= avia_new_section( $params );
  902.             $output .=      $cells_content;
  903.             $output .= avia_section_after_element_content( $meta , 'after_grid_row_' . avia_sc_grid_row::$count, false );
  904.  
  905.  
  906.             // added to fix https://kriesi.at/support/topic/footer-disseapearing/#post-427764
  907.             avia_sc_section::$close_overlay = '';
  908.  
  909.             return $output;
  910.         }
  911.     }
  912. }
  913.  
  914.  
Advertisement
Add Comment
Please, Sign In to add comment