PluginProbe
Portfolio Block – show off your work with stunning layouts / trunk
Portfolio Block – show off your work with stunning layouts vtrunk
2.1.5 2.1.3 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1
portfolio-block / includes / rootPlugin / Init.php

Init.php in Portfolio Block – show off your work with stunning layouts trunk, at includes/rootPlugin/Init.php

87 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace PFB;
3 class Init
4 {
5 function __construct()
6 {
7 add_action('init', [$this, 'onInit']);
8 }
9 function onInit()
10 {
11 $this->register_all_blocks();
12
13 $template = [];
14
15 if (pfb_fs()->can_use_premium_code()) {
16 $template = [
17 ["pfb/portfolio-parent"]
18 ];
19 } else {
20
21 $template = [
22 ["pfb/portfolio"]
23 ];
24 }
25
26
27 register_post_type('pfb', [
28 'labels' => [
29 'name' => __('Portfolios', 'portfolio-block'),
30 'singular_name' => __('Portfolio', 'portfolio-block'),
31 'add_new' => __('Add New', 'portfolio-block'),
32 'add_new_item' => __('Add New Portfolio', 'portfolio-block'),
33 'edit_item' => __('Edit Portfolio', 'portfolio-block'),
34 'new_item' => __('New Portfolio', 'portfolio-block'),
35 'view_item' => __('View Portfolio', 'portfolio-block'),
36 'search_items' => __('Search Portfolios', 'portfolio-block'),
37 'not_found' => __('Sorry, we couldn\'t find the Portfolio you are looking for.', 'portfolio-block'),
38 ],
39
40 'public' => false,
41 'publicly_queryable' => false,
42 'show_ui' => true,
43 'show_in_menu' => true,
44 'show_in_rest' => true,
45 'exclude_from_search' => true,
46 'hierarchical' => false,
47 'has_archive' => false,
48 'capability_type' => 'page',
49 'menu_position' => 22,
50 'menu_icon' => 'dashicons-portfolio',
51 'supports' => ['title', 'editor'],
52 'template' => $template,
53 'template_lock' => 'all',
54 'rewrite' => false,
55 ]);
56 }
57
58 function register_all_blocks()
59 {
60 $blocks_path = PFB_DIR_PATH . '/build/blocks/';
61 $all_blocks = glob($blocks_path . '*', GLOB_ONLYDIR);
62
63 if (empty($all_blocks)) {
64 return;
65 }
66
67 $disabled_blocks = (array) get_option('pfb_disabled_blocks', []);
68
69 foreach ($all_blocks as $block_path) {
70
71 $block_name = basename($block_path);
72
73 if (in_array($block_name, $disabled_blocks, true)) {
74 continue;
75 }
76
77 if ($block_name === 'portfolio') {
78 register_block_type($block_path);
79 continue;
80 }
81
82 if (pfb_fs()->can_use_premium_code()) {
83 register_block_type($block_path);
84 }
85 }
86 }
87 }