Supertext / polylang-supertext

Supertext Plugin for the Wordpress Polylang Multilingual Add-On
7 stars 3 forks source link

Don't enqeue block editor script on posts screen or when classic editor is used #9

Closed ocean90 closed 5 years ago

ocean90 commented 5 years ago

Currently, when visiting wp-admin/edit.php with Query Monitor active, you get this warning: image

The script gets enqueued in https://github.com/Supertext/polylang-supertext/blob/5ff2a8eb9240c3e6a2bc38f9b1183030ee8768fc/src/Supertext/Polylang/Backend/AdminExtension.php#L124 and is registered in https://github.com/Supertext/polylang-supertext/blob/5ff2a8eb9240c3e6a2bc38f9b1183030ee8768fc/src/Supertext/Polylang/Core.php#L150

The issue is, that PLL_PREFIX . 'block-editor-plugin' doesn't exists until you are on the edit screen with the block editor active (and Polylang Pro installed).

The fix would be to enqueue the script only when AdminExtension::isEditPostScreen() and WP_Screen::is_block_editor() is true.

hmuralt commented 5 years ago

@ocean90 thanks for the detailed report.

The check for both the edit screen and block editor has been added (92a7323bce7db035a21ed8ae6be4ead08fefb0ec).