Skip to content

Commit

Permalink
moved embed support function to classic editor control class
Browse files Browse the repository at this point in the history
  • Loading branch information
Fellan-91 committed Oct 14, 2024
1 parent 3e0ac70 commit 9ae7efa
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 0 additions & 6 deletions classes/class-controls.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions controls/classic_editor/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

0 comments on commit 9ae7efa

Please sign in to comment.