Advertisement
Guest User

sect

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