get( 'Version' ); // Stylesheet wp_enqueue_style( 'blockstarter-styles', get_theme_file_uri( '/style.css' ), array(), $version ); if ( is_rtl() ) { wp_enqueue_style( 'rtl-css', get_template_directory_uri() . '/assets/css/rtl.css', 'rtl_css' ); } } add_action( 'wp_enqueue_scripts', 'blockstarter_scripts' ); function blockstarter_excerpt_length( $length ) { return 25; } add_filter( 'excerpt_length', 'blockstarter_excerpt_length' ); /** Add default theme logo if no logo is specified */ function blockstarter_get_custom_logo_callback( $html ) { if ( has_custom_logo() ) { return $html; } else { $logo = ''; return '' . $logo . ''; } } add_filter( 'get_custom_logo', 'blockstarter_get_custom_logo_callback' ); /** * Registers block patterns categories, and type. */ function blockstarter_register_block_patterns() { $block_pattern_categories = array( 'blockstarter' => array( 'label' => esc_html__( 'Blockstarter', 'blockstarter' ) ), ); $block_pattern_categories = apply_filters( 'blockstarter_block_pattern_categories', $block_pattern_categories ); foreach ( $block_pattern_categories as $name => $properties ) { if ( ! WP_Block_Pattern_Categories_Registry::get_instance()->is_registered( $name ) ) { register_block_pattern_category( $name, $properties ); } } } add_action( 'init', 'blockstarter_register_block_patterns', 9 ); /* Add custom body class based on the style variation */ function blockstarter_body_classes( $classes ) { $style_variation = wp_get_global_settings( array( 'custom', 'variation' ) ); if ( 'default' !== $style_variation ) { $classes[] = 'variation-' . $style_variation; } return $classes; } add_filter( 'body_class', 'blockstarter_body_classes' ); /** * Add block style variations. */ function blockstarter_register_block_styles() { $block_styles = array( 'core/query' => array( 'left-featured-image' => __( 'Left Featured Image', 'blockstarter' ), ), 'core/post-terms' => array( 'term-button' => __( 'Button Style', 'blockstarter' ), ), 'core/query-pagination' => array ( 'pagination-button' => __( 'Button Style', 'blockstarter' ), ) ); foreach ( $block_styles as $block => $styles ) { foreach ( $styles as $style_name => $style_label ) { register_block_style( $block, array( 'name' => $style_name, 'label' => $style_label, ) ); } } } add_action( 'init', 'blockstarter_register_block_styles' ); /** * Load custom block styles only when the block is used. */ function blockstarter_enqueue_custom_block_styles() { // Scan our css folder to locate block styles. $files = glob( get_template_directory() . '/assets/css/*.css' ); foreach ( $files as $file ) { // Get the filename and core block name. $filename = basename( $file, '.css' ); $block_name = str_replace( 'core-', 'core/', $filename ); wp_enqueue_block_style( $block_name, array( 'handle' => "blockstarter-block-{$filename}", 'src' => get_theme_file_uri( "assets/css/{$filename}.css" ), 'path' => get_theme_file_path( "assets/css/{$filename}.css" ), ) ); } } add_action( 'init', 'blockstarter_enqueue_custom_block_styles' ); /** * Display the admin notice. */ function blockstarter_admin_notice() { global $current_user; $user_id = $current_user->ID; if ( ! get_user_meta( $user_id, 'blockstarter_ignore_customizer_notice' ) ) { ?>
New! If you like the free version of the theme, you are gonna love the Pro version - Upgrade Now