post_type ) ? $post->post_type : false; $slug = 'fusion_tb_section' === $post_type ? 'avada-layouts' : 'avada-builder-library'; /* translators: Theme Builder|library. */ $message = sprintf( __( 'Back to %s', 'fusion-builder' ), 'fusion_tb_section' === $post_type ? __( 'Layout Builder', 'fusion-builder' ) : __( 'library', 'fusion-builder' ) ); $url = menu_page_url( $slug, false ); if ( ! in_array( $post_type, [ 'fusion_tb_section', 'fusion_template' ], true ) ) { return; } ?> post_type ) ? $post->post_type : false; if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && post_type_supports( $post_type, 'editor' ) ) { // Escaping is done on output. $publish_button_text = ( isset( $post->post_status ) && ( 'publish' === $post->post_status || 'private' === $post->post_status ) ) ? __( 'Update', 'fusion-builder' ) : __( 'Publish', 'fusion-builder' ); $fusion_builder_settings = get_option( 'fusion_builder_settings', [] ); $enable_builder_sticky_publish_buttons = true; if ( isset( $fusion_builder_settings['enable_builder_sticky_publish_buttons'] ) ) { $enable_builder_sticky_publish_buttons = $fusion_builder_settings['enable_builder_sticky_publish_buttons']; } if ( ! isset( $post->ID ) || ! $enable_builder_sticky_publish_buttons ) { return; } ?>
post_status && 'future' !== $post->post_status && 'pending' !== $post->post_status ) { ?> post_status ) ? ' style="display:none"' : ''; ?> class="button button-secondary fusion-save-draft">
  • scripts_general(); wp_enqueue_script( 'fusion_builder_admin_faq_js', FUSION_BUILDER_PLUGIN_URL . 'js/admin/fusion-builder-admin.js', [], FUSION_BUILDER_VERSION, false ); if ( class_exists( 'Avada' ) ) { wp_enqueue_style( 'avada_admin_css', trailingslashit( Avada::$template_dir_url ) . 'assets/admin/css/avada-admin.css', [], AVADA_VERSION ); } } /** * Admin scripts including js. * * @access public * @since 2.2 */ public function layout_builder() { include FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layout-builder/layouts.php'; include FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layout-builder/layout.php'; include FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layout-builder/layout-options.php'; include FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layout-builder/layout-child-option.php'; wp_enqueue_script( 'fusion_builder_app_util_js', FUSION_LIBRARY_URL . '/inc/fusion-app/util.js', [ 'jquery', 'jquery-ui-core', 'underscore', 'backbone' ], FUSION_BUILDER_VERSION, true ); wp_enqueue_script( 'fusion_layouts', FUSION_BUILDER_PLUGIN_URL . 'inc/admin-screens/layout-builder/layouts.js', [ 'fusion_builder_app_util_js' ], FUSION_BUILDER_VERSION, false ); wp_enqueue_script( 'fusion_layout', FUSION_BUILDER_PLUGIN_URL . 'inc/admin-screens/layout-builder/layout.js', [ 'fusion_builder_app_util_js' ], FUSION_BUILDER_VERSION, false ); wp_enqueue_script( 'fusion_layout_options', FUSION_BUILDER_PLUGIN_URL . 'inc/admin-screens/layout-builder/layout-options.js', [ 'fusion_builder_app_util_js' ], FUSION_BUILDER_VERSION, false ); } /** * Loads the template file. * * @since 2.2 * @access public */ public function layout_sections() { require_once FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layout-sections.php'; } /** * Loads the template file. * * @since 2.2 * @access public */ public function layouts() { require_once FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/layouts.php'; } /** * Loads the template file. * * @since 2.2 * @access public */ public function icons() { require_once FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/icons.php'; } /** * Loads the template file. * * @since 1.0 * @access public */ public function library() { require_once FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/library.php'; } /** * Loads the template file. * * @access public */ public function options() { require_once FUSION_BUILDER_PLUGIN_DIR . 'inc/admin-screens/options.php'; } /** * Add the title. * * @static * @access protected * @since 1.0 * @param string $title The title. * @param string $page The page slug. */ protected static function admin_tab( $title, $page ) { if ( isset( $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification $active_page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); // phpcs:ignore WordPress.Security.NonceVerification } if ( $active_page === $page ) { $link = 'javascript:void(0);'; $active_tab = ' nav-tab-active'; } else { $link = 'admin.php?page=' . $page; $active_tab = ''; } // Exception for layout section page, Layouts tab is active. if ( 'avada-layout-sections' === $active_page && 'fusion-layouts' === $page ) { $link = 'javascript:void(0);'; $active_tab = ' nav-tab-active'; } echo '' . $title . ''; // phpcs:ignore WordPress.Security.EscapeOutput } /** * Adds the header. * * @static * @access public * @param string $screen The current screen. * @return void */ public static function header( $screen = 'dashboard' ) { if ( class_exists( 'Avada' ) ) { Avada_Admin::get_admin_screens_header( $screen ); } } /** * Adds the footer. * * @static * @access public */ public static function footer() { if ( class_exists( 'Avada' ) ) { Avada_Admin::get_admin_screens_footer(); } } /** * Get social media links * * @static * @access public * @since 7.0 * @return string The social media link markup */ public static function get_social_media_links() { $social_media_markup = ' '; return apply_filters( 'fusion_admin_social_media_links', $social_media_markup ); } /** * Handles the saving of settings in admin area. * * @access private * @since 1.0 */ public function settings_save() { check_admin_referer( 'fusion_builder_save_fb_settings', 'fusion_builder_save_fb_settings' ); update_option( 'fusion_builder_settings', $_POST ); // Reset cache because CSS and JS depends on which elements are loaded. fusion_reset_all_caches(); wp_safe_redirect( admin_url( 'admin.php?page=avada-builder-options' ) ); exit; } /** * Handles the removal of a layout. * * @access private * @since 2.2 */ public function delete_layout() { check_ajax_referer( 'fusion_tb_new_layout', 'security' ); if ( isset( $_POST['post_id'] ) ) { $delete = wp_delete_post( absint( wp_unslash( $_POST['post_id'] ) ) ); if ( false !== $delete ) { echo wp_json_encode( [ 'success' => true ] ); wp_die(); } wp_send_json_error(); wp_die(); } wp_send_json_error(); wp_die(); } /** * Handles the update of a layout. * * @access private * @since 2.2 */ public function update_layout() { check_ajax_referer( 'fusion_tb_new_layout', 'security' ); // Initial checks. if ( ! isset( $_POST['action_type'] ) ) { wp_send_json_error( esc_html( 'Missing action_type' ) ); } $id = isset( $_POST['layout_id'] ) ? sanitize_text_field( wp_unslash( $_POST['layout_id'] ) ) : false; $action_type = sanitize_text_field( wp_unslash( $_POST['action_type'] ) ); $term_name = isset( $_POST['term'] ) ? sanitize_text_field( wp_unslash( $_POST['term'] ) ) : ''; switch ( $action_type ) { case 'update_title': if ( isset( $_POST['title'] ) && $id ) { Fusion_Template_Builder::update_layout_title( $id, $_POST['title'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput wp_send_json_success(); } break; case 'create_template': if ( isset( $_POST['name'] ) && $id && $term_name ) { $template = [ 'post_title' => isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '', 'post_status' => 'publish', 'post_type' => 'fusion_tb_section', ]; $template_id = wp_insert_post( $template ); if ( is_wp_error( $template_id ) ) { $error_string = $template_id->get_error_message(); wp_send_json_error( esc_html( $error_string ) ); } $template_type = wp_set_object_terms( $template_id, $term_name, 'fusion_tb_category' ); if ( is_wp_error( $template_type ) ) { $error_string = $template_type->get_error_message(); wp_send_json_error( esc_html( $error_string ) ); } $content = ( isset( $_POST['content'] ) ) ? $_POST['content'] : []; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput $content['template_terms'][ $term_name ] = $template_id; wp_send_json_success( [ 'content' => Fusion_Template_Builder::update_layout_content( $id, $content ), 'templates' => Fusion_Template_Builder()->get_templates_by_term(), ] ); } break; case 'update_layout': if ( isset( $_POST['layout_id'] ) && isset( $_POST['content'] ) && $id ) { wp_send_json_success( [ 'content' => Fusion_Template_Builder::update_layout_content( $id, $_POST['content'] ), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput ] ); } break; case 'update_layouts': if ( isset( $_POST['layouts'] ) ) { $layouts = wp_unslash( $_POST['layouts'] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput $data = []; foreach ( $layouts as $layout_id => $layout ) { $data[ $layout_id ] = Fusion_Template_Builder::update_layout_content( $layout_id, $layout ); } wp_send_json_success( $data ); } break; default: break; } wp_send_json_error( esc_html( 'Invalid action_type or missing layout_id' ) ); } /** * Ajax callback to get the layout options. * * @access public * @since 2.2 * @return void */ public function get_layout_options() { check_ajax_referer( 'fusion_tb_new_layout', 'security' ); $parent = isset( $_POST['parent'] ) ? sanitize_text_field( wp_unslash( $_POST['parent'] ) ) : ''; $search = isset( $_POST['search'] ) ? sanitize_text_field( wp_unslash( $_POST['search'] ) ) : ''; $page = isset( $_POST['page'] ) ? (int) $_POST['page'] : 1; $conditions = Fusion_Template_Builder()->get_layout_child_conditions( $parent, $page, $search ); wp_send_json_success( array_values( $conditions ) ); } /** * Check all elements on content. * * @access public * @since 3.0 * @return void */ public function check_elements() { global $all_fusion_builder_elements; check_ajax_referer( 'fusion_import_nonce', 'fusion_import_nonce' ); $elements = []; // No elements found, return empty. if ( empty( $all_fusion_builder_elements ) ) { wp_send_json_success( $elements ); die(); } if ( ! function_exists( 'export_wp' ) ) { include ABSPATH . '/wp-admin/includes/export.php'; } // Skip meta. add_filter( 'wxr_export_skip_postmeta', '__return_true' ); add_filter( 'wxr_export_skip_commentmeta', '__return_true' ); add_filter( 'wxr_export_skip_termmeta', '__return_true' ); ob_start(); export_wp(); // Prevent starting file download. header_remove( 'Content-Description' ); header_remove( 'Content-Disposition' ); header_remove( 'Content-Type' ); $content = ob_get_clean(); foreach ( $all_fusion_builder_elements as $module ) { if ( empty( $module['hide_from_builder'] ) ) { if ( false === strpos( $content, $module['shortcode'] ) ) { $elements[] = $module['shortcode']; } } } wp_send_json_success( $elements ); } } new Fusion_Builder_Admin();