/** * @function wpb_block * @since 0.1.0 */ function wpb_block($buib, $post_id, $page_id) { $block_template = wpb_block_template_by_buid($buib); if ($block_template == null) { return null; } $class_file = isset($block_template['class_file']) ? $block_template['class_file'] : null; $class_name = isset($block_template['class_name']) ? $block_template['class_name'] : null; require_once $block_template['path'] . '/' . $class_file; return new $class_name($post_id, $page_id, $block_template); }
$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; } } } return $field_groups; });