PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
← All changes | Modules/Gutenberg/EditorBlock.php +103 -57 1.0.962.10.0 View file →
@@ -3,8 +3,9 @@
3 3 namespace FluentCommunity\Modules\Gutenberg;
4 4
5 5 use FluentCommunity\App\Services\Helper;
6 6 use FluentCommunity\App\Vite;
7 +use FluentCommunity\Framework\Support\Arr;
7 8
8 9 class EditorBlock
9 10 {
10 11 public function register($app)
@@ -14,30 +15,45 @@
14 15
15 16 public function registerBlock()
16 17 {
17 18 global $pagenow;
18 - if ($pagenow == 'site-editor.php') {
19 - $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php');
20 - wp_register_style(
21 - 'custom-layout-block-editor-style',
22 - plugins_url('build/index.css', __FILE__),
23 - array(),
24 - $asset_file['version']
25 - );
26 19
27 - wp_register_style('fluent_community_global', Vite::getDynamicSrcUrl('global.scss'), [], FLUENT_COMMUNITY_PLUGIN_VERSION, 'screen');
20 + $asset_file = include(plugin_dir_path(__FILE__) . 'build/index.asset.php');
21 + wp_register_style(
22 + 'custom-layout-block-editor-style',
23 + plugins_url('build/index.css', __FILE__),
24 + array(),
25 + $asset_file['version']
26 + );
28 27
29 - wp_register_script(
30 - 'custom-layout-block-editor',
31 - plugins_url('build/index.js', __FILE__),
32 - $asset_file['dependencies'],
33 - $asset_file['version']
34 - );
35 - }
28 + wp_register_style('fluent_community_global', Vite::getStaticSrcUrl('global.css', Helper::isRtl()), [], FLUENT_COMMUNITY_PLUGIN_VERSION, 'screen');
29 +
30 + wp_register_script(
31 + 'custom-layout-block-editor',
32 + plugins_url('build/index.js', __FILE__),
33 + $asset_file['dependencies'],
34 + $asset_file['version'],
35 + true
36 + );
37 +
38 + wp_localize_script(
39 + 'custom-layout-block-editor',
40 + 'fluentCommunityBlockEditor',
41 + array(
42 + 'blockEditor' => array(
43 + 'isGutenberg' => true,
44 + 'isBlockEditor' => true,
45 + 'isPage' => $pagenow == 'post.php' || $pagenow == 'post-new.php',
46 + 'isPostType' => get_post_type(),
47 + ),
48 + )
49 + );
50 +
36 51 if (function_exists('\register_block_type')) {
37 52 \register_block_type(
38 53 'fluent-community/page-layout',
39 54 array(
55 + 'api_version' => '3', // WP core uses int but stub declares string
40 56 'editor_script' => 'custom-layout-block-editor',
41 57 'editor_style' => 'custom-layout-block-editor-style',
42 58 'style' => 'fluent_community_global',
43 59 'render_callback' => [$this, 'render'],
@@ -64,15 +80,41 @@
64 80 ),
65 81 )
66 82 );
67 83 }
84 +
85 + $this->registerBuiltInTemplate();
68 86 }
69 87
88 + private function registerBuiltInTemplate()
89 + {
90 + if (!wp_is_block_theme() || !function_exists('\register_block_template')) {
91 + return;
92 + }
93 +
94 + $supportedPostTypes = apply_filters('fluent_communuty/block_templates_post_types', ['page', 'post']);
95 +
96 + register_block_template('fluent-community//frame-template', [
97 + 'title' => __('FluentCommunity Page Template', 'fluent-community'),
98 + 'description' => __('A Page Template that render your WP content into FluentCommunity UI Frame', 'fluent-community'),
99 + 'content' => '<!-- wp:fluent-community/page-layout --><!-- wp:post-title /--><!-- wp:post-content /--><!-- /wp:fluent-community/page-layout -->',
100 + 'post_types' => $supportedPostTypes
101 + ]);
102 +
103 + add_filter('get_block_templates', function ($templates) {
104 + if (isset($templates['fluent-community//frame-template'])) {
105 + return array_values($templates);
106 + }
107 + return $templates;
108 + });
109 +
110 + }
111 +
70 112 public function render($attributes, $content)
71 113 {
72 114 static $isLoaded;
73 115 if ($isLoaded) {
74 - return 'Space Layout is already loaded before';
116 + return esc_html__('Layout is already loaded before', 'fluent-community');
75 117 }
76 118
77 119 if (!$isLoaded) {
78 120 $isLoaded = true;
@@ -78,9 +120,9 @@
78 120 $isLoaded = true;
79 121 }
80 122
81 123 $contenx = 'wp';
82 - if (isset($_REQUEST['context']) && $_REQUEST['context'] == 'edit' && Helper::isSiteAdmin()) {
124 + if (isset($_REQUEST['context']) && $_REQUEST['context'] == 'edit' && Helper::isSiteAdmin()) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
83 125 $contenx = 'block_editor';
84 126 }
85 127
86 128 $useBuildInTheme = $attributes['useBuildInTheme'] ?? false;
@@ -85,48 +127,47 @@
85 127
86 128 $useBuildInTheme = $attributes['useBuildInTheme'] ?? false;
87 129
88 130 do_action('fluent_community/enqueue_global_assets', $useBuildInTheme);
89 - $showHeader = $attributes['showPageHeader'] ?? true;
90 131 $useFullWidth = $attributes['useFullWidth'] ?? true;
91 - $hideCommunityHeader = $attributes['hideCommunityHeader'] ?? false;
132 + $hideCommunityHeader = false;
133 + $className = Arr::get($attributes, 'className', '');
92 134
135 + $widthClass = $useFullWidth ? 'fcom_template_full' : 'fcom_template_standard';
136 +
137 + $disableDarkMode = Arr::has($attributes, 'disableDarkMode');
138 +
139 + if ($disableDarkMode) {
140 + add_filter('body_class', function ($classes) {
141 + $classes[] = 'fcom_disable_dark_mode';
142 + return $classes;
143 + });
144 + } else if (Helper::hasColorScheme()) {
145 + add_action('wp_head', function () {
146 + Helper::renderColorSchemePrePaintScript();
147 + });
148 + }
149 +
93 150 ob_start();
94 151 ?>
95 - <div class="fluent_com fluent_com_wp_pages">
96 - <div class="fhr_wrap">
97 - <?php if (!$hideCommunityHeader): ?>
98 - <?php do_action('fluent_community/portal_header', $contenx); ?>
99 - <?php endif; ?>
100 - <div class="fhr_content">
101 - <div class="fhr_home">
102 - <div class="feed_layout">
103 - <div class="spaces">
104 - <div id="fluent_community_sidebar_menu" class="space_contents">
105 - <!-- start-->
106 - <?php do_action('fluent_community/portal_sidebar', $contenx); ?>
107 - <!-- end-->
152 + <div class="fcom_wrap fcom_wp_frame">
153 + <?php do_action('fluent_community/before_portal_dom'); ?>
154 + <div class="fluent_com">
155 + <div class="fhr_wrap">
156 + <?php if (!$hideCommunityHeader): ?>
157 + <?php do_action('fluent_community/portal_header', $contenx); ?>
158 + <?php endif; ?>
159 + <div class="fhr_content">
160 + <div class="fhr_home">
161 + <div class="feed_layout">
162 + <div class="spaces">
163 + <div id="fluent_community_sidebar_menu" class="space_contents">
164 + <?php do_action('fluent_community/portal_sidebar', $contenx); ?>
165 + </div>
108 166 </div>
109 - </div>
110 - <div class="fcom_wp_page">
111 - <?php if ($showHeader): ?>
112 - <div class="fhr_content_layout_header">
113 - <?php if ($contenx == 'block_editor'): ?>
114 - <div class="fhr_page_title">{{ Page Title }}</div>
115 - <?php else: ?>
116 - <div class="fhr_page_title"><?php the_title(); ?></div>
117 - <?php endif; ?>
118 - </div>
119 - <?php endif; ?>
120 167 <div
121 - class="wp_content_wrapper <?php echo $useFullWidth ? 'wp_content_wrapper_full' : ''; ?>">
122 - <div class="wp_content">
123 - <?php if ($contenx == 'block_editor'): ?>
124 - <p>Your page content will be shown here</p>
125 - <?php else: ?>
126 - <?php the_content(); ?>
127 - <?php endif; ?>
128 - </div>
168 + class="feeds_main fcom_wp_content fcom_fallback_wp_content <?php echo esc_attr($className); ?> <?php echo esc_attr($widthClass); ?>">
169 + <?php echo do_blocks($content); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
129 170 </div>
130 171 </div>
131 172 </div>
132 173 </div>
@@ -132,10 +173,14 @@
132 173 </div>
133 174 </div>
134 175 </div>
135 176 </div>
136 - </div>
137 177 <?php
178 +
179 + add_action('wp_footer', function () {
180 + do_action('fluent_community/template_footer');
181 + }, 99);
182 +
138 183 return ob_get_clean();
139 184 }
140 185
141 186 public function useCommunityTemplate($title, $contentCallback = null)
@@ -142,9 +187,9 @@
142 187 {
143 188 do_action('fluent_community/enqueue_global_assets', true);
144 189 $useFullWidth = false;
145 190 $hideCommunityHeader = false;
146 -
191 +
147 192 ob_start();
148 193 ?>
149 194 <div class="fluent_com">
150 195 <div class="fhr_wrap">
@@ -155,11 +200,11 @@
155 200 <div class="fhr_home">
156 201 <div class="feed_layout">
157 202 <div class="spaces">
158 203 <div id="fluent_community_sidebar_menu" class="space_contents">
159 - <!-- start-->
204 + <!-- start-->
160 205 <?php do_action('fluent_community/portal_sidebar', 'headless'); ?>
161 - <!-- end-->
206 + <!-- end-->
162 207 </div>
163 208 </div>
164 209 <div class="fcom_wp_page">
165 210 <?php if ($title): ?>
@@ -166,9 +211,10 @@
166 211 <div class="fhr_content_layout_header">
167 212 <div class="fhr_page_title"><?php echo wp_kses_post($title); ?></div>
168 213 </div>
169 214 <?php endif; ?>
170 - <div class="wp_content_wrapper <?php echo $useFullWidth ? 'wp_content_wrapper_full' : ''; ?>">
215 + <div
216 + class="wp_content_wrapper <?php echo $useFullWidth ? 'wp_content_wrapper_full' : ''; ?>">
171 217 <div class="wp_content">
172 218 <?php if ($contentCallback): ?>
173 219 <?php call_user_func($contentCallback); ?>
174 220 <?php endif; ?>