うまくいかない

theme.jsonのここを変更しても、反映しない

“settings”: { ”typography”: { ”fontFamilies”: [

"fontFamilies": [
                {
                    "fontFamily": "-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Oxygen-Sans,Ubuntu,Cantarell,\"Helvetica Neue\",sans-serif",
                    "slug": "system-font",
                    "name": "System Font"
                },
                {
                    "fontFamily": "Helvetica Neue, Helvetica, Arial, sans-serif",
                    "slug": "helvetica-arial",
                    "name": "Helvetica Arial"
                },
                {
                    "fontFamily": "Geneva, Tahoma, Verdana, sans-serif",
                    "slug": "geneva-verdana",
                    "name": "Geneva Verdana"
                },
                {
                    "fontFamily": "Cambria, Georgia, serif",
                    "slug": "cambria-georgia",
                    "name": "Cambria Georgia"
                },
                {
                    "fontFamily": "Hoefler Text, Baskerville Old Face, Garamond, Times New Roman, serif",
                    "slug": "hoefler-times-new-roman",
                    "name": "Hoefler Times-new Roman"
                }

            ]
,
                {
                    "fontFamily": "Montserrat",
                    "name": "Montserrat",
                    "slug": "montserrat",
                    "fontFace": [
                        {
                            "fontFamily": "Montserrat",
                            "fontWeight": "100 200 300 400 500 600 700 800 900",
                            "fontStyle": "normal",
                            "src": ["https://fonts.googleapis.com/css2?family=Montserrat:wght@100;200;300;400;500;600;700;800;900&display=swap"]
                        },
                        {
                            "fontFamily": "Montserrat",
                            "fontWeight": "100 200 300 400 500 600 700 800 900",
                            "fontStyle": "italic",
                            "src": ["https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap"]
                        }
                    ]
                }

定義していない x-large font size が定義される

	--wp--preset--font-size--small: 13px;
    --wp--preset--font-size--normal: 16px;
    --wp--preset--font-size--medium: 20px;
    --wp--preset--font-size--large: 24px;
    --wp--preset--font-size--extra-large: 32px;	
    --wp--preset--font-size--x-large: 42px;
    --wp--preset--font-size--huge: 48px;
"fontSizes": [
                {
                    "slug": "small",
                    "size": "13px",
                    "name": "Small"
                },
                {
                    "slug": "normal",
                    "size": "16px",
                    "name": "Normal"
                },
                {
                    "slug": "large",
                    "size": "24px",
                    "name": "Large"
                },
                {
                    "slug": "extra-large",
                    "size": "32px",
                    "name": "Extra large"
                },
                {
                    "slug": "huge",
                    "size": "48px",
                    "name": "Huge"
                }
            ],

“fontFamilies”: [,”fontSizes”: [ の順番に変更すると  ”fontFamilies”は、正常に反映する結果となった。なんで?

サイトエディタ 背景色やカラーボタンが style bookで反映しない

add_filter( 'render_block', 'emulsion_test', 20, 2 );
if ( ! function_exists( 'emulsion_test' ) ) {

	function emulsion_test( $block_content, $block ) {


		$block_name = 'wp-block-' . substr( strrchr( $block['blockName'], "/" ), 1 );
		if( $block_name == 'wp-block-heading'){
			$font_family = !empty( $block["attrs"]["fontFamily"] ) ? 'font-family: var(--wp--preset--font-family--'. $block["attrs"]["fontFamily"].')' : '';
			$text_transform = !empty( $block["style"]["typography"]["textTransform"] ) ? 'text-transformy: '. $block["style"]["typography"]["textTransform"] : '';
			$stock = get_theme_mod('test','');
			'.'. $block_name.'{'

					. ''
					. '}';

			var_dump( $block);
		}
		return $block_content;
	}

}
		if( function_exists('gutenberg_get_global_styles_custom_css')){
			$global_styles = gutenberg_get_global_styles_custom_css();
		}
		if( function_exists('wp_get_global_styles_custom_css')){
			$global_styles = wp_get_global_styles_custom_css();
		}

		//$tree       = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data();
		//$global_styles = $tree->get_custom_css();
		var_dump( $global_styles );

function filter_theme_json_theme( $theme_json ) {

	$json_color_scheme = emulsion_get_css_variables_value( '--wp--custom--color--scheme' );

	if ( 'default' !== $json_color_scheme ) {
		$file_path	 = get_stylesheet_directory() . '/styles/' . $json_color_scheme . '.json';
		$json		 = file_get_contents( $file_path );
		$data		 = json_decode( trim( $json ), true );

		$file_path_base	 = get_stylesheet_directory() . '/theme.json';
		$json_base		 = file_get_contents( $file_path_base );
		$base_data		 = json_decode( trim( $json_base ), true );

		$new_data = array_replace( $base_data, $data );
//Not Work
		return $theme_json->update_with( $new_data );
	}
	return $theme_json;
}

add_filter( 'theme_json_theme', 'filter_theme_json_theme' );

/*
$html = '<p><img src="https://cdn-ak.f.st-hatena.com/images/fotolife/t/tenman/20190408/20190408110434.jpg"></p>';
$p = new WP_HTML_Tag_Processor($html);
$p->next_tag('img');
//$p->next_tag();
//if( $p->next_tag()){
	$p->set_attribute('alt','test test');
	$p->add_class('hello-world');
//}
echo $p->get_updated_html();
 *
 */
/*
$block_gap             = wp_get_global_settings( array( 'spacing', 'blockGap' ) );
$default_layout        = wp_get_global_settings( array( 'layout' ) );
$default_block_layout  = _wp_array_get( $block_type->supports, array( '__experimentalLayout', 'default' ), array() );
$used_layout           = isset( $block['attrs']['layout'] ) ? $block['attrs']['layout'] : $default_block_layout;
if ( isset( $used_layout['inherit'] ) && $used_layout['inherit'] ) {
		if ( ! $default_layout ) {
			return $block_content;
		}
		$used_layout = $default_layout;
	}
var_dump( $used_layout );
 *
 */
/*
 add_filter('render_block','my_block_query');


function my_block_query($block_content){

		$block_name			 = 'wp-block-' . substr( strrchr( $block['blockName'], "/" ), 1 );

	if('grid' == emulsion_get_css_variables_value( '--wp--custom--color--scheme' ) && 'wp-block-' == $block_name){

		$p = new WP_HTML_Tag_Processor($block_content);
		$p->next_tag('.wp-block-query');
		$p->add_class('hello-world');

		return $p->get_updated_html();
	}

	return $block_content;
}
 *
 */

//add_action('wp_body_open', 'my_cache_cdd');
function my_cache_cdd(){
	//テキストエリアに入力したスタイル。
$cache_key   = 'wp_get_global_styles_custom_css';
$cache_group = 'theme_json';
var_dump( wp_cache_get( $cache_key, $cache_group ) );
}

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

[emulsion_relate_posts]