$args ) { $defaults = array( 'handle' => 'hybridextend' . $style, 'src' => '', 'deps' => null, 'version' => false, 'media' => 'all' ); $args = wp_parse_args( $args, $defaults ); if ( !empty( $args['src'] ) ) { wp_register_style( sanitize_key( $args['handle'] ), esc_url( $args['src'] ), is_array( $args['deps'] ) ? $args['deps'] : null, preg_replace( '/[^a-z0-9_\-.]/', '', strtolower( $args['version'] ) ), esc_attr( $args['media'] ) ); } } } /** * Tells WordPress to load the styles using the wp_enqueue_style() function. * * @since 1.0.0 * @access public * @return void */ function hybridextend_enqueue_styles() { $style = hybridextend_get_styles( 'parent' ); if ( !empty( $style['handle'] ) && !empty( $style['src'] ) ) wp_enqueue_style( sanitize_key( $style['handle'] ) ); } function hybridextend_enqueue_child_styles() { if ( is_child_theme() ) : $style = hybridextend_get_styles( 'child' ); if ( !empty( $style['handle'] ) && !empty( $style['src'] ) ) wp_enqueue_style( sanitize_key( $style['handle'] ) ); endif; } /** * Returns an array of the available styles for use in themes. * * @since 1.0.0 * @access public * @return array */ function hybridextend_get_styles( $return = '' ) { static $styles; if ( empty( $styles ) ) : /* Initialize */ $styles = array(); /* If a child theme is active, add the parent theme's style. */ // Cannot use 'hybridextend_locate_style()' as the function will always return child // theme stylesheet. Hence we have to manually locate and add parent stylesheet. if ( is_child_theme() ) { $loadminified = ( defined( 'HYBRIDEXTEND_DEBUG' ) ) ? ( ( HYBRIDEXTEND_DEBUG ) ? false : true ) : hoot_get_mod( 'load_minified', 0 ); /* Get the parent theme stylesheet (if a '.min' version of the stylesheet exists, use it) */ if ( $loadminified && file_exists( HYBRID_PARENT . "style.min.css" ) ) $src = HYBRID_PARENT_URI . "style.min.css"; else // We can skip file_exists for src as parent style.css will always be there. $src = HYBRID_PARENT_URI . "style.css"; $styles['parent'] = array( 'handle' => 'hybridextend-style', 'src' => $src, 'version' => HYBRIDEXTEND_THEME_VERSION, ); $styles['child'] = array( 'handle' => 'hybridextend-child-style', 'src' => get_stylesheet_uri(), 'version' => HYBRIDEXTEND_CHILDTHEME_VERSION, ); } else { $styles[ 'parent' ] = array( 'handle' => 'hybridextend-style', 'src' => get_stylesheet_uri(), 'version' => HYBRIDEXTEND_THEME_VERSION, ); } endif; /* Return the array of styles. */ return ( $return && !empty( $styles[ $return ] ) ) ? $styles[ $return ] : $styles; } /** * Filters the 'stylesheet_uri' returned by get_stylesheet_uri() to allow theme developers to offer a * minimized version of their main 'style.css' file. It will detect if a 'style.min.css' file is available * and use it if HYBRIDEXTEND_DEBUG is disabled. * * @since 1.0.0 * @access public * @param string $stylesheet_uri The URI of the active theme's stylesheet. * @param string $stylesheet_dir_uri The directory URI of the active theme's stylesheet. * @return string $stylesheet_uri */ function hybridextend_min_stylesheet_uri( $stylesheet_uri, $stylesheet_dir_uri ) { if ( defined( 'HYBRIDEXTEND_DEBUG' ) ) $loadminified = ( HYBRIDEXTEND_DEBUG ) ? false : true; else $loadminified = hoot_get_mod( 'load_minified', 0 ); /* Use the .min stylesheet if available. */ if ( $loadminified ) { /* Remove the stylesheet directory URI from the file name. */ $stylesheet = str_replace( trailingslashit( $stylesheet_dir_uri ), '', $stylesheet_uri ); /* Change the stylesheet name to 'style.min.css'. */ $stylesheet = str_replace( '.css', ".min.css", $stylesheet ); /* If the stylesheet exists in the stylesheet directory, set the stylesheet URI to the dev stylesheet. */ if ( file_exists( trailingslashit( get_stylesheet_directory() ) . $stylesheet ) ) $stylesheet_uri = esc_url( trailingslashit( $stylesheet_dir_uri ) . $stylesheet ); } /* Return the theme stylesheet. */ return $stylesheet_uri; } /** * Registers the admin stylesheet files. The function does not load the stylesheet. * It merely registers it with WordPress. * * @since 1.0.0 * @access public * @return void */ function hybridextend_register_adminstyles() { if ( apply_filters( 'hoot_force_theme_fa', true, 'admin' ) ) wp_deregister_style( 'font-awesome' ); // Bug Fix for plugins using older font-awesome library $style_uri = hybridextend_locate_style( HYBRIDEXTEND_CSS . 'font-awesome' ); wp_register_style( 'font-awesome', $style_uri, false, '5.15.4' ); // hybridextend-font-awesome }