PageRenderTime 53ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/fusion-core/shortcodes/class-content-boxes.php

https://gitlab.com/webkod3r/tripolis
PHP | 972 lines | 736 code | 216 blank | 20 comment | 332 complexity | 120a84c212995904ccbc46e04350129b MD5 | raw file
  1. <?php
  2. class FusionSC_ContentBoxes {
  3. private $content_box_counter = 1;
  4. private $column_counter = 1;
  5. private $num_of_columns = 1;
  6. private $total_num_of_columns = 1;
  7. private $row_counter = 1;
  8. public static $parent_args;
  9. public static $child_args;
  10. /**
  11. * Initiate the shortcode
  12. */
  13. public function __construct() {
  14. add_filter( 'fusion_attr_content-box-shortcode', array( $this, 'child_attr' ) );
  15. add_filter( 'fusion_attr_content-box-shortcode-content-wrapper', array( $this, 'content_wrapper_attr' ) );
  16. add_filter( 'fusion_attr_content-box-shortcode-heading-wrapper', array( $this, 'heading_wrapper_attr' ) );
  17. add_filter( 'fusion_attr_content-box-shortcode-content-container', array( $this, 'content_container_attr' ) );
  18. add_filter( 'fusion_attr_content-box-shortcode-link', array( $this, 'link_attr' ) );
  19. add_filter( 'fusion_attr_content-box-shortcode-icon-parent', array( $this, 'icon_parent_attr' ) );
  20. add_filter( 'fusion_attr_content-box-shortcode-icon-wrapper', array( $this, 'icon_wrapper_attr' ) );
  21. add_filter( 'fusion_attr_content-box-shortcode-icon', array( $this, 'icon_attr' ) );
  22. add_filter( 'fusion_attr_content-box-shortcode-timeline', array( $this, 'timeline_attr' ) );
  23. add_filter( 'fusion_attr_content-box-heading', array( $this, 'content_box_heading_attr' ) );
  24. add_shortcode( 'content_box', array( $this, 'render_child' ) );
  25. add_filter( 'fusion_attr_content-boxes-shortcode', array( $this, 'parent_attr' ) );
  26. add_shortcode( 'content_boxes', array( $this, 'render_parent' ) );
  27. }
  28. /**
  29. * Render the shortcode
  30. *
  31. * @param array $args Shortcode paramters
  32. * @param string $content Content between shortcode
  33. * @return string HTML output
  34. */
  35. function render_parent( $args, $content = '') {
  36. global $smof_data;
  37. $defaults = FusionCore_Plugin::set_shortcode_defaults(
  38. array(
  39. 'class' => '',
  40. 'id' => '',
  41. 'backgroundcolor' => $smof_data['content_box_bg_color'],
  42. 'columns' => '',
  43. 'circle' => '',
  44. 'iconcolor' => $smof_data['content_box_icon_color'],
  45. 'circlecolor' => $smof_data['content_box_icon_bg_color'],
  46. 'circlebordercolor' => $smof_data['content_box_icon_bg_inner_border_color'],
  47. 'circlebordersize' => $smof_data['content_box_icon_bg_inner_border_size'],
  48. 'outercirclebordercolor'=> $smof_data['content_box_icon_bg_outer_border_color'],
  49. 'outercirclebordersize' => $smof_data['content_box_icon_bg_outer_border_size'],
  50. 'icon_circle' => $smof_data['content_box_icon_circle'],
  51. 'icon_circle_radius' => $smof_data['content_box_icon_circle_radius'],
  52. 'icon_size' => $smof_data['content_box_icon_size'],
  53. 'icon_align' => '',
  54. 'icon_hover_type' => $smof_data['content_box_icon_hover_type'],
  55. 'hover_accent_color' => array_key_exists( 'content_box_hover_animation_accent_color', $smof_data ) && ! empty( $smof_data['content_box_hover_animation_accent_color'] ) ? $smof_data['content_box_hover_animation_accent_color'] : $smof_data['primary_color'],
  56. 'layout' => 'icon-with-title',
  57. 'margin_top' => $smof_data['content_box_margin_top'],
  58. 'margin_bottom' => $smof_data['content_box_margin_bottom'],
  59. 'title_size' => $smof_data['content_box_title_size'],
  60. 'title_color' => $smof_data['content_box_title_color'],
  61. 'body_color' => $smof_data['content_box_body_color'],
  62. 'link_type' => $smof_data['content_box_link_type'],
  63. 'link_area' => $smof_data['content_box_link_area'],
  64. 'link_target' => $smof_data['content_box_link_target'],
  65. 'animation_type' => '',
  66. 'animation_delay' => '',
  67. 'animation_direction' => 'left',
  68. 'animation_speed' => '0.1',
  69. 'animation_offset' => Avada()->settings->get( 'animation_offset' ),
  70. 'settings_lvl' => 'child',
  71. 'linktarget' => '' // deprecated
  72. ), $args
  73. );
  74. if ( $defaults['linktarget'] ) {
  75. $defaults['link_target'] = $defaults['linktarget'];
  76. }
  77. if( $defaults['layout'] == 'timeline-vertical' ) {
  78. $defaults['columns'] = 1;
  79. }
  80. if( $defaults['layout'] == 'timeline-vertical' || $defaults['layout'] == 'timeline-horizontal' ) { // See #1362
  81. $defaults['animation_delay'] = 350;
  82. $defaults['animation_speed'] = 0.25;
  83. $defaults['animation_type'] = 'fade';
  84. $defaults['animation_direction'] = '';
  85. }
  86. extract( $defaults );
  87. self::$parent_args = $defaults;
  88. $this->column_counter = 1;
  89. $this->row_counter = 1;
  90. preg_match_all( '/(\[content_box (.*?)\](.*?)\[\/content_box\])/s', $content, $matches );
  91. $this->total_num_of_columns = count( $matches[0] );
  92. if( ! $columns ||
  93. empty( $columns )
  94. ) {
  95. if( is_array( $matches ) &&
  96. ! empty( $matches )
  97. ) {
  98. $this->num_of_columns = count( $matches[0] );
  99. if( $this->num_of_columns > 6 ) {
  100. $this->num_of_columns = 6;
  101. }
  102. } else {
  103. $this->num_of_columns = 1;
  104. }
  105. } elseif( $columns > 6 ) {
  106. $this->num_of_columns = 6;
  107. } else {
  108. $this->num_of_columns = $columns;
  109. }
  110. $styles = '<style type="text/css" scoped="scoped">';
  111. if( $title_color ) {
  112. $styles .= ".fusion-content-boxes-{$this->content_box_counter} .heading h2{color:{$title_color};}";
  113. }
  114. $styles .= "
  115. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover .heading h2,
  116. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover .heading .heading-link h2,
  117. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover .heading h2,
  118. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover .heading .heading-link h2,
  119. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover.link-area-box .fusion-read-more,
  120. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover.link-area-box .fusion-read-more::after,
  121. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover.link-area-box .fusion-read-more::before,
  122. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .fusion-read-more:hover:after,
  123. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .fusion-read-more:hover:before,
  124. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .fusion-read-more:hover,
  125. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover.link-area-box .fusion-read-more,
  126. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover.link-area-box .fusion-read-more::after,
  127. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover.link-area-box .fusion-read-more::before,
  128. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover .icon .circle-no,
  129. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover .icon .circle-no {
  130. color: {$hover_accent_color} !important;
  131. }";
  132. $circle_hover_accent_color = $hover_accent_color;
  133. if ( $circlecolor == 'transparent' ) {
  134. $circle_hover_accent_color = 'transparent';
  135. }
  136. $styles .= "
  137. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .heading-link:hover .icon i.circle-yes,
  138. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box:hover .heading-link .icon i.circle-yes,
  139. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover .heading .icon i.circle-yes,
  140. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover .heading .icon i.circle-yes {
  141. background-color: {$circle_hover_accent_color} !important;
  142. border-color: {$hover_accent_color} !important;
  143. }";
  144. if ( $icon_hover_type == 'pulsate' && $hover_accent_color ) {
  145. $styles .= "
  146. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover.icon-hover-animation-pulsate .fontawesome-icon:after,
  147. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover.icon-hover-animation-pulsate .fontawesome-icon:after,
  148. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-link-icon-hover.icon-wrapper-hover-animation-pulsate .icon span:after,
  149. .fusion-content-boxes-{$this->content_box_counter} .fusion-content-box-hover .link-area-box-hover.icon-wrapper-hover-animation-pulsate .icon span:after {
  150. -webkit-box-shadow:0 0 0 2px rgba(255,255,255,0.1), 0 0 10px 10px {$hover_accent_color}, 0 0 0 10px rgba(255,255,255,0.5);
  151. -moz-box-shadow:0 0 0 2px rgba(255,255,255,0.1), 0 0 10px 10px {$hover_accent_color}, 0 0 0 10px rgba(255,255,255,0.5);
  152. box-shadow: 0 0 0 2px rgba(255,255,255,0.1), 0 0 10px 10px {$hover_accent_color}, 0 0 0 10px rgba(255,255,255,0.5);
  153. }
  154. ";
  155. }
  156. $styles .= '</style>';
  157. $html = sprintf( '<div %s>%s%s<div class="fusion-clearfix"></div></div>', FusionCore_Plugin::attributes( 'content-boxes-shortcode' ), $styles, do_shortcode( $content ) );
  158. $this->content_box_counter++;
  159. return $html;
  160. }
  161. function parent_attr() {
  162. $attr['class'] = sprintf( 'fusion-content-boxes content-boxes columns fusion-columns-%s fusion-columns-total-%s fusion-content-boxes-%s content-boxes-%s row content-%s', $this->num_of_columns, $this->total_num_of_columns, $this->content_box_counter, self::$parent_args['layout'], self::$parent_args['icon_align'] );
  163. if( self::$parent_args['layout'] == 'timeline-horizontal' || self::$parent_args['layout'] == 'clean-vertical' ) {
  164. $attr['class'] .= ' content-boxes-icon-on-top';
  165. }
  166. if( self::$parent_args['layout'] == 'timeline-vertical' ) {
  167. $attr['class'] .= ' content-boxes-icon-with-title';
  168. }
  169. if( self::$parent_args['layout'] == 'clean-horizontal' ) {
  170. $attr['class'] .= ' content-boxes-icon-on-side';
  171. }
  172. if( self::$parent_args['class'] ) {
  173. $attr['class'] .= ' ' . self::$parent_args['class'];
  174. }
  175. if( self::$parent_args['id'] ) {
  176. $attr['id'] = self::$parent_args['id'];
  177. }
  178. if( self::$parent_args['animation_delay'] ) {
  179. $attr['data-animation-delay'] = self::$parent_args['animation_delay'];
  180. $attr['class'] .= ' fusion-delayed-animation';
  181. }
  182. if ( self::$parent_args['animation_offset'] ) {
  183. $animations = FusionCore_Plugin::animations( array(
  184. 'offset' => self::$parent_args['animation_offset'],
  185. ) );
  186. $attr = array_merge( $attr, $animations );
  187. }
  188. $attr['style'] = sprintf( 'margin-top:%s;margin-bottom:%s;', Avada_Sanitize::get_value_with_unit( self::$parent_args['margin_top'] ), Avada_Sanitize::get_value_with_unit( self::$parent_args['margin_bottom'] ) );
  189. return $attr;
  190. }
  191. /**
  192. * Render the child shortcode
  193. *
  194. * @param array $args Shortcode paramters
  195. * @param string $content Content between shortcode
  196. * @return string HTML output
  197. */
  198. function render_child( $args, $content = '') {
  199. $defaults = FusionCore_Plugin::set_shortcode_defaults(
  200. array(
  201. 'class' => '',
  202. 'id' => '',
  203. 'backgroundcolor' => self::$parent_args['backgroundcolor'],
  204. 'circle' => '',
  205. 'circlecolor' => self::$parent_args['circlecolor'],
  206. 'circlebordercolor' => self::$parent_args['circlebordercolor'],
  207. 'circlebordersize' => self::$parent_args['circlebordersize'],
  208. 'outercirclebordercolor' => self::$parent_args['outercirclebordercolor'],
  209. 'outercirclebordersize' => self::$parent_args['outercirclebordersize'],
  210. 'icon' => '',
  211. 'iconcolor' => self::$parent_args['iconcolor'],
  212. 'iconrotate' => '',
  213. 'iconspin' => '',
  214. 'image' => '',
  215. 'image_height' => '35',
  216. 'image_width' => '35',
  217. 'link' => '',
  218. 'link_target' => self::$parent_args['link_target'],
  219. 'linktext' => '',
  220. 'textcolor' => '',
  221. 'title' => '',
  222. 'animation_type' => self::$parent_args['animation_type'],
  223. 'animation_direction' => self::$parent_args['animation_direction'],
  224. 'animation_speed' => self::$parent_args['animation_speed'],
  225. 'animation_offset' => self::$parent_args['animation_offset'],
  226. 'linktarget' => '' // deprecated
  227. ), $args
  228. );
  229. if ( $defaults['linktarget'] ) {
  230. $defaults['link_target'] = $defaults['linktarget'];
  231. }
  232. if( self::$parent_args['settings_lvl'] == 'parent' ) {
  233. $defaults['backgroundcolor'] = self::$parent_args['backgroundcolor'];
  234. $defaults['circlecolor'] = self::$parent_args['circlecolor'];
  235. $defaults['circlebordercolor'] = self::$parent_args['circlebordercolor'];
  236. $defaults['circlebordersize'] = self::$parent_args['circlebordersize'];
  237. $defaults['outercirclebordercolor'] = self::$parent_args['outercirclebordercolor'];
  238. $defaults['outercirclebordersize'] = self::$parent_args['outercirclebordersize'];
  239. $defaults['iconcolor'] = self::$parent_args['iconcolor'];
  240. $defaults['animation_type'] = self::$parent_args['animation_type'];
  241. $defaults['animation_direction'] = self::$parent_args['animation_direction'];
  242. $defaults['animation_speed'] = self::$parent_args['animation_speed'];
  243. $defaults['link_target'] = self::$parent_args['link_target'];
  244. }
  245. if( self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'timeline-horizontal' ) {
  246. $defaults['animation_speed'] = 0.25;
  247. $defaults['animation_type'] = 'fade';
  248. $defaults['animation_direction'] = '';
  249. }
  250. extract( $defaults );
  251. self::$child_args = $defaults;
  252. $output = '';
  253. $icon_output = '';
  254. $title_output = '';
  255. $content_output = '';
  256. $link_output = '';
  257. $alt = '';
  258. $heading = '';
  259. if( $image &&
  260. $image_width &&
  261. $image_height
  262. ) {
  263. $image_id = FusionCore_Plugin::get_attachment_id_from_url( $image );
  264. if( $image_id ) {
  265. $alt = get_post_meta( $image_id, '_wp_attachment_image_alt', true );
  266. }
  267. $icon_output = sprintf( '<div %s><img src="%s" width="%s" height="%s" alt="%s" /></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-icon' ), $image, $image_width, $image_height, $alt );
  268. } elseif( $icon ) {
  269. if( $outercirclebordercolor && $outercirclebordersize ) {
  270. $icon_output = sprintf( '<div %s><span %s><i %s></i></span></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-icon-parent' ), FusionCore_Plugin::attributes( 'content-box-shortcode-icon-wrapper' ), FusionCore_Plugin::attributes( 'content-box-shortcode-icon' ) );
  271. } else {
  272. $icon_output = sprintf( '<div %s><i %s></i></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-icon-parent' ), FusionCore_Plugin::attributes( 'content-box-shortcode-icon' ) );
  273. }
  274. }
  275. if( $title ) {
  276. $title_output = sprintf( '<h2 %s>%s</h2>', FusionCore_Plugin::attributes( 'content-box-heading' ), $title );
  277. }
  278. if( ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'icon-with-title' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) && self::$parent_args['icon_align'] == 'right' ) {
  279. $heading_content = $title_output . $icon_output;
  280. } else {
  281. $heading_content = $icon_output . $title_output;
  282. }
  283. if( $link ) {
  284. $heading_content = sprintf( '<a %s %s>%s</a>', FusionCore_Plugin::attributes( 'heading-link' ),
  285. FusionCore_Plugin::attributes( 'content-box-shortcode-link' ), $heading_content );
  286. }
  287. if ( $heading_content ) {
  288. $heading = sprintf( '<div %s>%s</div>', FusionCore_Plugin::attributes( 'content-box-shortcode-heading-wrapper' ), $heading_content );
  289. }
  290. if( $link &&
  291. $linktext
  292. ) {
  293. if( self::$parent_args['link_type'] == 'text' || self::$parent_args['link_type'] == 'button-bar' ) {
  294. $link_output = sprintf( '<div class="fusion-clearfix"></div><a %s %s>%s</a><div class="fusion-clearfix"></div>', FusionCore_Plugin::attributes( 'fusion-read-more' ), FusionCore_Plugin::attributes( 'content-box-shortcode-link', array( 'readmore' => true ) ), $linktext );
  295. } else if( self::$parent_args['link_type'] == 'button' ) {
  296. $link_output = sprintf( '<div class="fusion-clearfix"></div><a %s>%s</a><div class="fusion-clearfix"></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-link' ), $linktext );
  297. }
  298. }
  299. $content_output = sprintf( '<div class="fusion-clearfix"></div><div %s>%s</div>', FusionCore_Plugin::attributes( 'content-box-shortcode-content-container'), do_shortcode( $content ) . $link_output );
  300. $output = $heading . $content_output;
  301. $timeline = '';
  302. if( $icon && self::$parent_args['icon_circle'] == 'yes' && self::$parent_args['layout'] == 'timeline-horizontal' && self::$parent_args['columns'] != '1' ) {
  303. $timeline = sprintf( '<div %s></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-timeline' ) );
  304. }
  305. if( $icon && self::$parent_args['icon_circle'] == 'yes' && self::$parent_args['layout'] == 'timeline-vertical' ) {
  306. $timeline = sprintf( '<div %s></div>', FusionCore_Plugin::attributes( 'content-box-shortcode-timeline' ) );
  307. }
  308. $html = sprintf( '<div %s><div %s>%s%s</div></div>', FusionCore_Plugin::attributes( 'content-box-shortcode' ),
  309. FusionCore_Plugin::attributes( 'content-box-shortcode-content-wrapper' ), $output, $timeline );
  310. $clearfix_test = $this->column_counter / $this->num_of_columns;
  311. if ( is_int( $clearfix_test ) ) {
  312. $html .= '<div class="fusion-clearfix"></div>';
  313. }
  314. $this->column_counter++;
  315. return $html;
  316. }
  317. function child_attr() {
  318. $columns = 12 / $this->num_of_columns;
  319. if( $this->row_counter > intval( $this->num_of_columns ) ) {
  320. $this->row_counter = 1;
  321. }
  322. $attr['style'] = '';
  323. $attr['class'] = sprintf( 'fusion-column content-box-column content-box-column-%s col-lg-%s col-md-%s col-sm-%s', $this->column_counter, $columns, $columns, $columns );
  324. if ( $this->num_of_columns == '5' ) {
  325. $attr['class'] = sprintf( 'fusion-column content-box-column content-box-column-%s col-lg-2 col-md-2 col-sm-2', $this->column_counter );
  326. }
  327. $attr['class'] .= ' fusion-content-box-hover';
  328. $border_color = '';
  329. if( self::$child_args['circlebordercolor'] ) {
  330. $border_color = self::$child_args['circlebordercolor'];
  331. }
  332. if( self::$child_args['outercirclebordercolor'] ) {
  333. $border_color = self::$child_args['outercirclebordercolor'];
  334. }
  335. if( ! self::$child_args['circlebordercolor'] && ! self::$child_args['outercirclebordercolor'] ) {
  336. $border_color = '#f6f6f6';
  337. }
  338. if( intval( $this->column_counter ) % intval( $this->num_of_columns ) == 1 ) {
  339. $attr['class'] .= ' content-box-column-first-in-row';
  340. }
  341. if( intval( $this->column_counter ) == intval( $this->total_num_of_columns ) ) {
  342. $attr['class'] .= ' content-box-column-last';
  343. }
  344. if( $this->row_counter == intval( $this->num_of_columns ) ) {
  345. $attr['class'] .= ' content-box-column-last-in-row';
  346. }
  347. if( $border_color && ( self::$parent_args['layout'] == 'clean-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) ) {
  348. $attr['style'] .= sprintf( 'border-color:%s;', $border_color );
  349. }
  350. if( self::$child_args['class'] ) {
  351. $attr['class'] .= ' ' . self::$child_args['class'];
  352. }
  353. if( self::$child_args['id'] ) {
  354. $attr['id'] = self::$child_args['id'];
  355. }
  356. $this->row_counter++;
  357. return $attr;
  358. }
  359. function content_wrapper_attr() {
  360. $attr['class'] = 'col content-wrapper';
  361. // set parent values if child values are unset to get downwards compatibility
  362. if( ! self::$child_args['backgroundcolor'] ) {
  363. self::$child_args['backgroundcolor'] = self::$parent_args['backgroundcolor'];
  364. }
  365. if( self::$child_args['backgroundcolor'] ) {
  366. $attr['style'] = sprintf( 'background-color:%s;', self::$child_args['backgroundcolor'] );
  367. if ( self::$child_args['backgroundcolor'] != 'transparent' ) {
  368. $attr['class'] .= '-background';
  369. }
  370. }
  371. if( self::$parent_args['layout'] == 'icon-boxed' ) {
  372. $attr['class'] .= ' content-wrapper-boxed';
  373. }
  374. if( self::$child_args['link'] && self::$parent_args['link_area'] == 'box' ) {
  375. $attr['data-link'] = self::$child_args['link'];
  376. }
  377. $attr['class'] .= ' link-area-' . self::$parent_args['link_area'];
  378. if( self::$child_args['link'] && self::$parent_args['link_type'] ) {
  379. $attr['class'] .= ' link-type-' . self::$parent_args['link_type'];
  380. }
  381. if( self::$child_args['outercirclebordercolor'] && self::$child_args['outercirclebordersize'] ) {
  382. $attr['class'] .= ' content-icon-wrapper-yes';
  383. }
  384. if( self::$child_args['outercirclebordercolor'] && self::$child_args['outercirclebordersize'] && self::$parent_args['icon_hover_type'] == 'pulsate' ) {
  385. $attr['class'] .= ' icon-wrapper-hover-animation-' . self::$parent_args['icon_hover_type'];
  386. } else {
  387. $attr['class'] .= ' icon-hover-animation-' . self::$parent_args['icon_hover_type'];
  388. }
  389. if( self::$child_args['textcolor'] ) {
  390. $attr['style'] .= sprintf( 'color:%s;', self::$child_args['textcolor'] );
  391. }
  392. if ( self::$child_args['animation_type'] ) {
  393. $animations = FusionCore_Plugin::animations( array(
  394. 'type' => self::$child_args['animation_type'],
  395. 'direction' => self::$child_args['animation_direction'],
  396. 'speed' => self::$child_args['animation_speed'],
  397. 'offset' => self::$child_args['animation_offset'],
  398. ) );
  399. $attr = array_merge( $attr, $animations );
  400. $attr['class'] .= ' ' . $attr['animation_class'];
  401. unset( $attr['animation_class'] );
  402. }
  403. return $attr;
  404. }
  405. function link_attr( $args ) {
  406. global $smof_data;
  407. $attr['class'] = '';
  408. if( self::$child_args['link'] ) {
  409. $attr['href'] = self::$child_args['link'];
  410. }
  411. if( self::$child_args['link_target'] ) {
  412. $attr['target'] = self::$child_args['link_target'];
  413. }
  414. if( self::$parent_args['link_type'] == 'button' ) {
  415. $attr['class'] .= sprintf( 'fusion-read-more-button fusion-button fusion-button-default fusion-button-%s fusion-button-%s fusion-button-%s', strtolower( $smof_data['button_size'] ), strtolower( $smof_data['button_shape'] ), strtolower( $smof_data['button_type'] ) );
  416. }
  417. if ( self::$parent_args['link_type'] == 'button-bar' &&
  418. self::$parent_args['layout'] == 'timeline-vertical' &&
  419. isset( $args['readmore'] )
  420. ) {
  421. $attr['style'] = '';
  422. if( self::$child_args['image'] &&
  423. self::$child_args['image_width'] &&
  424. self::$child_args['image_height']
  425. ) {
  426. if ( self::$parent_args['icon_align'] == 'right' ) {
  427. $attr['style'] .= sprintf( 'margin-right:%spx;', self::$child_args['image_width'] + 20 );
  428. } else {
  429. $attr['style'] .= sprintf( 'margin-left:%spx;', self::$child_args['image_width'] + 20 );
  430. }
  431. $attr['style'] .= 'width:calc(100% - ' . ( self::$child_args['image_width'] + 20 ) . 'px);';
  432. } else if ( self::$child_args['icon'] ) {
  433. if ( self::$parent_args['icon_circle'] == 'yes' ) {
  434. $full_icon_size = ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) + ( intval( self::$child_args['outercirclebordersize'] ) * 2 );
  435. } else {
  436. $full_icon_size = self::$parent_args['icon_size'];
  437. }
  438. if ( self::$parent_args['icon_align'] == 'right' ) {
  439. $attr['style'] .= sprintf( 'margin-right:%spx;', $full_icon_size + 20 );
  440. } else {
  441. $attr['style'] .= sprintf( 'margin-left:%spx;', $full_icon_size + 20 );
  442. }
  443. $attr['style'] .= 'width:calc(100% - ' . ( $full_icon_size + 20 ) . 'px);';
  444. }
  445. }
  446. return $attr;
  447. }
  448. function heading_wrapper_attr() {
  449. $attr['class'] = 'heading';
  450. $attr['style'] = '';
  451. if( self::$child_args['icon'] || self::$child_args['image'] ) {
  452. $attr['class'] .= ' heading-with-icon';
  453. }
  454. if( self::$parent_args['icon_align'] ) {
  455. $attr['class'] .= ' icon-'.self::$parent_args['icon_align'];
  456. }
  457. return $attr;
  458. }
  459. function icon_parent_attr() {
  460. $attr['class'] = 'icon';
  461. $attr['style'] = '';
  462. if( self::$parent_args['icon_circle'] != 'yes' && self::$parent_args['layout'] == 'icon-boxed' ) {
  463. $attr['style'] .= sprintf( 'position:absolute;width: 100%%;top:-%spx;', 50 + intval( self::$parent_args['icon_size'] ) / 2 );
  464. }
  465. if ( self::$parent_args['layout'] == 'timeline-vertical' && self::$parent_args['icon_align'] == 'right' && ( ! self::$child_args['outercirclebordercolor'] || ! self::$child_args['circlebordersize'] ) ) {
  466. $attr['style'] .= 'padding-left:20px;';
  467. }
  468. if( self::$parent_args['animation_delay'] ) {
  469. $animation_delay = self::$parent_args['animation_delay'];
  470. $attr['style'] .= '-webkit-animation-duration: ' . $animation_delay . 'ms;';
  471. $attr['style'] .= 'animation-duration: ' . $animation_delay . 'ms;';
  472. }
  473. return $attr;
  474. }
  475. function icon_wrapper_attr() {
  476. $attr['style'] = '';
  477. if( self::$child_args['icon'] ) {
  478. $attr['class'] = '';
  479. if( self::$parent_args['icon_circle'] == 'yes' ) {
  480. $attr['style'] .= sprintf( 'height:%spx;width:%spx;line-height:%spx;', ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ), ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ), ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) );
  481. if( self::$child_args['outercirclebordercolor'] ) {
  482. $attr['style'] .= sprintf( 'border-color:%s;', self::$child_args['outercirclebordercolor'] );
  483. }
  484. if( self::$child_args['outercirclebordersize'] ) {
  485. $attr['style'] .= sprintf( 'border-width:%s;', self::$child_args['outercirclebordersize'] );
  486. }
  487. $attr['style'] .= sprintf( 'border-style:%s;', 'solid' );
  488. if( self::$child_args['circlebordercolor'] ) {
  489. $attr['style'] .= sprintf( 'background-color:%s;', self::$child_args['circlebordercolor'] );
  490. }
  491. if( self::$parent_args['layout'] == 'icon-boxed' ) {
  492. $attr['style'] .= sprintf( 'position:absolute;top:-%spx;margin-left:-%spx;', 50 + ( ( ( self::$parent_args['icon_size'] * 2 ) + intval( self::$child_args['circlebordersize'] ) * 2 ) / 2 ), ( ( self::$parent_args['icon_size'] * 2 ) + intval( self::$child_args['circlebordersize'] ) * 2 ) / 2 );
  493. }
  494. if( self::$parent_args['icon_circle_radius'] == 'round' ) {
  495. self::$parent_args['icon_circle_radius'] = '100%';
  496. }
  497. if( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) {
  498. $margin_direction = 'margin-right';
  499. if ( self::$parent_args['icon_align'] == 'right' ) {
  500. $margin_direction = 'margin-left';
  501. }
  502. $margin = '20px';
  503. if ( self::$parent_args['layout'] == 'timeline-vertical' && self::$parent_args['icon_align'] == 'right' ) {
  504. $margin = '10px';
  505. }
  506. $attr['style'] .= sprintf( '%s:%s;', $margin_direction, $margin );
  507. }
  508. $attr['style'] .= sprintf( 'box-sizing:%s;', 'content-box' );
  509. $attr['style'] .= sprintf( 'border-radius:%s;', self::$parent_args['icon_circle_radius'] );
  510. }
  511. }
  512. return $attr;
  513. }
  514. function icon_attr() {
  515. $attr['style'] = '';
  516. if( self::$child_args['image'] ) {
  517. $attr['class'] = 'image';
  518. if( self::$parent_args['layout'] == 'icon-boxed' &&
  519. self::$child_args['image_width'] &&
  520. self::$child_args['image_height']
  521. ) {
  522. $attr['style'] = sprintf( 'margin-left:-%spx;', self::$child_args['image_width'] / 2 );
  523. $attr['style'] .= sprintf( 'top:-%spx;', self::$child_args['image_height'] / 2 + 50 );
  524. }
  525. } else if( self::$child_args['icon'] ) {
  526. $attr['class'] = sprintf( 'fa fontawesome-icon %s', FusionCore_Plugin::font_awesome_name_handler( self::$child_args['icon'] ) );
  527. // set parent values if child values are unset to get downwards compatibility
  528. if( ! self::$child_args['circle'] ) {
  529. self::$child_args['circle'] = self::$parent_args['circle'];
  530. }
  531. if( self::$parent_args['icon_circle'] == 'yes' ) {
  532. $attr['class'] .= ' circle-yes';
  533. if( self::$child_args['circlebordercolor'] ) {
  534. $attr['style'] .= sprintf( 'border-color:%s;', self::$child_args['circlebordercolor'] );
  535. }
  536. if( self::$child_args['circlebordersize'] ) {
  537. $attr['style'] .= sprintf( 'border-width:%s;', self::$child_args['circlebordersize'] );
  538. }
  539. if( self::$child_args['circlecolor'] ) {
  540. $attr['style'] .= sprintf( 'background-color:%s;', self::$child_args['circlecolor'] );
  541. }
  542. $attr['style'] .= sprintf( 'height:%spx;width:%spx;line-height:%spx;', self::$parent_args['icon_size'] * 2, self::$parent_args['icon_size'] * 2, self::$parent_args['icon_size'] * 2 );
  543. if( self::$parent_args['layout'] == 'icon-boxed' && ( ! self::$child_args['outercirclebordercolor'] || ! self::$child_args['outercirclebordersize'] ) ) {
  544. $attr['style'] .= sprintf( 'top:-%spx;margin-left:-%spx;', 50 + ( ( self::$parent_args['icon_size'] * 2 ) / 2 ), ( self::$parent_args['icon_size'] * 2 ) / 2 );
  545. }
  546. if( self::$parent_args['icon_circle_radius'] == 'round' ) {
  547. self::$parent_args['icon_circle_radius'] = '100%';
  548. }
  549. $attr['style'] .= sprintf( 'border-radius:%s;', self::$parent_args['icon_circle_radius'] );
  550. if( self::$child_args['outercirclebordercolor'] && self::$child_args['outercirclebordersize'] ) {
  551. // If there is a thick border, kill border width and make it center aligned positioned
  552. $attr['style'] .= sprintf( 'border-width:%s;', '0' );
  553. $attr['style'] .= sprintf( 'position:%s;', 'relative' );
  554. $attr['style'] .= sprintf( 'top:%s;', self::$child_args['circlebordersize'] );
  555. $attr['style'] .= sprintf( 'left:%s;', self::$child_args['circlebordersize'] );
  556. $attr['style'] .= 'margin:0;';
  557. $attr['style'] .= sprintf( 'border-radius:%spx;', intval( self::$parent_args['icon_circle_radius'] ) - intval( self::$child_args['outercirclebordersize'] ) );
  558. }
  559. } else {
  560. $attr['class'] .= ' circle-no';
  561. $attr['style'] .= sprintf( 'background-color:%s;border-color:%s;height:%s;width:%spx;line-height:%s;', 'transparent', 'transparent', 'auto', self::$parent_args['icon_size'], 'normal' );
  562. if( self::$parent_args['layout'] == 'icon-boxed' ) {
  563. $attr['style'] .= sprintf( 'position:%s;left:%s;right:%s;top:%s;margin-left:%s;margin-right:%s;', 'relative', 'auto', 'auto', 'auto', 'auto', 'auto' );
  564. }
  565. }
  566. if( self::$child_args['iconcolor'] ) {
  567. $attr['style'] .= sprintf( 'color:%s;', self::$child_args['iconcolor'] );
  568. }
  569. if( self::$child_args['iconrotate'] ) {
  570. $attr['class'] .= ' fa-rotate-' . self::$child_args['iconrotate'];
  571. }
  572. if( self::$child_args['iconspin'] == 'yes' ) {
  573. $attr['class'] .= ' fa-spin';
  574. }
  575. $attr['style'] .= sprintf( 'font-size:%spx;', FusionCore_Plugin::strip_unit( self::$parent_args['icon_size'] ) );
  576. }
  577. return $attr;
  578. }
  579. function content_container_attr() {
  580. $attr['class'] = 'content-container';
  581. $attr['style'] = '';
  582. if( ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) &&
  583. self::$child_args['image'] &&
  584. self::$child_args['image_width'] &&
  585. self::$child_args['image_height']
  586. ) {
  587. if( self::$parent_args['layout'] == 'clean-horizontal' ) {
  588. $attr['style'] .= sprintf( 'padding-left:%spx;', self::$child_args['image_width'] + 20 );
  589. } else {
  590. if ( self::$parent_args['icon_align'] == 'right' ) {
  591. $attr['style'] .= sprintf( 'padding-right:%spx;', self::$child_args['image_width'] + 20 );
  592. } else {
  593. $attr['style'] .= sprintf( 'padding-left:%spx;', self::$child_args['image_width'] + 20 );
  594. }
  595. }
  596. if ( self::$parent_args['layout'] == 'timeline-vertical' ) {
  597. $image_height = self::$child_args['image_height'];
  598. if ( $image_height > self::$parent_args['title_size'] &&
  599. $image_height - self::$parent_args['title_size'] - 15 > 0
  600. ) {
  601. $attr['style'] .= sprintf( 'margin-top:-%spx;', $image_height - self::$parent_args['title_size'] );
  602. }
  603. }
  604. } else if ( ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) && self::$child_args['icon'] ) {
  605. if ( self::$parent_args['icon_circle'] == 'yes' ) {
  606. $full_icon_size = ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) + ( intval( self::$child_args['outercirclebordersize'] ) * 2 );
  607. } else {
  608. $full_icon_size = self::$parent_args['icon_size'];
  609. }
  610. if( self::$parent_args['layout'] == 'clean-horizontal' ) {
  611. $attr['style'] .= sprintf( 'padding-left:%spx;', $full_icon_size + 20 );
  612. } else {
  613. if ( self::$parent_args['icon_align'] == 'right' ) {
  614. $attr['style'] .= sprintf( 'padding-right:%spx;', $full_icon_size + 20 );
  615. } else {
  616. $attr['style'] .= sprintf( 'padding-left:%spx;', $full_icon_size + 20 );
  617. }
  618. }
  619. if ( self::$parent_args['layout'] == 'timeline-vertical' ) {
  620. if ( $full_icon_size > self::$parent_args['title_size'] &&
  621. $full_icon_size - self::$parent_args['title_size'] - 15 > 0
  622. ) {
  623. if ( self::$parent_args['layout'] == 'timeline-vertical' ) {
  624. $attr['style'] .= sprintf( 'margin-top:-%spx;', ( $full_icon_size - self::$parent_args['title_size'] ) / 2 );
  625. } else {
  626. $attr['style'] .= sprintf( 'margin-top:-%spx;', $full_icon_size - self::$parent_args['title_size'] );
  627. }
  628. }
  629. }
  630. }
  631. if( self::$parent_args['icon_align'] == 'right' && isset ( $attr['style'] ) && ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'icon-with-title' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) ) {
  632. $attr['style'] .= sprintf( ' text-align:%s;', self::$parent_args['icon_align'] );
  633. } else if( self::$parent_args['icon_align'] == 'right' && !isset( $attr['style'] ) && ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'icon-with-title' || self::$parent_args['layout'] == 'timeline-vertical' || self::$parent_args['layout'] == 'clean-horizontal' ) ) {
  634. $attr['style'] .= sprintf( ' text-align:%s;', self::$parent_args['icon_align'] );
  635. }
  636. if( self::$parent_args['body_color'] ) {
  637. $attr['style'] .= sprintf( 'color:%s;', self::$parent_args['body_color'] );
  638. }
  639. return $attr;
  640. }
  641. function timeline_attr() {
  642. if( self::$parent_args['layout'] == 'timeline-horizontal' ) {
  643. $attr['class'] = 'content-box-shortcode-timeline';
  644. $attr['style'] = '';
  645. $border_color = '';
  646. if ( self::$parent_args['icon_circle'] == 'yes' ) {
  647. if ( intval( self::$child_args['outercirclebordersize'] ) ) {
  648. $full_icon_size = ( intval( self::$parent_args['icon_size'] ) * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) + ( intval( self::$child_args['outercirclebordersize'] ) * 2 );
  649. } else {
  650. $full_icon_size = intval( self::$parent_args['icon_size'] ) * 2;
  651. }
  652. } else {
  653. $full_icon_size = intval( self::$parent_args['icon_size'] );
  654. }
  655. $position_top = $full_icon_size / 2;
  656. if ( self::$child_args['backgroundcolor'] && self::$child_args['backgroundcolor'] != 'transparent' ) {
  657. $position_top += 35;
  658. }
  659. if( self::$child_args['circlebordercolor'] ) {
  660. $border_color = self::$child_args['circlebordercolor'];
  661. }
  662. if( self::$child_args['outercirclebordercolor'] && self::$child_args['outercirclebordersize'] ) {
  663. $border_color = self::$child_args['outercirclebordercolor'];
  664. }
  665. if( ! self::$child_args['circlebordercolor'] && ! self::$child_args['outercirclebordercolor'] ) {
  666. $border_color = '#f6f6f6';
  667. }
  668. if( $border_color ) {
  669. $attr['style'] .= sprintf( 'border-color:%s;', $border_color );
  670. }
  671. if( $position_top ) {
  672. $attr['style'] .= sprintf( 'top:%spx;', intval( $position_top ) );
  673. }
  674. } else if( self::$parent_args['layout'] == 'timeline-vertical' ) {
  675. $attr['class'] = 'content-box-shortcode-timeline-vertical';
  676. $attr['style'] = '';
  677. $border_color = '';
  678. if ( self::$parent_args['icon_circle'] == 'yes' ) {
  679. if ( intval( self::$child_args['outercirclebordersize'] ) ) {
  680. $full_icon_size = ( intval( self::$parent_args['icon_size'] ) * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) + ( intval( self::$child_args['outercirclebordersize'] ) * 2 );
  681. } else {
  682. $full_icon_size = intval( self::$parent_args['icon_size'] ) * 2;
  683. }
  684. } else {
  685. $full_icon_size = intval( self::$parent_args['icon_size'] );
  686. }
  687. $position_top = $full_icon_size;
  688. $position_horizontal = $full_icon_size / 2 + 15;
  689. if ( self::$child_args['backgroundcolor'] && self::$child_args['backgroundcolor'] != 'transparent' ) {
  690. $position_top += 35;
  691. $position_horizontal += 35;
  692. }
  693. if( self::$child_args['circlebordercolor'] ) {
  694. $border_color = self::$child_args['circlebordercolor'];
  695. }
  696. if( self::$child_args['outercirclebordercolor'] && self::$child_args['outercirclebordersize'] ) {
  697. $border_color = self::$child_args['outercirclebordercolor'];
  698. }
  699. if( ! self::$child_args['circlebordercolor'] && ! self::$child_args['outercirclebordercolor'] ) {
  700. $border_color = '#f6f6f6';
  701. }
  702. if( $border_color ) {
  703. $attr['style'] .= sprintf( 'border-color:%s;', $border_color );
  704. }
  705. if ( $position_horizontal ) {
  706. if ( self::$parent_args['icon_align'] == 'right' ) {
  707. $attr['style'] .= sprintf( 'right:%spx;', intval( $position_horizontal ) );
  708. } else {
  709. $attr['style'] .= sprintf( 'left:%spx;', intval( $position_horizontal ) );
  710. }
  711. }
  712. if ( $position_top ) {
  713. $attr['style'] .= sprintf( 'top:%spx;', $position_top );
  714. }
  715. }
  716. if( self::$parent_args['animation_delay'] ) {
  717. $animation_delay = self::$parent_args['animation_delay'];
  718. $attr['style'] .= '-webkit-transition-duration: ' . $animation_delay . 'ms;';
  719. $attr['style'] .= 'animation-duration: ' . $animation_delay . 'ms;';
  720. }
  721. return $attr;
  722. }
  723. function content_box_heading_attr() {
  724. $attr['class'] = 'content-box-heading';
  725. $attr['style'] = '';
  726. if( self::$parent_args['title_size'] ) {
  727. $font_size = FusionCore_Plugin::strip_unit( self::$parent_args['title_size'] );
  728. $attr['style'] = sprintf( 'font-size: %spx;line-height:%spx;', $font_size, $font_size + 5 );
  729. }
  730. if ( self::$parent_args['layout'] == 'icon-on-side' || self::$parent_args['layout'] == 'clean-horizontal' ) {
  731. if ( self::$child_args['image'] &&
  732. self::$child_args['image_width'] &&
  733. self::$child_args['image_height']
  734. ) {
  735. if ( self::$parent_args['icon_align'] == 'right' ) {
  736. $attr['style'] .= sprintf( 'padding-right:%spx;', self::$child_args['image_width'] + 20 );
  737. } else {
  738. $attr['style'] .= sprintf( 'padding-left:%spx;', self::$child_args['image_width'] + 20 );
  739. }
  740. } else if ( self::$child_args['icon'] ) {
  741. if ( self::$parent_args['icon_circle'] == 'yes' ) {
  742. $full_icon_size = ( self::$parent_args['icon_size'] * 2 ) + ( intval( self::$child_args['circlebordersize'] ) * 2 ) + ( intval( self::$child_args['outercirclebordersize'] ) * 2 );
  743. } else {
  744. $full_icon_size = self::$parent_args['icon_size'];
  745. }
  746. if ( self::$parent_args['icon_align'] == 'right' ) {
  747. $attr['style'] .= sprintf( 'padding-right:%spx;', $full_icon_size + 20 );
  748. } else {
  749. $attr['style'] .= sprintf( 'padding-left:%spx;', $full_icon_size + 20 );
  750. }
  751. }
  752. }
  753. return $attr;
  754. }
  755. }
  756. new FusionSC_ContentBoxes();