Addressed a bug in WordPress 5.4 and a custom post on HPB that prevented the block editor from working

update Last updated: April 11, 2023 at 3:37 AM

Since I have too much time to refrain from corona, I performed maintenance on the server as follows.

As we have already reported to the WordPress forum linked below, after upgrading to WordPress 5.4, the multi-file uploader no longer works in the browser "Microsoft Edge".

📎 Unable to Upload Media Files in Microsoft Edge

It looks like this issue has also been escalated to the WordPress development team as a known bug, so it should be fixed in the upcoming version 5.4.1.

However, it is inconvenient that this function cannot be used, so we are currently operating this system with the following patch (addition to function.php).

2020.05.03 update
This bug has been fixed with the release of WordPress 5.4.1.

/* 【WordPress5.4】マルチファイルアップローダバグ対応 */
function my_admin_media_views_style() {
	if ( wp_style_is( 'media-views' ) ) {
		$style = <<<STYLE
div.moxie-shim.moxie-shim-html5,
div.moxie-shim.moxie-shim-html5 input[type="file"] {
	display: inline;
}
STYLE;
		wp_add_inline_style( 'media-views', $style );
	}
}
add_action( 'admin_enqueue_scripts', 'my_admin_media_views_style' );


Next question.

With WordPress 5.4, the functionality of the block editor (commonly known as Gutenberg) has been enhanced and it has become very easy to use, so all new posts are standardized to the block editor. (However, it is inconvenient that tags cannot be selected)

However, I couldn't use the convenient block editor for custom posts such as news and galleries.

Therefore, this time, it became possible to edit it in the block editor by modifying two functions regist_posttype_news described in the program "functions.regist_posttype_gallery" of the theme as follows.
Add two lines for each function. (set the value of the parameter 'show_in_rest' to true)

In the world of WordPress, it seems that there are not many users, but this site uses the homepage builder of JustSystems (transferred from developer IBM Japan in 2011) for the theme PHP program.

2022.07.28 update – Enable post excerpts as well

<?php
}
function regist_posttype_news(){
	register_post_type(
		'news',
		array(
		'label'         => 'ニュース',
		'hierarchical'  => false,
		'public'        => true,
		'has_archive'   => true,
		'supports'      => array(
		'title',
		'editor',
		'thumbnail',
		'comments',
		'excerpt'	// 抜粋を有効
		),
		'menu_position' => 5,
		'show_in_rest'  => true, // ブロックエディタ対応
		'menu_icon'     => get_template_directory_uri() . '/post-types/menu_news.png'
		)
	);

	register_taxonomy(
		'newscat',
		'news',
		array(
		'label'        => 'ニュースのカテゴリー',
		'show_in_rest' => true, // ブロックエディタ対応
		'hierarchical' => true,
		)
	);
}

function regist_posttype_gallery(){
	register_post_type(
		'gallery',
		array(
		'label'         => 'ギャラリー',
		'hierarchical'  => false,
		'public'        => true,
		'has_archive'   => true,
		'supports'      => array(
		'title',
		'editor',
		'thumbnail',
		'comments',
		'excerpt'	// 抜粋を有効
		),
		'menu_position' => 5,
		'show_in_rest'  => true, // ブロックエディタ対応
		'menu_icon'     => get_template_directory_uri() . '/post-types/menu_user.png'
		)
	);

	register_taxonomy(
		'gallerycat',
		'gallery',
		array(
		'label'        => 'ギャラリーのカテゴリー',
		'show_in_rest' => true, // ブロックエディタ対応
		'hierarchical' => true,
		)
	);
}


This allows news articles to be edited in the block editor as shown below! 😀


2020.05.03 Postscript
installing imagick

Leave this problem as a memorandum.
In the core server, the module imagick that calls the image processing library ImageMagick from PHP is not installed in the standard PHP configuration.
Therefore, when you run Jetpack Site Health, you will see the warning screen "One or more recommended modules does not exist" shown below.

This issue is resolved by adding the extension module definition to the core server's php.ini file (php7.1) in the path below.

public_htmlfast-cgi-binphp71.ini

extension = imagick.so


After correcting php.ini, after a while, when executing site health, the warning "One or more recommended modules does not exist" disappears as shown below.

If you select "Information" ⇒ "Media Processing" on the site health screen, you can confirm that ImageMagick is built in as follows.

Add this entry to the hasebookmark
X (post)

Leave a Reply