Guenni007

cell

Sep 2nd, 2025 (edited)
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 41.58 KB | None | 0 0
  1. <?php
  2. /**
  3.  * COLUMNS
  4.  *
  5.  * Shortcode which creates columns for better content separation
  6.  * Modified: Padding now applies to .flex_cell_inner instead of .flex_cell
  7.  */
  8.  
  9.  // Don't load directly
  10. if( ! defined( 'ABSPATH' ) ) { die( '-1' ); }
  11.  
  12.  
  13.  
  14. if( ! class_exists( 'avia_sc_cell', false ) )
  15. {
  16.   class avia_sc_cell extends aviaShortcodeTemplate
  17.   {
  18.     /**
  19.      *
  20.      * @var array
  21.      */
  22.     static $attr = array();
  23.  
  24.     /**
  25.      * All available column width sizes
  26.      *
  27.      * @since 4.2.1
  28.      * @var array
  29.      */
  30.     static private $size_array = array(
  31.                   'av_cell_one_full'    => '1/1',
  32.                   'av_cell_one_half'    => '1/2',
  33.                   'av_cell_one_third'   => '1/3',
  34.                   'av_cell_one_fourth'  => '1/4',
  35.                   'av_cell_one_fifth'   => '1/5',
  36.                   'av_cell_two_third'   => '2/3',
  37.                   'av_cell_three_fourth'  => '3/4',
  38.                   'av_cell_two_fifth'   => '2/5',
  39.                   'av_cell_three_fifth' => '3/5',
  40.                   'av_cell_four_fifth'  => '4/5'
  41.                 );
  42.  
  43.     /**
  44.      * Define the width for a cell
  45.      *
  46.      * @since 4.2.1
  47.      * @var array
  48.      */
  49.     static protected $size_width = array(
  50.                   'av_cell_one_full'    => 1.0,
  51.                   'av_cell_one_half'    => 0.5,
  52.                   'av_cell_one_third'   => 0.33,
  53.                   'av_cell_one_fourth'  => 0.25,
  54.                   'av_cell_one_fifth'   => 0.2,
  55.                   'av_cell_two_third'   => 0.66,
  56.                   'av_cell_three_fourth'  => 0.75,
  57.                   'av_cell_two_fifth'   => 0.4,
  58.                   'av_cell_three_fifth'   => 0.6,
  59.                   'av_cell_four_fifth'  => 0.8
  60.                 );
  61.  
  62.     /**
  63.      * This constructor is implicity called by all derived classes
  64.      * To avoid duplicating code we put this in the constructor
  65.      *
  66.      * @since 4.2.1
  67.      * @param AviaBuilder $builder
  68.      */
  69.     public function __construct( $builder )
  70.     {
  71.       parent::__construct( $builder );
  72.  
  73.       $this->config['version']      = '1.0';
  74.       $this->config['type']       = 'layout';
  75.       $this->config['self_closing']   = 'no';
  76.       $this->config['contains_text']    = 'no';
  77.       $this->config['contains_layout']  = 'yes';
  78.       $this->config['contains_content'] = 'yes';
  79. //      $this->config['first_in_row']   = 'first';
  80.     }
  81.  
  82.     /**
  83.      * Create the config array for the shortcode button
  84.      */
  85.     protected function shortcode_insert_button()
  86.     {
  87.       $this->config['invisible']  = true;
  88.       $this->config['name']   = '1/1';
  89.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-full.png';
  90.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  91.       $this->config['order']    = 100;
  92.       $this->config['target']   = 'avia-section-drop';
  93.       $this->config['shortcode']  = 'av_cell_one_full';
  94.       $this->config['html_renderer']  = false;
  95.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  96.       $this->config['tooltip']  = __( 'Creates a single full width column', 'avia_framework' );
  97.       $this->config['drag-level'] = 2;
  98.       $this->config['drop-level'] = 1;
  99.     }
  100.  
  101.     /**
  102.      * Popup Elements
  103.      *
  104.      * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  105.      * opens a modal window that allows to edit the element properties
  106.      *
  107.      * @return void
  108.      */
  109.     protected function popup_elements()
  110.     {
  111.  
  112.       $this->elements = array(
  113.  
  114.         array(
  115.             'type'  => 'tab_container',
  116.             'nodescription' => true
  117.           ),
  118.  
  119.         array(
  120.             'type'  => 'tab',
  121.             'name'  => __( 'Layout' , 'avia_framework' ),
  122.             'nodescription' => true
  123.           ),
  124.  
  125.           array(
  126.                 'type'      => 'template',
  127.                 'template_id' => $this->popup_key( 'layout_alignment' )
  128.               ),
  129.  
  130.         array(
  131.             'type'  => 'tab_close',
  132.             'nodescription' => true
  133.           ),
  134.  
  135.         array(
  136.             'type'  => 'tab',
  137.             'name'  => __( 'Styling', 'avia_framework' ),
  138.             'nodescription' => true
  139.           ),
  140.  
  141.           array(
  142.               'type'      => 'template',
  143.               'template_id' => 'toggle_container',
  144.               'templates_include' => array(
  145.                           $this->popup_key( 'styling_padding' ),
  146.                           $this->popup_key( 'styling_background' ),
  147.                           $this->popup_key( 'layout_svg_dividers' )
  148.                         ),
  149.               'nodescription' => true
  150.             ),
  151.  
  152.         array(
  153.             'type'  => 'tab_close',
  154.             'nodescription' => true
  155.           ),
  156.  
  157.         array(
  158.             'type'  => 'tab',
  159.             'name'  => __( 'Advanced', 'avia_framework' ),
  160.             'nodescription' => true
  161.           ),
  162.  
  163.           array(
  164.               'type'  => 'toggle_container',
  165.               'nodescription' => true
  166.             ),
  167.  
  168.             array(
  169.                 'type'      => 'template',
  170.                 'template_id' => $this->popup_key( 'advanced_link' )
  171.               ),
  172.  
  173.             array(
  174.                 'type'      => 'template',
  175.                 'template_id' => 'columns_visibility_toggle'
  176.               ),
  177.  
  178.             array(
  179.                 'type'      => 'template',
  180.                 'template_id' => 'developer_options_toggle',
  181.                 'args'      => array( 'sc' => $this )
  182.               ),
  183.  
  184.           array(
  185.               'type'  => 'toggle_container_close',
  186.               'nodescription' => true
  187.             ),
  188.  
  189.         array(
  190.             'type'  => 'tab_close',
  191.             'nodescription' => true
  192.           ),
  193.  
  194.         array(
  195.             'type'  => 'tab_container_close',
  196.             'nodescription' => true
  197.           )
  198.  
  199.       );
  200.     }
  201.  
  202.     /**
  203.      * Create and register templates for easier maintainance
  204.      *
  205.      * @since 4.6.4
  206.      */
  207.     protected function register_dynamic_templates()
  208.     {
  209.       /**
  210.        * Layout Tab
  211.        * ===========
  212.        */
  213.  
  214.       $c = array(
  215.             array(
  216.               'name'  => __( 'Vertical Align', 'avia_framework' ),
  217.               'desc'  => __( 'Choose the vertical alignment of your cells content.', 'avia_framework' ),
  218.               'id'  => 'vertical_align',
  219.               'type'  => 'select',
  220.               'std'   => 'top',
  221.               'subtype' => array(
  222.                         __( 'Top', 'avia_framework' )   => 'top',
  223.                         __( 'Middle', 'avia_framework' )  => 'middle',
  224.                         __( 'Bottom', 'avia_framework' )  => 'bottom',
  225.                       )
  226.             )
  227.  
  228.         );
  229.  
  230.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_alignment' ), $c, true );
  231.  
  232.       /**
  233.        * Styling Tab
  234.        * ===========
  235.        */
  236.  
  237.       $c = array(
  238.             array(
  239.               'type'      => 'template',
  240.               'template_id' => 'margin_padding',
  241.               'content'   => array( 'padding' ),
  242.               'name'      => __( 'Cell Padding', 'avia_framework' ),
  243.               'desc'      => __( 'Set the distance from the cell content to the border here. Theme default is 30px.', 'avia_framework' ),
  244.               'lockable'    => true
  245.             )
  246.         );
  247.  
  248.       $template = array(
  249.               array(
  250.                 'type'      => 'template',
  251.                 'template_id' => 'toggle',
  252.                 'title'     => __( 'Padding', 'avia_framework' ),
  253.                 'content'   => $c
  254.               ),
  255.           );
  256.  
  257.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_padding' ), $template, true );
  258.  
  259.  
  260.       $c = array(
  261.              array(
  262.               'name'    => __( 'Background', 'avia_framework' ),
  263.               'desc'    => __( 'Select the type of background for the column.', 'avia_framework' ),
  264.               'id'    => 'background',
  265.               'type'    => 'select',
  266.               'std'   => 'bg_color',
  267.               'subtype' => array(
  268.                         __( 'Background Color', 'avia_framework' )    => 'bg_color',
  269.                         __( 'Background Gradient', 'avia_framework' ) => 'bg_gradient',
  270.                       )
  271.             ),
  272.  
  273.             array(
  274.               'name'    => __( 'Custom Background Color', 'avia_framework' ),
  275.               'desc'    => __( 'Select a custom background color for this cell here. Leave empty for default color', 'avia_framework' ),
  276.               'id'    => 'background_color',
  277.               'type'    => 'colorpicker',
  278.               'rgba'    => true,
  279.               'required'  => array( 'background', 'equals', 'bg_color' ),
  280.               'std'   => '',
  281.             ),
  282.  
  283.             array(
  284.               'type'      => 'template',
  285.               'template_id' => 'gradient_colors',
  286.               'id'      => array( 'background_gradient_direction', 'background_gradient_color1', 'background_gradient_color2', 'background_gradient_color3' ),
  287.               'lockable'    => true,
  288.               'required'    => array( 'background', 'equals', 'bg_gradient' ),
  289.               'container_class' => array( '', 'av_third av_third_first', 'av_third', 'av_third' ),
  290.             ),
  291.  
  292.             array(
  293.               'name'    => __( 'Custom Background Image', 'avia_framework' ),
  294.               'desc'    => __( "Either upload a new, or choose an existing image from your media library. Leave empty if you don't want to use a background image.", 'avia_framework' ),
  295.               'id'    => 'src',
  296.               'type'    => 'image',
  297.               'title'   => __( 'Insert Image', 'avia_framework' ),
  298.               'button'  => __( 'Insert', 'avia_framework' ),
  299.               'std'   => ''
  300.             ),
  301.  
  302.             array(
  303.               'name'    => __( 'Background Attachment', 'avia_framework' ),
  304.               'desc'    => __( 'Background can either scroll with the page or be fixed', 'avia_framework' ),
  305.               'id'    => 'background_attachment',
  306.               'type'    => 'select',
  307.               'std'   => 'scroll',
  308.               'required'  => array( 'src', 'not', '' ),
  309.               'subtype' => array(
  310.                         __( 'Scroll', 'avia_framework' )              => 'scroll',
  311.                         __( 'Fixed (relative to the viewport)', 'avia_framework' )  => 'fixed',
  312.                         __( 'Local (relative to cell)', 'avia_framework' )      => 'local'
  313.               )
  314.             ),
  315.  
  316.             array(
  317.               'type'      => 'template',
  318.               'template_id' => 'background_image_position'
  319.             )
  320.  
  321.         );
  322.  
  323.       $template = array(
  324.               array(
  325.                 'type'      => 'template',
  326.                 'template_id' => 'toggle',
  327.                 'title'     => __( 'Background', 'avia_framework' ),
  328.                 'content'   => $c
  329.               ),
  330.           );
  331.  
  332.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'styling_background' ), $template, true );
  333.  
  334.  
  335. // new insertion dividers
  336.       $template = array(
  337.               array(
  338.                 'type'      => 'template',
  339.                 'template_id' => 'svg_divider_toggle',
  340.                 'lockable'    => true
  341.               )
  342.           );
  343.  
  344.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'layout_svg_dividers' ), $template );
  345.  
  346.  
  347.  
  348.       /**
  349.        * Advanced Tab
  350.        * ============
  351.        */
  352.  
  353.       $c = array(
  354.             array(
  355.               'type'      => 'template',
  356.               'template_id' => 'linkpicker_toggle',
  357.               'name'      => __( 'Cell Link', 'avia_framework' ),
  358.               'desc'      => __( 'Select where this cell should link to', 'avia_framework' ),
  359.               'subtypes'    => array( 'no', 'manually', 'single', 'taxonomy' ),
  360.               'no_toggle'   => true,
  361.               'title_attr'  => true
  362.             ),
  363.  
  364.             array(
  365.               'name'      => __( 'Hover Effect', 'avia_framework' ),
  366.               'desc'      => __( 'Choose if you want to have a hover effect on the column', 'avia_framework' ),
  367.               'id'      => 'link_hover',
  368.               'type'      => 'select',
  369.               'required'    => array( 'link', 'not', '' ),
  370.               'std'     => '',
  371.               'subtype'   => array(
  372.                           __( 'No', 'avia_framework' )  => '',
  373.                           __( 'Yes', 'avia_framework' ) => 'opacity80'
  374.                       )
  375.             )
  376.  
  377.  
  378.         );
  379.  
  380.       $template = array(
  381.               array(
  382.                 'type'      => 'template',
  383.                 'template_id' => 'toggle',
  384.                 'title'     => __( 'Column Link', 'avia_framework' ),
  385.                 'content'   => $c
  386.               ),
  387.           );
  388.  
  389.       AviaPopupTemplates()->register_dynamic_template( $this->popup_key( 'advanced_link' ), $template, true );
  390.  
  391.     }
  392.  
  393.     /**
  394.      * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  395.      * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  396.      * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  397.      *
  398.      * @param array $params     holds the default values for $content and $args.
  399.      * @return array        usually holds an innerHtml key that holds item specific markup.
  400.      */
  401.     public function editor_element( $params )
  402.     {
  403.  
  404.       extract( $params );
  405.  
  406.       if( empty( $data ) || ! is_array( $data ) )
  407.       {
  408.         $data = array();
  409.       }
  410.  
  411.       $name = $this->config['shortcode'];
  412.       $drag = $this->config['drag-level'];
  413.       $drop = $this->config['drop-level'];
  414.  
  415.       $data['shortcodehandler']   = $this->config['shortcode'];
  416.       $data['modal_title']    = __( 'Edit Cell','avia_framework' );
  417.       $data['modal_ajax_hook']  = $this->config['shortcode'];
  418.       $data['dragdrop-level']   = $this->config['drag-level'];
  419.       $data['allowed-shortcodes'] = $this->config['shortcode'];
  420.       $data['closing_tag']    = $this->is_self_closing() ? 'no' : 'yes';
  421.  
  422.       if( ! empty( $this->config['modal_on_load'] ) )
  423.       {
  424.         $data['modal_on_load']  = $this->config['modal_on_load'];
  425.       }
  426.  
  427.       $dataString  = AviaHelper::create_data_string( $data );
  428.  
  429.       // add background color or gradient to indicator
  430.       $el_bg = '';
  431.  
  432.       if( empty( $args['background'] ) || ( $args['background'] == 'bg_color' ) )
  433.       {
  434.         $el_bg = ! empty( $args['background_color'] ) ? " style='background:{$args['background_color']};'" : '';
  435.       }
  436.       else
  437.       {
  438.         if( $args['background_gradient_color1'] && $args['background_gradient_color2'] )
  439.         {
  440.           $el_bg = "style='background:linear-gradient({$args['background_gradient_color1']},{$args['background_gradient_color2']});'";
  441.         }
  442.       }
  443.  
  444.       $output  = "<div class='avia_layout_column avia_layout_cell avia_pop_class avia-no-visual-updates {$name} av_drag' {$dataString} data-width='{$name}'>";
  445.       $output .=    "<div class='avia_sorthandle'>";
  446.  
  447.       $output .=      "<span class='avia-col-size'><span class='avia-element-bg-color' {$el_bg}></span>" . avia_sc_cell::$size_array[ $name ] . '</span>';
  448.       $output .=      "<a class='avia-delete'  href='#delete' title='" . __( 'Delete Cell', 'avia_framework' ) . "'>x</a>";
  449.       $output .=      "<a class='avia-clone'  href='#clone' title='" . __( 'Clone Cell', 'avia_framework' ) . "' >" . __( 'Clone Cell', 'avia_framework' ) . '</a>';
  450.  
  451.       if( ! empty( $this->config['popup_editor'] ) )
  452.       {
  453.         $output .= "    <a class='avia-edit-element'  href='#edit-element' title='" . __( 'Edit Cell', 'avia_framework' ) . "'>" . __( 'edit', 'avia_framework' ) . '</a>';
  454.       }
  455.  
  456.       $output .=    '</div>';
  457.       $output .=    "<div class='avia_inner_shortcode avia_connect_sort av_drop ' data-dragdrop-level='{$drop}'><span class='av-fake-cellborder'></span>";
  458.       $output .=      "<textarea data-name='text-shortcode' cols='20' rows='4'>" . ShortcodeHelper::create_shortcode_by_array( $name, $content, $args ) . '</textarea>';
  459.  
  460.       if( $content )
  461.       {
  462.         $output .=    $this->builder->do_shortcode_backend( $content );
  463.       }
  464.  
  465.       $output .=    '</div>';
  466.       $output .=    "<div class='avia-layout-element-bg' " . $this->get_bg_string( $args ) . "></div>";
  467.       $output .=  '</div>';
  468.  
  469.       return $output;
  470.     }
  471.  
  472.     /**
  473.      * Returns the width of the cells. As this is the base class for all cells we only need to implement it here.
  474.      *
  475.      * @since 4.2.1
  476.      * @return float
  477.      */
  478.     public function get_element_width()
  479.     {
  480.       return isset( avia_sc_cell::$size_width[ $this->config['shortcode'] ] ) ? avia_sc_cell::$size_width[ $this->config['shortcode'] ] : 1.0;
  481.     }
  482.  
  483.     /**
  484.      * Only needed for backend canvas
  485.      *
  486.      * @param array $args
  487.      * @return string
  488.      */
  489.     protected function get_bg_string( $args )
  490.     {
  491.       $style = '';
  492.  
  493.       if( ! empty( $args['attachment'] ) )
  494.       {
  495.         $image = false;
  496.         $src = wp_get_attachment_image_src( $args['attachment'], $args['attachment_size'] );
  497.         if( ! empty( $src[0] ) )
  498.         {
  499.           $image = $src[0];
  500.         }
  501.  
  502.         if( $image )
  503.         {
  504.           $element_styling = new aviaElementStyling( $this, 'xxx' );
  505.  
  506.           $bg = ! empty( $args['background_color'] ) ? $args['background_color'] : 'transparent';
  507.           $pos = $element_styling->background_position_string( $args['background_position'], 'center center' );
  508.           $repeat = ! empty( $args['background_repeat'] ) ? $args['background_repeat'] : 'no-repeat';
  509.           $extra = '';
  510.  
  511.           if( $repeat == 'stretch' )
  512.           {
  513.             $repeat = 'no-repeat';
  514.             $extra = 'background-size: cover;';
  515.           }
  516.  
  517.           if( $repeat == 'contain' )
  518.           {
  519.             $repeat = 'no-repeat';
  520.             $extra = 'background-size: contain;';
  521.           }
  522.  
  523.           $style = "style='background: {$bg} url($image) {$repeat} {$pos}; {$extra}'";
  524.         }
  525.  
  526.       }
  527.  
  528.       return $style;
  529.     }
  530.  
  531.     /**
  532.      * Create custom stylings
  533.      *
  534.      * @since 4.8.7
  535.      * @param array $args
  536.      * @return array
  537.      */
  538.     protected function get_element_styles( array $args )
  539.     {
  540.       $result = parent::get_element_styles( $args );
  541.  
  542.       extract( $result );
  543.  
  544.       $default = array(
  545.             'vertical_align'    => '',
  546.             'padding'       => '',
  547.             'background'                    => 'bg_color',
  548.             'background_gradient_color1'    => '',
  549.             'background_gradient_color2'      => '',
  550.             'background_gradient_direction'     => '',
  551.             'background_color'                => '',
  552.             'background_position'   => '',
  553.             'background_repeat'   => '',
  554.             'background_attachment' => '',
  555.             'fetch_image'     => '',
  556.             'attachment_size'   => '',
  557.             'attachment'      => '',
  558.             'link'          => '',
  559.             'linktarget'      => '',
  560.             'link_hover'      => '',
  561.             'mobile_display'    => '',
  562.             'mobile_col_pos'    => 0,
  563.             'svg_dividers'   => ''
  564.           );
  565.  
  566.       $default = $this->sync_sc_defaults_array( $default, 'no_modal_item', 'no_content' );
  567.  
  568.       $atts = shortcode_atts( $default, $atts, $this->config['shortcode'] );
  569.  
  570.       //  fallback - prior 4.8.7 '0px' was handled this way
  571.       if( $atts['padding'] == '0px' || $atts['padding'] == '0' || $atts['padding'] == '0%' )
  572.       {
  573.         $atts['padding'] = '0px';
  574.       }
  575.  
  576.       $element_styling->create_callback_styles( $atts );
  577.  
  578.       $classes = array(
  579.             'flex_cell',
  580.             $element_id,
  581.             'av-gridrow-cell',
  582.             str_replace( 'av_cell_', 'av_', $shortcodename ),
  583.             'no_margin',
  584.             $atts['mobile_display']
  585.           );
  586.  
  587.       $element_styling->add_classes( 'container', $classes );
  588.       $element_styling->add_classes_from_array( 'container', $meta, 'el_class' );
  589.  
  590.       if( ! empty( $atts['vertical_align'] ) )
  591.       {
  592.         $element_styling->add_classes( 'container', "content-align-{$atts['vertical_align']}" );
  593.         $element_styling->add_styles( 'container', array(
  594.                         'vertical-align'  => $atts['vertical_align']
  595.                     ) );
  596.       }
  597.  
  598.       if( ! empty( avia_sc_cell::$attr['mobile_column_order'] ) && 'individual' == avia_sc_cell::$attr['mobile_column_order'] )
  599.       {
  600.         $element_styling->add_styles( 'container', array( 'order' => $atts['mobile_col_pos'] ) );
  601.       }
  602.  
  603.       if( ! empty( avia_sc_cell::$attr['min_height'] ) && empty( avia_sc_cell::$attr['min_height_percent'] ) )
  604.       {
  605.         $min = (int) avia_sc_cell::$attr['min_height'];
  606.         $element_styling->add_styles( 'container', array(
  607.                         'height'    => $min . 'px',
  608.                         'min-height'  => $min . 'px'
  609.                     ) );
  610.       }
  611.  
  612.  
  613. //  SVG Dividers
  614.       $element_styling->add_classes( 'divider-top', array( 'avia-divider-svg', 'avia-divider-svg-' . $atts['svg_div_top'] ) );
  615.       $element_styling->add_classes( 'divider-bottom', array( 'avia-divider-svg', 'avia-divider-svg-' . $atts['svg_div_bottom'] ) );
  616.  
  617.       $element_styling->add_callback_styles( 'divider-top-svg', array( 'svg_div_top_svg', 'svg_div_top_color' ) );
  618.       $element_styling->add_callback_styles( 'divider-bottom-svg', array( 'svg_div_bottom_svg', 'svg_div_bottom_color' ) );
  619.  
  620.       $element_styling->add_callback_classes( 'divider-top', array( 'svg_div_top' ) );
  621.       $element_styling->add_callback_classes( 'divider-bottom', array( 'svg_div_bottom' ) );
  622.  
  623.  
  624.       /**
  625.        * MODIFIKATION: Padding-Behandlung für .flex_cell_inner
  626.        * =====================================================
  627.        */
  628.      
  629.       // Füge Klassen für .flex_cell_inner hinzu
  630.       $inner_classes = array();
  631.      
  632.       //  fallback - prior 4.8.7 '0px' was handled this way
  633.       if( $atts['padding'] == '0px' )
  634.       {
  635.         $inner_classes[] = 'av-zero-padding';
  636.       }
  637.  
  638.       $element_styling->add_classes( 'inner', $inner_classes );
  639.  
  640.       /**
  641.        * Allow fallback to ignore responsive padding in case a page/site gets broken
  642.        *
  643.        * @since 5.3
  644.        * @param boolean $disable_responsive_padding
  645.        * @param array $atts
  646.        * @param array $result
  647.        * @param aviaShortcodeTemplate $this
  648.        * @return false|mixed            anything not false to fallback
  649.        */
  650.       $disable_responsive_padding = apply_filters( 'avf_disable_grid_cells_responsive_padding', false, $atts, $result, $this );
  651.  
  652.       // MODIFIKATION: Padding jetzt auf 'inner' statt 'container'
  653.       if( false !== $disable_responsive_padding )
  654.       {
  655.         //  fallback
  656.         $element_styling->add_callback_styles( 'inner', array( 'padding' ) );
  657.       }
  658.       else
  659.       {
  660.         $element_styling->add_responsive_styles( 'inner-padding', 'padding', $atts, $this, '!important' );
  661.       }
  662.  
  663.       /**
  664.        * Style Background (bleibt auf .flex_cell)
  665.        * =========================================
  666.        */
  667.       if( ! empty( $atts['attachment'] ) )
  668.       {
  669.         $src = wp_get_attachment_image_src( $atts['attachment'], $atts['attachment_size'] );
  670.         if( ! empty( $src[0] ) )
  671.         {
  672.           $atts['fetch_image'] = $src[0];
  673.         }
  674.       }
  675.  
  676.       if( $atts['background_repeat'] == 'stretch' )
  677.       {
  678.         $element_styling->add_classes( 'container', 'avia-full-stretch' );
  679.         $atts['background_repeat'] = 'no-repeat';
  680.       }
  681.  
  682.       if( $atts['background_repeat'] == 'contain' )
  683.       {
  684.         $element_styling->add_classes( 'container', 'avia-full-contain' );
  685.         $atts['background_repeat'] = 'no-repeat';
  686.       }
  687.  
  688.       // background image, color and gradient
  689.       $bg_image = '';
  690.  
  691.       if( ! empty( $atts['fetch_image'] ) )
  692.       {
  693.         $bg_pos = $element_styling->background_position_string( $atts['background_position'] );
  694.         $bg_image = "url({$atts['fetch_image']}) {$bg_pos} {$atts['background_repeat']} {$atts['background_attachment']}";
  695.       }
  696.  
  697.       if( $atts['background'] != 'bg_gradient' )
  698.       {
  699.         if( ! empty( $bg_image ) )
  700.         {
  701.           $element_styling->add_styles( 'container', array( 'background' => "{$bg_image} {$atts['background_color']}" ) );
  702.         }
  703.         else if( ! empty( $atts['background_color'] ) )
  704.         {
  705.           $element_styling->add_styles( 'container', array( 'background-color' => $atts['background_color'] ) );
  706.         }
  707.       }
  708.       // assemble gradient declaration
  709.       else if( ! empty( $atts['background_gradient_color1'] ) && ! empty( $atts['background_gradient_color2'] ) )
  710.       {
  711.         // fallback background color for IE9
  712.         $element_styling->add_styles( 'container', array( 'background-color' => $atts['background_gradient_color1'] ) );
  713.  
  714.         if( empty( $bg_image ) )
  715.         {
  716.           $element_styling->add_callback_styles( 'container', array( 'background_gradient_direction' ) );
  717.         }
  718.         else
  719.         {
  720.           $gradient_val_array = $element_styling->get_callback_settings( 'background_gradient_direction', 'styles' );
  721.           $gradient_val = isset( $gradient_val_array['background'] ) ? $gradient_val_array['background'] : '';
  722.  
  723.           //  ',' is needed !!!
  724.           $gradient_style = ! empty( $gradient_val ) ? "{$bg_image}, {$gradient_val}" : $bg_image;
  725.  
  726.           $element_styling->add_styles( 'container', array( 'background' => $gradient_style ) );
  727.         }
  728.       }
  729.       else
  730.       {
  731.         //  fallback to image and first gradient color
  732.         if( ! empty( $bg_image ) )
  733.         {
  734.           $element_styling->add_styles( 'container', array( 'background' => "{$bg_image} {$atts['background_gradient_color1']}" ) );
  735.         }
  736.         else if( ! empty( $atts['background_gradient_color1'] ) )
  737.         {
  738.           $element_styling->add_styles( 'container', array( 'background-color' => $atts['background_gradient_color1'] ) );
  739.         }
  740.       }
  741.  
  742.  
  743.  
  744.  
  745.       // MODIFIKATION: Erweiterte Selektoren für .flex_cell_inner
  746.       $selectors = array(
  747.             'container'     => ".flex_cell.{$element_id}",
  748.             'inner'             => ".flex_cell.{$element_id} .flex_cell_inner",
  749.  
  750.             'divider-top-div'     => ".flex_cell.{$element_id} .avia-divider-svg-top",
  751.             'divider-bottom-div'  => ".flex_cell.{$element_id} .avia-divider-svg-bottom",
  752.             'divider-top-svg'     => ".flex_cell.{$element_id} .avia-divider-svg-top svg",
  753.             'divider-bottom-svg'  => ".flex_cell.{$element_id} .avia-divider-svg-bottom svg",
  754.  
  755.             //  see grid.css !!!
  756.             'inner-padding'     => ".responsive #top #wrap_all .flex_cell.{$element_id} .flex_cell_inner"
  757.           );
  758.  
  759.       $element_styling->add_selectors( $selectors );
  760.  
  761.       $result['default'] = $default;
  762.       $result['atts'] = $atts;
  763.       $result['content'] = $content;
  764.       $result['element_styling'] = $element_styling;
  765.       $result['meta'] = $meta;
  766.  
  767.       return $result;
  768.     }
  769.  
  770.  
  771.  
  772.  /**
  773.      * Returns the modal popups svg divider preview windows in $svg_list
  774.      *
  775.      * @since 4.8.4
  776.      * @param array $args
  777.      * @param array $svg_list
  778.      * @return array
  779.      */
  780.     public function build_svg_divider_preview( array $args, array $svg_list )
  781.     {
  782.       //  clear content and not needed settings - we only need minimal stylings
  783.       $args['content'] = '';
  784.       unset( $args['atts']['content'] );
  785.  
  786.  
  787.       $result = $this->get_element_styles( $args );
  788.  
  789.       extract( $result );
  790.  
  791.       $dummy_text = __( 'Grid Cell Dummy Content to demonstrate &quot;Bring To Front&quot; option', 'avia_framework' );
  792.  
  793.       foreach( $svg_list as $id => $info )
  794.       {
  795.         $svg_height = $atts[ $id . '_height' ];
  796.         $svg_max_height = $atts[ $id . '_max_height' ];
  797.  
  798.         if( ! is_numeric( $svg_height ) )
  799.         {
  800.           $svg_height = is_numeric( $svg_max_height ) ? $svg_max_height : 100;
  801.         }
  802.  
  803.         $dummy_dist = $svg_height > 30 ? 20 : 5;
  804.         $dummy_height = $svg_height + 20;
  805.  
  806.         $style_col = array(
  807.                 'height'  => max( $svg_height + 120, 150 ) . 'px'
  808.               );
  809.  
  810.         $style_dummy = array(
  811.                 'height'      => $dummy_height . 'px',
  812.                 'line-height' => $dummy_height . 'px',
  813.               );
  814.  
  815.         if( 'top' == $info['location'] )
  816.         {
  817.           $class = 'av-top-divider';
  818.           $element_styling->add_styles( 'preview-column-top', $style_col );
  819.           $element_styling->add_styles( 'preview-dummy-top', array( 'top' => $dummy_dist . 'px' ) );
  820.           $element_styling->add_styles( 'preview-dummy-top', $style_dummy );
  821.         }
  822.         else
  823.         {
  824.           $class = 'av-bottom-divider';
  825.           $element_styling->add_styles( 'preview-column-bottom', $style_col );
  826.           $element_styling->add_styles( 'preview-dummy-bottom', array( 'bottom' => $dummy_dist . 'px' ) );
  827.           $element_styling->add_styles( 'preview-dummy-bottom', $style_dummy );
  828.         }
  829.  
  830.         $selectors = array(
  831.                 'preview-column-top'  => ".flex_cell.{$element_id}.av-top-divider",
  832.                 'preview-column-bottom' => ".flex_cell.{$element_id}.av-bottom-divider",
  833.                 'preview-dummy-top'   => ".flex_cell.{$element_id}.av-top-divider .av-dummy-text",
  834.                 'preview-dummy-bottom'  => ".flex_cell.{$element_id}.av-bottom-divider .av-dummy-text"
  835.               );
  836.  
  837.  
  838.         $element_styling->add_selectors( $selectors );
  839.  
  840.         $style_tag = $element_styling->get_style_tag( $element_id );
  841.  
  842.         $html  = '';
  843.         $html .= $style_tag;
  844.         $html .= "<div class='svg-shape-container flex_cell {$element_id} {$class}'>";
  845.  
  846.         if( ! empty( $atts[ $id ] ) )
  847.         {
  848.           $html .= AviaSvgShapes()->get_svg_dividers( $atts, $element_styling, $info['location'] );
  849.         }
  850.  
  851.         $html .=    '<div class="av-dummy-text">';
  852.         $html .=      '<p>' . esc_html( $dummy_text ) . '</p>';
  853.         $html .=    '</div>';
  854.  
  855.         $html .= '</div>';
  856.  
  857.         $svg_list[ $id ]['html'] = $html;
  858.       }
  859.  
  860.  
  861.       return $svg_list;
  862.     }
  863.  
  864.  
  865.     /**
  866.      * Frontend Shortcode Handler (angepasst für flex_cell_inner Klassen)
  867.      *
  868.      * @param array $atts array of attributes
  869.      * @param string $content text within enclosing form of shortcode element
  870.      * @param string $shortcodename the shortcode found, when == callback name
  871.      * @return string $output returns the modified html string
  872.      */
  873.     public function shortcode_handler( $atts, $content = '', $shortcodename = '', $meta = '')
  874.     {
  875.       global $avia_config;
  876.  
  877.       $result = $this->get_element_styles( compact( array( 'atts', 'content', 'shortcodename', 'meta' ) ) );
  878.  
  879.       extract( $result );
  880.  
  881.       $avia_config['current_column'] = str_replace( 'av_cell_', 'av_', $shortcodename );
  882.  
  883.       $link = AviaHelper::get_url( $atts['link'] );
  884.       $link_data = '';
  885.       $title_attr_markup = '';
  886.       $reader_html = '';
  887.  
  888.       if( ! empty( $link ) )
  889.       {
  890.         $element_styling->add_classes( 'container', array( 'avia-link-column', 'av-cell-link' ) );
  891.         if( ! empty( $atts['link_hover'] ) )
  892.         {
  893.           $element_styling->add_classes( 'container', 'avia-link-column-hover' );
  894.         }
  895.  
  896.         $screen_reader = '';
  897.  
  898.         $link_data .= ' data-link-column-url="' . esc_attr( $link ) . '" ';
  899.  
  900.         $title_attr_markup = AviaHelper::get_link_title_attr_markup( $atts['title_attr'] );
  901.  
  902.         if( ( strpos( $atts['linktarget'], '_blank' ) !== false ) )
  903.         {
  904.           $link_data .= ' data-link-column-target="_blank" ';
  905.           $screen_reader .= ' target="_blank" ';
  906.         }
  907.  
  908.         //  we add this, but currently not supported in js
  909.         if( strpos( $atts['linktarget'], 'nofollow' ) !== false )
  910.         {
  911.           $link_data .= ' data-link-column-rel="nofollow" ';
  912.           $screen_reader .= ' rel="nofollow" ';
  913.         }
  914.  
  915.         /**
  916.          * Add an invisible link also for screen readers
  917.          */
  918.         $reader_html .= '<a class="av-screen-reader-only" href="' . esc_attr( $link ) . '" ' . $screen_reader . '>';
  919.  
  920.         if( ! empty( $atts['title_attr'] ) )
  921.         {
  922.           $reader_html .=   esc_html( $atts['title_attr'] );
  923.         }
  924.         else
  925.         {
  926.           $reader_html .=   AviaHelper::get_screen_reader_url_text( $atts['link'] );
  927.         }
  928.  
  929.         $reader_html .= '</a>';
  930.       }
  931.  
  932.  
  933.       //  if the user uses the column shortcode without the layout builder make sure that paragraphs are applied to the text
  934.       $inner_content = ( empty( $avia_config['conditionals']['is_builder_template'] ) ) ? ShortcodeHelper::avia_apply_autop( ShortcodeHelper::avia_remove_autop( $content ) ) : ShortcodeHelper::avia_remove_autop( $content, true );
  935.  
  936.       $style_tag = $element_styling->get_style_tag( $element_id );
  937.       $container_class = $element_styling->get_class_string( 'container' );
  938.      
  939.       // MODIFIKATION: Hole die inner-Klassen
  940.       $inner_class = $element_styling->get_class_string( 'inner' );
  941.  
  942.       $output  = '';
  943.       $output .= $style_tag;
  944.       $output .= $reader_html;
  945.       $output .= "<div class='{$container_class}' {$link_data} {$title_attr_markup}>";
  946.       $output .= AviaSvgShapes()->get_svg_dividers( $atts, $element_styling, 'top' );
  947.       // MODIFIKATION: Füge die inner-Klassen hinzu
  948.       $output .=    "<div class='flex_cell_inner {$inner_class}'>";
  949.       $output .=      $inner_content;
  950.       $output .=    '</div>';
  951.       $output .= AviaSvgShapes()->get_svg_dividers( $atts, $element_styling, 'bottom' );
  952.       $output .= '</div>';
  953.  
  954.       unset( $avia_config['current_column'] );
  955.  
  956.       return $output;
  957.     }
  958.  
  959.   }
  960. }
  961.  
  962.  
  963.  
  964.  
  965. if( ! class_exists( 'avia_sc_cell_one_half', false ) )
  966. {
  967.   class avia_sc_cell_one_half extends avia_sc_cell
  968.   {
  969.  
  970.     protected function shortcode_insert_button()
  971.     {
  972.       $this->config['invisible'] = true;
  973.       $this->config['name']   = '1/2';
  974.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-half.png';
  975.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  976.       $this->config['order']    = 90;
  977.       $this->config['target']   = 'avia-section-drop';
  978.       $this->config['shortcode']  = 'av_cell_one_half';
  979.       $this->config['html_renderer']  = false;
  980.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  981.       $this->config['tooltip']  = __( 'Creates a single column with 50&percnt; width', 'avia_framework' );
  982.       $this->config['drag-level'] = 2;
  983.       $this->config['drop-level'] = 1;
  984.     }
  985.   }
  986. }
  987.  
  988.  
  989. if( ! class_exists( 'avia_sc_cell_one_third', false ) )
  990. {
  991.   class avia_sc_cell_one_third extends avia_sc_cell
  992.   {
  993.  
  994.     protected function shortcode_insert_button()
  995.     {
  996.       $this->config['invisible'] = true;
  997.       $this->config['name']   = '1/3';
  998.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-third.png';
  999.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1000.       $this->config['order']    = 80;
  1001.       $this->config['target']   = 'avia-section-drop';
  1002.       $this->config['shortcode']  = 'av_cell_one_third';
  1003.       $this->config['html_renderer']  = false;
  1004.       $this->config['tooltip']  = __( 'Creates a single column with 33&percnt; width', 'avia_framework' );
  1005.       $this->config['drag-level'] = 2;
  1006.       $this->config['drop-level'] = 1;
  1007.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1008.     }
  1009.   }
  1010. }
  1011.  
  1012. if( ! class_exists( 'avia_sc_cell_two_third', false ) )
  1013. {
  1014.   class avia_sc_cell_two_third extends avia_sc_cell
  1015.   {
  1016.  
  1017.     protected function shortcode_insert_button()
  1018.     {
  1019.       $this->config['invisible'] = true;
  1020.       $this->config['name']   = '2/3';
  1021.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-two_third.png';
  1022.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1023.       $this->config['order']    = 70;
  1024.       $this->config['target']   = 'avia-section-drop';
  1025.       $this->config['shortcode']  = 'av_cell_two_third';
  1026.       $this->config['html_renderer']  = false;
  1027.       $this->config['tooltip']  = __( 'Creates a single column with 67&percnt; width', 'avia_framework' );
  1028.       $this->config['drag-level'] = 2;
  1029.       $this->config['drop-level'] = 1;
  1030.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1031.     }
  1032.   }
  1033. }
  1034.  
  1035. if( ! class_exists( 'avia_sc_cell_one_fourth', false ) )
  1036. {
  1037.   class avia_sc_cell_one_fourth extends avia_sc_cell
  1038.   {
  1039.  
  1040.     protected function shortcode_insert_button()
  1041.     {
  1042.       $this->config['invisible'] = true;
  1043.       $this->config['name']   = '1/4';
  1044.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-fourth.png';
  1045.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1046.       $this->config['order']    = 60;
  1047.       $this->config['target']   = 'avia-section-drop';
  1048.       $this->config['shortcode']  = 'av_cell_one_fourth';
  1049.       $this->config['tooltip']  = __( 'Creates a single column with 25&percnt; width', 'avia_framework' );
  1050.       $this->config['html_renderer']  = false;
  1051.       $this->config['drag-level'] = 2;
  1052.       $this->config['drop-level'] = 1;
  1053.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1054.     }
  1055.   }
  1056. }
  1057.  
  1058. if( ! class_exists( 'avia_sc_cell_three_fourth', false ) )
  1059. {
  1060.   class avia_sc_cell_three_fourth extends avia_sc_cell
  1061.   {
  1062.  
  1063.     protected function shortcode_insert_button()
  1064.     {
  1065.       $this->config['invisible'] = true;
  1066.       $this->config['name']   = '3/4';
  1067.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-three_fourth.png';
  1068.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1069.       $this->config['order']    = 50;
  1070.       $this->config['target']   = 'avia-section-drop';
  1071.       $this->config['shortcode']  = 'av_cell_three_fourth';
  1072.       $this->config['tooltip']  = __( 'Creates a single column with 75&percnt; width', 'avia_framework' );
  1073.       $this->config['html_renderer']  = false;
  1074.       $this->config['drag-level'] = 2;
  1075.       $this->config['drop-level'] = 1;
  1076.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1077.     }
  1078.   }
  1079. }
  1080.  
  1081. if( ! class_exists( 'avia_sc_cell_one_fifth', false ) )
  1082. {
  1083.   class avia_sc_cell_one_fifth extends avia_sc_cell
  1084.   {
  1085.  
  1086.     protected function shortcode_insert_button()
  1087.     {
  1088.       $this->config['invisible'] = true;
  1089.       $this->config['name']   = '1/5';
  1090.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-fifth.png';
  1091.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1092.       $this->config['order']    = 40;
  1093.       $this->config['target']   = 'avia-section-drop';
  1094.       $this->config['shortcode']  = 'av_cell_one_fifth';
  1095.       $this->config['html_renderer']  = false;
  1096.       $this->config['tooltip']  = __( 'Creates a single column with 20&percnt; width', 'avia_framework' );
  1097.       $this->config['drag-level'] = 2;
  1098.       $this->config['drop-level'] = 1;
  1099.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1100.     }
  1101.   }
  1102. }
  1103.  
  1104. if( ! class_exists( 'avia_sc_cell_two_fifth', false ) )
  1105. {
  1106.   class avia_sc_cell_two_fifth extends avia_sc_cell
  1107.   {
  1108.  
  1109.     protected function shortcode_insert_button()
  1110.     {
  1111.       $this->config['invisible'] = true;
  1112.       $this->config['name']   = '2/5';
  1113.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-two_fifth.png';
  1114.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1115.       $this->config['order']    = 39;
  1116.       $this->config['target']   = 'avia-section-drop';
  1117.       $this->config['shortcode']  = 'av_cell_two_fifth';
  1118.       $this->config['html_renderer']  = false;
  1119.       $this->config['tooltip']  = __( 'Creates a single column with 40&percnt; width', 'avia_framework' );
  1120.       $this->config['drag-level'] = 2;
  1121.       $this->config['drop-level'] = 1;
  1122.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1123.     }
  1124.   }
  1125. }
  1126.  
  1127. if( ! class_exists( 'avia_sc_cell_three_fifth', false ) )
  1128. {
  1129.   class avia_sc_cell_three_fifth extends avia_sc_cell
  1130.   {
  1131.  
  1132.     protected function shortcode_insert_button()
  1133.     {
  1134.       $this->config['invisible'] = true;
  1135.       $this->config['name']   = '3/5';
  1136.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-three_fifth.png';
  1137.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1138.       $this->config['order']    = 38;
  1139.       $this->config['target']   = 'avia-section-drop';
  1140.       $this->config['shortcode']  = 'av_cell_three_fifth';
  1141.       $this->config['html_renderer']  = false;
  1142.       $this->config['tooltip']  = __( 'Creates a single column with 60&percnt; width', 'avia_framework' );
  1143.       $this->config['drag-level'] = 2;
  1144.       $this->config['drop-level'] = 1;
  1145.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1146.     }
  1147.   }
  1148. }
  1149.  
  1150. if( ! class_exists( 'avia_sc_cell_four_fifth', false ) )
  1151. {
  1152.   class avia_sc_cell_four_fifth extends avia_sc_cell
  1153.   {
  1154.  
  1155.     protected function shortcode_insert_button()
  1156.     {
  1157.       $this->config['invisible'] = true;
  1158.       $this->config['name']   = '4/5';
  1159.       $this->config['icon']   = AviaBuilder::$path['imagesURL'] . 'sc-four_fifth.png';
  1160.       $this->config['tab']    = __( 'Layout Elements', 'avia_framework' );
  1161.       $this->config['order']    = 37;
  1162.       $this->config['target']   = 'avia-section-drop';
  1163.       $this->config['shortcode']  = 'av_cell_four_fifth';
  1164.       $this->config['html_renderer']  = false;
  1165.       $this->config['tooltip']  = __( 'Creates a single column with 80&percnt; width', 'avia_framework' );
  1166.       $this->config['drag-level'] = 2;
  1167.       $this->config['drop-level'] = 1;
  1168.       $this->config['tinyMCE']  = array( 'disable' => 'true' );
  1169.     }
  1170.   }
  1171. }
  1172.  
  1173.  
  1174.  
Advertisement
Add Comment
Please, Sign In to add comment