From 9ae7efa10dee47bed6b2f476fc465b9dba2e5fee Mon Sep 17 00:00:00 2001 From: Fellan-91 Date: Mon, 14 Oct 2024 16:03:36 +0300 Subject: [PATCH] moved embed support function to classic editor control class --- classes/class-controls.php | 6 ------ controls/classic_editor/index.php | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/classes/class-controls.php b/classes/class-controls.php index 3f21fd671..4d7320628 100644 --- a/classes/class-controls.php +++ b/classes/class-controls.php @@ -66,12 +66,6 @@ public function filter_control_value( $value, $control_data, $block_data, $conte $value = apply_filters( 'lzb/control_value/control_type=' . $control_data['type'], $value, $control_data, $block_data, $context ); $value = apply_filters( 'lzb/control_value/control_name=' . $control_data['name'], $value, $control_data, $block_data, $context ); $value = apply_filters( 'lzb/control_value/block_slug=' . $block_data['slug'], $value, $control_data, $block_data, $context ); - - // added embed support for classic editor control. - if ( 'classic_editor' === $control_data['type'] ) { - global $wp_embed; - $value = $wp_embed->autoembed( $value ); - } } return $value; diff --git a/controls/classic_editor/index.php b/controls/classic_editor/index.php index 21a610fc7..578f366a3 100644 --- a/controls/classic_editor/index.php +++ b/controls/classic_editor/index.php @@ -51,6 +51,26 @@ public function get_script_depends() { return array( 'lazyblocks-control-classic-editor' ); } + + /** + * Embed support for classic editor control. + * + * @param mixed $value - control value. + * @param array $control_data - control data. + * @param array $block_data - block data. + * @param string $context - block render context. + * + * @return string|array + */ + // phpcs:ignore + public function filter_control_value( $value, $control_data, $block_data, $context ) { + if ( 'classic_editor' === $control_data['type'] ) { + global $wp_embed; + $value = $wp_embed->autoembed( $value ); + } + + return $value; + } } new LazyBlocks_Control_ClassicEditor();