\add_action('load_custom_scripts', function () use($wp_scripts, $assets) { // With this action, we are in the footer (end of ``) $wp_scripts->do_items($assets->handleBlocker); }); } /** * Enqueue the cookie banner on 'CMP – Coming Soon & Maintenance Plugin by NiteoThemes' plugin . With this hook, we are in the `getAssets(); $assets->enqueue_scripts_and_styles(Constants::ASSETS_TYPE_FRONTEND); // The plugin does not automatically print the head, instead it uses `do_items` explicitly $wp_scripts->do_items($assets->handleBanner); \add_action('cmp-before-footer-scripts', function () use($wp_scripts, $assets) { // With this action, we are in the footer (end of ``) $wp_scripts->do_items($assets->handleBlocker); }); } /** * Add the home URL to the scanner when the maintenance plugin does not provide a "preview" URL. */ public function addHomeUrlToQueue() { Core::getInstance()->getScanner()->addUrlsToQueue([\home_url()]); } /** * When updating the "Maintenance" plugin options, add the preview to the scanner. * * @see https://wordpress.org/plugins/maintenance/ */ public function update_option_maintenance_options() { Core::getInstance()->getScanner()->addUrlsToQueue([$this->getPreviewUrlForMaintenancePlugin()]); } /** * When updating the "WP Maintenance Mode & Coming Soon" plugin options, add the preview to the scanner. * * @see https://wordpress.org/plugins/wp-maintenance-mode/ */ public function update_option_wpmm_settings() { Core::getInstance()->getScanner()->addUrlsToQueue([$this->getPreviewUrlForWPMaintenanceModePlugin()]); } /** * When updating the "CMP – Coming Soon & Maintenance Plugin by NiteoThemes" plugin options, add the preview to the scanner. * * @see https://wordpress.org/plugins/cmp-coming-soon-maintenance/ */ public function cmp_save_settings() { Core::getInstance()->getScanner()->addUrlsToQueue([$this->getPreviewUrlForCmpPlugin()]); } /** * Get preview URL for "Maintenance" plugin. * * @see https://wordpress.org/plugins/maintenance/ */ protected function getPreviewUrlForMaintenancePlugin() { return \is_plugin_active('maintenance/maintenance.php') ? \home_url('?maintenance-preview=1') : null; } /** * Get preview URL for "CMP – Coming Soon & Maintenance Plugin by NiteoThemes" plugin. * * @see https://wordpress.org/plugins/cmp-coming-soon-maintenance/ */ protected function getPreviewUrlForCmpPlugin() { return \is_plugin_active('cmp-coming-soon-maintenance/niteo-cmp.php') ? \home_url('?cmp_preview=true') : null; } /** * Get preview URL for "Website Builder by SeedProd — Theme Builder, Landing Page Builder, Coming Soon Page, Maintenance Mode" plugin. * * @see https://wordpress.org/plugins/coming-soon/ */ protected function getPreviewUrlForSeedProdPlugin() { if (\is_plugin_active('coming-soon/coming-soon.php')) { $posts = \get_posts(['post_type' => 'seedprod', 'post_status' => 'any', 'numberposts' => -1, 'nopaging' => \true]); return \array_values(\array_map([Utils::class, 'getPreviewUrl'], $posts)); } return null; } /** * Get preview URL for "WP Maintenance Mode & Coming Soon" plugin. * * @see https://wordpress.org/plugins/wp-maintenance-mode/ */ protected function getPreviewUrlForWPMaintenanceModePlugin() { if (\is_plugin_active('wp-maintenance-mode/wp-maintenance-mode.php')) { $options = \get_option('wpmm_settings'); if (\is_array($options) && isset($options['design'])) { $pageId = $options['design']['page_id'] ?? 0; $pageId = \intval($pageId); if ($pageId > 0) { $post = \get_post($pageId); if ($post instanceof WP_Post) { return Utils::getPreviewUrl($post); } } } } return null; } /** * Get singleton instance. * * @codeCoverageIgnore */ public static function getInstance() { return self::$me === null ? self::$me = new \DevOwl\RealCookieBanner\comp\ComingSoonPlugins() : self::$me; } }