fix: guard CHRNX editorial state

This commit is contained in:
chrnx committed 2026-08-11 14:44:31 -05:00
1 parent e031b753cd
commit a5b94123a8
8 files changed
+285 -19

No files matched your search

+16 -1
View File
@@ -5,12 +5,27 @@
* @package CHRNX
*/
/**
* Determine whether a screen is the post block editor.
*
* @param mixed $screen Potential WordPress screen.
* @return bool Whether editor assets belong on the screen.
*/
function chrnx_is_post_block_editor_screen( $screen ) {
return is_object( $screen ) &&
isset( $screen->base, $screen->post_type ) &&
'post' === $screen->base &&
'post' === $screen->post_type &&
is_callable( array( $screen, 'is_block_editor' ) ) &&
$screen->is_block_editor();
}
/**
* Enqueue CHRNX controls only in the post block editor.
*/
function chrnx_enqueue_editor_assets() {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
if ( ! $screen || 'post' !== $screen->base || 'post' !== $screen->post_type || ! $screen->is_block_editor() ) {
if ( ! chrnx_is_post_block_editor_screen( $screen ) ) {
return;
}
+2 -7
View File
@@ -72,16 +72,11 @@ function chrnx_sanitize_canonical_episode_url( $value ) {
return '';
}
$value = trim( $value );
if ( ! filter_var( $value, FILTER_VALIDATE_URL ) ) {
return '';
}
$url = esc_url_raw( $value, array( 'https' ) );
$url = esc_url_raw( trim( $value ) );
$scheme = wp_parse_url( $url, PHP_URL_SCHEME );
$host = wp_parse_url( $url, PHP_URL_HOST );
return 'https' === $scheme && ! empty( $host ) ? $url : '';
return ! empty( $url ) && 'https' === $scheme && ! empty( $host ) ? $url : '';
}
/**