PageRenderTime 55ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-content/plugins/fusion-core/admin/page-builder/classes/class-fusion-reversal.php

https://gitlab.com/webkod3r/tripolis
PHP | 1328 lines | 894 code | 214 blank | 220 comment | 104 complexity | 51b81ab16d70a752a75b530a7a9a8033 MD5 | raw file
  1. <?php
  2. /**
  3. * content to builder elements convertor
  4. *
  5. * @package FusionCore
  6. * @author ThemeFusion
  7. * @link http://theme-fusion.com
  8. * @copyright ThemeFusion
  9. */
  10. if ( ! class_exists( 'Fusion_Core_Reversal' ) ) {
  11. class Fusion_Core_Reversal {
  12. /**
  13. * Instance of this class.
  14. *
  15. * @since 2.0.0
  16. * @var object
  17. */
  18. protected static $instance = null;
  19. /**
  20. * content of current post/page.
  21. *
  22. * @since 2.0.0
  23. * @var object
  24. */
  25. protected static $content = null;
  26. /**
  27. * array of all matched short-codes.
  28. *
  29. * @since 2.0.0
  30. * @var Array
  31. */
  32. protected static $matches = null;
  33. /**
  34. * array of all created elements.
  35. *
  36. * @since 2.0.0
  37. * @var Array
  38. */
  39. protected static $elements = array();
  40. /**
  41. * builder blocks count
  42. *
  43. * @since 2.0.0
  44. * @var Integer
  45. */
  46. protected static $builder_blocks_count = 1;
  47. /**
  48. * prepared builder blocks
  49. *
  50. * @since 2.0.0
  51. * @var Array
  52. */
  53. protected static $prepared_builder_blocks = array();
  54. /**
  55. * array of all available short-codes.
  56. *
  57. * @since 2.0.0
  58. * @var object
  59. */
  60. public static $tags = array(
  61. 'one_full' => 'one_full',
  62. 'one_half' => 'one_half',
  63. 'one_third' => 'one_third',
  64. 'one_fourth' => 'one_fourth',
  65. 'one_fifth' => 'one_fifth',
  66. 'two_fifth' => 'two_fifth',
  67. 'three_fifth' => 'three_fifth',
  68. 'four_fifth' => 'four_fifth',
  69. 'one_sixth' => 'one_sixth',
  70. 'five_sixth' => 'five_sixth',
  71. 'three_fourth' => 'three_fourth',
  72. 'two_third' => 'two_third',
  73. 'fullwidth' => 'fullwidth',
  74. 'alert' => 'alert',
  75. 'blog' => 'blog',
  76. 'button' => 'button',
  77. 'checklist' => 'checklist',
  78. 'clients' => 'clients',
  79. 'fusion_code' => 'fusion_code',
  80. 'content_boxes' => 'content_boxes',
  81. 'fusion_countdown' => 'fusion_countdown',
  82. 'counters_circle' => 'counters_circle',
  83. 'counters_box' => 'counters_box',
  84. //'dropcap' => 'dropcap',
  85. 'postslider' => 'postslider',
  86. 'flip_boxes' => 'flip_boxes',
  87. 'fontawesome' => 'fontawesome',
  88. 'map' => 'map',
  89. //'highlight' => 'highlight',
  90. 'imageframe' => 'imageframe',
  91. 'images' => 'images',
  92. //TODO:: add lightbox shortcode
  93. 'layerslider' => 'layerslider',
  94. 'fusion_lightbox' => 'fusion_lightbox',
  95. 'fusion_login' => 'fusion_login',
  96. 'fusion_register' => 'fusion_register',
  97. 'fusion_lost_password' => 'fusion_lost_password',
  98. 'menu_anchor' => 'menu_anchor',
  99. 'modal' => 'modal',
  100. //'modal_text_link' => 'modal_text_link',
  101. 'person' => 'person',
  102. //'popover' => 'popover',
  103. //'pricing_table' => 'pricing_table',
  104. 'progress' => 'progress',
  105. 'recent_posts' => 'recent_posts',
  106. 'recent_works' => 'recent_works',
  107. 'rev_slider' => 'rev_slider',
  108. 'section_separator' => 'section_separator',
  109. 'separator' => 'separator',
  110. 'sharing' => 'sharing',
  111. 'slider' => 'slider',
  112. 'soundcloud' => 'soundcloud',
  113. 'social_links' => 'social_links',
  114. 'fusion_tabs' => 'fusion_tabs',
  115. //TODO:: add table shortocode
  116. 'tagline_box' => 'tagline_box',
  117. 'testimonials' => 'testimonials',
  118. 'fusion_text' => 'fusion_text',
  119. 'title' => 'title',
  120. 'accordian' => 'accordian',
  121. //'tooltip' => 'tooltip',
  122. 'vimeo' => 'vimeo',
  123. 'fusion_widget_area' => 'fusion_widget_area',
  124. 'featured_products_slider' => 'featured_products_slider',
  125. 'products_slider' => 'products_slider',
  126. //TODO:: add woo shortcodes
  127. 'youtube' => 'youtube',
  128. //child attribs
  129. 'li_item' => 'li_item',
  130. 'client' => 'client',
  131. 'content_box' => 'content_box',
  132. 'counter_circle' => 'counter_circle',
  133. 'counter_box' => 'counter_box',
  134. 'flip_box' => 'flip_box',
  135. 'image' => 'image',
  136. 'slide' => 'slide',
  137. 'fusion_tab' => 'fusion_tab',
  138. 'testimonial' => 'testimonial',
  139. 'toggle' => 'toggle',
  140. 'fusionslider' => 'fusionslider',
  141. 'fusion_events' => 'fusion_events'
  142. );
  143. /**
  144. * Initialize the hooks and filters for the page builder UI
  145. *
  146. * @since 2.0.0
  147. */
  148. private function __construct() {
  149. }
  150. /**
  151. * return an instance of this class.
  152. *
  153. * @since 2.0.0
  154. * @return object A single instance of this class.
  155. */
  156. public static function get_instance() {
  157. // If the single instance hasn't been set, set it now.
  158. if ( null == self::$instance ) {
  159. self::$instance = new self;
  160. }
  161. return self::$instance;
  162. }
  163. /**
  164. * Print array nicely
  165. *
  166. * @since 2.0.0
  167. * @return null
  168. */
  169. private static function print_array( $array ) {
  170. echo "<pre>";
  171. print_r( $array );
  172. echo "</pre>";
  173. }
  174. public static function content_to_elements( $content ) {
  175. //turn off error reporting in order to avoid notices and errors. :: Required for compatiblity
  176. /*ini_set('display_errors',1);
  177. ini_set('display_startup_errors',1);*/
  178. error_reporting( 0 );
  179. $index = 0;
  180. //echo memory_get_usage() . "\n";
  181. $content = Fusion_Core_Reversal::convert_to_builder_blocks( $content );
  182. preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex() . '/s', $content, Fusion_Core_Reversal::$matches, PREG_SET_ORDER );
  183. //$memory_1 = memory_get_usage();
  184. if ( ! empty( Fusion_Core_Reversal::$matches ) ) {
  185. foreach ( Fusion_Core_Reversal::$matches as $match ) {
  186. switch ( $match[2] ) {
  187. case 'fullwidth':
  188. $full_width = new TF_FullWidthContainer();
  189. $full_width->config['index'] = $index;
  190. $full_width->config['id'] = Fusion_Core_Reversal::GUID();
  191. $index = $index + 1;
  192. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  193. if ( method_exists( 'TF_FullWidthContainer', 'deprecated_args' ) ) {
  194. $attribs = $full_width->deprecated_args( $attribs );
  195. }
  196. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $full_width->config['id'] );
  197. if ( ! is_array( $children ) ) {
  198. $attribs['content'] = stripslashes( $children );
  199. } else if ( is_array( $children ) ) {
  200. $full_width->config['childrenId'] = $children;
  201. }
  202. $full_width = Fusion_Core_Reversal::prepare_full_width( $attribs, $full_width );
  203. array_push( Fusion_Core_Reversal::$elements, $full_width->element_to_array() );
  204. break;
  205. default:
  206. Fusion_Core_Reversal::convert_builder_elements( $match, $index );
  207. break;
  208. }
  209. }
  210. }
  211. //var_dump(Fusion_Core_Reversal::$elements);
  212. header( "Content-Type: application/json" );
  213. //echo json_encode( array('count' => count( Fusion_Core_Reversal::$elements ) ) );
  214. echo json_encode( Fusion_Core_Reversal::$elements );
  215. //echo memory_get_usage() - $memory_1 . "\r\r";
  216. //echo memory_get_usage();
  217. exit();
  218. }
  219. /**
  220. * Retrieve the shortcode regular expression for searching.
  221. * The regular expression combines the shortcode tags in the regular expression
  222. * in a regex class.
  223. * The regular expression contains 6 different sub matches to help with parsing.
  224. * 1 - An extra [ to allow for escaping shortcodes with double [[]]
  225. * 2 - The shortcode name
  226. * 3 - The shortcode argument list
  227. * 4 - The self closing /
  228. * 5 - The content of a shortcode when it wraps some content.
  229. * 6 - An extra ] to allow for escaping shortcodes with double [[]]
  230. *
  231. * @since 2.0
  232. * @uses $shortcode_tags
  233. * @return string The shortcode search regular expression
  234. */
  235. public static function get_shortcode_regex( $ignored = false, $all = false ) {
  236. $shortcode_tags = Fusion_Core_Reversal::$tags;
  237. $ignored_shortcode_tags = array(
  238. 'highlight' => 'highlight',
  239. 'tooltip' => 'tooltip',
  240. 'popover' => 'popover',
  241. 'modal_text_link' => 'modal_text_link'
  242. );
  243. if ( $ignored ) {
  244. $shortcode_tags = $ignored_shortcode_tags;
  245. }
  246. if ( $all ) {
  247. $shortcode_tags = array_merge( $shortcode_tags, $ignored_shortcode_tags );
  248. }
  249. $tagnames = array_keys( $shortcode_tags );
  250. $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
  251. // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag()
  252. // Also, see shortcode_unautop() and shortcode.js.
  253. return
  254. '\\[' // Opening bracket
  255. . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]]
  256. . "($tagregexp)" // 2: Shortcode name
  257. . '(?![\\w-])' // Not followed by word character or hyphen
  258. . '(' // 3: Unroll the loop: Inside the opening shortcode tag
  259. . '[^\\]\\/]*' // Not a closing bracket or forward slash
  260. . '(?:'
  261. . '\\/(?!\\])' // A forward slash not followed by a closing bracket
  262. . '[^\\]\\/]*' // Not a closing bracket or forward slash
  263. . ')*?'
  264. . ')'
  265. . '(?:'
  266. . '(\\/)' // 4: Self closing tag ...
  267. . '\\]' // ... and closing bracket
  268. . '|'
  269. . '\\]' // Closing bracket
  270. . '(?:'
  271. . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags
  272. . '[^\\[]*+' // Not an opening bracket
  273. . '(?:'
  274. . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
  275. . '[^\\[]*+' // Not an opening bracket
  276. . ')*+'
  277. . ')'
  278. . '\\[\\/\\2\\]' // Closing shortcode tag
  279. . ')?'
  280. . ')'
  281. . '(\\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]]
  282. }
  283. /**
  284. * Get globally unique identifier
  285. *
  286. * @since 2.0.0
  287. * @return String
  288. */
  289. public static function GUID() {
  290. return 'fusionb_' . sprintf( '%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand( 0, 65535 ), mt_rand( 0, 65535 ),
  291. mt_rand( 0, 65535 ), mt_rand( 16384, 20479 ), mt_rand( 32768, 49151 ), mt_rand( 0, 65535 ),
  292. mt_rand( 0, 65535 ), mt_rand( 0, 65535 ) );
  293. }
  294. /**
  295. * Retrieve all attribsutes from the shortcodes tag.
  296. * The attributes list has the attribute name as the key and the value of the
  297. * attribute as the value in the key/value pair. This allows for easier
  298. * retrieval of the attributes, since all attributes have to be known.
  299. *
  300. * @since 2.0
  301. *
  302. * @param string $text
  303. *
  304. * @return array List of attributes and their value.
  305. */
  306. public static function shortcode_parse_atts( $text ) {
  307. $atts = array();
  308. $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
  309. $text = preg_replace( "/[\x{00a0}\x{200b}]+/u", " ", $text );
  310. if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) {
  311. foreach ( $match as $m ) {
  312. if ( ! empty( $m[1] ) ) {
  313. $atts[ strtolower( $m[1] ) ] = stripcslashes( $m[2] );
  314. } elseif ( ! empty( $m[3] ) ) {
  315. $atts[ strtolower( $m[3] ) ] = stripcslashes( $m[4] );
  316. } elseif ( ! empty( $m[5] ) ) {
  317. $atts[ strtolower( $m[5] ) ] = stripcslashes( $m[6] );
  318. } elseif ( isset( $m[7] ) and strlen( $m[7] ) ) {
  319. $atts[] = stripcslashes( $m[7] );
  320. } elseif ( isset( $m[8] ) ) {
  321. $atts[] = stripcslashes( $m[8] );
  322. }
  323. }
  324. } else {
  325. $atts = ltrim( $text );
  326. }
  327. return $atts;
  328. }
  329. /**
  330. * Whether the passed content contains the specified shortcode
  331. *
  332. * @since 2.0
  333. *
  334. * @param String $tags
  335. * @param string $tag
  336. *
  337. * @return boolean
  338. */
  339. public static function has_shortcode( $content, $tag, $ignored_shortcode = false ) {
  340. if ( false === strpos( $content, '[' ) ) {
  341. return false;
  342. }
  343. preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex( $ignored_shortcode ) . '/s', $content, $matches, PREG_SET_ORDER );
  344. if ( empty( $matches ) ) {
  345. return false;
  346. }
  347. foreach ( $matches as $shortcode ) {
  348. if ( $tag === $shortcode[2] ) {
  349. return true;
  350. }
  351. }
  352. return false;
  353. }
  354. /**
  355. * whether shortcode exists in provided content
  356. *
  357. * @since 2.0
  358. *
  359. * @param String $content
  360. *
  361. * @return boolean
  362. */
  363. public static function is_shortcode( $content ) {
  364. foreach ( Fusion_Core_Reversal::$tags as $tag ) {
  365. if ( Fusion_Core_Reversal::has_shortcode( $content, $tag ) ) {
  366. return true;
  367. }
  368. }
  369. return false;
  370. }
  371. /**
  372. * Whether child elements exists. Will be checked via parent tag
  373. *
  374. * @since 2.0
  375. *
  376. * @param String $content
  377. * @param Interger $index
  378. * @param string $parent
  379. *
  380. * @return Array ChildrenID
  381. */
  382. public static function check_for_child_elements( $content, &$index, $parent = null ) {
  383. if ( ! empty( $content ) && $content != ' ' ) {
  384. $content = Fusion_Core_Reversal::convert_to_builder_blocks( $content );
  385. if ( Fusion_Core_Reversal::is_shortcode( $content ) ) {
  386. $matches = null;
  387. $children = array();
  388. preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
  389. foreach ( $matches as $match ) {
  390. $child_id = Fusion_Core_Reversal::convert_builder_elements( $match, $index, $parent );
  391. array_push( $children, $child_id );
  392. }
  393. return $children;
  394. } else {
  395. return $content;
  396. }
  397. }
  398. return $content;
  399. }
  400. /**
  401. * Create text block element.
  402. *
  403. * @since 2.0
  404. *
  405. * @param String $content
  406. * @param Interger $index
  407. * @param String $parent
  408. *
  409. * @return Array ElementId
  410. */
  411. public static function create_text_element( $content, &$index, $parent = null ) {
  412. $children = array();
  413. $text_block = new TF_FusionText();
  414. $text_block->config['index'] = $index;
  415. $text_block->config['id'] = Fusion_Core_Reversal::GUID();
  416. $index = $index + 1;
  417. $text_block->config['subElements'][0]['value'] = stripslashes( $content );
  418. if ( ! is_null( $parent ) ) {
  419. $text_block->config['parentId'] = $parent;
  420. }
  421. array_push( Fusion_Core_Reversal::$elements, $text_block->element_to_array() );
  422. array_push( $children, array( 'id' => $text_block->config['id'] ) );
  423. return $children;
  424. }
  425. /**
  426. * Assign attributes to column options.
  427. *
  428. * @since 2.0
  429. *
  430. * @param String $match
  431. * @param Array $element
  432. *
  433. * @return Array Element
  434. */
  435. public static function prepare_column_options( $match, $element ) {
  436. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match ) );
  437. foreach ( $attribs as $key => $value ) {
  438. switch ( $key ) {
  439. case 'last':
  440. $element->config['subElements'][0]['value'] = $attribs[ $key ];
  441. break;
  442. case 'spacing':
  443. $element->config['subElements'][1]['value'] = $attribs[ $key ];
  444. break;
  445. case 'center_content':
  446. $element->config['subElements'][2]['value'] = $attribs[ $key ];
  447. break;
  448. case 'hide_on_mobile':
  449. $element->config['subElements'][3]['value'] = $attribs[ $key ];
  450. break;
  451. case 'background_color':
  452. $element->config['subElements'][4]['value'] = $attribs[ $key ];
  453. break;
  454. case 'background_image':
  455. $element->config['subElements'][5]['value'] = $attribs[ $key ];
  456. break;
  457. case 'background_repeat';
  458. $element->config['subElements'][6]['value'] = $attribs[ $key ];
  459. break;
  460. case 'background_position';
  461. $element->config['subElements'][7]['value'] = $attribs[ $key ];
  462. break;
  463. case 'hover_type':
  464. $element->config['subElements'][8]['value'] = $attribs[ $key ];
  465. break;
  466. case 'link':
  467. $element->config['subElements'][9]['value'] = $attribs[ $key ];
  468. break;
  469. case 'border_position';
  470. $element->config['subElements'][10]['value'] = $attribs[ $key ];
  471. break;
  472. case 'border_size';
  473. $element->config['subElements'][11]['value'] = $attribs[ $key ];
  474. break;
  475. case 'border_color';
  476. $element->config['subElements'][12]['value'] = $attribs[ $key ];
  477. break;
  478. case 'border_style';
  479. $element->config['subElements'][13]['value'] = $attribs[ $key ];
  480. break;
  481. case 'padding';
  482. $element->config['subElements'][14]['value'] = $attribs[ $key ];
  483. break;
  484. case 'margin_top';
  485. $element->config['subElements'][15]['value'] = $attribs[ $key ];
  486. break;
  487. case 'margin_bottom';
  488. $element->config['subElements'][16]['value'] = $attribs[ $key ];
  489. break;
  490. case 'animation_type';
  491. $element->config['subElements'][17]['value'] = $attribs[ $key ];
  492. break;
  493. case 'animation_direction';
  494. $element->config['subElements'][18]['value'] = $attribs[ $key ];
  495. break;
  496. case 'animation_speed';
  497. $element->config['subElements'][19]['value'] = $attribs[ $key ];
  498. break;
  499. case 'animation_offset';
  500. $element->config['subElements'][20]['value'] = $attribs[ $key ];
  501. break;
  502. case 'class':
  503. $element->config['subElements'][21]['value'] = $attribs[ $key ];
  504. break;
  505. case 'id':
  506. $element->config['subElements'][22]['value'] = $attribs[ $key ];
  507. break;
  508. }
  509. }
  510. return $element;
  511. }
  512. /**
  513. * Converted matched short-codes to builder elements.
  514. *
  515. * @since 2.0
  516. *
  517. * @param String $match
  518. * @param Interger $index
  519. * @param string $parent
  520. *
  521. * @return Array ID
  522. */
  523. public static function convert_builder_elements( $match, &$index, $parent = null ) {
  524. switch ( $match[2] ) {
  525. case 'one_full':
  526. $grid_one = new TF_GridOne();
  527. $grid_one->config['index'] = $index;
  528. $grid_one->config['id'] = Fusion_Core_Reversal::GUID();
  529. $grid_one = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_one );
  530. $index = $index + 1;
  531. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_one->config['id'] );
  532. if ( is_array( $children ) ) {
  533. $grid_one->config['childrenId'] = $children;
  534. }
  535. if ( ! is_null( $parent ) ) {
  536. $grid_one->config['parentId'] = $parent;
  537. }
  538. array_push( Fusion_Core_Reversal::$elements, $grid_one->element_to_array() );
  539. return array( 'id' => $grid_one->config['id'] );
  540. break;
  541. case 'one_half':
  542. $grid_two = new TF_GridTwo();
  543. $grid_two->config['index'] = $index;
  544. $grid_two->config['id'] = Fusion_Core_Reversal::GUID();
  545. $grid_two = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two );
  546. $index = $index + 1;
  547. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two->config['id'] );
  548. if ( is_array( $children ) ) {
  549. $grid_two->config['childrenId'] = $children;
  550. }
  551. if ( ! is_null( $parent ) ) {
  552. $grid_two->config['parentId'] = $parent;
  553. }
  554. array_push( Fusion_Core_Reversal::$elements, $grid_two->element_to_array() );
  555. return array( 'id' => $grid_two->config['id'] );
  556. break;
  557. case 'one_third':
  558. $grid_three = new TF_GridThree();
  559. $grid_three->config['index'] = $index;
  560. $grid_three->config['id'] = Fusion_Core_Reversal::GUID();
  561. $grid_three = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three );
  562. $index = $index + 1;
  563. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three->config['id'] );
  564. if ( is_array( $children ) ) {
  565. $grid_three->config['childrenId'] = $children;
  566. }
  567. if ( ! is_null( $parent ) ) {
  568. $grid_three->config['parentId'] = $parent;
  569. }
  570. array_push( Fusion_Core_Reversal::$elements, $grid_three->element_to_array() );
  571. return array( 'id' => $grid_three->config['id'] );
  572. break;
  573. case 'one_fourth':
  574. $grid_four = new TF_GridFour();
  575. $grid_four->config['index'] = $index;
  576. $grid_four->config['id'] = Fusion_Core_Reversal::GUID();
  577. $grid_four = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_four );
  578. $index = $index + 1;
  579. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_four->config['id'] );
  580. if ( is_array( $children ) ) {
  581. $grid_four->config['childrenId'] = $children;
  582. }
  583. if ( ! is_null( $parent ) ) {
  584. $grid_four->config['parentId'] = $parent;
  585. }
  586. array_push( Fusion_Core_Reversal::$elements, $grid_four->element_to_array() );
  587. return array( 'id' => $grid_four->config['id'] );
  588. break;
  589. case 'one_fifth':
  590. $grid_five = new TF_GridFive();
  591. $grid_five->config['index'] = $index;
  592. $grid_five->config['id'] = Fusion_Core_Reversal::GUID();
  593. $grid_five = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_five );
  594. $index = $index + 1;
  595. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_five->config['id'] );
  596. if ( is_array( $children ) ) {
  597. $grid_five->config['childrenId'] = $children;
  598. }
  599. if ( ! is_null( $parent ) ) {
  600. $grid_five->config['parentId'] = $parent;
  601. }
  602. array_push( Fusion_Core_Reversal::$elements, $grid_five->element_to_array() );
  603. return array( 'id' => $grid_five->config['id'] );
  604. break;
  605. case 'two_fifth':
  606. $grid_two_fifth = new TF_GridTwoFifth();
  607. $grid_two_fifth->config['index'] = $index;
  608. $grid_two_fifth->config['id'] = Fusion_Core_Reversal::GUID();
  609. $grid_two_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two_fifth );
  610. $index = $index + 1;
  611. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two_fifth->config['id'] );
  612. if ( is_array( $children ) ) {
  613. $grid_two_fifth->config['childrenId'] = $children;
  614. }
  615. if ( ! is_null( $parent ) ) {
  616. $grid_two_fifth->config['parentId'] = $parent;
  617. }
  618. array_push( Fusion_Core_Reversal::$elements, $grid_two_fifth->element_to_array() );
  619. return array( 'id' => $grid_two_fifth->config['id'] );
  620. break;
  621. case 'three_fifth':
  622. $grid_three_fifth = new TF_GridThreeFifth();
  623. $grid_three_fifth->config['index'] = $index;
  624. $grid_three_fifth->config['id'] = Fusion_Core_Reversal::GUID();
  625. $grid_three_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three_fifth );
  626. $index = $index + 1;
  627. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three_fifth->config['id'] );
  628. if ( is_array( $children ) ) {
  629. $grid_three_fifth->config['childrenId'] = $children;
  630. }
  631. if ( ! is_null( $parent ) ) {
  632. $grid_three_fifth->config['parentId'] = $parent;
  633. }
  634. array_push( Fusion_Core_Reversal::$elements, $grid_three_fifth->element_to_array() );
  635. return array( 'id' => $grid_three_fifth->config['id'] );
  636. break;
  637. case 'four_fifth':
  638. $grid_four_fifth = new TF_GridFourFifth();
  639. $grid_four_fifth->config['index'] = $index;
  640. $grid_four_fifth->config['id'] = Fusion_Core_Reversal::GUID();
  641. $grid_four_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_four_fifth );
  642. $index = $index + 1;
  643. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_four_fifth->config['id'] );
  644. if ( is_array( $children ) ) {
  645. $grid_four_fifth->config['childrenId'] = $children;
  646. }
  647. if ( ! is_null( $parent ) ) {
  648. $grid_four_fifth->config['parentId'] = $parent;
  649. }
  650. array_push( Fusion_Core_Reversal::$elements, $grid_four_fifth->element_to_array() );
  651. return array( 'id' => $grid_four_fifth->config['id'] );
  652. break;
  653. case 'one_sixth':
  654. $grid_six = new TF_GridSix();
  655. $grid_six->config['index'] = $index;
  656. $grid_six->config['id'] = Fusion_Core_Reversal::GUID();
  657. $grid_six = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_six );
  658. $index = $index + 1;
  659. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_six->config['id'] );
  660. if ( is_array( $children ) ) {
  661. $grid_six->config['childrenId'] = $children;
  662. }
  663. if ( ! is_null( $parent ) ) {
  664. $grid_six->config['parentId'] = $parent;
  665. }
  666. array_push( Fusion_Core_Reversal::$elements, $grid_six->element_to_array() );
  667. return array( 'id' => $grid_six->config['id'] );
  668. break;
  669. case 'five_sixth':
  670. $grid_five_six = new TF_GridFiveSix();
  671. $grid_five_six->config['index'] = $index;
  672. $grid_five_six->config['id'] = Fusion_Core_Reversal::GUID();
  673. $grid_five_six = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_five_six );
  674. $index = $index + 1;
  675. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_five_six->config['id'] );
  676. if ( is_array( $children ) ) {
  677. $grid_five_six->config['childrenId'] = $children;
  678. }
  679. if ( ! is_null( $parent ) ) {
  680. $grid_five_six->config['parentId'] = $parent;
  681. }
  682. array_push( Fusion_Core_Reversal::$elements, $grid_five_six->element_to_array() );
  683. return array( 'id' => $grid_five_six->config['id'] );
  684. break;
  685. case 'three_fourth':
  686. $grid_three_fourth = new TF_GridThreeFourth();
  687. $grid_three_fourth->config['index'] = $index;
  688. $grid_three_fourth->config['id'] = Fusion_Core_Reversal::GUID();
  689. $grid_three_fourth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three_fourth );
  690. $index = $index + 1;
  691. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three_fourth->config['id'] );
  692. if ( is_array( $children ) ) {
  693. $grid_three_fourth->config['childrenId'] = $children;
  694. }
  695. if ( ! is_null( $parent ) ) {
  696. $grid_three_fourth->config['parentId'] = $parent;
  697. }
  698. array_push( Fusion_Core_Reversal::$elements, $grid_three_fourth->element_to_array() );
  699. return array( 'id' => $grid_three_fourth->config['id'] );
  700. break;
  701. case 'two_third':
  702. $grid_two_third = new TF_GridTwoThird();
  703. $grid_two_third->config['index'] = $index;
  704. $grid_two_third->config['id'] = Fusion_Core_Reversal::GUID();
  705. $grid_two_third = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two_third );
  706. $index = $index + 1;
  707. $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two_third->config['id'] );
  708. if ( is_array( $children ) ) {
  709. $grid_two_third->config['childrenId'] = $children;
  710. }
  711. if ( ! is_null( $parent ) ) {
  712. $grid_two_third->config['parentId'] = $parent;
  713. }
  714. array_push( Fusion_Core_Reversal::$elements, $grid_two_third->element_to_array() );
  715. return array( 'id' => $grid_two_third->config['id'] );
  716. break;
  717. case 'alert':
  718. $alert_box = new TF_AlertBox();
  719. $alert_box->config['index'] = $index;
  720. $alert_box->config['id'] = Fusion_Core_Reversal::GUID();
  721. $index = $index + 1;
  722. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  723. $attribs['content'] = stripslashes( $match[5] );
  724. $alert_box = Fusion_Core_Reversal::prepare_alert_box( $attribs, $alert_box );
  725. if ( ! is_null( $parent ) ) {
  726. $alert_box->config['parentId'] = $parent;
  727. }
  728. array_push( Fusion_Core_Reversal::$elements, $alert_box->element_to_array() );
  729. return array( 'id' => $alert_box->config['id'] );
  730. break;
  731. case 'blog':
  732. $wp_blog = new TF_WpBlog();
  733. $wp_blog->config['index'] = $index;
  734. $wp_blog->config['id'] = Fusion_Core_Reversal::GUID();
  735. $index = $index + 1;
  736. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  737. $wp_blog = Fusion_Core_Reversal::prepare_wp_blog( $attribs, $wp_blog );
  738. if ( ! is_null( $parent ) ) {
  739. $wp_blog->config['parentId'] = $parent;
  740. }
  741. array_push( Fusion_Core_Reversal::$elements, $wp_blog->element_to_array() );
  742. return array( 'id' => $wp_blog->config['id'] );
  743. break;
  744. case 'button':
  745. $wp_button = new TF_ButtonBlock();
  746. $wp_button->config['index'] = $index;
  747. $wp_button->config['id'] = Fusion_Core_Reversal::GUID();
  748. $index = $index + 1;
  749. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  750. $attribs['content'] = stripslashes( $match[5] );
  751. $wp_button = Fusion_Core_Reversal::prepare_wp_button( $attribs, $wp_button );
  752. if ( ! is_null( $parent ) ) {
  753. $wp_button->config['parentId'] = $parent;
  754. }
  755. array_push( Fusion_Core_Reversal::$elements, $wp_button->element_to_array() );
  756. return array( 'id' => $wp_button->config['id'] );
  757. break;
  758. case 'checklist':
  759. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  760. $attribs = Fusion_Core_Reversal::get_checklist_child_attrib( $match, $attribs );
  761. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  762. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  763. if ( $am_actual_value == null ) {
  764. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  765. }
  766. }
  767. }
  768. $checklist = new TF_CheckList( $attribs['addmore'] );
  769. $checklist->config['index'] = $index;
  770. $checklist->config['id'] = Fusion_Core_Reversal::GUID();
  771. $index = $index + 1;
  772. $checklist = Fusion_Core_Reversal::prepare_checklist( $attribs, $checklist );
  773. if ( ! is_null( $parent ) ) {
  774. $checklist->config['parentId'] = $parent;
  775. }
  776. array_push( Fusion_Core_Reversal::$elements, $checklist->element_to_array() );
  777. return array( 'id' => $checklist->config['id'] );
  778. break;
  779. case 'clients':
  780. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  781. $attribs['lightbox'] = 'no';
  782. $attribs = Fusion_Core_Reversal::get_carousel_child_attrib( $match, $attribs );
  783. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  784. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  785. if ( $am_actual_value == null ) {
  786. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  787. }
  788. }
  789. }
  790. $image_carousel = new TF_ImageCarousel( $attribs['addmore'] );
  791. $image_carousel->config['index'] = $index;
  792. $image_carousel->config['id'] = Fusion_Core_Reversal::GUID();
  793. $index = $index + 1;
  794. $image_carousel = Fusion_Core_Reversal::prepare_carousel( $attribs, $image_carousel );
  795. if ( ! is_null( $parent ) ) {
  796. $image_carousel->config['parentId'] = $parent;
  797. }
  798. array_push( Fusion_Core_Reversal::$elements, $image_carousel->element_to_array() );
  799. return array( 'id' => $image_carousel->config['id'] );
  800. break;
  801. case 'fusion_code':
  802. $code_block = new TF_CodeBlock();
  803. $code_block->config['index'] = $index;
  804. $code_block->config['id'] = Fusion_Core_Reversal::GUID();
  805. $index = $index + 1;
  806. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  807. $code_content = stripslashes( $match[5] );
  808. if ( base64_encode( base64_decode( $code_content ) ) === $code_content ){
  809. $code_content = base64_decode( $code_content );
  810. } else {
  811. //not encoded
  812. }
  813. $attribs['content'] = str_replace('</textarea>', htmlentities('</textarea>'), $code_content);
  814. $code_block = Fusion_Core_Reversal::prepare_code_block( $attribs, $code_block );
  815. if ( ! is_null( $parent ) ) {
  816. $code_block->config['parentId'] = $parent;
  817. }
  818. array_push( Fusion_Core_Reversal::$elements, $code_block->element_to_array() );
  819. return array( 'id' => $code_block->config['id'] );
  820. break;
  821. case 'content_boxes':
  822. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  823. $attribs = Fusion_Core_Reversal::get_content_boxes_child_attrib( $match, $attribs );
  824. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  825. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  826. if ( $am_actual_value == null ) {
  827. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  828. }
  829. }
  830. }
  831. if ( ( $attribs['layout'] == 'none' || $attribs['layout'] == 'icon-on-side' || $attribs['layout'] == 'icon-with-title' ) && ( ! isset( $attribs['icon_circle_size'] ) || $attribs['icon_circle_size'] == '' ) ) {
  832. $attribs['icon_circle_size'] = 'small';
  833. } elseif ( ! isset( $attribs['icon_circle_size'] ) && $attribs['icon_circle_size'] == '' ) {
  834. $attribs['icon_circle_size'] = 'large';
  835. }
  836. $content_boxes = new TF_ContentBoxes( $attribs['addmore'] );
  837. $content_boxes->config['index'] = $index;
  838. $content_boxes->config['id'] = Fusion_Core_Reversal::GUID();
  839. $index = $index + 1;
  840. $content_boxes = Fusion_Core_Reversal::prepare_content_boxes( $attribs, $content_boxes );
  841. if ( ! is_null( $parent ) ) {
  842. $content_boxes->config['parentId'] = $parent;
  843. }
  844. array_push( Fusion_Core_Reversal::$elements, $content_boxes->element_to_array() );
  845. return array( 'id' => $content_boxes->config['id'] );
  846. break;
  847. case 'fusion_countdown':
  848. $countdown = new TF_CountDown();
  849. $countdown->config['index'] = $index;
  850. $countdown->config['id'] = Fusion_Core_Reversal::GUID();
  851. $index = $index + 1;
  852. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  853. $attribs['content'] = stripslashes( $match[5] );
  854. $countdown = Fusion_Core_Reversal::prepare_countdown( $attribs, $countdown );
  855. if ( ! is_null( $parent ) ) {
  856. $countdown->config['parentId'] = $parent;
  857. }
  858. array_push( Fusion_Core_Reversal::$elements, $countdown->element_to_array() );
  859. return array( 'id' => $countdown->config['id'] );
  860. break;
  861. case 'counters_circle':
  862. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  863. $attribs = Fusion_Core_Reversal::get_counter_circle_child_attrib( $match, $attribs );
  864. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  865. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  866. if ( $am_actual_value == null ) {
  867. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  868. }
  869. }
  870. }
  871. $counter_circle = new TF_CounterCircle( $attribs['addmore'] );
  872. $counter_circle->config['index'] = $index;
  873. $counter_circle->config['id'] = Fusion_Core_Reversal::GUID();
  874. $index = $index + 1;
  875. $counter_circle = Fusion_Core_Reversal::prepare_counter_circle( $attribs, $counter_circle );
  876. if ( ! is_null( $parent ) ) {
  877. $counter_circle->config['parentId'] = $parent;
  878. }
  879. array_push( Fusion_Core_Reversal::$elements, $counter_circle->element_to_array() );
  880. return array( 'id' => $counter_circle->config['id'] );
  881. break;
  882. case 'counters_box':
  883. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  884. $attribs = Fusion_Core_Reversal::get_counter_box_child_attrib( $match, $attribs );
  885. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  886. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  887. if ( $am_actual_value == null ) {
  888. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  889. }
  890. }
  891. }
  892. $counter_box = new TF_CounterBox( $attribs['addmore'] );
  893. $counter_box->config['index'] = $index;
  894. $counter_box->config['id'] = Fusion_Core_Reversal::GUID();
  895. $index = $index + 1;
  896. $counter_box = Fusion_Core_Reversal::prepare_counter_box( $attribs, $counter_box );
  897. if ( ! is_null( $parent ) ) {
  898. $counter_box->config['parentId'] = $parent;
  899. }
  900. array_push( Fusion_Core_Reversal::$elements, $counter_box->element_to_array() );
  901. return array( 'id' => $counter_box->config['id'] );
  902. break;
  903. /*case 'dropcap':
  904. $drop_Cap = new TF_DropCap();
  905. $drop_Cap->config['index'] = $index;
  906. $drop_Cap->config['id'] = Fusion_Core_Reversal::GUID();
  907. $index = $index + 1;
  908. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  909. $attribs['content'] = stripslashes( $match[5] );
  910. $drop_Cap = Fusion_Core_Reversal::prepare_wp_drop_Cap( $attribs, $drop_Cap );
  911. if ( !is_null( $parent ) ) { $drop_Cap->config['parentId'] = $parent; }
  912. array_push( Fusion_Core_Reversal::$elements , $drop_Cap->element_to_array() );
  913. return array( 'id' => $drop_Cap->config['id'] );
  914. break;*/
  915. case 'postslider':
  916. $post_slider = new TF_PostSlider();
  917. $post_slider->config['index'] = $index;
  918. $post_slider->config['id'] = Fusion_Core_Reversal::GUID();
  919. $index = $index + 1;
  920. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  921. $post_slider = Fusion_Core_Reversal::prepare_post_slider( $attribs, $post_slider );
  922. if ( ! is_null( $parent ) ) {
  923. $post_slider->config['parentId'] = $parent;
  924. }
  925. array_push( Fusion_Core_Reversal::$elements, $post_slider->element_to_array() );
  926. return array( 'id' => $post_slider->config['id'] );
  927. break;
  928. case 'flip_boxes':
  929. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  930. $attribs = Fusion_Core_Reversal::get_flip_boxes_child_attrib( $match, $attribs );
  931. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  932. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  933. if ( $am_actual_value == null ) {
  934. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  935. }
  936. }
  937. }
  938. $flip_boxes = new TF_FlipBoxes( $attribs['addmore'] );
  939. $flip_boxes->config['index'] = $index;
  940. $flip_boxes->config['id'] = Fusion_Core_Reversal::GUID();
  941. $index = $index + 1;
  942. $flip_boxes = Fusion_Core_Reversal::prepare_flip_boxes( $attribs, $flip_boxes );
  943. if ( ! is_null( $parent ) ) {
  944. $flip_boxes->config['parentId'] = $parent;
  945. }
  946. array_push( Fusion_Core_Reversal::$elements, $flip_boxes->element_to_array() );
  947. return array( 'id' => $flip_boxes->config['id'] );
  948. break;
  949. case 'fontawesome':
  950. $font_awesmoe = new TF_FontAwesome();
  951. $font_awesmoe->config['index'] = $index;
  952. $font_awesmoe->config['id'] = Fusion_Core_Reversal::GUID();
  953. $index = $index + 1;
  954. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  955. $font_awesmoe = Fusion_Core_Reversal::prepare_wp_font_awesmoe( $attribs, $font_awesmoe );
  956. if ( ! is_null( $parent ) ) {
  957. $font_awesmoe->config['parentId'] = $parent;
  958. }
  959. array_push( Fusion_Core_Reversal::$elements, $font_awesmoe->element_to_array() );
  960. return array( 'id' => $font_awesmoe->config['id'] );
  961. break;
  962. case 'map':
  963. $google_map = new TF_GoogleMap();
  964. $google_map->config['index'] = $index;
  965. $google_map->config['id'] = Fusion_Core_Reversal::GUID();
  966. $index = $index + 1;
  967. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  968. $google_map = Fusion_Core_Reversal::prepare_wp_google_map( $attribs, $google_map );
  969. if ( ! is_null( $parent ) ) {
  970. $google_map->config['parentId'] = $parent;
  971. }
  972. array_push( Fusion_Core_Reversal::$elements, $google_map->element_to_array() );
  973. return array( 'id' => $google_map->config['id'] );
  974. break;
  975. /*case 'highlight':
  976. $high_light = new TF_HighLight();
  977. $high_light->config['index'] = $index;
  978. $high_light->config['id'] = Fusion_Core_Reversal::GUID();
  979. $index = $index + 1;
  980. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  981. $attribs['content'] = stripslashes( $match[5] );
  982. $high_light = Fusion_Core_Reversal::prepare_wp_high_light( $attribs, $high_light );
  983. if ( !is_null( $parent ) ) { $high_light->config['parentId'] = $parent; }
  984. array_push( Fusion_Core_Reversal::$elements , $high_light->element_to_array() );
  985. return array( 'id' => $high_light->config['id'] );
  986. break;*/
  987. case 'imageframe':
  988. $image_frame = new TF_ImageFrame();
  989. $image_frame->config['index'] = $index;
  990. $image_frame->config['id'] = Fusion_Core_Reversal::GUID();
  991. $index = $index + 1;
  992. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  993. //get img src and alt attribs
  994. $image_attrib = null;
  995. $doc = new DOMDocument();
  996. $doc->encoding = 'utf-8'; //for sepcial characters handeling
  997. @$doc->loadHTML( '<?xml encoding="UTF-8">' . stripslashes( $match[5] ) );
  998. $tags = $doc->getElementsByTagName( 'img' );
  999. foreach ( $tags as $tag ) {
  1000. $attribs['src'] = $tag->getAttribute( 'src' );
  1001. $attribs['alt'] = $tag->getAttribute( 'alt' );
  1002. }
  1003. $image_frame = Fusion_Core_Reversal::prepare_image_frame( $attribs, $image_frame );
  1004. if ( ! is_null( $parent ) ) {
  1005. $image_frame->config['parentId'] = $parent;
  1006. }
  1007. array_push( Fusion_Core_Reversal::$elements, $image_frame->element_to_array() );
  1008. return array( 'id' => $image_frame->config['id'] );
  1009. break;
  1010. case 'images':
  1011. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  1012. $attribs = Fusion_Core_Reversal::get_carousel_child_attrib( $match, $attribs );
  1013. foreach ( $attribs['addmore'] as $am_key => $am_value ) {
  1014. foreach ( $am_value as $am_actual_key => $am_actual_value ) {
  1015. if ( $am_actual_value == null ) {
  1016. $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
  1017. }
  1018. }
  1019. }
  1020. $image_carousel = new TF_ImageCarousel( $attribs['addmore'] );
  1021. $image_carousel->config['index'] = $index;
  1022. $image_carousel->config['id'] = Fusion_Core_Reversal::GUID();
  1023. $index = $index + 1;
  1024. $image_carousel = Fusion_Core_Reversal::prepare_carousel( $attribs, $image_carousel );
  1025. if ( ! is_null( $parent ) ) {
  1026. $image_carousel->config['parentId'] = $parent;
  1027. }
  1028. array_push( Fusion_Core_Reversal::$elements, $image_carousel->element_to_array() );
  1029. return array( 'id' => $image_carousel->config['id'] );
  1030. break;
  1031. case 'layerslider':
  1032. $layer_slider = new TF_LayerSlider();
  1033. $layer_slider->config['index'] = $index;
  1034. $layer_slider->config['id'] = Fusion_Core_Reversal::GUID();
  1035. $index = $index + 1;
  1036. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  1037. $layer_slider = Fusion_Core_Reversal::prepare_layerslider( $attribs, $layer_slider );
  1038. if ( ! is_null( $parent ) ) {
  1039. $layer_slider->config['parentId'] = $parent;
  1040. }
  1041. array_push( Fusion_Core_Reversal::$elements, $layer_slider->element_to_array() );
  1042. return array( 'id' => $layer_slider->config['id'] );
  1043. break;
  1044. case 'fusion_lightbox':
  1045. $image_frame = new TF_ImageFrame();
  1046. $image_frame->config['index'] = $index;
  1047. $image_frame->config['id'] = Fusion_Core_Reversal::GUID();
  1048. $index = $index + 1;
  1049. //get attribs
  1050. $doc = new DOMDocument();
  1051. $aData = array();
  1052. $iData = array();
  1053. $doc->loadHTML( '<?xml encoding="UTF-8">' . stripslashes( $match[5] ) );
  1054. $anchor = $doc->getElementsByTagName( 'a' );
  1055. $image = $doc->getElementsByTagName( 'img' );
  1056. //get anchor data
  1057. foreach ( $anchor as $node ) {
  1058. if ( $node->hasAttributes() ) {
  1059. foreach ( $node->attributes as $a ) {
  1060. if ( $a->name == 'href' ) {
  1061. $aData[ 'lightbox_image' ] = $a->value;
  1062. } else if ( $a->name == 'data-caption' ) {
  1063. $aData[ 'alt' ] = $a->value;
  1064. } else {
  1065. $aData[ $a->name ] = $a->value;
  1066. }
  1067. }
  1068. }
  1069. $aData[ 'lightbox' ] = 'yes';
  1070. }
  1071. //get image data
  1072. foreach ( $image as $node ) {
  1073. if ( $node->hasAttributes() ) {
  1074. foreach ( $node->attributes as $a ) {
  1075. $iData[ $a->name ] = $a->value;
  1076. }
  1077. }
  1078. }
  1079. //combine data
  1080. $attribs = array_merge( $iData, $aData );
  1081. $image_frame = Fusion_Core_Reversal::prepare_image_frame( $attribs, $image_frame );
  1082. if ( ! is_null( $parent ) ) {
  1083. $image_frame->config['parentId'] = $parent;
  1084. }
  1085. array_push( Fusion_Core_Reversal::$elements, $image_frame->element_to_array() );
  1086. return array( 'id' => $image_frame->config['id'] );
  1087. break;
  1088. case 'fusion_login':
  1089. case 'fusion_register':
  1090. case 'fusion_lost_password':
  1091. $login = new TF_Login();
  1092. $login->config['index'] = $index;
  1093. $login->config['id'] = Fusion_Core_Reversal::GUID();
  1094. $index = $index + 1;
  1095. $attribs = array_merge( array( 'fusion_login_type' => $match[2] ), Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) ) );
  1096. $login = Fusion_Core_Reversal::prepare_login( $attribs, $login );
  1097. if ( ! is_null( $parent ) ) {
  1098. $login->config['parentId'] = $parent;
  1099. }
  1100. array_push( Fusion_Core_Reversal::$elements, $login->element_to_array() );
  1101. return array( 'id' => $login->config['id'] );
  1102. break;
  1103. case 'menu_anchor':
  1104. $menu_anchor = new TF_MenuAnchor();
  1105. $menu_anchor->config['index'] = $index;
  1106. $menu_anchor->config['id'] = Fusion_Core_Reversal::GUID();
  1107. $index = $index + 1;
  1108. $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
  1109. $menu_anchor = Fusion_Core_Reversal::prepare_menu_anchor( $attribs, $menu_anch