/wp-content/plugins/fusion-core/admin/page-builder/classes/class-fusion-reversal.php
PHP | 1328 lines | 894 code | 214 blank | 220 comment | 104 complexity | 51b81ab16d70a752a75b530a7a9a8033 MD5 | raw file
- <?php
- /**
- * content to builder elements convertor
- *
- * @package FusionCore
- * @author ThemeFusion
- * @link http://theme-fusion.com
- * @copyright ThemeFusion
- */
- if ( ! class_exists( 'Fusion_Core_Reversal' ) ) {
- class Fusion_Core_Reversal {
- /**
- * Instance of this class.
- *
- * @since 2.0.0
- * @var object
- */
- protected static $instance = null;
- /**
- * content of current post/page.
- *
- * @since 2.0.0
- * @var object
- */
- protected static $content = null;
- /**
- * array of all matched short-codes.
- *
- * @since 2.0.0
- * @var Array
- */
- protected static $matches = null;
- /**
- * array of all created elements.
- *
- * @since 2.0.0
- * @var Array
- */
- protected static $elements = array();
- /**
- * builder blocks count
- *
- * @since 2.0.0
- * @var Integer
- */
- protected static $builder_blocks_count = 1;
- /**
- * prepared builder blocks
- *
- * @since 2.0.0
- * @var Array
- */
- protected static $prepared_builder_blocks = array();
- /**
- * array of all available short-codes.
- *
- * @since 2.0.0
- * @var object
- */
- public static $tags = array(
- 'one_full' => 'one_full',
- 'one_half' => 'one_half',
- 'one_third' => 'one_third',
- 'one_fourth' => 'one_fourth',
- 'one_fifth' => 'one_fifth',
- 'two_fifth' => 'two_fifth',
- 'three_fifth' => 'three_fifth',
- 'four_fifth' => 'four_fifth',
- 'one_sixth' => 'one_sixth',
- 'five_sixth' => 'five_sixth',
- 'three_fourth' => 'three_fourth',
- 'two_third' => 'two_third',
- 'fullwidth' => 'fullwidth',
- 'alert' => 'alert',
- 'blog' => 'blog',
- 'button' => 'button',
- 'checklist' => 'checklist',
- 'clients' => 'clients',
- 'fusion_code' => 'fusion_code',
- 'content_boxes' => 'content_boxes',
- 'fusion_countdown' => 'fusion_countdown',
- 'counters_circle' => 'counters_circle',
- 'counters_box' => 'counters_box',
- //'dropcap' => 'dropcap',
- 'postslider' => 'postslider',
- 'flip_boxes' => 'flip_boxes',
- 'fontawesome' => 'fontawesome',
- 'map' => 'map',
- //'highlight' => 'highlight',
- 'imageframe' => 'imageframe',
- 'images' => 'images',
- //TODO:: add lightbox shortcode
- 'layerslider' => 'layerslider',
- 'fusion_lightbox' => 'fusion_lightbox',
- 'fusion_login' => 'fusion_login',
- 'fusion_register' => 'fusion_register',
- 'fusion_lost_password' => 'fusion_lost_password',
- 'menu_anchor' => 'menu_anchor',
- 'modal' => 'modal',
- //'modal_text_link' => 'modal_text_link',
- 'person' => 'person',
- //'popover' => 'popover',
- //'pricing_table' => 'pricing_table',
- 'progress' => 'progress',
- 'recent_posts' => 'recent_posts',
- 'recent_works' => 'recent_works',
- 'rev_slider' => 'rev_slider',
- 'section_separator' => 'section_separator',
- 'separator' => 'separator',
- 'sharing' => 'sharing',
- 'slider' => 'slider',
- 'soundcloud' => 'soundcloud',
- 'social_links' => 'social_links',
- 'fusion_tabs' => 'fusion_tabs',
- //TODO:: add table shortocode
- 'tagline_box' => 'tagline_box',
- 'testimonials' => 'testimonials',
- 'fusion_text' => 'fusion_text',
- 'title' => 'title',
- 'accordian' => 'accordian',
- //'tooltip' => 'tooltip',
- 'vimeo' => 'vimeo',
- 'fusion_widget_area' => 'fusion_widget_area',
- 'featured_products_slider' => 'featured_products_slider',
- 'products_slider' => 'products_slider',
- //TODO:: add woo shortcodes
- 'youtube' => 'youtube',
- //child attribs
- 'li_item' => 'li_item',
- 'client' => 'client',
- 'content_box' => 'content_box',
- 'counter_circle' => 'counter_circle',
- 'counter_box' => 'counter_box',
- 'flip_box' => 'flip_box',
- 'image' => 'image',
- 'slide' => 'slide',
- 'fusion_tab' => 'fusion_tab',
- 'testimonial' => 'testimonial',
- 'toggle' => 'toggle',
- 'fusionslider' => 'fusionslider',
- 'fusion_events' => 'fusion_events'
- );
- /**
- * Initialize the hooks and filters for the page builder UI
- *
- * @since 2.0.0
- */
- private function __construct() {
- }
- /**
- * return an instance of this class.
- *
- * @since 2.0.0
- * @return object A single instance of this class.
- */
- public static function get_instance() {
- // If the single instance hasn't been set, set it now.
- if ( null == self::$instance ) {
- self::$instance = new self;
- }
- return self::$instance;
- }
- /**
- * Print array nicely
- *
- * @since 2.0.0
- * @return null
- */
- private static function print_array( $array ) {
- echo "<pre>";
- print_r( $array );
- echo "</pre>";
- }
- public static function content_to_elements( $content ) {
- //turn off error reporting in order to avoid notices and errors. :: Required for compatiblity
- /*ini_set('display_errors',1);
- ini_set('display_startup_errors',1);*/
- error_reporting( 0 );
- $index = 0;
- //echo memory_get_usage() . "\n";
- $content = Fusion_Core_Reversal::convert_to_builder_blocks( $content );
- preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex() . '/s', $content, Fusion_Core_Reversal::$matches, PREG_SET_ORDER );
- //$memory_1 = memory_get_usage();
- if ( ! empty( Fusion_Core_Reversal::$matches ) ) {
- foreach ( Fusion_Core_Reversal::$matches as $match ) {
- switch ( $match[2] ) {
- case 'fullwidth':
- $full_width = new TF_FullWidthContainer();
- $full_width->config['index'] = $index;
- $full_width->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- if ( method_exists( 'TF_FullWidthContainer', 'deprecated_args' ) ) {
- $attribs = $full_width->deprecated_args( $attribs );
- }
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $full_width->config['id'] );
- if ( ! is_array( $children ) ) {
- $attribs['content'] = stripslashes( $children );
- } else if ( is_array( $children ) ) {
- $full_width->config['childrenId'] = $children;
- }
- $full_width = Fusion_Core_Reversal::prepare_full_width( $attribs, $full_width );
- array_push( Fusion_Core_Reversal::$elements, $full_width->element_to_array() );
- break;
- default:
- Fusion_Core_Reversal::convert_builder_elements( $match, $index );
- break;
- }
- }
- }
- //var_dump(Fusion_Core_Reversal::$elements);
- header( "Content-Type: application/json" );
- //echo json_encode( array('count' => count( Fusion_Core_Reversal::$elements ) ) );
- echo json_encode( Fusion_Core_Reversal::$elements );
- //echo memory_get_usage() - $memory_1 . "\r\r";
- //echo memory_get_usage();
- exit();
- }
- /**
- * Retrieve the shortcode regular expression for searching.
- * The regular expression combines the shortcode tags in the regular expression
- * in a regex class.
- * The regular expression contains 6 different sub matches to help with parsing.
- * 1 - An extra [ to allow for escaping shortcodes with double [[]]
- * 2 - The shortcode name
- * 3 - The shortcode argument list
- * 4 - The self closing /
- * 5 - The content of a shortcode when it wraps some content.
- * 6 - An extra ] to allow for escaping shortcodes with double [[]]
- *
- * @since 2.0
- * @uses $shortcode_tags
- * @return string The shortcode search regular expression
- */
- public static function get_shortcode_regex( $ignored = false, $all = false ) {
- $shortcode_tags = Fusion_Core_Reversal::$tags;
- $ignored_shortcode_tags = array(
- 'highlight' => 'highlight',
- 'tooltip' => 'tooltip',
- 'popover' => 'popover',
- 'modal_text_link' => 'modal_text_link'
- );
- if ( $ignored ) {
- $shortcode_tags = $ignored_shortcode_tags;
- }
- if ( $all ) {
- $shortcode_tags = array_merge( $shortcode_tags, $ignored_shortcode_tags );
- }
- $tagnames = array_keys( $shortcode_tags );
- $tagregexp = join( '|', array_map( 'preg_quote', $tagnames ) );
- // WARNING! Do not change this regex without changing do_shortcode_tag() and strip_shortcode_tag()
- // Also, see shortcode_unautop() and shortcode.js.
- return
- '\\[' // Opening bracket
- . '(\\[?)' // 1: Optional second opening bracket for escaping shortcodes: [[tag]]
- . "($tagregexp)" // 2: Shortcode name
- . '(?![\\w-])' // Not followed by word character or hyphen
- . '(' // 3: Unroll the loop: Inside the opening shortcode tag
- . '[^\\]\\/]*' // Not a closing bracket or forward slash
- . '(?:'
- . '\\/(?!\\])' // A forward slash not followed by a closing bracket
- . '[^\\]\\/]*' // Not a closing bracket or forward slash
- . ')*?'
- . ')'
- . '(?:'
- . '(\\/)' // 4: Self closing tag ...
- . '\\]' // ... and closing bracket
- . '|'
- . '\\]' // Closing bracket
- . '(?:'
- . '(' // 5: Unroll the loop: Optionally, anything between the opening and closing shortcode tags
- . '[^\\[]*+' // Not an opening bracket
- . '(?:'
- . '\\[(?!\\/\\2\\])' // An opening bracket not followed by the closing shortcode tag
- . '[^\\[]*+' // Not an opening bracket
- . ')*+'
- . ')'
- . '\\[\\/\\2\\]' // Closing shortcode tag
- . ')?'
- . ')'
- . '(\\]?)'; // 6: Optional second closing brocket for escaping shortcodes: [[tag]]
- }
- /**
- * Get globally unique identifier
- *
- * @since 2.0.0
- * @return String
- */
- public static function GUID() {
- return 'fusionb_' . sprintf( '%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand( 0, 65535 ), mt_rand( 0, 65535 ),
- mt_rand( 0, 65535 ), mt_rand( 16384, 20479 ), mt_rand( 32768, 49151 ), mt_rand( 0, 65535 ),
- mt_rand( 0, 65535 ), mt_rand( 0, 65535 ) );
- }
- /**
- * Retrieve all attribsutes from the shortcodes tag.
- * The attributes list has the attribute name as the key and the value of the
- * attribute as the value in the key/value pair. This allows for easier
- * retrieval of the attributes, since all attributes have to be known.
- *
- * @since 2.0
- *
- * @param string $text
- *
- * @return array List of attributes and their value.
- */
- public static function shortcode_parse_atts( $text ) {
- $atts = array();
- $pattern = '/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*\'([^\']*)\'(?:\s|$)|(\w+)\s*=\s*([^\s\'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/';
- $text = preg_replace( "/[\x{00a0}\x{200b}]+/u", " ", $text );
- if ( preg_match_all( $pattern, $text, $match, PREG_SET_ORDER ) ) {
- foreach ( $match as $m ) {
- if ( ! empty( $m[1] ) ) {
- $atts[ strtolower( $m[1] ) ] = stripcslashes( $m[2] );
- } elseif ( ! empty( $m[3] ) ) {
- $atts[ strtolower( $m[3] ) ] = stripcslashes( $m[4] );
- } elseif ( ! empty( $m[5] ) ) {
- $atts[ strtolower( $m[5] ) ] = stripcslashes( $m[6] );
- } elseif ( isset( $m[7] ) and strlen( $m[7] ) ) {
- $atts[] = stripcslashes( $m[7] );
- } elseif ( isset( $m[8] ) ) {
- $atts[] = stripcslashes( $m[8] );
- }
- }
- } else {
- $atts = ltrim( $text );
- }
- return $atts;
- }
- /**
- * Whether the passed content contains the specified shortcode
- *
- * @since 2.0
- *
- * @param String $tags
- * @param string $tag
- *
- * @return boolean
- */
- public static function has_shortcode( $content, $tag, $ignored_shortcode = false ) {
- if ( false === strpos( $content, '[' ) ) {
- return false;
- }
- preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex( $ignored_shortcode ) . '/s', $content, $matches, PREG_SET_ORDER );
- if ( empty( $matches ) ) {
- return false;
- }
- foreach ( $matches as $shortcode ) {
- if ( $tag === $shortcode[2] ) {
- return true;
- }
- }
- return false;
- }
- /**
- * whether shortcode exists in provided content
- *
- * @since 2.0
- *
- * @param String $content
- *
- * @return boolean
- */
- public static function is_shortcode( $content ) {
- foreach ( Fusion_Core_Reversal::$tags as $tag ) {
- if ( Fusion_Core_Reversal::has_shortcode( $content, $tag ) ) {
- return true;
- }
- }
- return false;
- }
- /**
- * Whether child elements exists. Will be checked via parent tag
- *
- * @since 2.0
- *
- * @param String $content
- * @param Interger $index
- * @param string $parent
- *
- * @return Array ChildrenID
- */
- public static function check_for_child_elements( $content, &$index, $parent = null ) {
- if ( ! empty( $content ) && $content != ' ' ) {
- $content = Fusion_Core_Reversal::convert_to_builder_blocks( $content );
- if ( Fusion_Core_Reversal::is_shortcode( $content ) ) {
- $matches = null;
- $children = array();
- preg_match_all( '/' . Fusion_Core_Reversal::get_shortcode_regex() . '/s', $content, $matches, PREG_SET_ORDER );
- foreach ( $matches as $match ) {
- $child_id = Fusion_Core_Reversal::convert_builder_elements( $match, $index, $parent );
- array_push( $children, $child_id );
- }
- return $children;
- } else {
- return $content;
- }
- }
- return $content;
- }
- /**
- * Create text block element.
- *
- * @since 2.0
- *
- * @param String $content
- * @param Interger $index
- * @param String $parent
- *
- * @return Array ElementId
- */
- public static function create_text_element( $content, &$index, $parent = null ) {
- $children = array();
- $text_block = new TF_FusionText();
- $text_block->config['index'] = $index;
- $text_block->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $text_block->config['subElements'][0]['value'] = stripslashes( $content );
- if ( ! is_null( $parent ) ) {
- $text_block->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $text_block->element_to_array() );
- array_push( $children, array( 'id' => $text_block->config['id'] ) );
- return $children;
- }
- /**
- * Assign attributes to column options.
- *
- * @since 2.0
- *
- * @param String $match
- * @param Array $element
- *
- * @return Array Element
- */
- public static function prepare_column_options( $match, $element ) {
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match ) );
- foreach ( $attribs as $key => $value ) {
- switch ( $key ) {
- case 'last':
- $element->config['subElements'][0]['value'] = $attribs[ $key ];
- break;
- case 'spacing':
- $element->config['subElements'][1]['value'] = $attribs[ $key ];
- break;
- case 'center_content':
- $element->config['subElements'][2]['value'] = $attribs[ $key ];
- break;
- case 'hide_on_mobile':
- $element->config['subElements'][3]['value'] = $attribs[ $key ];
- break;
- case 'background_color':
- $element->config['subElements'][4]['value'] = $attribs[ $key ];
- break;
- case 'background_image':
- $element->config['subElements'][5]['value'] = $attribs[ $key ];
- break;
- case 'background_repeat';
- $element->config['subElements'][6]['value'] = $attribs[ $key ];
- break;
- case 'background_position';
- $element->config['subElements'][7]['value'] = $attribs[ $key ];
- break;
-
- case 'hover_type':
- $element->config['subElements'][8]['value'] = $attribs[ $key ];
- break;
- case 'link':
- $element->config['subElements'][9]['value'] = $attribs[ $key ];
- break;
- case 'border_position';
- $element->config['subElements'][10]['value'] = $attribs[ $key ];
- break;
- case 'border_size';
- $element->config['subElements'][11]['value'] = $attribs[ $key ];
- break;
- case 'border_color';
- $element->config['subElements'][12]['value'] = $attribs[ $key ];
- break;
- case 'border_style';
- $element->config['subElements'][13]['value'] = $attribs[ $key ];
- break;
- case 'padding';
- $element->config['subElements'][14]['value'] = $attribs[ $key ];
- break;
- case 'margin_top';
- $element->config['subElements'][15]['value'] = $attribs[ $key ];
- break;
- case 'margin_bottom';
- $element->config['subElements'][16]['value'] = $attribs[ $key ];
- break;
- case 'animation_type';
- $element->config['subElements'][17]['value'] = $attribs[ $key ];
- break;
- case 'animation_direction';
- $element->config['subElements'][18]['value'] = $attribs[ $key ];
- break;
- case 'animation_speed';
- $element->config['subElements'][19]['value'] = $attribs[ $key ];
- break;
-
- case 'animation_offset';
- $element->config['subElements'][20]['value'] = $attribs[ $key ];
- break;
- case 'class':
- $element->config['subElements'][21]['value'] = $attribs[ $key ];
- break;
- case 'id':
- $element->config['subElements'][22]['value'] = $attribs[ $key ];
- break;
- }
- }
- return $element;
- }
- /**
- * Converted matched short-codes to builder elements.
- *
- * @since 2.0
- *
- * @param String $match
- * @param Interger $index
- * @param string $parent
- *
- * @return Array ID
- */
- public static function convert_builder_elements( $match, &$index, $parent = null ) {
- switch ( $match[2] ) {
- case 'one_full':
- $grid_one = new TF_GridOne();
- $grid_one->config['index'] = $index;
- $grid_one->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_one = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_one );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_one->config['id'] );
- if ( is_array( $children ) ) {
- $grid_one->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_one->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_one->element_to_array() );
- return array( 'id' => $grid_one->config['id'] );
- break;
- case 'one_half':
- $grid_two = new TF_GridTwo();
- $grid_two->config['index'] = $index;
- $grid_two->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_two = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two->config['id'] );
- if ( is_array( $children ) ) {
- $grid_two->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_two->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_two->element_to_array() );
- return array( 'id' => $grid_two->config['id'] );
- break;
- case 'one_third':
- $grid_three = new TF_GridThree();
- $grid_three->config['index'] = $index;
- $grid_three->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_three = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three->config['id'] );
- if ( is_array( $children ) ) {
- $grid_three->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_three->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_three->element_to_array() );
- return array( 'id' => $grid_three->config['id'] );
- break;
- case 'one_fourth':
- $grid_four = new TF_GridFour();
- $grid_four->config['index'] = $index;
- $grid_four->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_four = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_four );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_four->config['id'] );
- if ( is_array( $children ) ) {
- $grid_four->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_four->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_four->element_to_array() );
- return array( 'id' => $grid_four->config['id'] );
- break;
- case 'one_fifth':
- $grid_five = new TF_GridFive();
- $grid_five->config['index'] = $index;
- $grid_five->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_five = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_five );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_five->config['id'] );
- if ( is_array( $children ) ) {
- $grid_five->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_five->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_five->element_to_array() );
- return array( 'id' => $grid_five->config['id'] );
- break;
- case 'two_fifth':
- $grid_two_fifth = new TF_GridTwoFifth();
- $grid_two_fifth->config['index'] = $index;
- $grid_two_fifth->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_two_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two_fifth );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two_fifth->config['id'] );
- if ( is_array( $children ) ) {
- $grid_two_fifth->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_two_fifth->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_two_fifth->element_to_array() );
- return array( 'id' => $grid_two_fifth->config['id'] );
- break;
- case 'three_fifth':
- $grid_three_fifth = new TF_GridThreeFifth();
- $grid_three_fifth->config['index'] = $index;
- $grid_three_fifth->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_three_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three_fifth );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three_fifth->config['id'] );
- if ( is_array( $children ) ) {
- $grid_three_fifth->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_three_fifth->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_three_fifth->element_to_array() );
- return array( 'id' => $grid_three_fifth->config['id'] );
- break;
- case 'four_fifth':
- $grid_four_fifth = new TF_GridFourFifth();
- $grid_four_fifth->config['index'] = $index;
- $grid_four_fifth->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_four_fifth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_four_fifth );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_four_fifth->config['id'] );
- if ( is_array( $children ) ) {
- $grid_four_fifth->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_four_fifth->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_four_fifth->element_to_array() );
- return array( 'id' => $grid_four_fifth->config['id'] );
- break;
- case 'one_sixth':
- $grid_six = new TF_GridSix();
- $grid_six->config['index'] = $index;
- $grid_six->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_six = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_six );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_six->config['id'] );
- if ( is_array( $children ) ) {
- $grid_six->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_six->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_six->element_to_array() );
- return array( 'id' => $grid_six->config['id'] );
- break;
- case 'five_sixth':
- $grid_five_six = new TF_GridFiveSix();
- $grid_five_six->config['index'] = $index;
- $grid_five_six->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_five_six = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_five_six );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_five_six->config['id'] );
- if ( is_array( $children ) ) {
- $grid_five_six->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_five_six->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_five_six->element_to_array() );
- return array( 'id' => $grid_five_six->config['id'] );
- break;
- case 'three_fourth':
- $grid_three_fourth = new TF_GridThreeFourth();
- $grid_three_fourth->config['index'] = $index;
- $grid_three_fourth->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_three_fourth = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_three_fourth );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_three_fourth->config['id'] );
- if ( is_array( $children ) ) {
- $grid_three_fourth->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_three_fourth->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_three_fourth->element_to_array() );
- return array( 'id' => $grid_three_fourth->config['id'] );
- break;
- case 'two_third':
- $grid_two_third = new TF_GridTwoThird();
- $grid_two_third->config['index'] = $index;
- $grid_two_third->config['id'] = Fusion_Core_Reversal::GUID();
- $grid_two_third = Fusion_Core_Reversal::prepare_column_options( $match[3], $grid_two_third );
- $index = $index + 1;
- $children = Fusion_Core_Reversal::check_for_child_elements( $match[5], $index, $grid_two_third->config['id'] );
- if ( is_array( $children ) ) {
- $grid_two_third->config['childrenId'] = $children;
- }
- if ( ! is_null( $parent ) ) {
- $grid_two_third->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $grid_two_third->element_to_array() );
- return array( 'id' => $grid_two_third->config['id'] );
- break;
- case 'alert':
- $alert_box = new TF_AlertBox();
- $alert_box->config['index'] = $index;
- $alert_box->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['content'] = stripslashes( $match[5] );
- $alert_box = Fusion_Core_Reversal::prepare_alert_box( $attribs, $alert_box );
- if ( ! is_null( $parent ) ) {
- $alert_box->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $alert_box->element_to_array() );
- return array( 'id' => $alert_box->config['id'] );
- break;
- case 'blog':
- $wp_blog = new TF_WpBlog();
- $wp_blog->config['index'] = $index;
- $wp_blog->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $wp_blog = Fusion_Core_Reversal::prepare_wp_blog( $attribs, $wp_blog );
- if ( ! is_null( $parent ) ) {
- $wp_blog->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $wp_blog->element_to_array() );
- return array( 'id' => $wp_blog->config['id'] );
- break;
- case 'button':
- $wp_button = new TF_ButtonBlock();
- $wp_button->config['index'] = $index;
- $wp_button->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['content'] = stripslashes( $match[5] );
- $wp_button = Fusion_Core_Reversal::prepare_wp_button( $attribs, $wp_button );
- if ( ! is_null( $parent ) ) {
- $wp_button->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $wp_button->element_to_array() );
- return array( 'id' => $wp_button->config['id'] );
- break;
- case 'checklist':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_checklist_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $checklist = new TF_CheckList( $attribs['addmore'] );
- $checklist->config['index'] = $index;
- $checklist->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $checklist = Fusion_Core_Reversal::prepare_checklist( $attribs, $checklist );
- if ( ! is_null( $parent ) ) {
- $checklist->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $checklist->element_to_array() );
- return array( 'id' => $checklist->config['id'] );
- break;
- case 'clients':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['lightbox'] = 'no';
- $attribs = Fusion_Core_Reversal::get_carousel_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $image_carousel = new TF_ImageCarousel( $attribs['addmore'] );
- $image_carousel->config['index'] = $index;
- $image_carousel->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $image_carousel = Fusion_Core_Reversal::prepare_carousel( $attribs, $image_carousel );
- if ( ! is_null( $parent ) ) {
- $image_carousel->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $image_carousel->element_to_array() );
- return array( 'id' => $image_carousel->config['id'] );
- break;
- case 'fusion_code':
- $code_block = new TF_CodeBlock();
- $code_block->config['index'] = $index;
- $code_block->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $code_content = stripslashes( $match[5] );
-
- if ( base64_encode( base64_decode( $code_content ) ) === $code_content ){
- $code_content = base64_decode( $code_content );
- } else {
- //not encoded
- }
-
- $attribs['content'] = str_replace('</textarea>', htmlentities('</textarea>'), $code_content);
- $code_block = Fusion_Core_Reversal::prepare_code_block( $attribs, $code_block );
- if ( ! is_null( $parent ) ) {
- $code_block->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $code_block->element_to_array() );
- return array( 'id' => $code_block->config['id'] );
- break;
- case 'content_boxes':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_content_boxes_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- if ( ( $attribs['layout'] == 'none' || $attribs['layout'] == 'icon-on-side' || $attribs['layout'] == 'icon-with-title' ) && ( ! isset( $attribs['icon_circle_size'] ) || $attribs['icon_circle_size'] == '' ) ) {
- $attribs['icon_circle_size'] = 'small';
- } elseif ( ! isset( $attribs['icon_circle_size'] ) && $attribs['icon_circle_size'] == '' ) {
- $attribs['icon_circle_size'] = 'large';
- }
- $content_boxes = new TF_ContentBoxes( $attribs['addmore'] );
- $content_boxes->config['index'] = $index;
- $content_boxes->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $content_boxes = Fusion_Core_Reversal::prepare_content_boxes( $attribs, $content_boxes );
- if ( ! is_null( $parent ) ) {
- $content_boxes->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $content_boxes->element_to_array() );
- return array( 'id' => $content_boxes->config['id'] );
- break;
- case 'fusion_countdown':
- $countdown = new TF_CountDown();
- $countdown->config['index'] = $index;
- $countdown->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['content'] = stripslashes( $match[5] );
- $countdown = Fusion_Core_Reversal::prepare_countdown( $attribs, $countdown );
- if ( ! is_null( $parent ) ) {
- $countdown->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $countdown->element_to_array() );
- return array( 'id' => $countdown->config['id'] );
- break;
- case 'counters_circle':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_counter_circle_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $counter_circle = new TF_CounterCircle( $attribs['addmore'] );
- $counter_circle->config['index'] = $index;
- $counter_circle->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $counter_circle = Fusion_Core_Reversal::prepare_counter_circle( $attribs, $counter_circle );
- if ( ! is_null( $parent ) ) {
- $counter_circle->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $counter_circle->element_to_array() );
- return array( 'id' => $counter_circle->config['id'] );
- break;
- case 'counters_box':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_counter_box_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $counter_box = new TF_CounterBox( $attribs['addmore'] );
- $counter_box->config['index'] = $index;
- $counter_box->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $counter_box = Fusion_Core_Reversal::prepare_counter_box( $attribs, $counter_box );
- if ( ! is_null( $parent ) ) {
- $counter_box->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $counter_box->element_to_array() );
- return array( 'id' => $counter_box->config['id'] );
- break;
- /*case 'dropcap':
-
- $drop_Cap = new TF_DropCap();
- $drop_Cap->config['index'] = $index;
- $drop_Cap->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['content'] = stripslashes( $match[5] );
- $drop_Cap = Fusion_Core_Reversal::prepare_wp_drop_Cap( $attribs, $drop_Cap );
- if ( !is_null( $parent ) ) { $drop_Cap->config['parentId'] = $parent; }
- array_push( Fusion_Core_Reversal::$elements , $drop_Cap->element_to_array() );
- return array( 'id' => $drop_Cap->config['id'] );
-
- break;*/
- case 'postslider':
- $post_slider = new TF_PostSlider();
- $post_slider->config['index'] = $index;
- $post_slider->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $post_slider = Fusion_Core_Reversal::prepare_post_slider( $attribs, $post_slider );
- if ( ! is_null( $parent ) ) {
- $post_slider->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $post_slider->element_to_array() );
- return array( 'id' => $post_slider->config['id'] );
- break;
- case 'flip_boxes':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_flip_boxes_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $flip_boxes = new TF_FlipBoxes( $attribs['addmore'] );
- $flip_boxes->config['index'] = $index;
- $flip_boxes->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $flip_boxes = Fusion_Core_Reversal::prepare_flip_boxes( $attribs, $flip_boxes );
- if ( ! is_null( $parent ) ) {
- $flip_boxes->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $flip_boxes->element_to_array() );
- return array( 'id' => $flip_boxes->config['id'] );
- break;
- case 'fontawesome':
- $font_awesmoe = new TF_FontAwesome();
- $font_awesmoe->config['index'] = $index;
- $font_awesmoe->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $font_awesmoe = Fusion_Core_Reversal::prepare_wp_font_awesmoe( $attribs, $font_awesmoe );
- if ( ! is_null( $parent ) ) {
- $font_awesmoe->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $font_awesmoe->element_to_array() );
- return array( 'id' => $font_awesmoe->config['id'] );
- break;
- case 'map':
- $google_map = new TF_GoogleMap();
- $google_map->config['index'] = $index;
- $google_map->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $google_map = Fusion_Core_Reversal::prepare_wp_google_map( $attribs, $google_map );
- if ( ! is_null( $parent ) ) {
- $google_map->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $google_map->element_to_array() );
- return array( 'id' => $google_map->config['id'] );
- break;
- /*case 'highlight':
-
- $high_light = new TF_HighLight();
- $high_light->config['index'] = $index;
- $high_light->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs['content'] = stripslashes( $match[5] );
- $high_light = Fusion_Core_Reversal::prepare_wp_high_light( $attribs, $high_light );
-
- if ( !is_null( $parent ) ) { $high_light->config['parentId'] = $parent; }
- array_push( Fusion_Core_Reversal::$elements , $high_light->element_to_array() );
- return array( 'id' => $high_light->config['id'] );
-
- break;*/
- case 'imageframe':
- $image_frame = new TF_ImageFrame();
- $image_frame->config['index'] = $index;
- $image_frame->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- //get img src and alt attribs
- $image_attrib = null;
- $doc = new DOMDocument();
- $doc->encoding = 'utf-8'; //for sepcial characters handeling
- @$doc->loadHTML( '<?xml encoding="UTF-8">' . stripslashes( $match[5] ) );
- $tags = $doc->getElementsByTagName( 'img' );
- foreach ( $tags as $tag ) {
- $attribs['src'] = $tag->getAttribute( 'src' );
- $attribs['alt'] = $tag->getAttribute( 'alt' );
- }
- $image_frame = Fusion_Core_Reversal::prepare_image_frame( $attribs, $image_frame );
- if ( ! is_null( $parent ) ) {
- $image_frame->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $image_frame->element_to_array() );
- return array( 'id' => $image_frame->config['id'] );
- break;
- case 'images':
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $attribs = Fusion_Core_Reversal::get_carousel_child_attrib( $match, $attribs );
- foreach ( $attribs['addmore'] as $am_key => $am_value ) {
- foreach ( $am_value as $am_actual_key => $am_actual_value ) {
- if ( $am_actual_value == null ) {
- $attribs['addmore'][ $am_key ][ $am_actual_key ] = '';
- }
- }
- }
- $image_carousel = new TF_ImageCarousel( $attribs['addmore'] );
- $image_carousel->config['index'] = $index;
- $image_carousel->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $image_carousel = Fusion_Core_Reversal::prepare_carousel( $attribs, $image_carousel );
- if ( ! is_null( $parent ) ) {
- $image_carousel->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $image_carousel->element_to_array() );
- return array( 'id' => $image_carousel->config['id'] );
- break;
- case 'layerslider':
- $layer_slider = new TF_LayerSlider();
- $layer_slider->config['index'] = $index;
- $layer_slider->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $layer_slider = Fusion_Core_Reversal::prepare_layerslider( $attribs, $layer_slider );
- if ( ! is_null( $parent ) ) {
- $layer_slider->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $layer_slider->element_to_array() );
- return array( 'id' => $layer_slider->config['id'] );
- break;
- case 'fusion_lightbox':
- $image_frame = new TF_ImageFrame();
- $image_frame->config['index'] = $index;
- $image_frame->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- //get attribs
- $doc = new DOMDocument();
- $aData = array();
- $iData = array();
- $doc->loadHTML( '<?xml encoding="UTF-8">' . stripslashes( $match[5] ) );
- $anchor = $doc->getElementsByTagName( 'a' );
- $image = $doc->getElementsByTagName( 'img' );
- //get anchor data
- foreach ( $anchor as $node ) {
- if ( $node->hasAttributes() ) {
- foreach ( $node->attributes as $a ) {
-
- if ( $a->name == 'href' ) {
- $aData[ 'lightbox_image' ] = $a->value;
- } else if ( $a->name == 'data-caption' ) {
- $aData[ 'alt' ] = $a->value;
- } else {
- $aData[ $a->name ] = $a->value;
- }
- }
- }
-
- $aData[ 'lightbox' ] = 'yes';
- }
- //get image data
- foreach ( $image as $node ) {
- if ( $node->hasAttributes() ) {
- foreach ( $node->attributes as $a ) {
- $iData[ $a->name ] = $a->value;
- }
- }
- }
- //combine data
- $attribs = array_merge( $iData, $aData );
- $image_frame = Fusion_Core_Reversal::prepare_image_frame( $attribs, $image_frame );
- if ( ! is_null( $parent ) ) {
- $image_frame->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $image_frame->element_to_array() );
- return array( 'id' => $image_frame->config['id'] );
- break;
-
- case 'fusion_login':
- case 'fusion_register':
- case 'fusion_lost_password':
- $login = new TF_Login();
- $login->config['index'] = $index;
- $login->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = array_merge( array( 'fusion_login_type' => $match[2] ), Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) ) );
- $login = Fusion_Core_Reversal::prepare_login( $attribs, $login );
- if ( ! is_null( $parent ) ) {
- $login->config['parentId'] = $parent;
- }
- array_push( Fusion_Core_Reversal::$elements, $login->element_to_array() );
- return array( 'id' => $login->config['id'] );
- break;
-
- case 'menu_anchor':
- $menu_anchor = new TF_MenuAnchor();
- $menu_anchor->config['index'] = $index;
- $menu_anchor->config['id'] = Fusion_Core_Reversal::GUID();
- $index = $index + 1;
- $attribs = Fusion_Core_Reversal::shortcode_parse_atts( stripslashes( $match[3] ) );
- $menu_anchor = Fusion_Core_Reversal::prepare_menu_anchor( $attribs, $menu_anch