location = true === Fusion_App()->is_builder || ( isset( $_POST ) && isset( $_POST['fusion_front_end'] ) && $_POST['fusion_front_end'] ) ? 'front' : 'back'; // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput
}
/**
* Setup the post type and taxonomies.
*
* @since 2.2
* @access public
*/
public function register_layouts() {
$labels = [
'name' => _x( 'Fusion Templates', 'Layout type general name', 'fusion-builder' ),
'singular_name' => _x( 'Layout', 'Layout type singular name', 'fusion-builder' ),
'add_new' => _x( 'Add New', 'Layout item', 'fusion-builder' ),
'add_new_item' => esc_html__( 'Add New Layout', 'fusion-builder' ),
'edit_item' => esc_html__( 'Edit Layout', 'fusion-builder' ),
'new_item' => esc_html__( 'New Layout', 'fusion-builder' ),
'all_items' => esc_html__( 'All Layouts', 'fusion-builder' ),
'view_item' => esc_html__( 'View Layout', 'fusion-builder' ),
'search_items' => esc_html__( 'Search Layouts', 'fusion-builder' ),
'not_found' => esc_html__( 'Nothing found', 'fusion-builder' ),
'not_found_in_trash' => esc_html__( 'Nothing found in Trash', 'fusion-builder' ),
'item_published' => esc_html__( 'Layout published.', 'fusion-builder' ),
'item_published_privately' => esc_html__( 'Layout published privately.', 'fusion-builder' ),
'item_reverted_to_draft' => esc_html__( 'Layout reverted to draft.', 'fusion-builder' ),
'item_scheduled' => esc_html__( 'Layout scheduled.', 'fusion-builder' ),
'item_updated' => esc_html__( 'Layout updated.', 'fusion-builder' ),
'parent_item_colon' => '',
];
$args = [
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'can_export' => true,
'query_var' => true,
'has_archive' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'exclude_from_search' => true,
'hierarchical' => false,
'show_in_nav_menus' => false,
'show_ui' => true,
'show_in_menu' => false,
'supports' => [ 'title', 'editor', 'revisions' ],
];
register_post_type( 'fusion_template', apply_filters( 'fusion_layout_template_args', $args ) );
$labels = [
'name' => _x( 'Fusion Elements', 'element type general name', 'fusion-builder' ),
'singular_name' => _x( 'Element', 'Element type singular name', 'fusion-builder' ),
'add_new' => _x( 'Add New', 'Element item', 'fusion-builder' ),
'add_new_item' => esc_html__( 'Add New Element', 'fusion-builder' ),
'edit_item' => esc_html__( 'Edit Element', 'fusion-builder' ),
'new_item' => esc_html__( 'New Element', 'fusion-builder' ),
'all_items' => esc_html__( 'All Elements', 'fusion-builder' ),
'view_item' => esc_html__( 'View Element', 'fusion-builder' ),
'search_items' => esc_html__( 'Search Elements', 'fusion-builder' ),
'not_found' => esc_html__( 'Nothing found', 'fusion-builder' ),
'not_found_in_trash' => esc_html__( 'Nothing found in Trash', 'fusion-builder' ),
'item_published' => esc_html__( 'Element published.', 'fusion-builder' ),
'item_published_privately' => esc_html__( 'Element published privately.', 'fusion-builder' ),
'item_reverted_to_draft' => esc_html__( 'Element reverted to draft.', 'fusion-builder' ),
'item_scheduled' => esc_html__( 'Element scheduled.', 'fusion-builder' ),
'item_updated' => esc_html__( 'Element updated.', 'fusion-builder' ),
'parent_item_colon' => '',
];
$args = [
'labels' => $labels,
'public' => false,
'publicly_queryable' => true,
'can_export' => true,
'query_var' => true,
'has_archive' => false,
'capability_type' => 'post',
'map_meta_cap' => true,
'hierarchical' => false,
'supports' => [ 'title', 'editor', 'revisions' ],
'show_ui' => true,
'show_in_menu' => false,
/**
* Removed because of a WPML issue, see #2335
'capabilities' => array(
'create_posts' => 'do_not_allow',
),
*/
];
register_post_type( 'fusion_element', apply_filters( 'fusion_layout_element_args', $args ) );
$labels = [
'name' => esc_attr__( 'Category', 'fusion-builder' ),
];
register_taxonomy(
'element_category',
[ 'fusion_element' ],
[
'hierarchical' => true,
'labels' => $labels,
'show_ui' => false,
'show_admin_column' => true,
'query_var' => true,
'show_in_nav_menus' => false,
]
);
$labels = [
'name' => esc_attr__( 'Category', 'fusion-builder' ),
];
register_taxonomy(
'template_category',
[ 'fusion_template' ],
[
'hierarchical' => true,
'labels' => $labels,
'show_ui' => false,
'show_admin_column' => false,
'query_var' => true,
'show_in_nav_menus' => false,
]
);
}
/**
* Delete custom template or element.
*/
public function delete_layout() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( isset( $_POST['fusion_layout_id'] ) && '' !== $_POST['fusion_layout_id'] && current_user_can( 'delete_post', $_POST['fusion_layout_id'] ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$layout_id = (int) $_POST['fusion_layout_id'];
wp_delete_post( $layout_id, true );
}
wp_die();
}
/**
* Add custom template or element.
*
* @param string $post_type The post-type.
* @param string $name The post-title.
* @param string $content The post-content.
* @param array $meta The post-meta.
* @param array $taxonomy Taxonomies.
* @param string $term Term.
*/
public function create_layout( $post_type, $name, $content, $meta = [], $taxonomy = [], $term = '' ) {
$layout = [
'post_title' => sanitize_text_field( $name ),
'post_content' => $content,
'post_status' => 'publish',
'post_type' => $post_type,
];
$layout_id = wp_insert_post( $layout );
if ( ! empty( $meta ) ) {
foreach ( $meta as $meta_key => $meta_value ) {
add_post_meta( $layout_id, $meta_key, sanitize_text_field( $meta_value ) );
}
}
if ( '' !== $term ) {
wp_insert_term( $term, $taxonomy );
$term_id = term_exists( $term, $taxonomy );
wp_set_post_terms( $layout_id, $term_id, $taxonomy );
}
do_action( 'fusion_builder_create_layout_after' );
return $layout_id;
}
/**
* Save custom layout.
*/
public function save_layout() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( isset( $_POST['fusion_layout_name'] ) && '' !== $_POST['fusion_layout_name'] ) {
$layout_name = wp_unslash( $_POST['fusion_layout_name'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$taxonomy = 'element_category';
$term = '';
$meta = [];
$layout_type = '';
$global_data = '';
$global_type = [
'elements' => 'element',
'columns' => 'column',
'sections' => 'container',
];
if ( isset( $_POST['fusion_layout_post_type'] ) && '' !== $_POST['fusion_layout_post_type'] ) {
$post_type = sanitize_text_field( wp_unslash( $_POST['fusion_layout_post_type'] ) );
// Make sure only our library post types can be created.
$post_type_object = get_post_type_object( $post_type );
if ( ! current_user_can( $post_type_object->cap->edit_posts ) || ( 'fusion_template' !== $post_type && 'fusion_element' !== $post_type ) ) {
return;
}
if ( isset( $_POST['fusion_current_post_id'] ) && '' !== $_POST['fusion_current_post_id'] ) {
$post_id = wp_unslash( $_POST['fusion_current_post_id'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
if ( isset( $_POST['fusion_layout_element_type'] ) && '' !== $_POST['fusion_layout_element_type'] ) {
$meta['_fusion_element_type'] = wp_unslash( $_POST['fusion_layout_element_type'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$layout_type = ' fusion-element-type-' . wp_unslash( $_POST['fusion_layout_element_type'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
if ( 'fusion_template' === $post_type ) {
$meta['fusion_builder_status'] = 'active';
// Save custom css.
if ( isset( $_POST['fusion_custom_css'] ) && '' !== $_POST['fusion_custom_css'] ) {
$meta['_fusion_builder_custom_css'] = wp_unslash( $_POST['fusion_custom_css'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
// Save page template.
if ( isset( $_POST['fusion_page_template'] ) && '' !== $_POST['fusion_page_template'] ) {
$meta['_wp_page_template'] = wp_unslash( $_POST['fusion_page_template'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
// Save globals.
$_POST['fusion_layout_content'] = apply_filters( 'content_save_pre', $_POST['fusion_layout_content'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
// Globals.
if ( isset( $_POST['fusion_save_global'] ) && 'false' !== $_POST['fusion_save_global'] ) {
$meta['_fusion_is_global'] = 'yes';
$global_data = 'fusion-global';
} else {
$position = false;
if ( isset( $_POST['fusion_layout_content'] ) ) {
$position = strpos( sanitize_text_field( wp_unslash( $_POST['fusion_layout_content'] ) ), 'fusion_global' );
}
if ( false !== $position ) {
// Remove fusion_global attributes from content if it is simple library element.
$_POST['fusion_layout_content'] = preg_replace( '/fusion_global=[^][^][0-9]*[^][^]/', '', wp_unslash( $_POST['fusion_layout_content'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
}
}
// Add Fusion Options to meta data.
if ( isset( $_POST['fusion_options'] ) && '' !== wp_unslash( $_POST['fusion_options'] ) && is_array( wp_unslash( $_POST['fusion_options'] ) ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$_fusion_options = wp_unslash( $_POST['fusion_options'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
if ( isset( $_POST['fusion_po_type'] ) && 'object' === $_POST['fusion_po_type'] ) {
foreach ( $_fusion_options as $option => $value ) {
$meta[ $option ] = $value;
}
} else {
foreach ( $_fusion_options as $option ) {
$meta[ $option[0] ] = $option[1];
}
}
}
// Post category.
if ( isset( $_POST['fusion_layout_new_cat'] ) && '' !== $_POST['fusion_layout_new_cat'] ) {
$term = sanitize_text_field( wp_unslash( $_POST['fusion_layout_new_cat'] ) );
$global_type = $global_type[ $term ];
}
$post_fusion_layout_content = ( isset( $_POST['fusion_layout_content'] ) ) ? wp_unslash( $_POST['fusion_layout_content'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$new_layout_id = $this->create_layout( $post_type, $layout_name, $post_fusion_layout_content, $meta, $taxonomy, $term );
?>
location ) : ?>
location ) : ?>
location ) : ?>
location ? get_edit_post_link( $new_layout_id ) : add_query_arg( 'fb-edit', '1', get_permalink( $new_layout_id ) ); ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
cap->edit_posts ) ) {
return;
}
$category = 'elements';
if ( isset( $_GET['fusion_library_type'] ) ) {
$category = sanitize_text_field( wp_unslash( $_GET['fusion_library_type'] ) );
}
$post_content = '';
switch ( $category ) {
case 'sections':
$post_content = '[fusion_builder_container][fusion_builder_row][/fusion_builder_row][/fusion_builder_container]';
break;
case 'columns':
$post_content = '[fusion_builder_column type="1_1"][/fusion_builder_column]';
break;
}
$library_element = [
'post_title' => isset( $_GET['name'] ) ? sanitize_text_field( wp_unslash( $_GET['name'] ) ) : '',
'post_status' => 'publish',
'post_type' => $post_type,
'post_content' => $post_content,
];
// Set global if checked.
if ( 'fusion_element' === $post_type && isset( $_GET['global'] ) && sanitize_text_field( wp_unslash( $_GET['global'] ) ) ) {
$library_element['meta_input'] = [
'_fusion_is_global' => 'yes',
];
}
$library_id = wp_insert_post( $library_element );
if ( is_wp_error( $library_id ) ) {
$error_string = $library_id->get_error_message();
wp_die( esc_html( $error_string ) );
}
// If we are adding element, add type.
if ( 'fusion_element' === $post_type ) {
$library_type = wp_set_object_terms( $library_id, $category, 'element_category' );
if ( is_wp_error( $library_type ) ) {
$error_string = $library_type->get_error_message();
wp_die( esc_html( $error_string ) );
}
}
// Just redirect to back-end editor. In future tie it to default editor option.
wp_safe_redirect( get_edit_post_link( $library_id, false ) );
die();
}
/**
* Load custom elements.
*/
public function load_custom_elements() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( isset( $_POST['cat'] ) && '' !== $_POST['cat'] ) {
$cat = wp_unslash( $_POST['cat'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
// Query elements.
$query = fusion_cached_query(
[
'post_status' => 'publish',
'post_type' => 'fusion_element',
'posts_per_page' => '-1',
'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery
[
'taxonomy' => 'element_category',
'field' => 'slug',
'terms' => $cat,
],
],
]
);
?>
have_posts() ) : ?>
the_post(); ?>
ID, '_fusion_element_type', true ) ); ?>
-
location || ( 'front' !== $this->location && ! $query->have_posts() ) ) : ?>
location ) : ?>
post_content, ']' );
if ( false !== $position ) {
$layout->post_content = apply_filters( 'content_edit_pre', $layout->post_content, $layout->post_content, $layout_id );
$layout->post_content = substr_replace( $layout->post_content, ' fusion_global="' . $layout_id . '"]', $position, 1 );
}
}
if ( $layout ) {
// Set page content.
$data['post_content'] = apply_filters( 'content_edit_pre', $layout->post_content, $layout_id );
// Set page template.
if ( 'fusion_template' === get_post_type( $layout_id ) ) {
$page_template = get_post_meta( $layout_id, '_wp_page_template', true );
if ( isset( $page_template ) && ! empty( $page_template ) ) {
$data['page_template'] = $page_template;
}
$custom_css = get_post_meta( $layout_id, '_fusion_builder_custom_css', true );
$data['post_meta'] = get_post_meta( $layout_id );
if ( isset( $custom_css ) && ! empty( $custom_css ) ) {
$data['custom_css'] = $custom_css;
}
}
}
$json_data = wp_json_encode( $data );
die( $json_data ); // phpcs:ignore WordPress.Security.EscapeOutput
}
/**
* Load custom header demo.
*/
public function load_demo_header() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
$data = [];
$fusion_builder_demo_headers = apply_filters( 'fusion_builder_get_demo_headers', [] );
if ( isset( $_POST['header_name'] ) && '' !== $_POST['header_name'] && isset( $_POST['post_id'] ) && '' !== $_POST['post_id'] ) {
$header_name = sanitize_text_field( wp_unslash( $_POST['header_name'] ) );
$post_id = (int) $_POST['post_id'];
if ( isset( $fusion_builder_demo_headers[ $header_name ] ) ) {
$data['post_content'] = $fusion_builder_demo_headers[ $header_name ]['content'];
wp_send_json_success( $data );
}
}
wp_send_json_error( $fusion_builder_demo_headers, 500 );
}
/**
* Load custom page layout.
*/
public function load_demo() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( ! isset( $_POST['page_name'] ) && '' === $_POST['page_name'] ) {
die( -1 );
}
if ( ! isset( $_POST['demo_name'] ) && '' === $_POST['demo_name'] ) {
die( -1 );
}
if ( ! isset( $_POST['post_id'] ) && '' === $_POST['post_id'] ) {
die( -1 );
}
$data = [];
$page_name = sanitize_text_field( wp_unslash( $_POST['page_name'] ) );
$demo_name = sanitize_text_field( wp_unslash( $_POST['demo_name'] ) );
$post_id = (int) $_POST['post_id'];
$fusion_builder_demos = apply_filters( 'fusion_builder_get_demo_pages', [] );
if ( isset( $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ] ) && ! empty( $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ] ) ) {
// Set page content.
$data['post_content'] = $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ]['content'];
// Set page template.
$page_template = $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ]['page_template'];
if ( isset( $page_template ) && ! empty( $page_template ) ) {
$data['page_template'] = $page_template;
}
}
if ( isset( $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ]['meta'] ) && ! empty( $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ]['meta'] ) ) {
$data['meta'] = $fusion_builder_demos[ $demo_name ]['pages'][ $page_name ]['meta'];
}
$json_data = wp_json_encode( $data );
die( $json_data ); // phpcs:ignore WordPress.Security.EscapeOutput
}
/**
* Save custom layout.
*/
public function update_layout() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( isset( $_POST['fusion_layout_id'] ) && '' !== $_POST['fusion_layout_id'] && current_user_can( 'edit_post', $_POST['fusion_layout_id'] ) && apply_filters( 'fusion_global_save', true, 'ajax' ) ) { // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$layout_id = wp_unslash( $_POST['fusion_layout_id'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$content = isset( $_POST['fusion_layout_content'] ) ? wp_unslash( $_POST['fusion_layout_content'] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
$to_replace = addslashes( ' fusion_global="' . $layout_id . '"' );
$content = str_replace( $to_replace, '', $content );
// Filter nested globals.
$content = apply_filters( 'content_save_pre', $content, $content, $layout_id );
$post = [
'ID' => $layout_id,
'post_content' => $content,
];
wp_update_post( $post );
}
wp_die();
}
/**
* Get image URL from image ID.
*/
public function get_image_url() {
check_ajax_referer( 'fusion_load_nonce', 'fusion_load_nonce' );
if ( ! isset( $_POST['fusion_image_ids'] ) && '' === $_POST['fusion_image_ids'] ) {
die( -1 );
}
$data = [];
$image_ids = wp_unslash( $_POST['fusion_image_ids'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput
foreach ( $image_ids as $image_id ) {
if ( '' !== $image_id ) {
$image_url = wp_get_attachment_url( $image_id, 'thumbnail' );
$image_html = '';
$image_html .= '

';
$image_html .= '
';
$image_html .= '
';
$data['images'][] = $image_html;
}
}
$json_data = wp_json_encode( $data );
die( $json_data ); // phpcs:ignore WordPress.Security.EscapeOutput
}
/**
* Process action for trash element.
*
* @since 1.0
* @return void
*/
public function trash_element() {
if ( current_user_can( 'delete_published_pages' ) ) {
$element_ids = '';
if ( isset( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$element_ids = wp_unslash( $_GET['post'] ); // phpcs:ignore WordPress.Security
}
if ( '' !== $element_ids ) {
$element_ids = (array) $element_ids;
}
if ( ! empty( $element_ids ) ) {
foreach ( $element_ids as $id ) {
wp_trash_post( $id );
}
}
}
$referer = fusion_get_referer();
if ( $referer ) {
wp_safe_redirect( $referer );
exit;
}
}
/**
* Process action for restore element.
*
* @since 1.0
* @return void
*/
public function restore_element() {
if ( current_user_can( 'publish_pages' ) ) {
$element_ids = '';
if ( isset( $_GET['post'] ) ) { // // phpcs:ignore WordPress.Security.NonceVerification
$element_ids = wp_unslash( $_GET['post'] ); // phpcs:ignore WordPress.Security
}
if ( '' !== $element_ids ) {
$element_ids = (array) $element_ids;
}
if ( ! empty( $element_ids ) ) {
foreach ( $element_ids as $id ) {
wp_untrash_post( $id );
}
}
}
$referer = fusion_get_referer();
if ( $referer ) {
wp_safe_redirect( $referer );
exit;
}
}
/**
* Process action for untrash element.
*
* @since 1.0
* @return void
*/
public function delete_element_post() {
if ( current_user_can( 'delete_published_pages' ) ) {
$element_ids = '';
if ( isset( $_GET['post'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
$element_ids = wp_unslash( $_GET['post'] ); // phpcs:ignore WordPress.Security
}
if ( '' !== $element_ids ) {
$element_ids = (array) $element_ids;
}
if ( ! empty( $element_ids ) ) {
foreach ( $element_ids as $id ) {
wp_delete_post( $id, true );
}
}
}
$referer = fusion_get_referer();
if ( $referer ) {
wp_safe_redirect( $referer );
exit;
}
}
/**
* Get the library-edit link.
*
* @access public
* @since 2.2.0
* @param int $id The post-ID.
* @return string
*/
public function get_library_item_edit_link( $id ) {
if ( 'front' === $this->location ) {
return esc_url( add_query_arg( 'fb-edit', '1', get_the_permalink( $id ) ) );
}
return esc_url_raw( htmlspecialchars_decode( get_edit_post_link( $id ) ) );
}
/**
* Display library content in builder.
*
* @since 1.0
* @return void
*/
public function display_library_content() {
global $post;
$saved_post = $post;
?>
$fusion_builder_demo ) : ?>
is_template( 'header' ) ) :
?>
'publish',
'post_type' => 'fusion_element',
'posts_per_page' => '-1',
'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery
[
'taxonomy' => 'element_category',
'field' => 'slug',
'terms' => 'sections',
],
],
]
);
?>
have_posts() ) :
$query->the_post();
$is_global = ( 'yes' === get_post_meta( get_the_ID(), '_fusion_is_global', true ) ? 'fusion-global' : '' );
global $post;
?>
-
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location || ( 'front' !== $this->location && ! $query->have_posts() ) ) : ?>
location ) : ?>
'publish',
'post_type' => 'fusion_element',
'posts_per_page' => '-1',
'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery
[
'taxonomy' => 'element_category',
'field' => 'slug',
'terms' => 'columns',
],
],
]
);
?>
have_posts() ) : ?>
the_post();
$is_global = ( 'yes' === get_post_meta( get_the_ID(), '_fusion_is_global', true ) ? 'fusion-global' : '' );
global $post;
?>
-
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location || ( 'front' !== $this->location && ! $query->have_posts() ) ) : ?>
location ) : ?>
'publish',
'post_type' => 'fusion_element',
'posts_per_page' => '-1',
'tax_query' => [ // phpcs:ignore WordPress.DB.SlowDBQuery
[
'taxonomy' => 'element_category',
'field' => 'slug',
'terms' => 'elements',
],
],
]
);
?>
have_posts() ) :
$query->the_post();
$is_global = ( 'yes' === get_post_meta( get_the_ID(), '_fusion_is_global', true ) ? 'fusion-global' : '' );
global $post;
$element_type = esc_attr( get_post_meta( $post->ID, '_fusion_element_type', true ) );
?>
-
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location || ( 'front' !== $this->location && ! $query->have_posts() ) ) : ?>
location ) : ?>
'publish',
'post_type' => 'fusion_template',
'posts_per_page' => '-1',
]
);
?>
'
);
?>
location ) : ?>
location ) : ?>
location ) : ?>
location ) : ?>
location || ( 'front' !== $this->location && ! $query->have_posts() ) ) : ?>
location ) : ?>
post_content = fusion_is_preview_frame() ? $builder->front_end_content( $_post->post_content ) : $_post->post_content;
$overrides['footer'] = $_post;
} elseif ( has_term( 'page_title_bar', 'fusion_tb_category' ) ) {
$_post->post_content = fusion_is_preview_frame() ? $builder->front_end_content( $_post->post_content ) : $_post->post_content;
$overrides['page_title_bar'] = $_post;
} elseif ( has_term( 'header', 'fusion_tb_category' ) ) {
$_post->post_content = fusion_is_preview_frame() ? $builder->front_end_content( $_post->post_content ) : $_post->post_content;
$overrides['header'] = $_post;
}
// Prevent main content being filtered.
remove_filter( 'the_content', [ $builder, 'front_end_content' ], 99 );
remove_filter( 'body_class', [ $builder, 'body_class' ] );
remove_filter( 'do_shortcode_tag', [ $builder, 'create_shortcode_contents_map' ], 10, 4 );
// Create a dummy post to use as content.
if ( ! isset( $overrides['content'] ) ) {
$overrides['content'] = Fusion_Dummy_Post::get_dummy_post();
}
} else {
// Reset the content override because we are editing content directly.
if ( isset( $overrides['content'] ) ) {
$overrides['content'] = false;
}
}
}
return $overrides;
}
}
/**
* Instantiates the Fusion_Builder_Library class.
* Make sure the class is properly set-up.
*
* @since object 2.2
* @return object Fusion_Builder_Library
*/
function Fusion_Builder_Library() { // phpcs:ignore WordPress.NamingConventions
return Fusion_Builder_Library::get_instance();
}
Fusion_Builder_Library();