🤩Change field Description in slides Elementor to Text rich (ok)
wp-content\plugins\elementor-slides-wysiwyg\elementor-slides-wysiwyg.php (đã hoạt động)
<?php
/**
* Plugin Name: Elementor Pro Slides WYSIWYG Description
* Description: Convert Slides widget description field to WYSIWYG editor.
* Version: 1.1
* Author: Lionel
*/
if ( ! defined( 'ABSPATH' ) ) exit;
// Hook into the controls registration for the Slides widget
add_action( 'elementor/element/slides/section_slides/before_section_end', function( $element, $args ) {
// Get the repeater
$repeater = $element->get_controls( 'slides' );
if ( isset( $repeater['fields']['description'] ) ) {
// Replace the description field inside repeater with WYSIWYG
$repeater['fields']['description']['type'] = \Elementor\Controls_Manager::WYSIWYG;
$repeater['fields']['description']['label'] = __( 'Description (Rich Text)', 'plugin-name' );
$repeater['fields']['description']['show_label'] = true;
// Update the repeater back on the widget
$element->update_control( 'slides', $repeater );
}
}, 20, 2 );

Tham khảo
<?php
/**
* Plugin Name: Elementor Slides WYSIWYG Description
* Description: Convert Slides widget repeater "description" field to a WYSIWYG editor.
* Version: 1.1
* Author: Your Name
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function esw_convert_slides_description_to_wysiwyg() {
// Make sure Elementor is loaded
if ( ! did_action( 'elementor/loaded' ) ) {
return;
}
$widgets_manager = \Elementor\Plugin::instance()->widgets_manager;
$slides_widget = $widgets_manager->get_widget_types( 'slides' );
if ( ! $slides_widget ) {
return;
}
// Get the slides repeater control
$slides_control = $slides_widget->get_control( 'slides' );
if ( empty( $slides_control ) || empty( $slides_control['fields'] ) ) {
return;
}
$found = false;
// 1) Prefer explicit 'description' key
if ( isset( $slides_control['fields']['description'] ) ) {
$slides_control['fields']['description'] = array_merge( $slides_control['fields']['description'], [
'type' => \Elementor\Controls_Manager::WYSIWYG,
'label' => __( 'Description', 'elementor-slides-wysiwyg' ),
'show_label' => false,
] );
$found = true;
}
// 2) If not present, scan fields and convert the first TEXTAREA-like field
if ( ! $found ) {
foreach ( $slides_control['fields'] as $key => $field ) {
if ( isset( $field['type'] ) && $field['type'] === \Elementor\Controls_Manager::TEXTAREA ) {
$slides_control['fields'][ $key ] = array_merge( $field, [
'type' => \Elementor\Controls_Manager::WYSIWYG,
'label' => $field['label'] ?? __( 'Description', 'elementor-slides-wysiwyg' ),
'show_label' => false,
] );
$found = true;
break;
}
}
}
if ( $found ) {
// update the slides repeater control with our modified fields
$slides_widget->update_control( 'slides', $slides_control );
}
}
// Hook into two common points depending on Elementor versions
add_action( 'elementor/widgets/widgets_registered', 'esw_convert_slides_description_to_wysiwyg', 20 );
add_action( 'elementor/widgets/register', 'esw_convert_slides_description_to_wysiwyg', 20 );
PreviousChú ý các tham số của wp-login.php, wp-login.php?action=register ... (ok)NextSử dụng WC_Widget_Product_Categories trong theme như nào? (ok)
Last updated
Was this helpful?