registerModules($app); add_action('fluent_community/portal_header', [$this, 'maybePushDarkModeScript']); add_action('fluent_community/portal_sidebar', [$this, 'maybePushDarkModeScript']); add_action('init', [$this, 'maybeOembedRequest']); add_action('fluent_community/rendering_headless_portal', [$this, 'loadHeadlessPortalAssets']); } public function loadHeadlessPortalAssets($data) { add_action('fluent_community/portal_head', function () use ($data) { $cssFiles = Arr::get($data, 'css_files', []); foreach ($cssFiles as $file) { ?> $values) { ?> all(); unset($args['url']); // Copy maxwidth/maxheight to width/height since WP_oEmbed::fetch() uses these arg names. if (isset($args['maxwidth'])) { $args['width'] = $args['maxwidth']; } else { $args['maxwidth'] = 600; } if (isset($args['maxheight'])) { $args['height'] = $args['maxheight']; } // Short-circuit process for URLs belonging to the current site. $data = get_oembed_response_data_for_url($url, $args); if ($data) { wp_send_json($data, 200); } $data = _wp_oembed_get_object()->get_data($url, $args); if (false === $data) { // Try using a classic embed, instead. /* @var \WP_Embed $wp_embed */ $html = $wp_embed->get_embed_handler_html($args, $url); if ($html) { // Check if any scripts were enqueued by the shortcode, and include them in the response. $enqueued_scripts = array(); foreach ($wp_scripts->queue as $script) { $enqueued_scripts[] = $wp_scripts->registered[$script]->src; } wp_send_json(array( 'provider_name' => __('Embed Handler', 'fluent-community'), 'html' => $html, 'scripts' => $enqueued_scripts, ), 200); } wp_send_json([ 'error' => 'not_found', ], 404); } /** This filter is documented in wp-includes/class-wp-oembed.php */ $data->html = apply_filters('oembed_result', _wp_oembed_get_object()->data2html((object)$data, $url), $url, $args); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound wp_send_json($data, 200); } private function registerModules($app) { if (Helper::isFeatureEnabled('course_module')) { // Regitser the modules here (new \FluentCommunity\Modules\Course\CourseModule())->register($app); } if (apply_filters('fluent_community/use_editor_block', true)) { (new \FluentCommunity\Modules\Gutenberg\EditorBlock())->register($app); } (new \FluentCommunity\Modules\Auth\AuthModdule())->register($app); } }