Пример #1
0
 /**
  * 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 = wpb_get_blocks($page_id);
     $page_blocks = apply_filters('wpb/children_blocks', $page_blocks, $this);
     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_render_block_template($page_block['buid'], $page_block['post_id'], $page_block['page_id']);
             }
         }
     }
 }
Пример #2
0
        if (get_post_type() == $post_type) {
            $page_blocks = wpb_get_blocks($post->ID);
            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 (is_preview() === false && isset($page_block['post_revision_id'])) {
                        $rev = wp_get_post_revision($page_block['post_revision_id']);
                        if ($rev) {
                            $page_block['post_id'] = $rev->ID;
                        }
                    }
                    if ($page_block['into_id'] == 0) {
                        wpb_render_block_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