PluginProbe
Tag Groups is the Advanced Way to Display Your Taxonomy Terms / 2.2.2
Tag Groups is the Advanced Way to Display Your Taxonomy Terms v2.2.2
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 / src / init.php

init.php in Tag Groups is the Advanced Way to Display Your Taxonomy Terms 2.2.2, at src/init.php

126 lines 4.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Blocks Initializer
5 *
6 * Enqueue CSS/JS of all the blocks.
7 *
8 * @since 0.38
9 * @package Tag Groups
10 */
11
12 // Exit if accessed directly.
13 if (! defined('ABSPATH')) {
14 exit;
15 }
16
17 /**
18 * Enqueue Gutenberg block assets for both frontend + backend.
19 *
20 * `wp-blocks`: includes block type registration and related functions.
21 *
22 * @since 1.0.0
23 */
24
25 // We don't have any public Gutenberg styles
26 // function chatty_mango_tag_groups_block_assets() {
27 // // Styles.
28 // wp_enqueue_style(
29 // 'chatty-mango_tag-groups-style-css', // Handle.
30 // plugins_url( 'dist/blocks.style.build.css', dirname( __FILE__ ) ), // Block style CSS.
31 // array( 'wp-blocks' ) // Dependency to include the CSS after it.
32 // // filemtime( plugin_dir_path( __FILE__ ) . 'editor.css' ) // Version: filemtime — Gets file modification time.
33 // );
34 // } // End function chatty_mango_tag_groups_block_assets().
35
36 // Hook: Frontend assets.
37 // add_action( 'enqueue_block_assets', 'chatty_mango_tag_groups_block_assets' );
38
39 /**
40 * Enqueue Gutenberg block assets for backend editor.
41 *
42 * `wp-blocks`: includes block type registration and related functions.
43 * `wp-element`: includes the WordPress Element abstraction for describing the structure of your blocks.
44 * `wp-i18n`: To internationalize the block's text.
45 *
46 * @since 1.0.0
47 */
48 function chatty_mango_tag_groups_editor_assets()
49 {
50
51
52 $screen = get_current_screen();
53 if (is_object($screen) && property_exists($screen, 'base') && 'post' != $screen->base) {
54 $server_side_render = false;
55 } else {
56 $server_side_render = !!TagGroups_Options::get_option('tag_group_server_side_render', 1);
57 }
58
59 // make some data available
60 $args = array(
61 'siteUrl' => get_option('siteurl'),
62 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
63 'siteLang' => '', // for future use
64 'pluginUrl' => TAG_GROUPS_PLUGIN_URL,
65 'hasPremium' => TagGroups_Utilities::is_premium_plan(),
66 'serverSideRender' => $server_side_render,
67 'collapsible' => TagGroups_Options::get_option('tag_group_collapsible', 0),
68 'mouseover' => TagGroups_Options::get_option('tag_group_mouseover', 0),
69 'gutenbergSettings' => admin_url('admin.php?page=tag-groups-settings-back-end&active-tab=gutenberg')
70 );
71 $block_asset_url = TAG_GROUPS_PLUGIN_URL;
72 $block_asset_path = TAG_GROUPS_PLUGIN_ABSOLUTE_PATH;
73
74 if (defined('TAG_GROUPS_LOADED_BY_PRO') && TAG_GROUPS_LOADED_BY_PRO && defined('TAG_GROUPS_PRO_ABSPATH') && defined('TAG_GROUPS_PRO_URL')) {
75 $block_asset_url = TAG_GROUPS_PRO_URL;
76 $block_asset_path = TAG_GROUPS_PRO_ABSPATH;
77 }
78 $block_script_path = $block_asset_path . '/build/index.js';
79 $block_style_path = $block_asset_path . '/build/index.css';
80 // Scripts.
81 if (! empty($screen->base) && 'widgets' == $screen->base) {
82 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
83 // not yet implemented
84 // wp_enqueue_script(
85 // 'chatty-mango_tag-groups-block-js', // Handle.
86 // plugins_url( 'build/index.js', dirname( __FILE__ ) ),
87 // array( 'lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-polyfill', 'wp-url', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-edit-widgets' )
88 // );
89 } elseif (file_exists($block_script_path)) {
90 wp_enqueue_script(
91 'chatty-mango_tag-groups-block-js', // Handle.
92 $block_asset_url . '/build/index.js',
93 array( 'lodash', 'react', 'react-dom', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-polyfill', 'wp-url', 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-components', 'wp-editor' ),
94 TAG_GROUPS_VERSION
95 );
96 wp_localize_script('chatty-mango_tag-groups-block-js', 'ChattyMangoTagGroupsGlobal', $args);
97 }
98
99 // Styles.
100 if (file_exists($block_style_path)) {
101 wp_enqueue_style(
102 'chatty-mango_tag-groups-block-editor-css', // Handle.
103 $block_asset_url . '/build/index.css', // Block editor CSS.
104 array( 'wp-edit-blocks' ),
105 TAG_GROUPS_VERSION
106 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
107 // , $dependencies['version']
108 );
109 }
110 if (function_exists('wp_get_jed_locale_data')) {
111 $locale_data = wp_get_jed_locale_data('tag-groups');
112 } elseif (function_exists('gutenberg_get_jed_locale_data')) {
113 $locale_data = gutenberg_get_jed_locale_data('tag-groups');
114 } else {
115 $locale_data = [];
116 // Ensure it doesn't break if neither function exists
117 }
118
119 wp_add_inline_script('wp-i18n', 'wp.i18n.setLocaleData( ' . wp_json_encode($locale_data) . ' );');
120 }
121 // phpcs:ignore Squiz.PHP.CommentedOutCode.Found
122 // End function chatty_mango_tag_groups_editor_assets().
123
124 // Hook: Editor assets.
125 add_action('enqueue_block_editor_assets', 'chatty_mango_tag_groups_editor_assets');
126