/** * Get list of all blocks * @param $importer: Boolean to check if data is being imported or not */ function circleflip_get_blocks($template_id, $saved_blocks, $importer = false) { global $aq_page_builder; $aqpb_config = circleflip_page_builder_config(); $aq_page_builder = new AQ_Page_Builder($aqpb_config); $blocks = $aq_page_builder->retrieve_blocks($template_id, $saved_blocks, $importer); return $blocks; }
if (!defined('AQPB_PATH')) { define('AQPB_PATH', get_template_directory() . '/plugins/pagebuilder/'); } if (!defined('AQPB_DIR')) { define('AQPB_DIR', get_template_directory_uri() . '/plugins/pagebuilder/'); } // Required functions & classes require_once AQPB_PATH . 'functions/aqpb_config.php'; require_once AQPB_PATH . 'functions/aqpb_blocks.php'; require_once AQPB_PATH . 'classes/class-aq-page-builder.php'; require_once AQPB_PATH . 'classes/class-aq-block.php'; require_once AQPB_PATH . 'functions/aqpb_functions.php'; // Register blocks require_once get_template_directory() . '/plugins/pagebuilder/blocks/block-init.php'; $aqpb_config = aq_page_builder_config(); $aq_page_builder = new AQ_Page_Builder($aqpb_config); if (!is_network_admin()) { $aq_page_builder->init(); } /*-----------------------------------------------------------------------------------*/ /* ReduxFramework Admin Panel /*-----------------------------------------------------------------------------------*/ if (!class_exists('ReduxFramework')) { require_once get_template_directory() . '/plugins/admin-core/framework.php'; } if (!isset($redux_demo)) { require_once get_template_directory() . '/plugins/admin-core/admin-config.php'; } //include template functions: require_once get_template_directory() . '/includes/template.php'; /*-----------------------------------------------------------------------------------*/
function post_content_builder_mb_save() { global $post; $template_id = isset($_POST['post_ID']) ? $_POST['post_ID'] : ''; /*Security Check*/ if (!isset($_POST['rojo_mb_nonce-page_builder']) || !wp_verify_nonce($_POST['rojo_mb_nonce-page_builder'], 'rojo_mb_nonce-page_builder')) { return $template_id; } //now let's save our blocks & prepare haystack $blocks = AQ_Page_Builder::get_blocks($template_id); $haystack = array(); $template_transient_data = array(); $i = 1; foreach ($blocks as $new_instance) { global $aq_registered_blocks; global $post; $old_key = isset($new_instance['number']) ? 'aq_block_' . $new_instance['number'] : 'aq_block_0'; $new_key = isset($new_instance['number']) ? 'aq_block_' . $i : 'aq_block_0'; $old_instance = get_post_meta($template_id, $old_key, true); extract($new_instance); if (class_exists($id_base)) { //get the block object $block = $aq_registered_blocks[$id_base]; //insert template_id into $instance $new_instance['template_id'] = $template_id; //sanitize instance with AQ_Block::update() $new_instance = $block->update($new_instance, $old_instance); } //update block update_post_meta($template_id, $new_key, $new_instance); //store instance into $template_transient_data $template_transient_data[$new_key] = $new_instance; //prepare haystack $haystack[] = $new_key; $i++; } //update transient $template_transient = 'aq_template_' . $template_id; update_post_meta($template_id, $template_transient, $template_transient_data); //use haystack to check for deleted blocks $curr_blocks = AQ_Page_Builder::retrieve_blocks($template_id); //$curr_blocks = $this->get_blocks($template_id); $curr_blocks = is_array($curr_blocks) ? $curr_blocks : array(); foreach ($curr_blocks as $key => $block) { if (!in_array($key, $haystack)) { delete_post_meta($template_id, $key); } } $activate_builder = $_POST['rojo']['page_builder']; $old = get_post_meta($template_id, 'page_builder', $activate_builder, true); $new = $activate_builder; if ($new && $new != $old) { update_post_meta($template_id, 'page_builder', $new); } elseif ('' == $new && $old) { delete_post_meta($template_id, 'page_builder', $old); } return $template_id; }
function circleflip_save_post_content_builder() { $aqpb_config = circleflip_page_builder_config(); $aq_page_builder = new AQ_Page_Builder($aqpb_config); $blocks = $aq_page_builder->post_content_builder_mb_save(); }
?> <input type="hidden" name="template" id="template" value="<?php echo esc_attr($post->ID); ?> "/> </div> <div class="preloader hide"> <img src="<?php echo get_template_directory_uri() . '/creiden-framework/content-builder/assets/images/preloader.gif'; ?> " alt="" /> </div> <div id="aqpb-body"> <ul class="blocks cf" id="blocks-to-edit"> <?php AQ_Page_Builder::display_blocks($post->ID); ?> </ul> <div class="importCertainBlock"> <a href="#crdn-importCertainBlock" data-toggle="modal">Click Here to import a block</a> </div> <div class="modal fade" id="crdn-importCertainBlock"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4>Import Block</h4> <div type="button" class="tb-close-icon" data-dismiss="modal" aria-hidden="true"></div> </div> <div class="modal-body"> <p>Paste the code you copied from the exported block</p> <textarea></textarea>