dtbaker / elementor-custom-element Goto Github PK
View Code? Open in Web Editor NEWBasic plugin showing how you can add a custom widget to Elementor
Basic plugin showing how you can add a custom widget to Elementor
Hi David, thank you for taking the time to put together this highly useful plugin, as part of the guide on your website.
On trying to follow along and implement it into my testing site, I discovered that I was unable to get the plugin to work as per your instruction on your blog. I believe there are a couple of issues surrounding this. Please note that I will be submitting a pull request alongside this issue which will address the below items. ๐
On your blog, you state that you can place the my-widget.php
file, within the plugin folder, and that this function as intended. However, with the Github repo, you have the code (lines 40-47, see below) to find the my-widget.php
file, however it is not called by the Elementor\Widget_My_Custom_Elementor_Thing()
class instance. This means that even if the file is within the addon plugin folder, it will not be called into the registration of the widget.
$widget_file = 'plugins/elementor/my-widget.php';
$template_file = locate_template($widget_file);
if ( !$template_file || !is_readable( $template_file ) ) {
$template_file = plugin_dir_path(__FILE__).'my-widget.php';
}
if ( $template_file && is_readable( $template_file ) ) {
require_once $template_file;
}
Since your post, Elementor has updated the method of fetching the values of the controls from the _register_controls()
function. In the current code, this is done by calling values from the instance
array.
$custom_text = ! empty( $instance['some_text'] ) ? $instance['some_text'] : ' (no text was entered ) ';
$post_count = ! empty( $instance['posts_per_page'] ) ?
With the new versions of Elementor, this array will no longer produce the values, even though they can be set in the editor. This is due to a new method within the render function: $settings = $this->get_settings();
.
Since your blog post, Elementor have added support for Font Awesome icons to be used in the Elementor editor sidebar. This allows for a much higher range of choice than the standard WordPress iconset. However, I believe that they have deprieciated the standard iconset used by yourself, meaning that after correcting the above issues, there is not an icon associated with the custom widget in the dashboard.
The above issues were the things I ran into while trying to create my own Elementor widget via your blog post, which took me more time than I would like to admit to figure out. Keep an eye out for the upcoming pull request with the fixes for all of these.
Thanks, have a great day!
Ben
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.