Advertisement
cipher87

Change Subheading Size

Feb 12th, 2018
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.66 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Special Heading
  4.  *
  5.  * Creates a special Heading
  6.  */
  7.  
  8. // Don't load directly
  9. if ( !defined('ABSPATH') ) { die('-1'); }
  10.  
  11.  
  12.  
  13. if ( !class_exists( 'avia_sc_heading' ) )
  14. {
  15.     class avia_sc_heading extends aviaShortcodeTemplate{
  16.            
  17.             /**
  18.              * Create the config array for the shortcode button
  19.              */
  20.             function shortcode_insert_button()
  21.             {
  22.                 $this->config['self_closing']   =   'no';
  23.                
  24.                 $this->config['name']       = __('Special Heading', 'avia_framework' );
  25.                 $this->config['tab']        = __('Content Elements', 'avia_framework' );
  26.                 $this->config['icon']       = AviaBuilder::$path['imagesURL']."sc-heading.png";
  27.                 $this->config['order']      = 93;
  28.                 $this->config['target']     = 'avia-target-insert';
  29.                 $this->config['shortcode']  = 'av_heading';
  30.                 $this->config['modal_data'] = array('modal_class' => 'mediumscreen');
  31.                 $this->config['tooltip']    = __('Creates a special Heading', 'avia_framework' );
  32.                 $this->config['preview']    = true;
  33.             }
  34.            
  35.            
  36.             /**
  37.              * Popup Elements
  38.              *
  39.              * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  40.              * opens a modal window that allows to edit the element properties
  41.              *
  42.              * @return void
  43.              */
  44.             function popup_elements()
  45.             {
  46.                 $this->elements = array(
  47.                    
  48.                     array(
  49.                             "type"  => "tab_container", 'nodescription' => true
  50.                         ),
  51.                        
  52.                     array(
  53.                             "type"  => "tab",
  54.                             "name"  => __("Content" , 'avia_framework'),
  55.                             'nodescription' => true
  56.                         ),
  57.                    
  58.                     array( 
  59.                         "name"  => __("Heading Text", 'avia_framework' ),
  60.                         "id"    => "heading",
  61.                         'container_class' =>"avia-element-fullwidth",
  62.                         "std"   => __("Hello", 'avia_framework' ),
  63.                         "type"  => "input"),
  64.                        
  65.                      array(
  66.                             "name"  => __("Heading Type", 'avia_framework' ),
  67.                             "desc"  => __("Select which kind of heading you want to display.", 'avia_framework' ),
  68.                             "id"    => "tag",
  69.                             "type"  => "select",
  70.                             "std"   => "h3",
  71.                             "subtype" => array("H1"=>'h1',"H2"=>'h2',"H3"=>'h3',"H4"=>'h4',"H5"=>'h5',"H6"=>'h6')
  72.                             ),
  73.                            
  74.                    
  75.                     array( 
  76.                             "name"  => __("Heading Style", 'avia_framework' ),
  77.                             "desc"  => __("Select a heading style", 'avia_framework' ),
  78.                             "id"    => "style",
  79.                             "type"  => "select",
  80.                             "std"   => "",
  81.                             "subtype" => array( __("Default Style", 'avia_framework' )=>'',  __("Heading Style Modern (left)", 'avia_framework' )=>'blockquote modern-quote' , __("Heading Style Modern (centered)", 'avia_framework' )=>'blockquote modern-quote modern-centered', __("Heading Style Classic (centered, italic)", 'avia_framework' )=>'blockquote classic-quote')
  82.                             ),  
  83.                            
  84.                            
  85.                     array(  "name"  => __("Heading Size", 'avia_framework' ),
  86.                             "desc"  => __("Size of your Heading in Pixel", 'avia_framework' ),
  87.                             "id"    => "size",
  88.                             "type"  => "select",
  89.                             "subtype" => AviaHtmlHelper::number_array(20,90,1, array( __("Default Size", 'avia_framework' )=>'')),
  90.                             "required" => array('style','not',''),
  91.                             "std" => ""),
  92.                                                        
  93.                      array(
  94.                             "name"  => __("Subheading", 'avia_framework' ),
  95.                             "desc"  => __("Add an extra descriptive subheading above or below the actual heading", 'avia_framework' ),
  96.                             "id"    => "subheading_active",
  97.                             "type"  => "select",
  98.                             "std"   => "",
  99.                             "required" => array('style','not',''),
  100.                             "subtype" => array( __("No Subheading", 'avia_framework' )=>'',  __("Display subheading above", 'avia_framework' ) =>'subheading_above',  __("Display subheading below", 'avia_framework' )=>'subheading_below'),
  101.                             ),                               
  102.                              
  103.                     array(
  104.                         "name"  => __("Subheading Text",'avia_framework' ),
  105.                         "desc"  => __("Add your subheading here",'avia_framework' ),
  106.                         "id"    => "content",
  107.                         "type"  => "textarea",
  108.                         "required" => array('subheading_active','not',''),
  109.                         "std"   => ""),  
  110.                        
  111.                     array(  "name"  => __("Subheading Size", 'avia_framework' ),
  112.                             "desc"  => __("Size of your subeading in Pixel", 'avia_framework' ),
  113.                             "id"    => "subheading_size",
  114.                             "type"  => "select",
  115.                             "subtype" => AviaHtmlHelper::number_array(10,70,1),
  116.                             "required" => array('subheading_active','not',''),
  117.                             "std" => "15"),
  118.                                
  119.                     array(  "name"  => __("Padding Bottom", 'avia_framework' ),
  120.                             "desc"  => __("Bottom Padding in pixel", 'avia_framework' ),
  121.                             "id"    => "padding",
  122.                             "type"  => "select",
  123.                             "subtype" => AviaHtmlHelper::number_array(0,120,1),
  124.                             "std" => "10"),  
  125.                      
  126.                     array(
  127.                             "type"  => "close_div",
  128.                             'nodescription' => true
  129.                         ),
  130.                    
  131.                     array(
  132.                             "type"  => "tab",
  133.                             "name"  => __("Colors",'avia_framework' ),
  134.                             'nodescription' => true
  135.                         ),
  136.                            
  137.                     array( 
  138.                             "name"  => __("Heading Color", 'avia_framework' ),
  139.                             "desc"  => __("Select a heading color", 'avia_framework' ),
  140.                             "id"    => "color",
  141.                             "type"  => "select",
  142.                             "std"   => "",
  143.                             "subtype" => array( __("Default Color", 'avia_framework' )=>'', __("Meta Color", 'avia_framework' )=>'meta-heading', __("Custom Color", 'avia_framework' )=>'custom-color-heading')
  144.                             ),
  145.                    
  146.                     array( 
  147.                             "name"  => __("Custom Font Color", 'avia_framework' ),
  148.                             "desc"  => __("Select a custom font color for your Heading here", 'avia_framework' ),
  149.                             "id"    => "custom_font",
  150.                             "type"  => "colorpicker",
  151.                             "std"   => "",
  152.                             "required" => array('color','equals','custom-color-heading')
  153.                         ),
  154.                        
  155.                     array(
  156.                             "type"  => "close_div",
  157.                             'nodescription' => true
  158.                         ),
  159.                        
  160.                        
  161.                                 array(
  162.                                     "type"  => "tab",
  163.                                     "name"  => __("Screen Options",'avia_framework' ),
  164.                                     'nodescription' => true
  165.                                 ),
  166.                                
  167.                                
  168.                                 array(
  169.                                 "name"  => __("Element Visibility",'avia_framework' ),
  170.                                 "desc"  => __("Set the visibility for this element, based on the device screensize.", 'avia_framework' ),
  171.                                 "type"  => "heading",
  172.                                 "description_class" => "av-builder-note av-neutral",
  173.                                 ),
  174.                            
  175.                                 array( 
  176.                                         "desc"  => __("Hide on large screens (wider than 990px - eg: Desktop)", 'avia_framework'),
  177.                                         "id"    => "av-desktop-hide",
  178.                                         "std"   => "",
  179.                                         "container_class" => 'av-multi-checkbox',
  180.                                         "type"  => "checkbox"),
  181.                                
  182.                                 array( 
  183.                                    
  184.                                         "desc"  => __("Hide on medium sized screens (between 768px and 989px - eg: Tablet Landscape)", 'avia_framework'),
  185.                                         "id"    => "av-medium-hide",
  186.                                         "std"   => "",
  187.                                         "container_class" => 'av-multi-checkbox',
  188.                                         "type"  => "checkbox"),
  189.                                        
  190.                                 array( 
  191.                                    
  192.                                         "desc"  => __("Hide on small screens (between 480px and 767px - eg: Tablet Portrait)", 'avia_framework'),
  193.                                         "id"    => "av-small-hide",
  194.                                         "std"   => "",
  195.                                         "container_class" => 'av-multi-checkbox',
  196.                                         "type"  => "checkbox"),
  197.                                        
  198.                                 array( 
  199.                                    
  200.                                         "desc"  => __("Hide on very small screens (smaller than 479px - eg: Smartphone Portrait)", 'avia_framework'),
  201.                                         "id"    => "av-mini-hide",
  202.                                         "std"   => "",
  203.                                         "container_class" => 'av-multi-checkbox',
  204.                                         "type"  => "checkbox"),
  205.                                    
  206.                                
  207.                                    
  208.                                 array(
  209.                                     "name"  => __("Heading Font Size",'avia_framework' ),
  210.                                     "desc"  => __("Set the font size for the heading, based on the device screensize.", 'avia_framework' ),
  211.                                     "type"  => "heading",
  212.                                     "description_class" => "av-builder-note av-neutral",
  213.                                     ),
  214.                                        
  215.                                     array(  "name"  => __("Font Size for medium sized screens", 'avia_framework' ),
  216.                                     "id"    => "av-medium-font-size-title",
  217.                                     "type"  => "select",
  218.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'' , __("Hidden", 'avia_framework' )=>'hidden' ), "px"),
  219.                                     "std" => ""),
  220.                                    
  221.                                     array(  "name"  => __("Font Size for small screens", 'avia_framework' ),
  222.                                     "id"    => "av-small-font-size-title",
  223.                                     "type"  => "select",
  224.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'', __("Hidden", 'avia_framework' )=>'hidden'), "px"),
  225.                                     "std" => ""),
  226.                                    
  227.                                     array(  "name"  => __("Font Size for very small screens", 'avia_framework' ),
  228.                                     "id"    => "av-mini-font-size-title",
  229.                                     "type"  => "select",
  230.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'', __("Hidden", 'avia_framework' )=>'hidden'), "px"),
  231.                                     "std" => ""),
  232.                                    
  233.                                    
  234.                                 array(
  235.                                     "name"  => __("Subheading Font Size",'avia_framework' ),
  236.                                     "desc"  => __("Set the font size for the subheading, based on the device screensize.", 'avia_framework' ),
  237.                                     "type"  => "heading",
  238.                                     "description_class" => "av-builder-note av-neutral",
  239.                                     ),
  240.                                        
  241.                                     array(  "name"  => __("Font Size for medium sized screens", 'avia_framework' ),
  242.                                     "id"    => "av-medium-font-size",
  243.                                     "type"  => "select",
  244.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'', __("Hidden", 'avia_framework' )=>'hidden'), "px"),
  245.                                     "std" => ""),
  246.                                    
  247.                                     array(  "name"  => __("Font Size for small screens", 'avia_framework' ),
  248.                                     "id"    => "av-small-font-size",
  249.                                     "type"  => "select",
  250.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'', __("Hidden", 'avia_framework' )=>'hidden'), "px"),
  251.                                     "std" => ""),
  252.                                    
  253.                                     array(  "name"  => __("Font Size for very small screens", 'avia_framework' ),
  254.                                     "id"    => "av-mini-font-size",
  255.                                     "type"  => "select",
  256.                                     "subtype" => AviaHtmlHelper::number_array(10,120,1, array( __("Default", 'avia_framework' )=>'', __("Hidden", 'avia_framework' )=>'hidden'), "px"),
  257.                                     "std" => ""),    
  258.                
  259.                            
  260.                                
  261.                             array(
  262.                                     "type"  => "close_div",
  263.                                     'nodescription' => true
  264.                                 ), 
  265.                                
  266.                                
  267.                        
  268.                        
  269.                     array(
  270.                         "type"  => "close_div",
  271.                         'nodescription' => true
  272.                     ), 
  273.                    
  274.                  
  275.                 );
  276.  
  277.             }
  278.            
  279.              
  280.             /**
  281.              * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  282.              * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  283.              * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  284.              *
  285.              *
  286.              * @param array $params this array holds the default values for $content and $args.
  287.              * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  288.              */
  289.             function editor_element($params)
  290.             {
  291.                
  292.                 $params['args'] = shortcode_atts(array('tag' => 'h3', 'padding' => '5', 'heading'=>'', 'color'=>'', 'style'=>'', 'custom_font'=>'', 'size'=>'', 'subheading_active' => '', 'subheading_size'=>'', 'custom_class'=>'', 'admin_preview_bg'=>'',
  293.                 'av-desktop-hide'=>'',
  294.                 'av-medium-hide'=>'',
  295.                 'av-small-hide'=>'',
  296.                 'av-mini-hide'=>'',
  297.                 'av-medium-font-size-title'=>'',
  298.                 'av-small-font-size-title'=>'',
  299.                 'av-mini-font-size-title'=>'',
  300.                 'av-medium-font-size'=>'',
  301.                 'av-small-font-size'=>'',
  302.                 'av-mini-font-size'=>'',
  303.                
  304.                
  305.                 ), $params['args'], $this->config['shortcode']);
  306.                
  307.                 $templateNAME   = $this->update_template("name", "{{name}}");
  308.                
  309.                 $content = stripslashes(wpautop(trim(html_entity_decode( $params['content']) )));
  310.                
  311.                 $params['class'] = "";
  312.                 $params['innerHtml']  = "<div class='avia_textblock avia_textblock_style avia-special-heading' >";
  313.                
  314.                 $params['innerHtml'] .=     "<div ".$this->class_by_arguments('tag, style, color, subheading_active' ,$params['args']).">";
  315.                 $params['innerHtml'] .=         "<div class='av-subheading-top av-subheading' data-update_with='content'>".$content."</div>";
  316.                 $params['innerHtml'] .=         "<div data-update_with='heading'>";
  317.                 $params['innerHtml'] .=         stripslashes(trim(htmlspecialchars_decode($params['args']['heading'])));
  318.                 $params['innerHtml'] .=         "</div>";
  319.                 $params['innerHtml'] .=         "<div class='av-subheading-bottom av-subheading' data-update_with='content'>".$content."</div>";
  320.                 $params['innerHtml'] .=     "</div>";
  321.                 $params['innerHtml'] .= "</div>";
  322.                 return $params;
  323.             }
  324.            
  325.             /**
  326.              * Frontend Shortcode Handler
  327.              *
  328.              * @param array $atts array of attributes
  329.              * @param string $content text within enclosing form of shortcode element
  330.              * @param string $shortcodename the shortcode found, when == callback name
  331.              * @return string $output returns the modified html string
  332.              */
  333.             function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  334.             {
  335.                
  336.                 extract(AviaHelper::av_mobile_sizes($atts)); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  337.                
  338.                 extract(shortcode_atts(array('tag' => 'h3', 'padding' => '5', 'heading'=>'', 'color'=>'', 'style'=>'', 'custom_font'=>'', 'size'=>'', 'subheading_active' => '', 'subheading_size'=>''), $atts, $this->config['shortcode']));
  339.            
  340.                 $output  = "";
  341.                 $styling = "";
  342.                 $subheading = "";
  343.                 $border_styling = "";
  344.                 $before = $after = "";
  345.                 $class   = $meta['el_class'];
  346.                 $subheading_extra = "";
  347.                
  348.                 if($heading)
  349.                 {
  350.                     // add seo markup
  351.                     $markup = avia_markup_helper(array('context' => 'entry_title','echo'=>false, 'custom_markup'=>$meta['custom_markup']));
  352.                    
  353.                     // filter heading for & symbol and convert them                
  354.                     $heading = apply_filters('avia_ampersand', wptexturize($heading));
  355.                    
  356.                     //if the heading contains a strong tag make apply a custom class that makes the rest of the font appear smaller for a better effect
  357.                     if( strpos($heading, '<strong>') !== false ) $class .= " av-thin-font";
  358.                    
  359.                     //apply the padding bottom styling
  360.                     $styling .= "padding-bottom:{$padding}px;";
  361.                    
  362.                     // if the color is a custom hex value add the styling for both border and font
  363.                     if($color == "custom-color-heading" && $custom_font)  
  364.                     {
  365.                         $styling .= "color:{$custom_font};";
  366.                         $border_styling = "style='border-color:{$custom_font}'";
  367.                         $subheading_extra = "av_custom_color";
  368.                     }
  369.                    
  370.                     // if a custom font size is set apply it to the container and also apply the inherit class so the actual heading uses the size
  371.                     if(!empty($style) && !empty($size)) { $styling .= "font-size:{$size}px;"; $class .= " av-inherit-size";}
  372.                    
  373.                     //finish up the styling string
  374.                     if(!empty($styling)) $styling = "style='{$styling}'";
  375.                    
  376.                     //check if we got a subheading
  377.                     if( !empty( $style ) && !empty( $subheading_active ) && !empty( $content ) )
  378.                     {
  379.                        
  380.                         $content = "<div class ='av-subheading av-{$subheading_active} {$subheading_extra} {$av_font_classes}' style='font-size:{$subheading_size}px;'>".ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($content) )."</div>";
  381.                    
  382.                         if($subheading_active == "subheading_above")
  383.                         {
  384.                             $before = $content;
  385.                         }
  386.                         else
  387.                         {
  388.                             $after = $content;
  389.                         }
  390.                     }
  391.                
  392.                     //html markup
  393.                     $output .= "<div {$styling} class='av-special-heading av-special-heading-{$tag} {$color} {$style} {$class} {$av_display_classes}'>";
  394.                     $output .=      $before;
  395.                     $output .=      "<{$tag} class='av-special-heading-tag {$av_title_font_classes}' $markup >{$heading}</{$tag}>";
  396.                     $output .=      $after;
  397.                     $output .=      "<div class='special-heading-border'><div class='special-heading-inner-border' {$border_styling}></div></div>";
  398.                     $output .= "</div>";
  399.                 }
  400.                
  401.                 return $output;
  402.             }
  403.            
  404.            
  405.     }
  406. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement