Comments (12)
So the nested register_widget
needs to call the correct class definition. I changed that to Widget_Name
to match the boilerplate code.
As for your syntax error, you really should be able to figure it out yourself. There's nothing wrong with my boilerplate code above. Maybe you're misplacing it.
from wordpress-widget-boilerplate.
Just to clarify the above, as I had someone link here asking what's up, the above will work, with the addition of function
:
function sth_register_widgets() { register_widget( 'Widget_Name' ); } add_action( 'widgets_init', 'sth_register_widgets' );
from wordpress-widget-boilerplate.
However you can also use anonymous function. Often so much easier, shorter and do need any function there need namespace, memory space.
like this example:
add_action(
'widgets_init',
function () {
return register_widget( 'Widget_Name' );
},
10
);
from wordpress-widget-boilerplate.
@andrejcremoznik any idea how to implement this?
from wordpress-widget-boilerplate.
@justinpicard I don't follow. Working example is in the comment above in case you missed it.
from wordpress-widget-boilerplate.
@andrejcremoznik If i replace the deprecated line with your piece of code I get:
Parse error: syntax error, unexpected ';' in [local path to my widget file] on line 260
from wordpress-widget-boilerplate.
Thanks! I figured it out. Now the widget is showing without any errors in the backend :-)
from wordpress-widget-boilerplate.
public static function registerWidget($widgetName){
add_action('widgets_init', create_function('', 'return register_widget("'.$widgetName.'");'));
}
Deprecated: Function create_function() is deprecated in C:\wamp64\www\pro\wp-content\plugins\revslider\includes\framework\functions-wordpress.class.php
from wordpress-widget-boilerplate.
@riyazie yes, this is the topic of the issue and you fund more as one solutions for this problem, maybe my solid short one above. #38 (comment)
from wordpress-widget-boilerplate.
will a version with this fix be released?
from wordpress-widget-boilerplate.
from wordpress-widget-boilerplate.
Please see the branch develop, there have a solution for this topic.
https://github.com/tommcfarlin/WordPress-Widget-Boilerplate/tree/develop
from wordpress-widget-boilerplate.
Related Issues (14)
- Localization incomplete HOT 1
- wrong file names for widget style/script register HOT 1
- Color Picker Disappears on widget save HOT 1
- Improve stylesheet imports
- Error 500 on windows servers
- _multiwidget set to 1 HOT 3
- Minor comment fixes HOT 1
- Style and Script only on the widget page HOT 3
- Undefined index HOT 9
- ID class variable? HOT 1
- Load Scripts and Styles only on pages that use the widget HOT 3
- use of WP_PLUGIN_URL breaks secure sites HOT 2
- Load File Helper Not Working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wordpress-widget-boilerplate.