Создать расширение плагина elementor для новой структуры так же, как виджет столбца
Я хочу создать расширение плагина elementor для новой структуры так же, как виджет столбца, который может позволить добавлять другие виджеты внутри него.
Мне нужна новая структура, кроме структуры столбцов элемента.
Я указал ниже URL для создания виджета, но он может создать единственный виджет, а не раздел.
Реферальный URL: - https://developers.elementor.com/creating-an-extension-for-elementor/
0 ответов
Вы можете создать свой собственный плагин, который расширит функциональность существующего плагина, или вы сможете создать свой собственный функционал.
<?php
class Elementor_Test_Widget extends \Elementor\Widget_Base {
public function get_name() {}
public function get_title() {}
public function get_icon() {}
public function get_categories() {}
protected function _register_controls() {}
protected function render() {}
protected function _content_template() {}
}
Widget Name – The get_name() method is a simple one, you just need to return a widget name that will be used in the code.
Widget Title – The get_title() method, which again, is a very simple one, you need to return the widget title that will be displayed as the widget label.
Widget Icon – The get_icon() method, is an optional but recommended method, it lets you set the widget icon. you can use any of the eicon or font-awesome icons, simply return the class name as a string.
Widget Categories – The get_categories method, lets you set the category of the widget, return the category name as a string.
Widget Controls – The _register_controls method lets you define which controls (setting fields) your widget will have.
Render Frontend Output – The render() method, which is where you actually render the code and generate the final HTML on the frontend using PHP.
Render Editor Output – The _content_template() method, is where you render the editor output to generate the live preview using a Backbone JavaScript template.
В классе Widget_Base есть еще много методов, которые вы можете использовать для выполнения разных задач, но на данный момент этого должно быть достаточно.
Образец виджета
<?php
use Elementor\Widget_Base;
class Elementor_oEmbed_Widget extends Widget_Base {
public function get_name() {
return 'oembed';
}
public function get_title() {
return __( 'oEmbed', 'plugin-name' );
}
public function get_icon() {
return 'fa fa-code';
}
ategories.
*/
public function get_categories() {
return [ 'general' ];
}
protected function _register_controls() {
$this->start_controls_section(
'content_section',
[
'label' => __( 'Content', 'plugin-name' ),
'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
]
);
$this->add_control(
'url',
[
'label' => __( 'URL to embed', 'plugin-name' ),
'type' => \Elementor\Controls_Manager::TEXT,
'input_type' => 'url',
'placeholder' => __( 'https://your-link.com', 'plugin-name' ),
]
);
$this->end_controls_section();
}
protected function render() {
$settings = $this->get_settings_for_display();
$html = wp_oembed_get( $settings['url'] );
echo '<div class="oembed-elementor-widget">';
echo ( $html ) ? $html : $settings['url'];
echo '</div>';
}
}