'.$msg.'
'; } add_action( 'admin_notices', 'mfnvb_notice' ); } // get array of post types which uses bebuilder function mfnvb_get_builder_post_types(){ $types = [ 'page', 'post', 'portfolio', 'template', 'product' ]; return apply_filters( 'bebuilder_post_types', $types ); } // classic editor link add_action( 'edit_form_after_title', 'mfnvb_ce_live_button' ); function mfnvb_ce_live_button($post) { if( !current_user_can( 'edit_post', $post->ID ) ){ return; } if( !empty($post->post_type) && in_array($post->post_type, mfnvb_get_builder_post_types()) ){ global $replaced_logo; $link = admin_url('/post.php?post='. $post->ID .'&preview=true&action='. apply_filters('betheme_slug', 'mfn') .'-live-builder'); if( get_post_status($post->ID) == 'publish' ) { $link = admin_url('/post.php?post='. $post->ID .'&action='. apply_filters('betheme_slug', 'mfn').'-live-builder'); } echo ''; } } // gutenberg script add_action( 'enqueue_block_editor_assets', 'mfnvb_gutenberg_functions' ); function mfnvb_gutenberg_functions() { global $post; if( !empty($post->post_type) && ! in_array( $post->post_type, mfnvb_get_builder_post_types() ) ){ return; } wp_enqueue_script( 'mfn-page-edit-button', get_theme_file_uri('/visual-builder/assets/js/button.js'), array( 'wp-blocks', 'wp-element', 'wp-block-editor' ), time() ); } // add live builder link in admin page table add_filter( 'post_row_actions', 'mfnvb_list_row_actions', 10, 2 ); add_filter( 'page_row_actions', 'mfnvb_list_row_actions', 10, 2 ); function mfnvb_list_row_actions( $actions, $post ) { if( !current_user_can( 'edit_post', $post->ID ) ) return $actions; if ( !empty($post->post_type) && in_array( $post->post_type, mfnvb_get_builder_post_types() ) ) { $actions[] = 'Edit with '. apply_filters('betheme_label', "Be") .'Builder'; } return $actions; } add_action( 'init', 'mfn_init_bebuilder'); function mfn_init_bebuilder(){ // init vb class add_action( 'post_action_'. apply_filters('betheme_slug', 'mfn') .'-live-builder', 'mfnvb_init_vb' ); } } function mfnvb_init_vb($id){ if( ! current_user_can( 'edit_post', $id ) && ! defined('BEBUILDER_DEMO_VERSION') ){ wp_die(); } if( get_post_type($id) == 'template' ) flush_rewrite_rules(false); $mfnVisualBuilder = new MfnVisualBuilder(); if( is_admin() ){ //add_action( 'admin_enqueue_scripts', array( $mfnVisualBuilder, 'mfn_append_vb_styles'), 9999 ); wp_enqueue_style( 'imgareaselect' ); wp_plupload_default_settings(); require_once ABSPATH . WPINC . '/media-template.php'; add_action( 'mfn_footer_enqueue', 'wp_print_media_templates' ); add_action( 'mfn_footer_enqueue', 'wp_print_media_templates' ); add_action( 'mfn_footer_enqueue', 'wp_print_media_templates' ); add_action( 'mfn_header_enqueue', array( $mfnVisualBuilder, 'mfn_append_vb_header'), 10 ); add_action( 'mfn_footer_enqueue', array( $mfnVisualBuilder, 'mfn_append_vb_footer'), 10 ); }else{ remove_action('wp_enqueue_scripts', 'mfn_styles'); add_action( 'wp_enqueue_scripts', array( $mfnVisualBuilder, 'mfn_append_vb_header'), 999 ); add_action( 'wp_enqueue_scripts', array( $mfnVisualBuilder, 'mfn_append_vb_footer'), 999 ); //add_action( 'wp_enqueue_scripts', array( $mfnVisualBuilder, 'mfn_append_vb_styles'), 9999 ); } $mfnVisualBuilder->mfn_load_sidebar(); exit(); } // save draft add_action( 'wp_ajax_mfnvbsavedraft', 'mfnvb_save_draft' ); function mfnvb_save_draft(){ if( !current_user_can( 'edit_post', $_POST['id'] ) ){ wp_die(); } check_ajax_referer( 'mfn-builder-nonce', 'mfn-builder-nonce' ); if( get_post_status($_POST['id']) == 'auto-draft' ){ $name = 'BeBuilder #'.$_POST['id']; $slug = sanitize_title($name); wp_update_post( array( 'ID' => $_POST['id'], 'post_title' => $name, 'post_name' => $slug, 'post_status' => 'draft', )); update_post_meta($_POST['id'], 'mfn-page-items', ''); if( !empty($_POST['tmpl']) ){ update_post_meta($_POST['id'], 'mfn_template_type', $_POST['tmpl']); } } wp_die(); } // get another pages list add_action( 'wp_ajax_getpageslist', 'mfnvb_getpageslist' ); function mfnvb_getpageslist(){ if( !current_user_can( 'edit_post', $_POST['pageid'] ) ){ wp_die(); } check_ajax_referer( 'mfn-builder-nonce', 'mfn-builder-nonce' ); global $wpdb; $types = array('page', 'portfolio', 'post', 'template'); if( function_exists('is_woocommerce') ) $types[] = 'product'; $recents = $wpdb->get_results( "SELECT `ID`, `post_title`, `post_type` FROM {$wpdb->prefix}posts WHERE post_type IN ('page', 'portfolio', 'post', 'template') and post_status = 'publish' order by post_modified DESC LIMIT 6" ); $html = '