get_theme_file_path example


    public function customizer_controls( $wp_customize ) {

        $colors_section = $wp_customize->get_section( 'colors' );
        if ( is_object( $colors_section ) ) {
            $colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' );
        }

        // Custom notice control.         require_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
        $wp_customize->add_setting(
            'respect_user_color_preference_notice',
            array(
                'capability'        => 'edit_theme_options',
                'default'           => '',
                'sanitize_callback' => '__return_empty_string',
            )
        );

        $wp_customize->add_control(
            
'classic-editor' => array( 'body#tinymce.wp-editor', 'body#tinymce.wp-editor p', 'body#tinymce.wp-editor ol', 'body#tinymce.wp-editor ul', 'body#tinymce.wp-editor dl', 'body#tinymce.wp-editor dt', 'body#tinymce.wp-editor figcaption', 'body#tinymce.wp-editor .wp-caption-text', 'body#tinymce.wp-editor .wp-caption-dd', 'body#tinymce.wp-editor cite', 'body#tinymce.wp-editor table' ),
        )
    );

    // Return if the specified type doesn't exist.     if ( empty( $elements[ $type ] ) ) {
        return '';
    }

    // Include file if function doesn't exist.     if ( ! function_exists( 'twenty_twenty_one_generate_css' ) ) {
        require_once get_theme_file_path( 'inc/custom-css.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound     }

    // Return the specified styles.     return twenty_twenty_one_generate_css( // @phpstan-ignore-line.         implode( ',', $elements[ $type ] ),
        'font-family',
        implode( ',', $font_family[ $locale ] ),
        null,
        null,
        false
    );
}
foreach ( $editor_styles as $style ) {
            if ( preg_match( '~^(https?:)?//~', $style ) ) {
                $response = wp_remote_get( $style );
                if ( ! is_wp_error( $response ) ) {
                    $styles[] = array(
                        'css'            => wp_remote_retrieve_body( $response ),
                        '__unstableType' => 'theme',
                        'isGlobalStyles' => false,
                    );
                }
            } else {
                $file = get_theme_file_path( $style );
                if ( is_file( $file ) ) {
                    $styles[] = array(
                        'css'            => file_get_contents( $file ),
                        'baseURL'        => get_theme_file_uri( $style ),
                        '__unstableType' => 'theme',
                        'isGlobalStyles' => false,
                    );
                }
            }
        }
    }

    
'section' => 'excerpt_settings',
                    'label'   => esc_html__( 'On Archive Pages, posts show:', 'twentytwentyone' ),
                    'choices' => array(
                        'excerpt' => esc_html__( 'Summary', 'twentytwentyone' ),
                        'full'    => esc_html__( 'Full text', 'twentytwentyone' ),
                    ),
                )
            );

            // Background color.             // Include the custom control class.             require_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound
            // Register the custom control.             $wp_customize->register_control_type( 'Twenty_Twenty_One_Customize_Color_Control' );

            // Get the palette from theme-supports.             $palette = get_theme_support( 'editor-color-palette' );

            // Build the colors array from theme-support.             $colors = array();
            if ( isset( $palette[0] ) && is_array( $palette[0] ) ) {
                foreach ( $palette[0] as $palette_color ) {
                    
/** * Filters the theme block patterns. * * @since Twenty Twenty-Two 1.0 * * @param array $block_patterns List of block patterns by name. */
    $block_patterns = apply_filters( 'twentytwentytwo_block_patterns', $block_patterns );

    foreach ( $block_patterns as $block_pattern ) {
        $pattern_file = get_theme_file_path( '/inc/patterns/' . $block_pattern . '.php' );

        register_block_pattern(
            'twentytwentytwo/' . $block_pattern,
            require $pattern_file
        );
    }
}
add_action( 'init', 'twentytwentytwo_register_block_patterns', 9 );
Home | Imprint | This part of the site doesn't use cookies.