*
* @return array Registered widget types with each widget config.
*/
public function get_widget_types_config() {
$config = [];
foreach ( $this->get_widget_types() as $widget_key => $widget ) {
$config[ $widget_key ] = $widget->get_config();
}
return $config;
}
/**
* @throws \Exception
*/
public function ajax_get_widget_types_controls_config( array $data ) {
Plugin::$instance->documents->check_permissions( $data['editor_post_id'] );
wp_raise_memory_limit( 'admin' );
$config = [];
foreach ( $this->get_widget_types() as $widget_key => $widget ) {
if ( isset( $data['exclude'][ $widget_key ] ) ) {
continue;
}
$config[ $widget_key ] = [
'controls' => $widget->get_stack( false )['controls'],
'tabs_controls' => $widget->get_tabs_controls(),
];
}
return $config;
}
public function ajax_get_widgets_default_value_translations( array $data = [] ) {
$locale = empty( $data['locale'] )
? get_locale()
: $data['locale'];
$force_locale = new Force_Locale( $locale );
$force_locale->force();
$controls = ( new Collection( $this->get_widget_types() ) )
->map( function ( Widget_Base $widget ) {
$controls = $widget->get_stack( false )['controls'];
return [
'controls' => $this->pluck_default_controls( $controls ),
];
} )
->filter( function ( $widget ) {
return ! empty( $widget['controls'] );
} )
->all();
$force_locale->restore();
return $controls;
}
/**
* Ajax render widget.
*
* Ajax handler for Elementor render_widget.
*
* Fired by `wp_ajax_elementor_render_widget` action.
*
* @since 1.0.0
* @access public
*
* @throws \Exception If current user don't have permissions to edit the post.
*
* @param array $request Ajax request.
*
* @return array {
* Rendered widget.
*
* @type string $render The rendered HTML.
* }
*/
public function ajax_render_widget( $request ) {
$document = Plugin::$instance->documents->get_with_permissions( $request['editor_post_id'] );
// Override the global $post for the render.
query_posts(
[
'p' => $request['editor_post_id'],
'post_type' => 'any',
]
);
$editor = Plugin::$instance->editor;
$is_edit_mode = $editor->is_edit_mode();
$editor->set_edit_mode( true );
Plugin::$instance->documents->switch_to_document( $document );
$render_html = $document->render_element( $request['data'] );
$editor->set_edit_mode( $is_edit_mode );
return [
'render' => $render_html,
];
}
/**
* Ajax get WordPress widget form.
*
* Ajax handler for Elementor editor get_wp_widget_form.
*
* Fired by `wp_ajax_elementor_editor_get_wp_widget_form` action.
*
* @since 1.0.0
* @access public
*
* @param array $request Ajax request.
*
* @return bool|string Rendered widget form.
* @throws \Exception
*/
public function ajax_get_wp_widget_form( $request ) {
Plugin::$instance->documents->check_permissions( $request['editor_post_id'] );
if ( empty( $request['widget_type'] ) ) {
return false;
}
if ( empty( $request['data'] ) ) {
$request['data'] = [];
}
$element_data = [
'id' => $request['id'],
'elType' => 'widget',
'widgetType' => $request['widget_type'],
'settings' => $request['data'],
];
/**
* @var $widget_obj Widget_WordPress
*/
$widget_obj = Plugin::$instance->elements_manager->create_element_instance( $element_data );
if ( ! $widget_obj ) {
return false;
}
return $widget_obj->get_form();
}
/**
* Render widgets content.
*
* Used to generate the widget templates on the editor using Underscore JS
* template, for all the registered widget types.
*
* @since 1.0.0
* @access public
*/
public function render_widgets_content() {
foreach ( $this->get_widget_types() as $widget ) {
$widget->print_template();
}
}
/**
* Get widgets frontend settings keys.
*
* Retrieve frontend controls settings keys for all the registered widget
* types.
*
* @since 1.3.0
* @access public
*
* @return array Registered widget types with settings keys for each widget.
*/
public function get_widgets_frontend_settings_keys() {
$keys = [];
foreach ( $this->get_widget_types() as $widget_type_name => $widget_type ) {
$widget_type_keys = $widget_type->get_frontend_settings_keys();
if ( $widget_type_keys ) {
$keys[ $widget_type_name ] = $widget_type_keys;
}
}
return $keys;
}
/**
* Enqueue widgets scripts.
*
* Enqueue all the scripts defined as a dependency for each widget.
*
* @since 1.3.0
* @access public
*/
public function enqueue_widgets_scripts() {
foreach ( $this->get_widget_types() as $widget ) {
$widget->enqueue_scripts();
}
}
/**
* Enqueue widgets styles
*
* Enqueue all the styles defined as a dependency for each widget
*
* @access public
*/
public function enqueue_widgets_styles() {
foreach ( $this->get_widget_types() as $widget ) {
$widget->enqueue_styles();
}
}
/**
* Retrieve inline editing configuration.
*
* Returns general inline editing configurations like toolbar types etc.
*
* @access public
* @since 1.8.0
*
* @return array {
* Inline editing configuration.
*
* @type array $toolbar {
* Toolbar types and the actions each toolbar includes.
* Note: Wysiwyg controls uses the advanced toolbar, textarea controls
* uses the basic toolbar and text controls has no toolbar.
*
* @type array $basic Basic actions included in the edit tool.
* @type array $advanced Advanced actions included in the edit tool.
* }
* }
*/
public function get_inline_editing_config() {
$basic_tools = [
'bold',
'underline',
'italic',
];
$advanced_tools = array_merge( $basic_tools, [
'createlink',
'unlink',
'h1' => [
'h1',
'h2',
'h3',
'h4',
'h5',
'h6',
'p',
'blockquote',
'pre',
],
'list' => [
'insertOrderedList',
'insertUnorderedList',
],
] );
return [
'toolbar' => [
'basic' => $basic_tools,
'advanced' => $advanced_tools,
],
];
}
/**
* Widgets manager constructor.
*
* Initializing Elementor widgets manager.
*
* @since 1.0.0
* @access public
*/
public function __construct() {
$this->require_files();
add_action( 'elementor/ajax/register_actions', [ $this, 'register_ajax_actions' ] );
}
/**
* Register ajax actions.
*
* Add new actions to handle data after an ajax requests returned.
*
* @since 2.0.0
* @access public
*
* @param Ajax $ajax_manager
*/
public function register_ajax_actions( Ajax $ajax_manager ) {
$ajax_manager->register_ajax_action( 'render_widget', [ $this, 'ajax_render_widget' ] );
$ajax_manager->register_ajax_action( 'editor_get_wp_widget_form', [ $this, 'ajax_get_wp_widget_form' ] );
$ajax_manager->register_ajax_action( 'get_widgets_config', [ $this, 'ajax_get_widget_types_controls_config' ] );
$ajax_manager->register_ajax_action( 'get_widgets_default_value_translations', function ( array $data ) {
return $this->ajax_get_widgets_default_value_translations( $data );
} );
}
/**
* @param $experiment_name
* @param $classes
* @return void
*/
public function register_promoted_active_widgets( string $experiment_name, array $classes ) : void {
if ( ! Plugin::$instance->experiments->is_feature_active( $experiment_name ) || empty( $classes ) ) {
return;
}
foreach ( $classes as $class_name ) {
$this->register( new $class_name() );
}
}
}
Fatal error: Uncaught Error: Class 'Elementor\Widgets_Manager' not found in /var/www/html/padrepio.org.br/web/wp-content/plugins/elementor/includes/plugin.php:718
Stack trace:
#0 /var/www/html/padrepio.org.br/web/wp-content/plugins/elementor/includes/plugin.php(647): Elementor\Plugin->init_components()
#1 /var/www/html/padrepio.org.br/web/wp-includes/class-wp-hook.php(324): Elementor\Plugin->init('')
#2 /var/www/html/padrepio.org.br/web/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
#3 /var/www/html/padrepio.org.br/web/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
#4 /var/www/html/padrepio.org.br/web/wp-settings.php(695): do_action('init')
#5 /var/www/html/padrepio.org.br/web/wp-config.php(95): require_once('/var/www/html/p...')
#6 /var/www/html/padrepio.org.br/web/wp-load.php(50): require_once('/var/www/html/p...')
#7 /var/www/html/padrepio.org.br/web/wp-blog-header.php(13): require_once('/var/www/html/p...')
#8 /var/www/html/padrepio.org.br/web/index.php(17): require('/var/www/html/p... in /var/www/html/padrepio.org.br/web/wp-content/plugins/elementor/includes/plugin.php on line 718