push($scriptDeps, 'wp-pointer'); $assets->enqueueComposerScript(REAL_UTILS_SLUG, $scriptDeps, 'cross.js'); $assets->enqueueComposerStyle(REAL_UTILS_SLUG, ['wp-pointer'], 'cross.css'); } } /** * Enqueue helper from each initiator until one valid is found. */ protected function enqueueHelper() { $assets = $this->getFirstAssetsToEnqueueComposer(); $enqueuePointer = \count(Core::getInstance()->getRatingHandler()->getCanBeRated()) > 0; $handle = $assets->enqueueComposerScript(REAL_UTILS_SLUG, $enqueuePointer ? ['wp-pointer', REAL_UTILS_ROOT_SLUG . '-utils'] : [REAL_UTILS_ROOT_SLUG . '-utils'], 'helper.js'); $assets->enqueueComposerStyle(REAL_UTILS_SLUG, [], 'helper.css'); if (!empty($handle)) { // Do not enqueue until required \wp_dequeue_script($handle); \wp_dequeue_style($handle); } return $handle; } /** * Get first found instance of utils' Assets class. This is needed to we can enqueue assets from their. */ public function getFirstAssetsToEnqueueComposer() { foreach (Core::getInstance()->getInitiators() as $initiator) { $assets = $initiator->getPluginAssets(); if (isset($assets::$ASSETS_BUMP) && $assets::$ASSETS_BUMP >= 4) { return $assets; } } } /** * Get initiator if the current page is a welcome page. */ public function isSomeWelcomePage() { foreach (Core::getInstance()->getInitiators() as $initiator) { if ($initiator->getWelcomePage()->isCurrentPage()) { return $initiator; } } } /** * New instance. * * @codeCoverageIgnore */ public static function instance() { return new Assets(); } }