Advertisement
Guest User

Untitled

a guest
Nov 15th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.12 KB | None | 0 0
  1. <?php
  2. /**
  3. * COLUMNS
  4. * Shortcode which creates columns for better content separation
  5. */
  6.  
  7. // Don't load directly
  8. if ( !defined('ABSPATH') ) { die('-1'); }
  9.  
  10.  
  11.  
  12. if ( !class_exists( 'avia_sc_columns' ) )
  13. {
  14. class avia_sc_columns extends aviaShortcodeTemplate{
  15.  
  16. static $extraClass = "";
  17. static $calculated_size = 0;
  18. static $first_atts = array();
  19. static $size_array = array( 'av_one_full' => 1,
  20. 'av_one_half' => 0.5,
  21. 'av_one_third' => 0.33,
  22. 'av_one_fourth' => 0.25,
  23. 'av_one_fifth' => 0.2,
  24. 'av_one_sixth' => 0.15,
  25. 'av_two_third' => 0.66,
  26. 'av_three_fourth' => 0.75,
  27. 'av_two_fifth' => 0.4,
  28. 'av_three_fifth' => 0.6,
  29. 'av_four_fifth' => 0.8
  30. );
  31.  
  32. /**
  33. * Create the config array for the shortcode button
  34. */
  35. function shortcode_insert_button()
  36. {
  37. $this->config['name'] = '1/1';
  38. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-full.png";
  39. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  40. $this->config['order'] = 100;
  41. $this->config['target'] = "avia-section-drop";
  42. $this->config['shortcode'] = 'av_one_full';
  43. $this->config['html_renderer'] = false;
  44. $this->config['tinyMCE'] = array('instantInsert' => "[av_one_full first]Add Content here[/av_one_full]");
  45. $this->config['tooltip'] = __('Creates a single full width column', 'avia_framework' );
  46. $this->config['drag-level'] = 2;
  47. $this->config['drop-level'] = 2;
  48.  
  49. }
  50.  
  51.  
  52. /**
  53. * Editor Element - this function defines the visual appearance of an element on the AviaBuilder Canvas
  54. * Most common usage is to define some markup in the $params['innerHtml'] which is then inserted into the drag and drop container
  55. * Less often used: $params['data'] to add data attributes, $params['class'] to modify the className
  56. *
  57. *
  58. * @param array $params this array holds the default values for $content and $args.
  59. * @return $params the return array usually holds an innerHtml key that holds item specific markup.
  60. */
  61.  
  62. function editor_element($params)
  63. {
  64. extract($params);
  65.  
  66. $name = $this->config['shortcode'];
  67. $drag = $this->config['drag-level'];
  68. $drop = $this->config['drop-level'];
  69.  
  70. $size = array('av_one_full' => '1/1', 'av_one_half' => '1/2', 'av_one_third' => '1/3', 'av_one_fourth' => '1/4', 'av_one_fifth' => '1/5', 'av_one_sixth' => '1/6', 'av_two_third' => '2/3', 'av_three_fourth' => '3/4', 'av_two_fifth' => '2/5', 'av_three_fifth' => '3/5', 'av_four_fifth' => '4/5');
  71.  
  72.  
  73. $data['shortcodehandler'] = $this->config['shortcode'];
  74. $data['modal_title'] = __('Edit Column','avia_framework' );
  75. $data['modal_ajax_hook'] = $this->config['shortcode'];
  76. $data['dragdrop-level'] = $this->config['drag-level'];
  77. $data['allowed-shortcodes'] = $this->config['shortcode'];
  78.  
  79. if(!empty($this->config['modal_on_load']))
  80. {
  81. $data['modal_on_load'] = $this->config['modal_on_load'];
  82. }
  83.  
  84. $dataString = AviaHelper::create_data_string($data);
  85.  
  86. $el_bg = !empty($args['background_color']) ? " style='background:".$args['background_color'].";'" : "";
  87.  
  88. $extraClass = isset($args[0]) ? $args[0] == 'first' ? ' avia-first-col' : "" : "";
  89.  
  90. $output = "<div class='avia_layout_column avia_layout_column_no_cell avia_pop_class avia-no-visual-updates ".$name.$extraClass." av_drag' {$dataString} data-width='{$name}'>";
  91. $output .= "<div class='avia_sorthandle menu-item-handle'>";
  92.  
  93. $output .= "<a class='avia-smaller avia-change-col-size' href='#smaller' title='".__('Decrease Column Size','avia_framework' )."'>-</a>";
  94. $output .= "<span class='avia-col-size'>".$size[$name]."</span>";
  95. $output .= "<a class='avia-bigger avia-change-col-size' href='#bigger' title='".__('Increase Column Size','avia_framework' )."'>+</a>";
  96. $output .= "<a class='avia-delete' href='#delete' title='".__('Delete Column','avia_framework' )."'>x</a>";
  97. $output .= "<a class='avia-save-element' href='#save-element' title='".__('Save Element as Template','avia_framework' )."'>+</a>";
  98. //$output .= "<a class='avia-new-target' href='#new-target' title='".__('Move Element','avia_framework' )."'>+</a>";
  99. $output .= "<a class='avia-clone' href='#clone' title='".__('Clone Column','avia_framework' )."' >".__('Clone Column','avia_framework' )."</a><span class='avia-element-bg-color' ".$el_bg."></span>";
  100.  
  101. if(!empty($this->config['popup_editor']))
  102. {
  103. $output .= " <a class='avia-edit-element' href='#edit-element' title='".__('Edit Cell','avia_framework' )."'>edit</a>";
  104. }
  105.  
  106. $output .= "</div>";
  107. $output .= "<div class='avia_inner_shortcode avia_connect_sort av_drop ' data-dragdrop-level='{$drop}'>";
  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. $output .= "<div class='avia-layout-element-bg' ".$this->get_bg_string($args)."></div>";
  116. $output .= "</div>";
  117.  
  118. return $output;
  119. }
  120.  
  121. function get_bg_string($args)
  122. {
  123. $style = "";
  124.  
  125. if(!empty($args['attachment']))
  126. {
  127. $image = false;
  128. $src = wp_get_attachment_image_src($args['attachment'], $args['attachment_size']);
  129. if(!empty($src[0])) $image = $src[0];
  130.  
  131.  
  132. if($image)
  133. {
  134. $bg = !empty($args['background_color']) ? $args['background_color'] : "transparent"; $bg = "transparent";
  135. $pos = !empty($args['background_position']) ? $args['background_position'] : "center center";
  136. $repeat = !empty($args['background_repeat']) ? $args['background_repeat'] : "no-repeat";
  137. $extra = "";
  138.  
  139. if($repeat == "stretch")
  140. {
  141. $repeat = "no-repeat";
  142. $extra = "background-size: cover;";
  143. }
  144.  
  145. if($repeat == "contain")
  146. {
  147. $repeat = "no-repeat";
  148. $extra = "background-size: contain;";
  149. }
  150.  
  151.  
  152.  
  153. $style = "style='background: $bg url($image) $repeat $pos; $extra'";
  154. }
  155.  
  156. }
  157.  
  158. return $style;
  159. }
  160.  
  161.  
  162. /**
  163. * Popup Elements
  164. *
  165. * If this function is defined in a child class the element automatically gets an edit button, that, when pressed
  166. * opens a modal window that allows to edit the element properties
  167. *
  168. * @return void
  169. */
  170. function popup_elements()
  171. {
  172. global $avia_config;
  173.  
  174. $this->elements = array(
  175.  
  176. array( /*stores the "first" variable that removes margin from the first column*/
  177. "id" => 0,
  178. "std" => '',
  179. "type" => "hidden"),
  180.  
  181. array(
  182. "type" => "tab_container", 'nodescription' => true
  183. ),
  184.  
  185. array(
  186. "type" => "tab",
  187. "name" => __("Row Settings" , 'avia_framework'),
  188. 'nodescription' => true,
  189.  
  190. ),
  191.  
  192. array(
  193. "name" => __("Row Settings",'avia_framework' ),
  194. "desc" => __("Row Settings apply to all columns in this row but can only be set in the first column", 'avia_framework' ),
  195. "type" => "heading",
  196. "description_class" => "av-builder-note av-notice",
  197. "required" => array('0','equals',''),
  198. ),
  199.  
  200. array(
  201. "name" => __("Row Settings",'avia_framework' ),
  202. "desc" => __("These setting apply to all columns in this row and can only be set in the first column.", 'avia_framework' )
  203. ."<br/><strong>"
  204. . __("Please note:", 'avia_framework' )
  205. ."</strong> "
  206. . __("If you move another column into first position you will need to re-apply these settings.", 'avia_framework' ),
  207. "type" => "heading",
  208. "description_class" => "av-builder-note av-notice",
  209. "required" => array('0','not',''),
  210. ),
  211.  
  212. array(
  213. "name" => __("Equal Height Columns",'avia_framework' ),
  214. "desc" => __("Columns in this row can either have a height based on their content or all be of equal height based on the largest column ", 'avia_framework' ),
  215. "id" => "min_height",
  216. "type" => "select",
  217. "std" => "",
  218. "required" => array('0','not',''),
  219. "subtype" => array(
  220. __('Individual height','avia_framework' )=>'',
  221. __('Equal height','avia_framework' ) =>'av-equal-height-column',
  222. )
  223. ),
  224.  
  225. array(
  226. "name" => __("Vertical Alignment",'avia_framework' ),
  227. "desc" => __("If a column is larger than its content, were do you want to align the content vertically?", 'avia_framework' ),
  228. "id" => "vertical_alignment",
  229. "type" => "select",
  230. "std" => "",
  231. "required" => array('min_height','not',''),
  232. "subtype" => array(
  233. __('Top','avia_framework' )=>'av-align-top',
  234. __('Middle','avia_framework' ) =>'av-align-middle',
  235. __('Bottom','avia_framework' ) =>'av-align-bottom',
  236. )
  237. ),
  238.  
  239. array(
  240. "name" => __("Space between columns",'avia_framework' ),
  241. "desc" => __("You can remove the default space between columns here.", 'avia_framework' ),
  242. "id" => "space",
  243. "type" => "select",
  244. "std" => "",
  245. "required" => array('0','not',''),
  246. "subtype" => array(
  247. __('Space between columns','avia_framework' )=>'',
  248. __('No space between columns','avia_framework' ) =>'no_margin',
  249. )
  250. ),
  251.  
  252. array(
  253. "name" => __("Custom top and bottom margin",'avia_framework' ),
  254. "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' ),
  255. "required" => array('0','not',''),
  256. "id" => "custom_margin",
  257. "type" => "checkbox",
  258. "std" => "",
  259. ),
  260.  
  261. array(
  262. "name" => __("Custom top and bottom margin", 'avia_framework' ),
  263. "desc" => __("Set a custom top or bottom margin. Both pixel and &percnt; based values are accepted. eg: 30px, 5&percnt;", 'avia_framework' ),
  264. "id" => "margin",
  265. "type" => "multi_input",
  266. "required" => array('custom_margin','not',''),
  267. "std" => "0px",
  268. "sync" => true,
  269. "multi" => array( 'top' => __('Margin-Top','avia_framework'),
  270. 'bottom'=> __('Margin-Bottom','avia_framework'),
  271. )
  272. ),
  273.  
  274. array(
  275. "type" => "close_div",
  276. 'nodescription' => true
  277. ),
  278. array(
  279. "type" => "tab",
  280. "name" => __("Layout" , 'avia_framework'),
  281. 'nodescription' => true
  282. ),
  283.  
  284.  
  285. array(
  286. "name" => __("Inner Padding", 'avia_framework' ),
  287. "desc" => __("Set the distance from the column content to the border here. Both pixel and &percnt; based values are accepted. eg: 30px, 5&percnt;", 'avia_framework' ),
  288. "id" => "padding",
  289. "type" => "multi_input",
  290. "std" => "0px",
  291. "sync" => true,
  292. "multi" => array( 'top' => __('Padding-Top','avia_framework'),
  293. 'right' => __('Padding-Right','avia_framework'),
  294. 'bottom'=> __('Padding-Bottom','avia_framework'),
  295. 'left' => __('Padding-Left','avia_framework'),
  296. )
  297. ),
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306. array(
  307. "type" => "close_div",
  308. 'nodescription' => true
  309. ),
  310.  
  311. array(
  312. "type" => "tab",
  313. "name" => __("Border" , 'avia_framework' ),
  314. 'nodescription' => true
  315. ),
  316.  
  317.  
  318.  
  319. array(
  320. "name" => __("Border",'avia_framework' ),
  321. "desc" => __("Set the border of the column here", 'avia_framework' ),
  322. "id" => "border",
  323. "type" => "select",
  324. "std" => "",
  325. "subtype" => AviaHtmlHelper::number_array(1,40,1, array( __("None", 'avia_framework' )=>'') , 'px'),
  326. ),
  327.  
  328. array(
  329. "name" => __("Border Color", 'avia_framework' ),
  330. "desc" => __("Set a border color for this column", 'avia_framework' ),
  331. "id" => "border_color",
  332. "type" => "colorpicker",
  333. "rgba" => true,
  334. "required" => array('border','not',''),
  335. "std" => "",
  336. ),
  337.  
  338. array(
  339. "name" => __("Border Radius", 'avia_framework' ),
  340. "desc" => __("Set the border radius of the column", 'avia_framework' ),
  341. "id" => "radius",
  342. "type" => "multi_input",
  343. "std" => "0px",
  344. "sync" => true,
  345. "multi" => array( 'top' => __('Top-Left-Radius','avia_framework'),
  346. 'right' => __('Top-Right-Radius','avia_framework'),
  347. 'bottom'=> __('Bottom-Right-Radius','avia_framework'),
  348. 'left' => __('Bottom-Left-Radius','avia_framework'),
  349. )
  350. ),
  351.  
  352.  
  353.  
  354. array(
  355. "type" => "close_div",
  356. 'nodescription' => true
  357. ),
  358.  
  359. array(
  360. "type" => "tab",
  361. "name" => __("Colors" , 'avia_framework' ),
  362. 'nodescription' => true
  363. ),
  364.  
  365.  
  366. array(
  367. "name" => __("Custom Background Color", 'avia_framework' ),
  368. "desc" => __("Select a custom background color for this cell here. Leave empty for default color", 'avia_framework' ),
  369. "id" => "background_color",
  370. "type" => "colorpicker",
  371. "rgba" => true,
  372. "std" => "",
  373. ),
  374.  
  375. array(
  376. "name" => __("Custom Background Image",'avia_framework' ),
  377. "desc" => __("Either upload a new, or choose an existing image from your media library. Leave empty if you don't want to use a background image ",'avia_framework' ),
  378. "id" => "src",
  379. "type" => "image",
  380. "title" => __("Insert Image",'avia_framework' ),
  381. "button" => __("Insert",'avia_framework' ),
  382. "std" => ""),
  383.  
  384. /*
  385. array(
  386. "name" => __("Background Attachment",'avia_framework' ),
  387. "desc" => __("Background can either scroll with the page or be fixed", 'avia_framework' ),
  388. "id" => "background_attachment",
  389. "type" => "select",
  390. "std" => "scroll",
  391. "required" => array('src','not',''),
  392. "subtype" => array(
  393. __('Scroll','avia_framework' )=>'scroll',
  394. __('Fixed','avia_framework' ) =>'fixed',
  395. )
  396. ),
  397. */
  398.  
  399. array(
  400. "name" => __("Background Image Position",'avia_framework' ),
  401. "id" => "background_position",
  402. "type" => "select",
  403. "std" => "top left",
  404. "required" => array('src','not',''),
  405. "subtype" => array( __('Top Left','avia_framework' ) =>'top left',
  406. __('Top Center','avia_framework' ) =>'top center',
  407. __('Top Right','avia_framework' ) =>'top right',
  408. __('Bottom Left','avia_framework' ) =>'bottom left',
  409. __('Bottom Center','avia_framework' ) =>'bottom center',
  410. __('Bottom Right','avia_framework' ) =>'bottom right',
  411. __('Center Left','avia_framework' ) =>'center left',
  412. __('Center Center','avia_framework' ) =>'center center',
  413. __('Center Right','avia_framework' ) =>'center right'
  414. )
  415. ),
  416.  
  417. array(
  418. "name" => __("Background Repeat",'avia_framework' ),
  419. "id" => "background_repeat",
  420. "type" => "select",
  421. "std" => "no-repeat",
  422. "required" => array('src','not',''),
  423. "subtype" => array( __('No Repeat','avia_framework' ) =>'no-repeat',
  424. __('Repeat','avia_framework' ) =>'repeat',
  425. __('Tile Horizontally','avia_framework' ) =>'repeat-x',
  426. __('Tile Vertically','avia_framework' ) =>'repeat-y',
  427. __('Stretch to fit (stretches image to cover the element)','avia_framework' ) =>'stretch',
  428. __('Scale to fit (scales image so the whole image is always visible)','avia_framework' ) =>'contain'
  429. )
  430. ),
  431.  
  432.  
  433. array(
  434. "type" => "close_div",
  435. 'nodescription' => true
  436. ),
  437.  
  438.  
  439. array(
  440. "type" => "tab",
  441. "name" => __("Animation" , 'avia_framework' ),
  442. 'nodescription' => true
  443. ),
  444.  
  445. array(
  446. "name" => __("Animation",'avia_framework' ),
  447. "desc" => __("Set an animation for this element. The animation will be shown once the element appears first on screen. Animations only work in modern browsers and only on desktop computers to keep page rendering as fast as possible.",'avia_framework' ),
  448. "id" => "animation",
  449. "type" => "select",
  450. "std" => "",
  451. "subtype" => array(
  452. __('None', 'avia_framework' ) =>'',
  453.  
  454. __('Fade Animations', 'avia_framework') => array(
  455. __('Fade in', 'avia_framework' ) =>'fade-in',
  456. __('Pop up', 'avia_framework' ) =>'pop-up',
  457. ),
  458. __('Slide Animations', 'avia_framework') => array(
  459. __('Top to Bottom', 'avia_framework' ) =>'top-to-bottom',
  460. __('Bottom to Top', 'avia_framework' ) =>'bottom-to-top',
  461. __('Left to Right', 'avia_framework' ) =>'left-to-right',
  462. __('Right to Left', 'avia_framework' ) =>'right-to-left',
  463. ),
  464. __('Rotate', 'avia_framework') => array(
  465. __('Full rotation', 'avia_framework' ) =>'av-rotateIn',
  466. __('Bottom left rotation', 'avia_framework' ) =>'av-rotateInUpLeft',
  467. __('Bottom right rotation', 'avia_framework' ) =>'av-rotateInUpRight',
  468. )
  469.  
  470.  
  471.  
  472. )
  473. ),
  474.  
  475.  
  476.  
  477. array(
  478. "type" => "close_div",
  479. 'nodescription' => true
  480. ),
  481.  
  482.  
  483.  
  484.  
  485. array(
  486. "type" => "tab",
  487. "name" => __("Screen Options" , 'avia_framework'),
  488. 'nodescription' => true
  489. ),
  490.  
  491. array(
  492. "name" => __("ROW SETTING: Mobile Breaking Point",'avia_framework' ),
  493. "desc" => __("Set the screen width when columns in this row should switch to full width", 'avia_framework' ),
  494. "type" => "heading",
  495. "description_class" => "av-builder-note av-notice",
  496. "required" => array('0','not',''),
  497. ),
  498.  
  499.  
  500. array(
  501. "name" => __("Fullwidth Break Point", 'avia_framework' ),
  502. "desc" => __("The columns in this row will switch to fullwidth at this screen width ", 'avia_framework' ),
  503. "id" => "mobile_breaking",
  504. "type" => "select",
  505. "std" => "",
  506. "required" => array('0','not',''),
  507. "subtype" => array(
  508. __('On mobile devices (at a screen width of 767px or lower)','avia_framework' ) =>'',
  509. __('On tablets (at a screen width of 989px or lower)', 'avia_framework' ) =>'av-break-at-tablet',
  510. )
  511. ),
  512.  
  513. array(
  514. "name" => __("Element Visibility",'avia_framework' ),
  515. "desc" =>
  516. __("Set the visibility for this element, based on the device screensize.", 'avia_framework' )."<br><small>".
  517. __("In order to prevent breaking the layout it is only possible to change the visibility settings for columns once they take up the full screen width, which means only on mobile devices", 'avia_framework' )."</small>",
  518.  
  519. "type" => "heading",
  520. "description_class" => "av-builder-note av-neutral",
  521. ),
  522.  
  523. array(
  524. "name" => __("Mobile display", 'avia_framework' ),
  525. "desc" => __("Display settings for this element when viewed on smaller screens", 'avia_framework' ),
  526. "id" => "mobile_display",
  527. "type" => "select",
  528. "std" => "",
  529. "subtype" => array(
  530. __('Always display','avia_framework' ) =>'',
  531. __('Hide on mobile devices', 'avia_framework' ) =>'av-hide-on-mobile',
  532. )
  533. ),
  534.  
  535.  
  536. array(
  537. "type" => "close_div",
  538. 'nodescription' => true
  539. ),
  540.  
  541.  
  542.  
  543. array(
  544. "type" => "close_div",
  545. 'nodescription' => true
  546. ),
  547.  
  548.  
  549.  
  550.  
  551. );
  552. }
  553.  
  554.  
  555.  
  556.  
  557.  
  558. /**
  559. * Frontend Shortcode Handler
  560. *
  561. * @param array $atts array of attributes
  562. * @param string $content text within enclosing form of shortcode element
  563. * @param string $shortcodename the shortcode found, when == callback name
  564. * @return string $output returns the modified html string
  565. */
  566. function shortcode_handler($atts, $content = "", $shortcodename = "", $meta = "")
  567. {
  568. global $avia_config;
  569.  
  570. $avia_config['current_column'] = $shortcodename;
  571.  
  572.  
  573. $first = '';
  574. if (isset($atts[0]) && trim($atts[0]) == 'first') $first = 'first';
  575.  
  576. $atts = shortcode_atts(array(
  577. 'padding' => '',
  578. 'background_color' => '',
  579. 'background_position' => '',
  580. 'background_repeat' => '',
  581. 'background_attachment' => '',
  582. 'fetch_image' => '',
  583. 'attachment_size' => '',
  584. 'attachment' => 'scroll',
  585. 'radius' => '',
  586. 'space' => '',
  587. 'border' => '',
  588. 'border_color' => '',
  589. 'border_style' => 'solid',
  590. 'margin' => '',
  591. 'custom_margin' => '',
  592. 'min_height' => '',
  593. 'vertical_alignment' => 'av-align-top',
  594. 'animation' => '',
  595. 'mobile_display' => '',
  596. 'mobile_breaking' => ''
  597.  
  598.  
  599. ), $atts, $this->config['shortcode']);
  600.  
  601.  
  602. if($first)
  603. {
  604. avia_sc_columns::$first_atts = $atts;
  605. }
  606.  
  607.  
  608. $extraClass = "";
  609. $outer_style = "";
  610. $inner_style = "";
  611. $margin_style= "";
  612. $output = "";
  613. $extra_table_class = "";
  614. $anim_class = empty($atts['animation']) ? "" : " av-animated-generic ".$atts['animation']." ";
  615. $extraClass .= $anim_class;
  616. $extraClass .= empty($atts['mobile_display']) ? "" : " ".$atts['mobile_display']." ";
  617.  
  618.  
  619. if(!empty($atts['attachment']))
  620. {
  621. $src = wp_get_attachment_image_src($atts['attachment'], $atts['attachment_size']);
  622. if(!empty($src[0])) $atts['fetch_image'] = $src[0];
  623. }
  624.  
  625. if($atts['background_repeat'] == "stretch")
  626. {
  627. $extraClass .= " avia-full-stretch";
  628. $atts['background_repeat'] = "no-repeat";
  629. }
  630.  
  631. if($atts['background_repeat'] == "contain")
  632. {
  633. $extraClass .= " avia-full-contain";
  634. $atts['background_repeat'] = "no-repeat";
  635. }
  636.  
  637. if( !empty( avia_sc_columns::$first_atts['space'] ) )
  638. {
  639. $extraClass .= " ".avia_sc_columns::$first_atts['space'];
  640. }
  641.  
  642. if( !empty( avia_sc_columns::$first_atts['mobile_breaking'] ) )
  643. {
  644. $extraClass .= " ".avia_sc_columns::$first_atts['mobile_breaking'];
  645. $extra_table_class = " av-break-at-tablet-table";
  646. }
  647.  
  648.  
  649. if( !empty( avia_sc_columns::$first_atts['min_height'] ) )
  650. {
  651. $extraClass .= " flex_column_table_cell";
  652. $extraClass .= " ".avia_sc_columns::$first_atts['min_height']." ".avia_sc_columns::$first_atts['vertical_alignment'];
  653. }
  654. else
  655. {
  656. $extraClass .= " flex_column_div";
  657. }
  658.  
  659. if( !empty( avia_sc_columns::$first_atts['custom_margin'] ) )
  660. {
  661. $explode_margin = explode(',',avia_sc_columns::$first_atts['margin']);
  662. if(count($explode_margin) <= 1)
  663. {
  664. $explode_margin[1] = $explode_margin[0];
  665. }
  666.  
  667. $atts['margin-top'] = $explode_margin[0];
  668. $atts['margin-bottom'] = $explode_margin[1];
  669.  
  670. $margins = "";
  671. $margins .= AviaHelper::style_string($atts, 'margin-top');
  672. $margins .= AviaHelper::style_string($atts, 'margin-bottom');
  673.  
  674. if( !empty( avia_sc_columns::$first_atts['min_height'] ) )
  675. {
  676. $margin_style = AviaHelper::style_string( $margins );
  677. }
  678. else
  679. {
  680. $outer_style .= $margins;
  681. }
  682. }
  683.  
  684.  
  685.  
  686. $explode_padding = explode(',',$atts['padding']);
  687. if(count($explode_padding) > 1)
  688. {
  689. $atts['padding'] = "";
  690. foreach($explode_padding as $value)
  691. {
  692. if(empty($value)) $value = "0";
  693. $atts['padding'] .= $value ." ";
  694. }
  695. }
  696.  
  697. if($atts['padding'] == "0px" || $atts['padding'] == "0" || $atts['padding'] == "0%")
  698. {
  699. $extraClass .= " av-zero-column-padding";
  700. $atts['padding'] = "";
  701. }
  702.  
  703.  
  704. $explode_radius = explode(',',$atts['radius']);
  705. if(count($explode_radius) > 1)
  706. {
  707. $atts['radius'] = "";
  708. foreach($explode_radius as $value)
  709. {
  710. if(empty($value)) $value = "0";
  711. $atts['radius'] .= $value ." ";
  712. }
  713. }
  714.  
  715. if($atts['padding'] == "0px" || $atts['padding'] == "0" || $atts['padding'] == "0%")
  716. {
  717. $extraClass .= " av-zero-column-padding";
  718. $atts['padding'] = "";
  719. }
  720.  
  721.  
  722.  
  723.  
  724.  
  725. if(!empty($atts['fetch_image']))
  726. {
  727. $outer_style .= AviaHelper::style_string($atts, 'fetch_image', 'background-image');
  728. $outer_style .= AviaHelper::style_string($atts, 'background_position', 'background-position');
  729. $outer_style .= AviaHelper::style_string($atts, 'background_repeat', 'background-repeat');
  730. $outer_style .= AviaHelper::style_string($atts, 'background_attachment', 'background-attachment');
  731. }
  732.  
  733. if(!empty($atts['border']))
  734. {
  735. $outer_style .= AviaHelper::style_string($atts, 'border', 'border-width', 'px');
  736. $outer_style .= AviaHelper::style_string($atts, 'border_color', 'border-color');
  737. $outer_style .= AviaHelper::style_string($atts, 'border_style', 'border-style');
  738. }
  739.  
  740. $outer_style .= AviaHelper::style_string($atts, 'padding');
  741. $outer_style .= AviaHelper::style_string($atts, 'background_color', 'background-color');
  742. $outer_style .= AviaHelper::style_string($atts, 'radius', 'border-radius');
  743. $outer_style = AviaHelper::style_string($outer_style);
  744.  
  745.  
  746.  
  747.  
  748. if($first)
  749. {
  750. avia_sc_columns::$calculated_size = 0;
  751.  
  752. if(!empty($meta['siblings']['prev']['tag']) &&
  753. in_array($meta['siblings']['prev']['tag'], array('av_one_full','av_one_half', 'av_one_third', 'av_two_third', 'av_three_fourth' , 'av_one_fourth' , 'av_one_fifth', 'av_one_sixth' ,'av_textblock')))
  754. {
  755. avia_sc_columns::$extraClass = "column-top-margin";
  756. }
  757. else
  758. {
  759. avia_sc_columns::$extraClass = "";
  760. }
  761. }
  762.  
  763.  
  764.  
  765.  
  766. if(!empty( avia_sc_columns::$first_atts['min_height'] ) && avia_sc_columns::$calculated_size == 0)
  767. {
  768. $output .= "<div class='flex_column_table ".avia_sc_columns::$first_atts['min_height']."-flextable ".avia_sc_columns::$first_atts['mobile_breaking']."-flextable' {$margin_style}>";
  769. }
  770.  
  771. if(!$first && empty( avia_sc_columns::$first_atts['space'] ) && !empty( avia_sc_columns::$first_atts['min_height'] ))
  772. {
  773. $output .= "<div class='av-flex-placeholder'></div>";
  774. }
  775.  
  776. avia_sc_columns::$calculated_size += avia_sc_columns::$size_array[ $this->config['shortcode'] ];
  777.  
  778. $output .= '<div class="flex_column '.$shortcodename.' '.$extraClass.' '.$first.' '.$meta['el_class'].' '.avia_sc_columns::$extraClass.'" '.$outer_style.'>';
  779.  
  780. //if the user uses the column shortcode without the layout builder make sure that paragraphs are applied to the text
  781. $content = (empty($avia_config['conditionals']['is_builder_template'])) ? ShortcodeHelper::avia_apply_autop(ShortcodeHelper::avia_remove_autop($content)) : ShortcodeHelper::avia_remove_autop($content, true);
  782.  
  783. $output .= trim($content).'</div>';
  784.  
  785.  
  786.  
  787. $force_close = false;
  788.  
  789. if( isset($meta['siblings']) && isset($meta['siblings']['next']) && isset( $meta['siblings']['next']['tag'] ) )
  790. {
  791. if(!array_key_exists($meta['siblings']['next']['tag'], avia_sc_columns::$size_array))
  792. {
  793. $force_close = true;
  794. }
  795. }
  796.  
  797. /**
  798. * check if row will break into next column
  799. */
  800. if( ( false === $force_close ) && ! empty( avia_sc_columns::$first_atts['min_height'] ) && ( 'av-equal-height-column' == avia_sc_columns::$first_atts['min_height'] ) )
  801. {
  802. if( ! isset( $meta['siblings']['next']['tag'] ) )
  803. {
  804. $force_close = true;
  805. }
  806. else if( ( avia_sc_columns::$calculated_size + avia_sc_columns::$size_array[ $meta['siblings']['next']['tag'] ] ) > 1.0 )
  807. {
  808. $force_close = true;
  809. }
  810. }
  811.  
  812.  
  813. if( !empty( avia_sc_columns::$first_atts['min_height']) && (avia_sc_columns::$calculated_size >= 0.95 || $force_close) )
  814. {
  815. $output .= "</div><!--close column table wrapper. Autoclose: {$force_close} -->";
  816. avia_sc_columns::$calculated_size = 0;
  817. }
  818.  
  819. unset($avia_config['current_column']);
  820.  
  821. return $output;
  822. }
  823. }
  824. }
  825.  
  826.  
  827.  
  828.  
  829.  
  830.  
  831.  
  832.  
  833.  
  834. if ( !class_exists( 'avia_sc_columns_one_half' ) )
  835. {
  836. class avia_sc_columns_one_half extends avia_sc_columns{
  837.  
  838. function shortcode_insert_button()
  839. {
  840. $this->config['name'] = '1/2';
  841. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-half.png";
  842. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  843. $this->config['order'] = 90;
  844. $this->config['target'] = "avia-section-drop";
  845. $this->config['shortcode'] = 'av_one_half';
  846. $this->config['html_renderer'] = false;
  847. $this->config['tinyMCE'] = array('name' => '1/2 + 1/2', 'instantInsert' => "[av_one_half first]Add Content here[/av_one_half]\n\n\n[av_one_half]Add Content here[/av_one_half]");
  848. $this->config['tooltip'] = __('Creates a single column with 50&percnt; width', 'avia_framework' );
  849. $this->config['drag-level'] = 2;
  850. $this->config['drop-level'] = 2;
  851. }
  852. }
  853. }
  854.  
  855.  
  856. if ( !class_exists( 'avia_sc_columns_one_third' ) )
  857. {
  858. class avia_sc_columns_one_third extends avia_sc_columns{
  859.  
  860. function shortcode_insert_button()
  861. {
  862. $this->config['name'] = '1/3';
  863. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-third.png";
  864. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  865. $this->config['order'] = 80;
  866. $this->config['target'] = "avia-section-drop";
  867. $this->config['shortcode'] = 'av_one_third';
  868. $this->config['html_renderer'] = false;
  869. $this->config['tooltip'] = __('Creates a single column with 33&percnt; width', 'avia_framework' );
  870. $this->config['drag-level'] = 2;
  871. $this->config['drop-level'] = 2;
  872. $this->config['tinyMCE'] = array(
  873. 'name' => '1/3 + 1/3 + 1/3',
  874. 'instantInsert' => "[av_one_third first]Add Content here[/av_one_third]\n\n\n[av_one_third]Add Content here[/av_one_third]\n\n\n[av_one_third]Add Content here[/av_one_third]"
  875. );
  876. }
  877. }
  878. }
  879.  
  880. if ( !class_exists( 'avia_sc_columns_two_third' ) )
  881. {
  882. class avia_sc_columns_two_third extends avia_sc_columns{
  883.  
  884. function shortcode_insert_button()
  885. {
  886. $this->config['name'] = '2/3';
  887. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-two_third.png";
  888. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  889. $this->config['order'] = 70;
  890. $this->config['target'] = "avia-section-drop";
  891. $this->config['shortcode'] = 'av_two_third';
  892. $this->config['html_renderer'] = false;
  893. $this->config['tooltip'] = __('Creates a single column with 67&percnt; width', 'avia_framework' );
  894. $this->config['drag-level'] = 2;
  895. $this->config['drop-level'] = 2;
  896. $this->config['tinyMCE'] = array(
  897. 'name' => '2/3 + 1/3',
  898. 'instantInsert' => "[av_two_third first]Add 2/3 Content here[/av_two_third]\n\n\n[av_one_third]Add 1/3 Content here[/av_one_third]"
  899. );
  900. }
  901. }
  902. }
  903.  
  904. if ( !class_exists( 'avia_sc_columns_one_fourth' ) )
  905. {
  906. class avia_sc_columns_one_fourth extends avia_sc_columns{
  907.  
  908. function shortcode_insert_button()
  909. {
  910. $this->config['name'] = '1/4';
  911. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-fourth.png";
  912. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  913. $this->config['order'] = 60;
  914. $this->config['target'] = "avia-section-drop";
  915. $this->config['shortcode'] = 'av_one_fourth';
  916. $this->config['tooltip'] = __('Creates a single column with 25&percnt; width', 'avia_framework' );
  917. $this->config['html_renderer'] = false;
  918. $this->config['drag-level'] = 2;
  919. $this->config['drop-level'] = 2;
  920. $this->config['tinyMCE'] = array(
  921. 'name' => '1/4 + 1/4 + 1/4 + 1/4',
  922. 'instantInsert' => "[av_one_fourth first]Add Content here[/av_one_fourth]\n\n\n[av_one_fourth]Add Content here[/av_one_fourth]\n\n\n[av_one_fourth]Add Content here[/av_one_fourth]\n\n\n[av_one_fourth]Add Content here[/av_one_fourth]"
  923. );
  924. }
  925. }
  926. }
  927.  
  928. if ( !class_exists( 'avia_sc_columns_three_fourth' ) )
  929. {
  930. class avia_sc_columns_three_fourth extends avia_sc_columns{
  931.  
  932. function shortcode_insert_button()
  933. {
  934. $this->config['name'] = '3/4';
  935. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-three_fourth.png";
  936. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  937. $this->config['order'] = 50;
  938. $this->config['target'] = "avia-section-drop";
  939. $this->config['shortcode'] = 'av_three_fourth';
  940. $this->config['tooltip'] = __('Creates a single column with 75&percnt; width', 'avia_framework' );
  941. $this->config['html_renderer'] = false;
  942. $this->config['drag-level'] = 2;
  943. $this->config['drop-level'] = 2;
  944. $this->config['tinyMCE'] = array(
  945. 'name' => '3/4 + 1/4',
  946. 'instantInsert' => "[av_three_fourth first]Add 3/4 Content here[/av_three_fourth]\n\n\n[av_one_fourth]Add 1/4 Content here[/av_one_fourth]"
  947. );
  948. }
  949. }
  950. }
  951.  
  952. if ( !class_exists( 'avia_sc_columns_one_fifth' ) )
  953. {
  954. class avia_sc_columns_one_fifth extends avia_sc_columns{
  955.  
  956. function shortcode_insert_button()
  957. {
  958. $this->config['name'] = '1/5';
  959. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-fifth.png";
  960. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  961. $this->config['order'] = 40;
  962. $this->config['target'] = "avia-section-drop";
  963. $this->config['shortcode'] = 'av_one_fifth';
  964. $this->config['html_renderer'] = false;
  965. $this->config['tooltip'] = __('Creates a single column with 20&percnt; width', 'avia_framework' );
  966. $this->config['drag-level'] = 2;
  967. $this->config['drop-level'] = 2;
  968. $this->config['tinyMCE'] = array(
  969. 'name' => '1/5 + 1/5 + 1/5 + 1/5 + 1/5',
  970. 'instantInsert' => "[av_one_fifth first]1/5[/av_one_fifth]\n\n\n[av_one_fifth]2/5[/av_one_fifth]\n\n\n[av_one_fifth]3/5[/av_one_fifth]\n\n\n[av_one_fifth]4/5[/av_one_fifth]\n\n\n[av_one_fifth]5/5[/av_one_fifth]"
  971. );
  972. }
  973. }
  974. }
  975.  
  976. if ( !class_exists( 'avia_sc_columns_one_sixth' ) )
  977. {
  978. class avia_sc_columns_one_sixth extends avia_sc_columns{
  979.  
  980. function shortcode_insert_button()
  981. {
  982. $this->config['name'] = '1/6';
  983. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-fifth.png";
  984. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  985. $this->config['order'] = 40;
  986. $this->config['target'] = "avia-section-drop";
  987. $this->config['shortcode'] = 'av_one_sixth';
  988. $this->config['html_renderer'] = false;
  989. $this->config['tooltip'] = __('Creates a single column with 15&percnt; width', 'avia_framework' );
  990. $this->config['drag-level'] = 2;
  991. $this->config['drop-level'] = 2;
  992. $this->config['tinyMCE'] = array(
  993. 'name' => '1/6 + 1/6 + 1/6 + 1/6 + 1/6 + 1/6',
  994. 'instantInsert' => "[av_one_sixth first]1/6[/av_one_sixth]\n\n\n[av_one_sixth]2/6[/av_one_sixth]\n\n\n[av_one_sixth]3/6[/av_one_sixth]\n\n\n[av_one_sixth]4/6[/av_one_sixth]\n\n\n[av_one_sixth]5/6[/av_one_sixth]\n\n\n[av_one_sixth]6/6[/av_one_sixth]"
  995. );
  996. }
  997. }
  998. }
  999.  
  1000. if ( !class_exists( 'avia_sc_columns_two_fifth' ) )
  1001. {
  1002. class avia_sc_columns_two_fifth extends avia_sc_columns{
  1003.  
  1004. function shortcode_insert_button()
  1005. {
  1006. $this->config['name'] = '2/5';
  1007. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-two_fifth.png";
  1008. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  1009. $this->config['order'] = 39;
  1010. $this->config['target'] = "avia-section-drop";
  1011. $this->config['shortcode'] = 'av_two_fifth';
  1012. $this->config['html_renderer'] = false;
  1013. $this->config['tooltip'] = __('Creates a single column with 40&percnt; width', 'avia_framework' );
  1014. $this->config['drag-level'] = 2;
  1015. $this->config['drop-level'] = 2;
  1016. $this->config['tinyMCE'] = array(
  1017. 'name' => '2/5',
  1018. 'instantInsert' => "[av_two_fifth first]2/5[/av_two_fifth]"
  1019. );
  1020. }
  1021. }
  1022. }
  1023.  
  1024. if ( !class_exists( 'avia_sc_columns_three_fifth' ) )
  1025. {
  1026. class avia_sc_columns_three_fifth extends avia_sc_columns{
  1027.  
  1028. function shortcode_insert_button()
  1029. {
  1030. $this->config['name'] = '3/5';
  1031. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-three_fifth.png";
  1032. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  1033. $this->config['order'] = 38;
  1034. $this->config['target'] = "avia-section-drop";
  1035. $this->config['shortcode'] = 'av_three_fifth';
  1036. $this->config['html_renderer'] = false;
  1037. $this->config['tooltip'] = __('Creates a single column with 60&percnt; width', 'avia_framework' );
  1038. $this->config['drag-level'] = 2;
  1039. $this->config['drop-level'] = 2;
  1040. $this->config['tinyMCE'] = array(
  1041. 'name' => '3/5',
  1042. 'instantInsert' => "[av_three_fifth first]3/5[/av_three_fifth]"
  1043. );
  1044. }
  1045. }
  1046. }
  1047.  
  1048. if ( !class_exists( 'avia_sc_columns_four_fifth' ) )
  1049. {
  1050. class avia_sc_columns_four_fifth extends avia_sc_columns{
  1051.  
  1052. function shortcode_insert_button()
  1053. {
  1054. $this->config['name'] = '4/5';
  1055. $this->config['icon'] = AviaBuilder::$path['imagesURL']."sc-four_fifth.png";
  1056. $this->config['tab'] = __('Layout Elements', 'avia_framework' );
  1057. $this->config['order'] = 37;
  1058. $this->config['target'] = "avia-section-drop";
  1059. $this->config['shortcode'] = 'av_four_fifth';
  1060. $this->config['html_renderer'] = false;
  1061. $this->config['tooltip'] = __('Creates a single column with 80&percnt; width', 'avia_framework' );
  1062. $this->config['drag-level'] = 2;
  1063. $this->config['drop-level'] = 2;
  1064. $this->config['tinyMCE'] = array(
  1065. 'name' => '4/5',
  1066. 'instantInsert' => "[av_four_fifth first]4/5[/av_four_fifth]"
  1067. );
  1068. }
  1069. }
  1070. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement