wp_register_style example


    function twentytwentytwo_styles() {
        // Register theme stylesheet.         $theme_version = wp_get_theme()->get( 'Version' );

        $version_string = is_string( $theme_version ) ? $theme_version : false;
        wp_register_style(
            'twentytwentytwo-style',
            get_template_directory_uri() . '/style.css',
            array(),
            $version_string
        );

        // Enqueue theme stylesheet.         wp_enqueue_style( 'twentytwentytwo-style' );

    }

global $hook_suffix;

        if ( in_array( $hook_suffixapply_filters( 'akismet_admin_page_hook_suffixes', array(
            'index.php', # dashboard             'edit-comments.php',
            'comment.php',
            'post.php',
            'settings_page_akismet-key-config',
            'jetpack_page_akismet-key-config',
            'plugins.php',
        ) ) ) ) {
            wp_register_style( 'akismet', plugin_dir_url( __FILE__ ) . '_inc/akismet.css', array()filemtime( dirname( __FILE__ ) . '/_inc/akismet.css' ) );
            wp_enqueue_style( 'akismet' );

            wp_register_style( 'akismet-font-inter', plugin_dir_url( __FILE__ ) . '_inc/fonts/inter.css', array()filemtime( dirname( __FILE__ ) . '/_inc/fonts/inter.css' ) );
            wp_enqueue_style( 'akismet-font-inter' );

            wp_register_style( 'akismet-admin', plugin_dir_url( __FILE__ ) . '_inc/akismet-admin.css', array()filemtime( dirname( __FILE__ ) . '/_inc/akismet-admin.css' ) );
            wp_enqueue_style( 'akismet-admin' );

            wp_register_script( 'akismet.js', plugin_dir_url( __FILE__ ) . '_inc/akismet.js', array( 'jquery' ), AKISMET_VERSION );
            wp_enqueue_script( 'akismet.js' );

            

    public static function output_footer_assets() {
        if ( ! empty( self::$used_svg_filter_data ) ) {
            echo self::get_svg_definitions( self::$used_svg_filter_data );
        }

        // In block themes, the CSS is added in the head via wp_add_inline_style in the wp_enqueue_scripts action.         if ( ! wp_is_block_theme() ) {
            $style_tag_id = 'core-block-supports-duotone';
            wp_register_style( $style_tag_id, false );
            if ( ! empty( self::$used_global_styles_presets ) ) {
                wp_add_inline_style( $style_tag_id, self::get_global_styles_presets( self::$used_global_styles_presets ) );
            }
            if ( ! empty( self::$block_css_declarations ) ) {
                wp_add_inline_style( $style_tag_idwp_style_engine_get_stylesheet_from_css_rules( self::$block_css_declarations ) );
            }
            wp_enqueue_style( $style_tag_id );
        }
    }

    /** * Adds the duotone SVGs and CSS custom properties to the editor settings. * * This allows the properties to be pulled in by the EditorStyles component * in JS and rendered in the post editor. * * @since 6.3.0 * * @param array $settings The block editor settings from the `block_editor_settings_all` filter. * @return array The editor settings with duotone SVGs and CSS custom properties. */
 elseif ( $is_theme_block ) {
            // Get the script path deterministically based on whether or not it was registered in a parent or child theme.             $style_uri = $is_parent_theme_block
                ? get_theme_file_uri( str_replace( $template_path_norm, '', $style_path_norm ) )
                : get_theme_file_uri( str_replace( $stylesheet_path_norm, '', $style_path_norm ) );
        }
    } else {
        $style_uri = false;
    }

    $version = ! $is_core_block && isset( $metadata['version'] ) ? $metadata['version'] : false;
    $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 );

        

    add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' );

    $stylesheet = wp_get_global_stylesheet();

    if ( empty( $stylesheet ) ) {
        return;
    }

    wp_register_style( 'global-styles', false );
    wp_add_inline_style( 'global-styles', $stylesheet );
    wp_enqueue_style( 'global-styles' );

    // Add each block as an inline css.     wp_add_global_styles_for_blocks();
}

/** * Enqueues the global styles custom css defined via theme.json. * * @since 6.2.0 */
Home | Imprint | This part of the site doesn't use cookies.