PluginProbe
Tag Groups is the Advanced Way to Display Your Taxonomy Terms / trunk
Tag Groups is the Advanced Way to Display Your Taxonomy Terms vtrunk
2.2.2 2.2.1 2.2.0 trunk 1.40.0 1.40.2 1.41.0 1.42.1 1.43.0 1.43.1 1.43.10 1.43.10.1 1.43.2 1.43.3 1.43.4 1.43.5 1.43.6 1.43.7 1.43.9 1.44.0 1.44.1 1.44.3 1.44.3.1 2.0.0 2.0.1 All 36 releases
tag-groups / include / helpers / class.gutenberg.php

class.gutenberg.php in Tag Groups is the Advanced Way to Display Your Taxonomy Terms trunk, at include/helpers/class.gutenberg.php

75 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @package Tag Groups
5 * @author Christoph Amthor
6 * @copyright 2020 Christoph Amthor (@ Chatty Mango, chattymango.com)
7 * @license GPL-3.0+
8 */
9
10 // phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace, Squiz.Classes.ValidClassName.NotCamelCaps, PSR1.Methods.CamelCapsMethodName.NotCamelCaps
11 if (! class_exists('TagGroups_Gutenberg')) {
12 /**
13 *
14 */
15 class TagGroups_Gutenberg
16 {
17 /**
18 * Check if Gutenberg is active.
19 * Must be used not earlier than plugins_loaded action fired.
20 * from https://gist.github.com/mihdan/8ba1a70d8598460421177c7d31202908
21 *
22 * @return bool
23 */
24 public static function is_gutenberg_active()
25 {
26 $gutenberg = false;
27 $block_editor = false;
28 if (has_filter('replace_editor', 'gutenberg_init')) {
29 // Gutenberg is installed and activated.
30 $gutenberg = true;
31 }
32
33 if (version_compare($GLOBALS['wp_version'], '5.0-beta', '>')) {
34 // Block editor.
35 $block_editor = true;
36 }
37
38 if (! $gutenberg && ! $block_editor) {
39 return false;
40 }
41
42 include_once ABSPATH . 'wp-admin/includes/plugin.php';
43 if (! is_plugin_active('classic-editor/classic-editor.php')) {
44 return true;
45 }
46
47 $use_block_editor = ( get_option('classic-editor-replace') === 'no-replace' );
48 return $use_block_editor;
49 }
50
51
52 /**
53 * Create a new block category
54 *
55 * @param array $categories
56 * @return array
57 */
58 public static function block_categories($categories)
59 {
60
61 $category_slugs = wp_list_pluck($categories, 'slug');
62 return in_array('chatty-mango', $category_slugs, true) ? $categories : array_merge($categories, array(
63 array(
64 'slug' => 'chatty-mango',
65 'title' => 'Tag Groups',
66 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
67 'icon' => null, //'admin-plugins', // icons might be removed in future
68 ),
69 ));
70 }
71 }
72
73
74 }
75