wp_style_add_data example

    // to detect if the current browser is internet explorer.     global $is_IE$wp_scripts;
    if ( $is_IE ) {
        // If IE 11 or below, use a flattened stylesheet with static values replacing CSS Variables.         wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/assets/css/ie.css', array()wp_get_theme()->get( 'Version' ) );
    } else {
        // If not IE, use the standard stylesheet.         wp_enqueue_style( 'twenty-twenty-one-style', get_template_directory_uri() . '/style.css', array()wp_get_theme()->get( 'Version' ) );
    }

    // RTL styles.     wp_style_add_data( 'twenty-twenty-one-style', 'rtl', 'replace' );

    // Print styles.     wp_enqueue_style( 'twenty-twenty-one-print-style', get_template_directory_uri() . '/assets/css/print.css', array()wp_get_theme()->get( 'Version' ), 'print' );

    // Threaded comment reply styles.     if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
        wp_enqueue_script( 'comment-reply' );
    }

    // Register the IE11 polyfill file.     wp_register_script(
        

    $callback = static function( $content ) use ( $args ) {
        // Register the stylesheet.         if ( ! empty( $args['src'] ) ) {
            wp_register_style( $args['handle']$args['src']$args['deps']$args['ver']$args['media'] );
        }

        // Add `path` data if provided.         if ( isset( $args['path'] ) ) {
            wp_style_add_data( $args['handle'], 'path', $args['path'] );

            // Get the RTL file path.             $rtl_file_path = str_replace( '.css', '-rtl.css', $args['path'] );

            // Add RTL stylesheet.             if ( file_exists( $rtl_file_path ) ) {
                wp_style_add_data( $args['handle'], 'rtl', 'replace' );

                if ( is_rtl() ) {
                    wp_style_add_data( $args['handle'], 'path', $rtl_file_path );
                }
            }
$result  = wp_register_style(
        $style_handle_name,
        $style_uri,
        array(),
        $version
    );
    if ( ! $result ) {
        return false;
    }

    if ( $has_style_file ) {
        wp_style_add_data( $style_handle_name, 'path', $style_path_norm );

        if ( $is_core_block ) {
            $rtl_file = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $style_path_norm );
        } else {
            $rtl_file = str_replace( '.css', '-rtl.css', $style_path_norm );
        }

        if ( is_rtl() && file_exists( $rtl_file ) ) {
            wp_style_add_data( $style_handle_name, 'rtl', 'replace' );
            wp_style_add_data( $style_handle_name, 'suffix', $suffix );
            wp_style_add_data( $style_handle_name, 'path', $rtl_file );
        }
Home | Imprint | This part of the site doesn't use cookies.