PluginProbe
Block Manager / 1.0
Block Manager v1.0
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 1.0, at block-manager.php

99 lines 2.6 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: Globally manage the enabled/disabled state of each Gutenberg block.
6 Text Domain: block-manager
7 Author: Darren Cooney
8 Author URI: https://connekthq.com
9 Version: 1.0
10 License: GPL
11 Copyright: Darren Cooney & Connekt Media
12 */
13
14
15 // Exit if accessed directly.
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit;
18 }
19
20 define( 'BLOCK_MANAGER_VERSION', '1.0');
21 define( 'BLOCK_MANAGER_RELEASE', 'January 6, 2020');
22 define( 'BLOCK_MANAGER_DIR_PATH', plugin_dir_path( __FILE__ ) );
23 define( 'BLOCK_MANAGER_OPTION', 'gbm_disabled_blocks');
24
25
26 class Gutenberg_Block_Manager {
27
28 private static $instance = null;
29
30 public static function instance() {
31 if ( null === self::$instance ) {
32 self::$instance = new Gutenberg_Block_Manager();
33 }
34 return self::$instance;
35 }
36
37
38 /**
39 * Initialize plugin.
40 */
41 private function __construct() {
42
43 add_action( 'enqueue_block_editor_assets', array( $this, 'gbm_enqueue' ) );
44 load_plugin_textdomain( 'gutenberg-block-manager', false, dirname(plugin_basename( __FILE__ )).'/lang');
45 add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array(&$this, 'gbm_action_links') );
46 require_once(BLOCK_MANAGER_DIR_PATH . 'class-admin.php');
47 require_once('api/toggle.php');
48 require_once('api/bulk_process.php');
49 include_once('vendor/connekt-plugin-installer/class-connekt-plugin-installer.php');
50
51 }
52
53
54 /**
55 * Enqueue the scripts.
56 */
57 public function gbm_enqueue() {
58 $script = 'dist/js/gbm.js';
59 wp_enqueue_script( 'gutenberg-block-manager', plugins_url( $script, __FILE__ ), array( 'wp-edit-post' ), BLOCK_MANAGER_VERSION, false );
60 wp_localize_script( 'gutenberg-block-manager', 'gutenberg_block_manager', $this->gbm_get_disabled_blocks() );
61
62 }
63
64
65 /**
66 * Get all disabled blocks.
67 */
68 public function gbm_get_disabled_blocks() {
69 return (array) get_option(BLOCK_MANAGER_OPTION, array());
70 }
71
72
73
74 /**
75 * gbm_action_links
76 * Add plugin action links to WP plugin screen
77 *
78 * @since 1.0
79 */
80 public function gbm_action_links( $links ) {
81 $settings = '<a href="'. get_admin_url(null, 'options-general.php?page=gutenberg-block-manager') .'">'.__('Manage Blocks', 'gutenberg-block-manager').'</a>';
82 array_unshift( $links, $settings );
83 return $links;
84 }
85
86 }
87
88 /**
89 * The main function for Gutenberg_Block_Manager_Init
90 */
91 function Gutenberg_Block_Manager_Init() {
92 include_once ABSPATH . 'wp-admin/includes/plugin.php';
93 if ( is_plugin_active('gutenberg/gutenberg.php') || version_compare(get_bloginfo('version'), '4.9.9', '>')){
94 Gutenberg_Block_Manager::instance();
95 }
96 }
97
98 add_action( 'plugins_loaded', 'Gutenberg_Block_Manager_Init', 100 );
99