Guest User

section.php

a guest
Aug 16th, 2018
20
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /**
  3. * Color Section
  4. *
  5. * Shortcode creates a section with unique background image and colors for better content sepearation
  6. */
  7.  
  8. // Don't load directly
  9. if ( !defined('ABSPATH') ) { die('-1'); }
  10.  
  11.  
  12.  
  13. if ( !class_exists( 'avia_sc_section' ) )
  14. {
  15. class avia_sc_section extends aviaShortcodeTemplate{
  16.  
  17. static $section_count = 0;
  18. static $add_to_closing = "";
  19. static $close_overlay = "";
  20.  
  21.  
  22. /**
  23. * Create the config array for the shortcode button
  24. */
  25. function shortcode_insert_button()
  26. {
  27. $this->config['type'] = 'layout';
  28. $this->config['self_closing'] = 'no';
  29. $this->config['contains_text'] = 'no';
  30.  
  31. $this->config['name'] = __('Color Section', 'avia_framework' );
  32. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-section.png";
  33. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  34. $this->config['order'] = 20;
  35. $this->config['shortcode'] = 'av_section';
  36. $this->config['html_renderer'] = false;
  37. $this->config['tinyMCE'] = array('disable' => "true");
  38. $this->config['tooltip'] = __('Creates a section with unique background image and colors', 'avia_framework' );
  39. $this->config['drag-level'] = 1;
  40. $this->config['drop-level'] = 1;
  41. $this->config['preview'] = false;
  42.  
  43. }
  44.  
  45.  
  46. /**
  47. * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  48. * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  49. * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  50. *
  51. *
  52. * @param array $params this array holds the default values for $content and $args.
  53. * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  54. */
  55.  
  56. function editor_element($params)
  57. {
  58. extract($params);
  59. $name = $this->config['shortcode'];
  60. $data['shortcodehandler'] = $this->config['shortcode'];
  61. $data['modal_title'] = $this->config['name'];
  62. $data['modal_ajax_hook'] = $this->config['shortcode'];
  63. $data['dragdrop-level'] = $this->config['drag-level'];
  64. $data['allowed-shortcodes'] = $this->config['shortcode'];
  65. $data['preview'] = !empty($this->config['preview']) ? $this->config['preview'] : 0;
  66.  
  67. $title_id = !empty($args['id']) ? ": ".ucfirst($args['id']) : "";
  68.  
  69. // add background color or gradient to indicator
  70. $el_bg = "";
  71.  
  72. if( empty( $args['background'] ) || ( $args['background'] == 'bg_color' ) )
  73. {
  74. $el_bg = !empty($args['custom_bg']) ? " style='background:".$args['custom_bg'].";'" : "";
  75. }
  76. else {
  77. if ($args['background_gradient_color1'] && $args['background_gradient_color2']) {
  78. $el_bg = "style='background:linear-gradient(".$args['background_gradient_color1'].",".$args['background_gradient_color2'].");'";
  79. }
  80. }
  81.  
  82.  
  83.  
  84. $hidden_el_active = !empty($args['av_element_hidden_in_editor']) ? "av-layout-element-closed" : "";
  85.  
  86. if(!empty($this->config['modal_on_load']))
  87. {
  88. $data['modal_on_load'] = $this->config['modal_on_load'];
  89. }
  90.  
  91. $dataString = AviaHelper::create_data_string($data);
  92.  
  93. $output = "<div class='avia_layout_section {$hidden_el_active} avia_pop_class avia-no-visual-updates ".$name." av_drag' ".$dataString.">";
  94.  
  95. $output .= " <div class='avia_sorthandle menu-item-handle'>";
  96. $output .= " <span class='avia-element-title'><span class='avia-element-bg-color' ".$el_bg."></span>".$this->config['name']."<span class='avia-element-title-id'>".$title_id."</span></span>";
  97. //$output .= " <a class='avia-new-target' href='#new-target' title='".__('Move Section','avia_framework' )."'>+</a>";
  98. $output .= " <a class='avia-delete' href='#delete' title='".__('Delete Section','avia_framework' )."'>x</a>";
  99. $output .= " <a class='avia-toggle-visibility' href='#toggle' title='".__('Show/Hide Section','avia_framework' )."'></a>";
  100.  
  101. if(!empty($this->config['popup_editor']))
  102. {
  103. $output .= " <a class='avia-edit-element' href='#edit-element' title='".__('Edit Section','avia_framework' )."'>edit</a>";
  104. }
  105. $output .= "<a class='avia-save-element' href='#save-element' title='".__('Save Element as Template','avia_framework' )."'>+</a>";
  106. $output .= " <a class='avia-clone' href='#clone' title='".__('Clone Section','avia_framework' )."' >".__('Clone Section','avia_framework' )."</a></div>";
  107. $output .= " <div class='avia_inner_shortcode avia_connect_sort av_drop' data-dragdrop-level='".$this->config['drop-level']."'>";
  108. $output .= "<textarea data-name='text-shortcode' cols='20' rows='4'>".ShortcodeHelper::create_shortcode_by_array($name, $content, $args)."</textarea>";
  109. if($content)
  110. {
  111. $content = $this->builder->do_shortcode_backend($content);
  112. }
  113. $output .= $content;
  114. $output .= "</div>";
  115.  
  116. $output .= "<div class='avia-layout-element-bg' ".$this->get_bg_string($args)."></div>";
  117.  
  118.  
  119. $output .= "<a class='avia-layout-element-hidden' href='#'>".__('Section content hidden. Click here to show it','avia_framework')."</a>";
  120.  
  121. $output .= "</div>";
  122.  
  123. return $output;
  124. }
  125.  
  126.  
  127. function get_bg_string($args)
  128. {
  129. $style = "";
  130.  
  131. if(!empty($args['attachment']))
  132. {
  133. $image = false;
  134. $src = wp_get_attachment_image_src($args['attachment'], $args['attachment_size']);
  135. if(!empty($src[0])) $image = $src[0];
  136.  
  137.  
  138. if($image)
  139. {
  140. $bg = !empty($args['custom_bg']) ? $args['custom_bg'] : "transparent"; $bg = "transparent";
  141. $pos = !empty($args['position']) ? $args['position'] : "center center";
  142. $repeat = !empty($args['repeat']) ? $args['repeat'] : "no-repeat";
  143. $extra = "";
  144.  
  145. if($repeat == "stretch")
  146. {
  147. $repeat = "no-repeat";
  148. $extra = "background-size: cover;";
  149. }
  150.  
  151. if($repeat == "contain")
  152. {
  153. $repeat = "no-repeat";
  154. $extra = "background-size: contain;";
  155. }
  156.  
  157.  
  158.  
  159. $style = "style='background: $bg url($image) $repeat $pos; $extra'";
  160. }
  161. }
  162.  
  163. return $style;
  164. }
  165.  
  166.  
  167.  
  168.  
  169.  
  170. /**
  171. * Popup Elements
  172. *
  173. * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  174. * opens a modal window that allows to edit the element properties
  175. *
  176. * @return void
  177. */
  178. function popup_elements()
  179. {
  180. global $avia_config;
  181.  
  182. $this->elements = array(
  183.  
  184. array(
  185. "type" => "tab_container", 'nodescription' => true
  186. ),
  187.  
  188. array(
  189. "type" => "tab",
  190. "name" => __("Section Layout",'avia_framework' ),
  191. 'nodescription' => true
  192. ),
  193.  
  194.  
  195. array(
  196. "name" => __("Section Minimum Height",'avia_framework' ),
  197. "id" => "min_height",
  198. "desc" => __("Define a minimum height for the section. Content within the section will be centered vertically within the section",'avia_framework' ),
  199. "type" => "select",
  200. "std" => "",
  201. "subtype" => array( __('No minimum height, use content within section to define Section height','avia_framework' ) =>'',
  202. __('At least 100&percnt; of Browser Window height','avia_framework' )=>'100',
  203. __('At least 75&percnt; of Browser Window height','avia_framework' ) =>'75',
  204. __('At least 50&percnt; of Browser Window height','avia_framework' ) =>'50',
  205. __('At least 25&percnt; of Browser Window height','avia_framework' ) =>'25',
  206. __('Custom height in pixel','avia_framework' ) =>'custom',
  207. )
  208. ),
  209.  
  210. array(
  211. "name" => __("Section custom height", 'avia_framework' ),
  212. "desc" => __("Define a minimum height for the section. Use a pixel value. eg: 500px", 'avia_framework' ) ,
  213. "id" => "min_height_px",
  214. "required"=> array('min_height','equals','custom'),
  215. "std" => "500px",
  216. "type" => "input"),
  217.  
  218.  
  219. array(
  220. "name" => __("Section Padding",'avia_framework' ),
  221. "id" => "padding",
  222. "desc" => __("Define the sections top and bottom padding",'avia_framework' ),
  223. "type" => "select",
  224. "std" => "default",
  225. "subtype" => array( __('No Padding','avia_framework' ) =>'no-padding',
  226. __('Small Padding','avia_framework' ) =>'small',
  227. __('Default Padding','avia_framework' ) =>'default',
  228. __('Large Padding','avia_framework' ) =>'large',
  229. __('Huge Padding','avia_framework' ) =>'huge',
  230. )
  231. ),
  232.  
  233.  
  234. array(
  235. "name" => __("Section Top Border Styling",'avia_framework' ),
  236. "id" => "shadow",
  237. "desc" => __("Choose a border styling for the top of your section",'avia_framework' ),
  238. "type" => "select",
  239. "std" => "no-border-styling",
  240. "subtype" => array( __('Display a simple 1px top border','avia_framework' ) =>'no-shadow',
  241. __('Display a small styling shadow at the top of the section','avia_framework' ) =>'shadow',
  242. __('No border styling','avia_framework' ) =>'no-border-styling',
  243. )
  244. ),
  245.  
  246.  
  247. array(
  248. "name" => __("Section Bottom Border Styling",'avia_framework' ),
  249. "id" => "bottom_border",
  250. "desc" => __("Choose a border styling for the bottom of your section",'avia_framework' ),
  251. "type" => "select",
  252. "std" => "no-border-styling",
  253. "subtype" => array(
  254. __('No border styling','avia_framework' ) =>'no-border-styling',
  255. __('Display a small arrow that points down to the next section','avia_framework' ) =>'border-extra-arrow-down',
  256. __('Diagonal section border','avia_framework' ) =>'border-extra-diagonal',
  257. )
  258. ),
  259.  
  260.  
  261. array(
  262. "name" => __("Diagonal Border: Color", 'avia_framework' ),
  263. "desc" => __("Select a custom background color for your Section border here. ", 'avia_framework' ),
  264. "id" => "bottom_border_diagonal_color",
  265. "type" => "colorpicker",
  266. "container_class" => "av_third av_third_first",
  267. "required" => array('bottom_border','contains','diagonal'),
  268. "std" => "#333333",
  269. ),
  270.  
  271. array(
  272. "name" => __("Diagonal Border: Direction",'avia_framework' ),
  273. "desc" => __("Set the direction of the diagonal border", 'avia_framework' ),
  274. "id" => "bottom_border_diagonal_direction",
  275. "type" => "select",
  276. "std" => "scroll",
  277. "container_class" => "av_third",
  278. "required" => array('bottom_border','contains','diagonal'),
  279. "subtype" => array(
  280. __('Slanting from left to right','avia_framework' )=>'',
  281. __('Slanting from right to left' ) =>'border-extra-diagonal-inverse',
  282.  
  283. )
  284. ),
  285.  
  286. array(
  287. "name" => __("Diagonal Border Box Style",'avia_framework' ),
  288. "desc" => __("Set the style shadow of the border", 'avia_framework' ),
  289. "id" => "bottom_border_style",
  290. "type" => "select",
  291. "std" => "scroll",
  292. "container_class" => "av_third",
  293. "required" => array('bottom_border','contains','diagonal'),
  294. "subtype" => array(
  295. __('Minimal','avia_framework' )=>'',
  296. __('Box shadow' ) =>'diagonal-box-shadow',
  297.  
  298. )
  299. ),
  300.  
  301.  
  302.  
  303.  
  304. array(
  305. "name" => __("Display a scroll down arrow", 'avia_framework' ),
  306. "desc" => __("Check if you want to show a button at the bottom of the section that takes the user to the next section by scrolling down", 'avia_framework' ) ,
  307. "id" => "scroll_down",
  308. "std" => "",
  309. "type" => "checkbox"),
  310.  
  311.  
  312. array(
  313. "name" => __("Custom Arrow Color", 'avia_framework' ),
  314. "desc" => __("Select a custom arrow color. Leave empty if you want to use the default arrow color and style", 'avia_framework' ),
  315. "id" => "custom_arrow_bg",
  316. "type" => "colorpicker",
  317. "std" => "",
  318. "required" => array('scroll_down','not',''),
  319. ),
  320.  
  321.  
  322.  
  323.  
  324. array( "name" => __("For Developers: Section ID", 'avia_framework' ),
  325. "desc" => __("Apply a custom ID Attribute to the section, so you can apply a unique style via CSS. This option is also helpful if you want to use anchor links to scroll to a sections when a link is clicked", 'avia_framework' )."<br/><br/>".
  326. __("Use with caution and make sure to only use allowed characters. No special characters can be used.", 'avia_framework' ),
  327. "id" => "id",
  328. "type" => "input",
  329. "std" => ""),
  330.  
  331. array(
  332. "type" => "close_div",
  333. 'nodescription' => true
  334. ),
  335. array(
  336. "type" => "tab",
  337. "name" => __("Section Background" , 'avia_framework'),
  338. 'nodescription' => true
  339. ),
  340.  
  341.  
  342. array(
  343. "name" => __("Section Colors",'avia_framework' ),
  344. "id" => "color",
  345. "desc" => __("The section will use the color scheme you select. Color schemes are defined on your styling page",'avia_framework' ) .
  346. '<br/><a target="_blank" href="'.admin_url('admin.php?page=avia#goto_styling').'">'.__("(Show Styling Page)",'avia_framework' )."</a>",
  347. "type" => "select",
  348. "std" => "main_color",
  349. "subtype" => array_flip($avia_config['color_sets'])
  350. ),
  351.  
  352. array(
  353. "name" => __("Background",'avia_framework' ),
  354. "desc" => __("Select the type of background for the column.", 'avia_framework' ),
  355. "id" => "background",
  356. "type" => "select",
  357. "std" => "bg_color",
  358. "subtype" => array(
  359. __('Background Color','avia_framework' )=>'bg_color',
  360. __('Background Gradient','avia_framework' ) =>'bg_gradient',
  361. )
  362. ),
  363.  
  364. array(
  365. "name" => __("Custom Background Color", 'avia_framework' ),
  366. "desc" => __("Select a custom background color for this cell here. Leave empty for default color", 'avia_framework' ),
  367. "id" => "custom_bg",
  368. "type" => "colorpicker",
  369. "required" => array('background','equals','bg_color'),
  370. "rgba" => true,
  371. "std" => "",
  372. ),
  373.  
  374. array(
  375. "name" => __("Background Gradient Color 1", 'avia_framework' ),
  376. "desc" => __("Select the first color for the gradient.", 'avia_framework' ),
  377. "id" => "background_gradient_color1",
  378. "type" => "colorpicker",
  379. "container_class" => 'av_third av_third_first',
  380. "required" => array('background','equals','bg_gradient'),
  381. "rgba" => true,
  382. "std" => "",
  383. ),
  384. array(
  385. "name" => __("Background Gradient Color 2", 'avia_framework' ),
  386. "desc" => __("Select the second color for the gradient.", 'avia_framework' ),
  387. "id" => "background_gradient_color2",
  388. "type" => "colorpicker",
  389. "container_class" => 'av_third',
  390. "required" => array('background','equals','bg_gradient'),
  391. "rgba" => true,
  392. "std" => "",
  393. ),
  394.  
  395. array(
  396. "name" => __("Background Gradient Direction",'avia_framework' ),
  397. "desc" => __("Define the gradient direction", 'avia_framework' ),
  398. "id" => "background_gradient_direction",
  399. "type" => "select",
  400. "container_class" => 'av_third',
  401. "std" => "vertical",
  402. "required" => array('background','equals','bg_gradient'),
  403. "subtype" => array(
  404. __('Vertical','avia_framework' )=>'vertical',
  405. __('Horizontal','avia_framework' ) =>'horizontal',
  406. __('Radial','avia_framework' ) =>'radial',
  407. __('Diagonal Top Left to Bottom Right','avia_framework' ) =>'diagonal_tb',
  408. __('Diagonal Bottom Left to Top Right','avia_framework' ) =>'diagonal_bt',
  409. )
  410. ),
  411.  
  412. array(
  413. "name" => __("Custom Background Image",'avia_framework' ),
  414. "desc" => __("Either upload a new, or choose an existing image from your media library. Leave empty if you want to use the background image of the color scheme defined above",'avia_framework' ),
  415. "id" => "src",
  416. "type" => "image",
  417. "title" => __("Insert Image",'avia_framework' ),
  418. "button" => __("Insert",'avia_framework' ),
  419. "std" => ""),
  420.  
  421. array(
  422. "name" => __("Copyright Info", 'avia_framework' ),
  423. "desc" => __("Use the media manager to add/edit the copyright info.", 'avia_framework' ),
  424. "id" => "copyright",
  425. "type" => "select",
  426. "std" => "",
  427. "required" => array('src','not',''),
  428. "subtype" => array(
  429. __('No', 'avia_framework' ) =>'',
  430. __('Yes, always display copyright info', 'avia_framework' ) =>'always',
  431. __('Yes, display icon and reaveal copyright info on hover', 'avia_framework' ) =>'icon-reveal',
  432. )
  433. ),
  434.  
  435. array(
  436. "name" => __("Background Attachment",'avia_framework' ),
  437. "desc" => __("Background can either scroll with the page, be fixed or scroll with a parallax motion", 'avia_framework' ),
  438. "id" => "attach",
  439. "type" => "select",
  440. "std" => "scroll",
  441. "required" => array('src','not',''),
  442. "subtype" => array(
  443. __('Scroll','avia_framework' )=>'scroll',
  444. __('Fixed','avia_framework' ) =>'fixed',
  445. __('Parallax','avia_framework' ) =>'parallax'
  446.  
  447. )
  448. ),
  449.  
  450. array(
  451. "name" => __("Background Image Position",'avia_framework' ),
  452. "id" => "position",
  453. "type" => "select",
  454. "std" => "top left",
  455. "required" => array('src','not',''),
  456. "subtype" => array( __('Top Left','avia_framework' ) =>'top left',
  457. __('Top Center','avia_framework' ) =>'top center',
  458. __('Top Right','avia_framework' ) =>'top right',
  459. __('Bottom Left','avia_framework' ) =>'bottom left',
  460. __('Bottom Center','avia_framework' ) =>'bottom center',
  461. __('Bottom Right','avia_framework' ) =>'bottom right',
  462. __('Center Left','avia_framework' ) =>'center left',
  463. __('Center Center','avia_framework' ) =>'center center',
  464. __('Center Right','avia_framework' ) =>'center right'
  465. )
  466. ),
  467.  
  468. array(
  469. "name" => __("Background Repeat",'avia_framework' ),
  470. "id" => "repeat",
  471. "type" => "select",
  472. "std" => "no-repeat",
  473. "required" => array('src','not',''),
  474. "subtype" => array( __('No Repeat','avia_framework' ) =>'no-repeat',
  475. __('Repeat','avia_framework' ) =>'repeat',
  476. __('Tile Horizontally','avia_framework' ) =>'repeat-x',
  477. __('Tile Vertically','avia_framework' ) =>'repeat-y',
  478. __('Stretch to fit (stretches image to cover the element)','avia_framework' ) =>'stretch',
  479. __('Scale to fit (scales image so the whole image is always visible)','avia_framework' ) =>'contain'
  480. )
  481. ),
  482.  
  483.  
  484.  
  485.  
  486. array(
  487. "name" => __("Background Video", 'avia_framework' ),
  488. "desc" => __('You can also place a video as background for your section. Enter the URL to the Video. Currently supported are Youtube, Vimeo and direct linking of web-video files (mp4, webm, ogv)', 'avia_framework' ) .'<br/><br/>'.
  489. __('Working examples Youtube & Vimeo:', 'avia_framework' ).'<br/>
  490. <strong>http://vimeo.com/1084537</strong><br/>
  491. <strong>http://www.youtube.com/watch?v=5guMumPFBag</strong><br/><br/>',
  492. "id" => "video",
  493. "std" => "",
  494. "type" => "input"),
  495.  
  496. array(
  497. "name" => __("Video Aspect Ratio", 'avia_framework' ),
  498. "desc" => __("In order to calculate the correct height and width for the video slide you need to enter a aspect ratio (width:height). usually: 16:9 or 4:3.", 'avia_framework' )."<br/>".__("If left empty 16:9 will be used", 'avia_framework' ) ,
  499. "id" => "video_ratio",
  500. "required"=> array('video','not',''),
  501. "std" => "16:9",
  502. "type" => "input"),
  503.  
  504. array(
  505. "name" => __("Hide video on Mobile Devices?", 'avia_framework' ),
  506. "desc" => __("You can choose to hide the video entirely on Mobile devices and instead display the Section Background image", 'avia_framework' )."<br/><small>".__("Most mobile devices can't autoplay videos to prevent bandwidth problems for the user", 'avia_framework' ) ."</small>" ,
  507. "id" => "video_mobile_disabled",
  508. "required"=> array('video','not',''),
  509. "std" => "",
  510. "type" => "checkbox"),
  511.  
  512.  
  513. array(
  514. "type" => "close_div",
  515. 'nodescription' => true
  516. ),
  517.  
  518.  
  519.  
  520. array(
  521. "type" => "tab",
  522. "name" => __("Section Background Overlay" , 'avia_framework'),
  523. 'nodescription' => true
  524. ),
  525.  
  526. array(
  527. "name" => __("Enable Overlay?", 'avia_framework' ),
  528. "desc" => __("Check if you want to display a transparent color and/or pattern overlay above your section background image/video", 'avia_framework' ),
  529. "id" => "overlay_enable",
  530. "std" => "",
  531. "type" => "checkbox"),
  532.  
  533. array(
  534. "name" => __("Overlay Opacity",'avia_framework' ),
  535. "desc" => __("Set the opacity of your overlay: 0.1 is barely visible, 1.0 is opaque ", 'avia_framework' ),
  536. "id" => "overlay_opacity",
  537. "type" => "select",
  538. "std" => "0.5",
  539. "required" => array('overlay_enable','not',''),
  540. "subtype" => array( __('0.1','avia_framework' )=>'0.1',
  541. __('0.2','avia_framework' )=>'0.2',
  542. __('0.3','avia_framework' )=>'0.3',
  543. __('0.4','avia_framework' )=>'0.4',
  544. __('0.5','avia_framework' )=>'0.5',
  545. __('0.6','avia_framework' )=>'0.6',
  546. __('0.7','avia_framework' )=>'0.7',
  547. __('0.8','avia_framework' )=>'0.8',
  548. __('0.9','avia_framework' )=>'0.9',
  549. __('1.0','avia_framework' )=>'1',
  550. )
  551. ),
  552.  
  553. array(
  554. "name" => __("Overlay Color", 'avia_framework' ),
  555. "desc" => __("Select a custom color for your overlay here. Leave empty if you want no color overlay", 'avia_framework' ),
  556. "id" => "overlay_color",
  557. "type" => "colorpicker",
  558. "required" => array('overlay_enable','not',''),
  559. "std" => "",
  560. ),
  561.  
  562. array(
  563. "required" => array('overlay_enable','not',''),
  564. "id" => "overlay_pattern",
  565. "name" => __("Background Image", 'avia_framework'),
  566. "desc" => __("Select an existing or upload a new background image", 'avia_framework'),
  567. "type" => "select",
  568. "subtype" => array(__('No Background Image', 'avia_framework')=>'',__('Upload custom image', 'avia_framework')=>'custom'),
  569. "std" => "",
  570. "folder" => "images/background-images/",
  571. "folderlabel" => "",
  572. "group" => "Select predefined pattern",
  573. "exclude" => array('fullsize-', 'gradient')
  574. ),
  575.  
  576.  
  577. array(
  578. "name" => __("Custom Pattern",'avia_framework' ),
  579. "desc" => __("Upload your own seamless pattern",'avia_framework' ),
  580. "id" => "overlay_custom_pattern",
  581. "type" => "image",
  582. "fetch" => "url",
  583. "secondary_img"=>true,
  584. "required" => array('overlay_pattern','equals','custom'),
  585. "title" => __("Insert Pattern",'avia_framework' ),
  586. "button" => __("Insert",'avia_framework' ),
  587. "std" => ""),
  588.  
  589. array(
  590. "type" => "close_div",
  591. 'nodescription' => true
  592. ),
  593.  
  594. array(
  595. "type" => "tab",
  596. "name" => __("Screen Options",'avia_framework' ),
  597. 'nodescription' => true
  598. ),
  599.  
  600.  
  601. array(
  602. "name" => __("Element Visibility",'avia_framework' ),
  603. "desc" => __("Set the visibility for this element, based on the device screensize.", 'avia_framework' ),
  604. "type" => "heading",
  605. "description_class" => "av-builder-note av-neutral",
  606. ),
  607.  
  608. array(
  609. "desc" => __("Hide on large screens (wider than 990px - eg: Desktop)", 'avia_framework'),
  610. "id" => "av-desktop-hide",
  611. "std" => "",
  612. "container_class" => 'av-multi-checkbox',
  613. "type" => "checkbox"),
  614.  
  615. array(
  616.  
  617. "desc" => __("Hide on medium sized screens (between 768px and 989px - eg: Tablet Landscape)", 'avia_framework'),
  618. "id" => "av-medium-hide",
  619. "std" => "",
  620. "container_class" => 'av-multi-checkbox',
  621. "type" => "checkbox"),
  622.  
  623. array(
  624.  
  625. "desc" => __("Hide on small screens (between 480px and 767px - eg: Tablet Portrait)", 'avia_framework'),
  626. "id" => "av-small-hide",
  627. "std" => "",
  628. "container_class" => 'av-multi-checkbox',
  629. "type" => "checkbox"),
  630.  
  631. array(
  632.  
  633. "desc" => __("Hide on very small screens (smaller than 479px - eg: Smartphone Portrait)", 'avia_framework'),
  634. "id" => "av-mini-hide",
  635. "std" => "",
  636. "container_class" => 'av-multi-checkbox',
  637. "type" => "checkbox"),
  638.  
  639.  
  640. array(
  641. "type" => "close_div",
  642. 'nodescription' => true
  643. ),
  644.  
  645. array(
  646. "type" => "close_div",
  647. 'nodescription' => true
  648. ),
  649.  
  650.  
  651.  
  652. array( "id" => "av_element_hidden_in_editor",
  653. "type" => "hidden",
  654. "std" => "0"),
  655. );
  656. }
  657.  
  658. /**
  659. * Frontend Shortcode Handler
  660. *
  661. * @param array $atts array of attributes
  662. * @param string $content text within enclosing form of shortcode element
  663. * @param string $shortcodename the shortcode found, when == callback name
  664. * @return string $output returns the modified html string
  665. */
  666. function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  667. {
  668. global $avia_config;
  669.  
  670. extract(AviaHelper::av_mobile_sizes($atts)); //return $av_font_classes, $av_title_font_classes and $av_display_classes
  671.  
  672. avia_sc_section::$section_count ++;
  673. $atts = shortcode_atts(array( 'src' => '',
  674. 'position' => 'top left',
  675. 'repeat' => 'no-repeat',
  676. 'attach' => 'scroll',
  677. 'color' => 'main_color',
  678. 'background' => '',
  679. 'custom_bg' => '',
  680. 'background_gradient_color1' => '',
  681. 'background_gradient_color2' => '',
  682. 'background_gradient_direction' => '',
  683. 'padding'=>'default' ,
  684. 'shadow'=>'shadow',
  685. 'id'=>'',
  686. 'min_height' => '',
  687. 'min_height_px' => '',
  688. 'video' => '',
  689. 'video_ratio'=>'16:9',
  690. 'video_mobile_disabled'=>'',
  691. 'custom_markup' => '',
  692. 'attachment' => '',
  693. 'attachment_size' => '',
  694. 'bottom_border' => '',
  695. 'overlay_enable' => '',
  696. 'overlay_opacity' => '',
  697. 'overlay_color' => '',
  698. 'overlay_pattern' => '',
  699. 'overlay_custom_pattern' => '',
  700. 'scroll_down' => '',
  701. 'bottom_border_diagonal_color' => '',
  702. 'bottom_border_diagonal_direction' => '',
  703. 'bottom_border_style'=>'',
  704. 'custom_arrow_bg' => '',
  705. 'copyright' => ''
  706.  
  707. ),
  708. $atts, $this->config['shortcode']);
  709.  
  710.  
  711. extract($atts);
  712. $output = "";
  713. $class = "avia-section ".$color." avia-section-".$padding." avia-".$shadow;
  714. $background = "";
  715.  
  716.  
  717. $params['id'] = !empty($id) ? AviaHelper::save_string($id,'-') :"av_section_".avia_sc_section::$section_count;
  718. $params['custom_markup'] = $meta['custom_markup'];
  719. $params['attach'] = "";
  720.  
  721. if(!empty($attachment) && !empty($attachment_size))
  722. {
  723. $attachment_entry = get_post( $attachment );
  724.  
  725. if(!empty($attachment_entry))
  726. {
  727. if(!empty($attachment_size))
  728. {
  729. $src = wp_get_attachment_image_src($attachment_entry->ID, $attachment_size);
  730. $src = !empty($src[0]) ? $src[0] : "";
  731. }
  732. }
  733. }
  734. else
  735. {
  736. $attachment = false;
  737. }
  738.  
  739.  
  740. // background gradient
  741.  
  742. $gradient_val = "";
  743.  
  744. if ($atts['background'] == 'bg_gradient'){
  745. if ( $atts['background_gradient_color1'] && $atts['background_gradient_color2']) {
  746.  
  747. switch ($atts['background_gradient_direction']) {
  748. case 'vertical':
  749. $gradient_val .= 'linear-gradient(';
  750. break;
  751. case 'horizontal':
  752. $gradient_val .= 'linear-gradient(to right,';
  753. break;
  754. case 'radial':
  755. $gradient_val .= 'radial-gradient(';
  756. break;
  757. case 'diagonal_tb':
  758. $gradient_val .= 'linear-gradient(to bottom right,';
  759. break;
  760. case 'diagonal_bt':
  761. $gradient_val .= 'linear-gradient(45deg,';
  762. break;
  763. }
  764.  
  765. $gradient_val .= $atts['background_gradient_color1'].','.$atts['background_gradient_color2'].')';
  766.  
  767. // Fallback background color for IE9
  768. if($custom_bg == "") $background .= "background-color: {$atts['background_gradient_color1']};";
  769.  
  770. }
  771. }
  772.  
  773.  
  774. if($custom_bg != "")
  775. {
  776. $background .= "background-color: {$custom_bg}; ";
  777. }
  778.  
  779. $copyright_tag = '';
  780.  
  781. /*set background image*/
  782. if($src != "")
  783. {
  784. if ($copyright !== "") {
  785. $copyright_text = get_post_meta($attachment_entry->ID, '_avia_attachment_copyright', true );
  786. }
  787.  
  788. if ($copyright_text) {
  789. $copyright_tag = "<small class='avia-copyright'>{$copyright_text}</small>";
  790. $class .= ' av-has-copyright';
  791. if ($copyright !== '') $class .= ' av-copyright-'.$copyright;
  792. }
  793.  
  794. if($repeat == 'stretch')
  795. {
  796. $background .= "background-repeat: no-repeat; ";
  797. $class .= " avia-full-stretch";
  798. }
  799. else if($repeat == "contain")
  800. {
  801. $background .= "background-repeat: no-repeat; ";
  802. $class .= " avia-full-contain";
  803. }
  804. else
  805. {
  806. $background .= "background-repeat: {$repeat}; ";
  807. }
  808.  
  809. $background .= "background-image: url({$src})";
  810. if ($gradient_val !== '') {
  811. $background .= ", {$gradient_val}";
  812. }
  813. $background .= ";";
  814. $background .= $attach == 'parallax' ? "background-attachment: scroll; " : "background-attachment: {$attach}; ";
  815. $background .= "background-position: {$position}; ";
  816.  
  817.  
  818.  
  819. if($attach == 'parallax')
  820. {
  821. $attachment_class = "";
  822. if($repeat == 'stretch' || $repeat == 'no-repeat' ){ $attachment_class .= " avia-full-stretch"; }
  823. if($repeat == 'contain' ){ $attachment_class .= " avia-full-contain"; }
  824.  
  825. $class .= " av-parallax-section";
  826. $speed = apply_filters('avf_parallax_speed', "0.3", $params['id']);
  827. $params['attach'] .= "<div class='av-parallax' data-avia-parallax-ratio='{$speed}' >";
  828. $params['attach'] .= "<div class='av-parallax-inner {$color} {$attachment_class}' style = '{$background}' >";
  829. $params['attach'] .= "</div>";
  830. $params['attach'] .= "</div>";
  831. $background = "";
  832. }
  833.  
  834.  
  835. $params['data'] = "data-section-bg-repeat='{$repeat}'";
  836.  
  837. }
  838. else
  839. {
  840. $attach = "scroll";
  841. $background .= "background-image: {$gradient_val}";
  842. }
  843.  
  844.  
  845. if($custom_bg != "" && $background == "")
  846. {
  847. $background .= "background-color: {$custom_bg}; ";
  848. }
  849.  
  850.  
  851.  
  852.  
  853. if($background) $background = "style = '{$background}'";
  854.  
  855.  
  856. /*check/create overlay*/
  857. $overlay = "";
  858. $pre_wrap = "<div class='av-section-color-overlay-wrap'>" ;
  859. if(!empty($overlay_enable))
  860. {
  861. $overlay_src = "";
  862. $overlay = "opacity: {$overlay_opacity}; ";
  863. if(!empty($overlay_color)) $overlay .= "background-color: {$overlay_color}; ";
  864. if(!empty($overlay_pattern))
  865. {
  866. if($overlay_pattern == "custom")
  867. {
  868. $overlay_src = $overlay_custom_pattern;
  869. }
  870. else
  871. {
  872. $overlay_src = str_replace('{{AVIA_BASE_URL}}', AVIA_BASE_URL, $overlay_pattern);
  873. }
  874. }
  875.  
  876. if(!empty($overlay_src)) $overlay .= "background-image: url({$overlay_src}); background-repeat: repeat;";
  877. $overlay = "<div class='av-section-color-overlay' style='{$overlay}'></div>";
  878. $class .= " av-section-color-overlay-active";
  879.  
  880. $params['attach'] .= $pre_wrap . $overlay;
  881.  
  882. }
  883.  
  884.  
  885.  
  886.  
  887. if(!empty($scroll_down))
  888. {
  889. $arrow_style = "";
  890. $arrow_class = "";
  891.  
  892. if(!$overlay)
  893. {
  894. $params['attach'] .= $pre_wrap;
  895. }
  896.  
  897. if(!empty($custom_arrow_bg))
  898. {
  899. $arrow_style = "style='color: {$custom_arrow_bg};'";
  900. $arrow_class = " av-custom-scroll-down-color";
  901. }
  902.  
  903. $params['attach'] .= "<a href='#next-section' title='' class='scroll-down-link {$arrow_class}' {$arrow_style} ". av_icon_string( 'scrolldown' ). "></a>";
  904. }
  905.  
  906.  
  907.  
  908. $class .= " avia-bg-style-".$attach;
  909. $params['class'] = $class." ".$meta['el_class']." ".$av_display_classes;
  910. $params['bg'] = $background;
  911. $params['min_height'] = $min_height;
  912. $params['min_height_px'] = $min_height_px;
  913. $params['video'] = $video;
  914. $params['video_ratio'] = $video_ratio;
  915. $params['video_mobile_disabled'] = $video_mobile_disabled;
  916.  
  917. if(isset($meta['index']))
  918. {
  919. if($meta['index'] == 0)
  920. {
  921. $params['main_container'] = true;
  922. }
  923.  
  924. if($meta['index'] == 0 || (isset($meta['siblings']['prev']['tag']) && in_array($meta['siblings']['prev']['tag'], AviaBuilder::$full_el_no_section )))
  925. {
  926. $params['close'] = false;
  927. }
  928. }
  929.  
  930. if($bottom_border == 'border-extra-arrow-down')
  931. {
  932. $params['class'] .= " av-arrow-down-section";
  933. }
  934.  
  935.  
  936.  
  937. $avia_config['layout_container'] = "section";
  938.  
  939. $output .= avia_new_section($params) . $copyright_tag;
  940. $output .= ShortcodeHelper::avia_remove_autop($content,true) ;
  941.  
  942. /*set extra arrow element*/
  943. if(strpos($bottom_border, 'border-extra') !== false)
  944. {
  945. $backgroundEl = "";
  946. $backgroundElColor = !empty($custom_bg) ? $custom_bg : $avia_config['backend_colors']['color_set'][$color]['bg'];
  947.  
  948. if(strpos($bottom_border, 'diagonal') !== false)
  949. {
  950. // bottom_border_diagonal_direction // bottom_border_diagonal_color
  951. $backgroundElColor = "#333333";
  952. if(isset($bottom_border_diagonal_color)) $backgroundElColor = $bottom_border_diagonal_color;
  953.  
  954. $bottom_border .= " " . $bottom_border_diagonal_direction . " " .$bottom_border_style;
  955. }
  956.  
  957.  
  958. if($backgroundElColor) $backgroundEl = " style='background-color:{$backgroundElColor};' ";
  959.  
  960. avia_sc_section::$add_to_closing = "<div class='av-extra-border-element {$bottom_border}'><div class='av-extra-border-outer'><div class='av-extra-border-inner' {$backgroundEl}></div></div></div>";
  961. }
  962. else
  963. {
  964. avia_sc_section::$add_to_closing = "";
  965. }
  966.  
  967.  
  968. //next section needs an extra closing tag if overlay with wrapper was added:
  969. if($overlay || !empty($scroll_down))
  970. {
  971. avia_sc_section::$close_overlay = "</div>";
  972. }
  973. else
  974. {
  975. avia_sc_section::$close_overlay = "";
  976. }
  977.  
  978. //if the next tag is a section dont create a new section from this shortcode
  979. if(!empty($meta['siblings']['next']['tag']) && in_array($meta['siblings']['next']['tag'], AviaBuilder::$full_el))
  980. {
  981. $skipSecond = true;
  982. }
  983.  
  984. //if there is no next element dont create a new section. if we got a sidebar always create a next section at the bottom
  985. if(empty($meta['siblings']['next']['tag']) && !avia_has_sidebar())
  986. {
  987. $skipSecond = true;
  988. }
  989.  
  990. if(empty($skipSecond))
  991. {
  992. $new_params['id'] = "after_section_".( avia_sc_section::$section_count );
  993. $output .= avia_new_section($new_params);
  994. }
  995.  
  996. unset($avia_config['layout_container']);
  997. return $output;
  998. }
  999. }
  1000. }
  1001.  
  1002.  
  1003.  
  1004. if(!function_exists('avia_new_section'))
  1005. {
  1006. function avia_new_section($params = array())
  1007. {
  1008. global $avia_section_markup, $avia_config;
  1009.  
  1010. $defaults = array( 'class'=>'main_color',
  1011. 'bg'=>'',
  1012. 'close'=>true,
  1013. 'open'=>true,
  1014. 'open_structure' => true,
  1015. 'open_color_wrap' => true,
  1016. 'data'=>'',
  1017. "style"=>'',
  1018. 'id' => "",
  1019. 'main_container' => false,
  1020. 'min_height' => '',
  1021. 'min_height_px' => '',
  1022. 'video' => '',
  1023. 'video_ratio' => '16:9',
  1024. 'video_mobile_disabled' => '',
  1025. 'attach' => "",
  1026. 'before_new' => "",
  1027. 'custom_markup' => ''
  1028. );
  1029.  
  1030.  
  1031.  
  1032. $defaults = array_merge($defaults, $params);
  1033. extract($defaults);
  1034.  
  1035. $post_class = "";
  1036. $output = "";
  1037. $bg_slider = "";
  1038. $container_style = "";
  1039. if($id) $id = "id='{$id}'";
  1040.  
  1041. //close old content structure. only necessary when previous element was a section. other fullwidth elements dont need this
  1042. if($close)
  1043. {
  1044. $cm = avia_section_close_markup();
  1045. $output .= "</div></div>{$cm}</div>".avia_sc_section::$add_to_closing.avia_sc_section::$close_overlay."</div>";
  1046. avia_sc_section::$add_to_closing = '';
  1047. avia_sc_section::$close_overlay = "";
  1048. }
  1049. //start new
  1050. if($open)
  1051. {
  1052. if(function_exists('avia_get_the_id')) $post_class = "post-entry-".avia_get_the_id();
  1053.  
  1054. if($open_color_wrap)
  1055. {
  1056. if(!empty($min_height))
  1057. {
  1058. $class .= " av-minimum-height av-minimum-height-".$min_height;
  1059. if($min_height == 'custom' && $min_height_px != "")
  1060. {
  1061. $min_height_px = (int)$min_height_px;
  1062. $container_style = "style='height:{$min_height_px}px'";
  1063. }
  1064. }
  1065.  
  1066. if(!empty($video))
  1067. {
  1068. $slide = array(
  1069. 'shortcode' => 'av_slideshow',
  1070. 'content' => '',
  1071. 'attr' => array( 'id'=>'',
  1072. 'video'=>$video ,
  1073. 'slide_type' => 'video',
  1074. 'video_mute' => true,
  1075. 'video_loop' => true,
  1076. 'video_ratio' => $video_ratio,
  1077. 'video_controls' => 'disabled',
  1078. 'video_section_bg' => true,
  1079. 'video_format'=> '',
  1080. 'video_mobile' =>'',
  1081. 'video_mobile_disabled'=> $video_mobile_disabled
  1082. )
  1083. );
  1084.  
  1085.  
  1086. $bg_slider = new avia_slideshow( array('content' => array($slide) ) );
  1087. $bg_slider->set_extra_class('av-section-video-bg');
  1088. $class .= " av-section-with-video-bg";
  1089. $class .= !empty($video_mobile_disabled) ? " av-section-mobile-video-disabled" : "";
  1090. $data .= " data-section-video-ratio='{$video_ratio}'";
  1091.  
  1092. }
  1093. $output .= $before_new;
  1094.  
  1095. if($class == "main_color") $class .= " av_default_container_wrap";
  1096.  
  1097. $output .= "<div {$id} class='{$class} container_wrap ".avia_layout_class( 'main' , false )."' {$bg} {$data} {$style}>";
  1098. $output .= !empty($bg_slider) ? $bg_slider->html() : "";
  1099. $output .= $attach;
  1100. $output .= apply_filters('avf_section_container_add','',$defaults);
  1101. }
  1102.  
  1103.  
  1104. //this applies only for sections. other fullwidth elements dont need the container for centering
  1105. if($open_structure)
  1106. {
  1107. if(!empty($main_container))
  1108. {
  1109. $markup = 'main '.avia_markup_helper(array('context' =>'content','echo'=>false, 'custom_markup'=>$custom_markup));
  1110. $avia_section_markup = 'main';
  1111. }
  1112. else
  1113. {
  1114. $markup = "div";
  1115. }
  1116.  
  1117. $output .= "<div class='container' {$container_style}>";
  1118. $output .= "<{$markup} class='template-page content ".avia_layout_class( 'content' , false )." units'>";
  1119. $output .= "<div class='post-entry post-entry-type-page {$post_class}'>";
  1120. $output .= "<div class='entry-content-wrapper clearfix'>";
  1121. }
  1122. }
  1123. return $output;
  1124.  
  1125. }
  1126. }
  1127.  
  1128.  
  1129.  
  1130. if(!function_exists('avia_section_close_markup'))
  1131. {
  1132. function avia_section_close_markup()
  1133. {
  1134. global $avia_section_markup, $avia_config;
  1135.  
  1136. if(!empty($avia_section_markup))
  1137. {
  1138. $avia_section_markup = false;
  1139. $close_markup = "</main><!-- close content main element -->";
  1140.  
  1141. }
  1142. else
  1143. {
  1144. $close_markup = "</div><!-- close content main div -->";
  1145. }
  1146.  
  1147. return $close_markup;
  1148. }
  1149. }
  1150.  
  1151. if(!function_exists('avia_section_after_element_content'))
  1152. {
  1153. function avia_section_after_element_content($meta, $second_id = "", $skipSecond = false, $extra = "")
  1154. {
  1155. $output = "</div>"; //close section
  1156. $output .= $extra;
  1157.  
  1158. //if the next tag is a section dont create a new section from this shortcode
  1159. if(!empty($meta['siblings']['next']['tag']) && in_array($meta['siblings']['next']['tag'], AviaBuilder::$full_el )){ $skipSecond = true; }
  1160.  
  1161. //if there is no next element dont create a new section.
  1162. if(empty($meta['siblings']['next']['tag'])) { $skipSecond = true; }
  1163.  
  1164. if(empty($skipSecond)) { $output .= avia_new_section(array('close'=>false, 'id' => $second_id)); }
  1165.  
  1166. return $output;
  1167. }
  1168. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×