# portfolio-block/trunk/includes/rootPlugin/Init.php

Portfolio Block – show off your work with stunning layouts, version trunk. 87 lines.

- Page: https://pluginprobe.com/plugins/portfolio-block/trunk/code/includes/rootPlugin/Init.php
- Raw: https://pluginprobe.com/plugins/portfolio-block/trunk/raw/includes/rootPlugin/Init.php
- Modified: 2026-06-30T05:11:00+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/portfolio-block/trunk/code/includes/rootPlugin/Init.php#L10-L20`.

```php
<?php
namespace PFB;
class Init
{
	function __construct()
	{
		add_action('init', [$this, 'onInit']);
	}
	function onInit()
	{
		$this->register_all_blocks();

		$template = [];

		if (pfb_fs()->can_use_premium_code()) {
			$template = [
				["pfb/portfolio-parent"]
			];
		} else {

			$template = [
				["pfb/portfolio"]
			];
		}


		register_post_type('pfb', [
			'labels' => [
				'name' => __('Portfolios', 'portfolio-block'),
				'singular_name' => __('Portfolio', 'portfolio-block'),
				'add_new' => __('Add New', 'portfolio-block'),
				'add_new_item' => __('Add New Portfolio', 'portfolio-block'),
				'edit_item' => __('Edit Portfolio', 'portfolio-block'),
				'new_item' => __('New Portfolio', 'portfolio-block'),
				'view_item' => __('View Portfolio', 'portfolio-block'),
				'search_items' => __('Search Portfolios', 'portfolio-block'),
				'not_found' => __('Sorry, we couldn\'t find the Portfolio you are looking for.', 'portfolio-block'),
			],

			'public' => false,
			'publicly_queryable' => false,
			'show_ui' => true,
			'show_in_menu' => true,
			'show_in_rest' => true,
			'exclude_from_search' => true,
			'hierarchical' => false,
			'has_archive' => false,
			'capability_type' => 'page',
			'menu_position' => 22,
			'menu_icon' => 'dashicons-portfolio',
			'supports' => ['title', 'editor'],
			'template' => $template,
			'template_lock' => 'all',
			'rewrite' => false,
		]);
	}

	function register_all_blocks()
	{
		$blocks_path = PFB_DIR_PATH . '/build/blocks/';
		$all_blocks = glob($blocks_path . '*', GLOB_ONLYDIR);

		if (empty($all_blocks)) {
			return;
		}

		$disabled_blocks = (array) get_option('pfb_disabled_blocks', []);

		foreach ($all_blocks as $block_path) {

			$block_name = basename($block_path);

			if (in_array($block_name, $disabled_blocks, true)) {
				continue;
			}

			if ($block_name === 'portfolio') {
				register_block_type($block_path);
				continue;
			}

			if (pfb_fs()->can_use_premium_code()) {
				register_block_type($block_path);
			}
		}
	}
}
```
