function enqueue_admin() { global $wpenq; $scripts = $wpenq->get_option_map('scripts'); if ($scripts) { $default_scripts = WP_Enqueue_Helper::get_default_scripts(); $index = 0; foreach ((array) $scripts as $key => $values) { foreach ((array) $values as $value) { // increment only for admin scripts if (mb_stripos($value, 'admin') === 0) { $index++; } if (in_array($value, $default_scripts)) { $handle = $value; $value = false; } else { $handle = "wpenq-admin-script-{$index}"; $value = WP_Enqueue_Helper::get_full_url($value); } if ($key == 'admin') { wp_enqueue_script($handle, $value); } $condition = explode(' ', $key); if (count($condition) >= 2) { if (strcasecmp($condition[0], 'admin') === 0) { if (strcasecmp($condition[1], 'footer') === 0) { wp_enqueue_script($handle, $value, false, false, true); } } } } } } $styles = $wpenq->get_option_map('styles'); if ($styles) { $index = 0; foreach ((array) $styles as $key => $values) { foreach ((array) $values as $value) { if ($key == 'admin') { $index++; // increment only for admin styles $handle = "wpenq-admin-style-{$index}"; $value = WP_Enqueue_Helper::get_full_url($value); wp_enqueue_style($handle, $value); } } } } }
public function get_conditions($domain) { return WP_Enqueue_Helper::isset_array($this->options, array($domain, 'conditions'), array()); }
public static function set_default_scripts($scripts) { self::$default_scripts = $scripts; }
<code>admin</code> - enqueue in admin dashboard<br> <code>home</code> - enqueue only for homepage<br> <code>page</code> - enqueue for all pages<br> <code>page ...</code> - enqueue for a specific page<br> <code>single</code> - enqueue for all posts<br> <code>single ...</code> - enqueue for a specific post<br> <code>category</code> - enqueue for all categories<br> <code>category ...</code> - enqueue to a specific category<br> <code>archive</code> - enqueue for all archives<br><br> <code>page, single, category</code><br> - id or slug can be used<br> </p> <div class="wpenq-wrap wpenq-styles-wrap"> <?php // get all files in plugin $files = WP_Enqueue_Helper::scan_for_files('css', 1); // get all files in theme $files = array_merge($files, WP_Enqueue_Helper::scan_for_files('css', 0)); for ($i = 0; $path_value = isset($path_option[$i]) ? esc_attr($path_option[$i]) : ''; $i++) { include 'single-wrap.php'; } ?> </div> <?php // template for 'Add style' button ?> <template class="wpenq-styles-tpl"> <?php include 'single-wrap.php'; ?> </template>