PluginProbe
Block Manager / 3.2.1
Block Manager v3.2.1
trunk 1.0 1.0.1 1.1 1.2 1.2.1 1.2.2 1.2.3c 1.2.4 1.2.5 2.0.0 2.1.0 2.1.0.1 2.1.1 3.0.0 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1
block-manager / block-manager.php

block-manager.php in Block Manager 3.2.1, at block-manager.php

157 lines 4.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Plugin Name: Block Manager
4 * Plugin URI: https://connekthq.com/plugins/block-manager/
5 * Description: Take control of your WordPress blocks and patterns.
6 * Text Domain: block-manager
7 * Author: Darren Cooney
8 * Author URI: https://connekthq.com
9 * Version: 3.2.1
10 * License: GPL
11 * Copyright: Darren Cooney & Connekt Media
12 *
13 * @package blockmanager
14 */
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 define( 'BLOCK_MANAGER_VERSION', '3.2.1' );
21 define( 'BLOCK_MANAGER_RELEASE', 'June 10, 2026' );
22 define( 'BLOCK_MANAGER_BASENAME', plugin_basename( __FILE__ ) );
23 define( 'BLOCK_MANAGER_DIR_PATH', plugin_dir_path( __FILE__ ) );
24 define( 'BLOCK_MANAGER_URL', plugins_url( '', __FILE__ ) );
25 define( 'BLOCK_MANAGER_OPTION', 'gbm_disabled_blocks' );
26 define( 'BLOCK_MANAGER_CATEGORIES', 'gbm_categories' );
27 define( 'BLOCK_MANAGER_PATTERNS', 'gbm_disabled_patterns' );
28
29 /**
30 * Block Manager Class.
31 *
32 * @since 1.0
33 */
34 class Gutenberg_Block_Manager {
35
36 /**
37 * Block Manager Instance variable.
38 *
39 * @var $instance
40 * @since 1.0
41 */
42 private static $instance = null;
43
44
45 /**
46 * Define the Block Manager Instance
47 *
48 * @author ConnektMedia
49 * @since 1.0
50 * @return self
51 */
52 public static function instance() {
53 if ( null === self::$instance ) {
54 self::$instance = new Gutenberg_Block_Manager();
55 }
56 return self::$instance;
57 }
58
59
60 /**
61 * Initialize plugin.
62 *
63 * @author ConnektMedia
64 * @since 1.0
65 */
66 private function __construct() {
67 add_action( 'enqueue_block_editor_assets', [ $this, 'enqueue_block_editor_assets' ] );
68 load_plugin_textdomain( 'block-manager', false, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
69
70 require_once 'classes/class-admin.php';
71 require_once 'classes/class-blocks.php';
72 require_once 'classes/class-categories.php';
73 require_once 'classes/class-patterns.php';
74 require_once 'api/blocks-toggle.php';
75 require_once 'api/blocks-reset.php';
76 require_once 'api/category-reset.php';
77 require_once 'api/category-update.php';
78 require_once 'api/patterns-toggle.php';
79 require_once 'api/patterns-reset.php';
80 require_once 'api/bulk-process.php';
81 require_once 'api/export.php';
82 require_once 'includes/connekt-plugin-installer/class-connekt-plugin-installer.php';
83 }
84
85 /**
86 * Enqueue the scripts.
87 *
88 * @author ConnektMedia
89 * @since 1.0
90 */
91 public function enqueue_block_editor_assets() {
92 $screen = get_current_screen();
93 $wp_asset_file = require BLOCK_MANAGER_DIR_PATH . 'build/block-manager.asset.php'; // Get webpack asset file.
94 $dependencies = $wp_asset_file['dependencies'];
95
96 // Update script dependencies based on current screen.
97 if ( is_object( get_current_screen() ) ) {
98 if ( $screen === 'site-editor' ) {
99 $dependencies[] = 'wp-edit-site';
100 } elseif ( $screen->id === 'widgets' ) {
101 $dependencies[] = 'wp-edit-widgets';
102 } else {
103 $dependencies[] = 'wp-edit-post';
104 }
105 } else {
106 $dependencies[] = 'wp-edit-post';
107 }
108
109 wp_enqueue_script(
110 'block-manager',
111 plugins_url( 'build/block-manager.js', __FILE__ ),
112 $dependencies,
113 BLOCK_MANAGER_VERSION,
114 false
115 );
116
117 wp_localize_script(
118 'block-manager',
119 'gutenberg_block_manager',
120 [
121 'blocks' => GBM_Blocks::gbm_get_all_disabled_blocks(),
122 'categories' => GBM_Categories::gbm_get_all_block_categories(),
123 'patterns' => GBM_Patterns::gbm_get_all_disabled_patterns(),
124 ]
125 );
126 }
127
128 /**
129 * Confirm user has access to Block Manager.
130 *
131 * @author ConnektMedia
132 * @since 1.1
133 * @return Boolean
134 */
135 public static function has_access() {
136 $access = false;
137 if ( is_user_logged_in() && current_user_can( apply_filters( 'block_manager_user_role', 'activate_plugins' ) ) ) {
138 $access = true;
139 }
140 return $access;
141 }
142 }
143
144 /**
145 * The main function for Gutenberg_Block_Manager_Init
146 *
147 * @author ConnektMedia
148 * @since 1.0
149 */
150 function gbm_init() {
151 include_once ABSPATH . 'wp-admin/includes/plugin.php';
152 if ( is_plugin_active( 'gutenberg/gutenberg.php' ) || version_compare( get_bloginfo( 'version' ), '4.9.9', '>' ) ) {
153 Gutenberg_Block_Manager::instance();
154 }
155 }
156 add_action( 'plugins_loaded', 'gbm_init', 100 );
157