/** * Register and enqueue public-facing style sheet. * * @since 1.0.2 */ function wpas_assets_front_end() { // Make sure we only enqueue on our plugin's pages if (wpas_is_plugin_page()) { // Styles wp_enqueue_style('wpas-plugin-styles'); $stylesheet = wpas_get_theme_stylesheet(); if (file_exists($stylesheet) && true === boolval(wpas_get_option('theme_stylesheet'))) { wp_register_style('wpas-theme-styles', wpas_get_theme_stylesheet_uri(), array(), WPAS_VERSION); wp_enqueue_style('wpas-theme-styles'); } // Scripts wp_enqueue_script('wpas-plugin-script'); } }
/** * Register and enqueue public-facing style sheet. * * @since 1.0.2 */ public function enqueue_styles() { wp_register_style('wpas-plugin-styles', WPAS_URL . 'assets/public/css/public.css', array(), WPAS_VERSION); if (!is_admin() && wpas_is_plugin_page()) { wp_enqueue_style('wpas-plugin-styles'); $stylesheet = wpas_get_theme_stylesheet(); if (file_exists($stylesheet) && true === boolval(wpas_get_option('theme_stylesheet'))) { wp_register_style('wpas-theme-styles', wpas_get_theme_stylesheet_uri(), array(), WPAS_VERSION); wp_enqueue_style('wpas-theme-styles'); } } }
/** * Get plugin's theme stylesheet URI. * * @since 3.1.6 * @return string Stylesheet URI */ function wpas_get_theme_stylesheet_uri() { $template = wpas_get_theme_stylesheet(); /* Remove the root path and replace backslashes by slashes */ $truncate = str_replace('\\', '/', str_replace(untrailingslashit(ABSPATH), '', $template)); /* Make sure the truncated string doesn't start with a slash because we trailing slash the home URL) */ if ('/' === substr($truncate, 0, 1)) { $truncate = substr($truncate, 1); } /* Build the final URL to the resource */ $uri = trailingslashit(site_url()) . $truncate; return apply_filters('wpas_get_theme_stylesheet_uri', $uri); }