PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.10.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.10.01
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/FeaturesHandler.php +18 -47 1.0.962.10.01 View file →
@@ -1,10 +1,10 @@
1 1 <?php
2 2
3 3 namespace FluentCommunity\Modules;
4 4
5 -use FluentCommunity\App\Functions\Utility;
6 5 use FluentCommunity\App\Services\Helper;
6 +use FluentCommunity\App\Vite;
7 7 use FluentCommunity\Framework\Foundation\Application;
8 8 use FluentCommunity\Framework\Support\Arr;
9 9
10 10 class FeaturesHandler
@@ -19,14 +19,8 @@
19 19 add_action('fluent_community/portal_sidebar', [$this, 'maybePushDarkModeScript']);
20 20 add_action('init', [$this, 'maybeOembedRequest']);
21 21
22 22 add_action('fluent_community/rendering_headless_portal', [$this, 'loadHeadlessPortalAssets']);
23 -
24 - // require the CLI
25 - if (defined('WP_CLI') && WP_CLI) {
26 - \WP_CLI::add_command('fluent_community', '\FluentCommunity\Modules\CLI\Commands');
27 - \WP_CLI::add_command('fluent_com_dummy', '\FluentCommunity\Modules\CLI\DummyCommands');
28 - }
29 23 }
30 24
31 25 public function loadHeadlessPortalAssets($data)
32 26 {
@@ -33,13 +27,23 @@
33 27 add_action('fluent_community/portal_head', function () use ($data) {
34 28 $cssFiles = Arr::get($data, 'css_files', []);
35 29 foreach ($cssFiles as $file) {
36 30 ?>
37 - <link rel="stylesheet"
38 - href="<?php echo esc_url($file['url']); ?>?version=<?php echo esc_attr(FLUENT_COMMUNITY_PLUGIN_VERSION); ?>"
39 - media="screen"/>
31 + <link rel="stylesheet" href="<?php echo esc_url($file['url']); ?>?version=<?php echo esc_attr(FLUENT_COMMUNITY_PLUGIN_VERSION); ?>" media="screen"/> <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet ?>
40 32 <?php
41 33 }
34 + $jsFiles = Arr::get($data, 'header_js_files', []);
35 + foreach ($jsFiles as $file) {
36 + $jsVars = Arr::get($file, 'vars', []);
37 + foreach ($jsVars as $varKey => $values) {
38 + ?>
39 + <script>
40 + var <?php echo esc_attr($varKey); ?> = <?php echo wp_json_encode($values); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
41 + </script>
42 + <?php } ?>
43 + <script type="module" src="<?php echo esc_url(Vite::versionedUrl($file['url'])); ?>" defer="defer"></script> <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript ?>
44 + <?php
45 + }
42 46 });
43 47
44 48 add_action('fluent_community/before_js_loaded', function () use ($data) {
45 49 $jsVars = Arr::get($data, 'js_vars', []);
@@ -52,14 +56,12 @@
52 56 <?php
53 57 });
54 58
55 59 add_action('fluent_community/portal_footer', function () use ($data) {
56 -
57 60 $jsFiles = Arr::get($data, 'js_files', []);
58 -
59 61 foreach ($jsFiles as $file) {
60 62 ?>
61 - <script type="module" src="<?php echo esc_url($file['url']); ?>?version=<?php echo esc_attr(FLUENT_COMMUNITY_PLUGIN_VERSION); ?>" defer="defer"></script>
63 + <script type="module" src="<?php echo esc_url(Vite::versionedUrl($file['url'])); ?>" defer="defer"></script> <?php // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript ?>
62 64 <?php
63 65 }
64 66 });
65 67
@@ -66,46 +68,15 @@
66 68 }
67 69
68 70 public function maybePushDarkModeScript()
69 71 {
70 - static $pushed;
71 - if ($pushed) {
72 - return;
73 - }
74 - $pushed = true;
75 72
76 - if (!Helper::hasColorScheme()) {
77 - return;
78 - }
79 -
80 - ?>
81 - <script type="text/javascript">
82 - (function () {
83 - var globalStorage = localStorage.getItem('fcom_global_storage');
84 - var currentMode = '';
85 - if (globalStorage) {
86 - globalStorage = JSON.parse(globalStorage);
87 - if (globalStorage) {
88 - currentMode = globalStorage.fcom_color_mode;
89 - }
90 - }
91 -
92 - if (!currentMode) {
93 - currentMode = window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
94 - }
95 -
96 - if (currentMode === 'dark') {
97 - document.documentElement.classList.add('dark');
98 - }
99 - })();
100 - </script>
101 - <?php
102 73 }
103 74
104 75 public function maybeOembedRequest()
105 76 {
106 77 // this is temp hack
107 - if (!isset($_GET['url'])) {
78 + if (!isset($_GET['url'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
108 79 return;
109 80 }
110 81
111 82 if (defined('REST_REQUEST')) {
@@ -121,9 +92,9 @@
121 92 return;
122 93 }
123 94
124 95 global $wp_embed, $wp_scripts;
125 - $url = sanitize_url($_GET['url']);
96 + $url = sanitize_url(wp_unslash($_GET['url'] ?? '')); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
126 97
127 98 $request = \FluentCommunity\App\App::make('request');
128 99
129 100 $args = $request->all();
@@ -174,9 +145,9 @@
174 145 ], 404);
175 146 }
176 147
177 148 /** This filter is documented in wp-includes/class-wp-oembed.php */
178 - $data->html = apply_filters('oembed_result', _wp_oembed_get_object()->data2html((object)$data, $url), $url, $args);
149 + $data->html = apply_filters('oembed_result', _wp_oembed_get_object()->data2html((object)$data, $url), $url, $args); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
179 150
180 151 wp_send_json($data, 200);
181 152 }
182 153