/** * Renders a specific area of this block. * @method render_children * @since 0.3.0 */ public function render_children($area_id) { $page_id = $this->get_page_id(); $post_id = $this->get_post_id(); $page_blocks = get_post_meta($page_id, '_page_blocks', true); if ($page_blocks) { foreach ($page_blocks as $page_block) { if (!isset($page_block['buid']) || !isset($page_block['page_id']) || !isset($page_block['post_id'])) { continue; } if ($page_block['into_id'] == $post_id && $page_block['area_id'] == $area_id) { wpb_block_render_template($page_block['buid'], $page_block['post_id'], $page_block['page_id']); } } } }
*/ add_filter('the_content', function ($content) { global $post; if (is_admin()) { return $content; } if (get_post_type() == 'page') { $page_blocks = get_post_meta($post->ID, '_page_blocks', true); if ($page_blocks) { ob_start(); foreach ($page_blocks as $page_block) { if (!isset($page_block['buid']) || !isset($page_block['page_id']) || !isset($page_block['post_id'])) { continue; } if ($page_block['into_id'] == 0) { wpb_block_render_template($page_block['buid'], $page_block['post_id'], $page_block['page_id']); } } $content = ob_get_contents(); ob_end_clean(); } } return $content; }, 20); //------------------------------------------------------------------------------ // AJAX //------------------------------------------------------------------------------ /** * Adds a block to a page. * @action wp_ajax_add_page_block * @since 0.1.0