Пример #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
             continue;
         }
         $path = $block_template['path'];
         foreach ($block_template['fields'] as $json) {
             $json['ID'] = null;
             $json['style'] = 'seamless';
             $json['position'] = 'normal';
             $json['location'] = array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'block')));
             $field_groups[] = $json;
         }
     }
     return $field_groups;
 }
 $post_id = $_GET['post'];
 $page_id = $_GET['page_id'];
 $page_blocks = array_filter(wpb_get_blocks($page_id), function ($page_block) use($post_id) {
     return $page_block['post_id'] == $post_id;
 });
 if ($page_blocks) {
     foreach ($page_blocks as $page_block) {
         $block_template = wpb_block_template_by_buid($page_block['buid']);
         if ($block_template == null) {
             continue;
         }
         $path = $block_template['path'];
         foreach ($block_template['fields'] as $json) {
             $json['ID'] = null;
             $json['style'] = 'seamless';
             $json['position'] = 'normal';
             $json['location'] = array(array(array('param' => 'post_type', 'operator' => '==', 'value' => 'wpb-block')));
             $field_groups[] = $json;
Пример #3
0
/**
 * @function wpb_render_block_area
 * @since 0.3.0
 */
function wpb_render_block_area($area_id)
{
    $block = Block::get_current();
    if ($block == null) {
        return;
    }
    $page_id = $block->get_page_id();
    $post_id = $block->get_post_id();
    echo '<ul class="blocks" data-area-id="' . $area_id . '">';
    $page_blocks = wpb_get_blocks($page_id);
    $page_blocks = apply_filters('wpb/children_blocks', $page_blocks, $block);
    if ($page_blocks) {
        foreach ($page_blocks as $page_block) {
            if (!isset($page_block['buid']) || !isset($page_block['page_id']) || !isset($page_block['post_id']) || !isset($page_block['area_id'])) {
                continue;
            }
            $disable = isset($page_block['disable']);
            if ($page_block['into_id'] == $post_id && $page_block['area_id'] == $area_id) {
                wpb_render_block_preview($page_block['buid'], $page_block['post_id'], $page_block['page_id'], array('disable' => $disable, 'into_id' => $post_id, 'area_id' => $area_id));
            }
        }
    }
    echo '</ul>';
    echo '<div class="button block-add-button" data-area-id="' . $area_id . '">Add block</div>';
}