useNonMinifiedSources(); // Use this variable if you need to differ between minified or non minified sources // Our utils package relies on jQuery, but this shouldn't be a problem as the most themes still use jQuery (might be replaced with https://github.com/github/fetch) // Enqueue external utils package $scriptDeps = $this->enqueueUtils(); // Enqueue plugin entry points if ($type === self::$TYPE_ADMIN) { $handle = $this->enqueueScript('admin', 'admin.js', $scriptDeps); $this->enqueueStyle('admin', 'admin.css'); $this->enqueueStyle('metabox', 'metabox.css', ['admin']); $this->enqueueStyle('dashboard', 'dashboard.css', ['admin']); } elseif ($type === self::$TYPE_FRONTEND) { // include frontend files } // Localize script with server-side variables wp_localize_script($handle, BDOTSTD_SLUG_CAMELCASE, $this->localizeScript($type)); } /** * Localize the WordPress backend and frontend. If you want to provide URLs to the * frontend you have to consider that some JS libraries do not support umlauts * in their URI builder. For this you can use utils Assets#getAsciiUrl. * * Also, if you want to use the options typed in your frontend you should * adjust the following file too: src/public/ts/store/option.tsx * * @param string $context * @return array */ public function overrideLocalizeScript($context) { if ($context === self::$TYPE_ADMIN) { return [ '_' => '_' // Hold at least one object so it is interpreted as object and not array ]; } elseif ($context === self::$TYPE_FRONTEND) { return [ '_' => '_' // Hold at least one object so it is interpreted as object and not array ]; } return []; } }