Coder Social home page Coder Social logo

Comments (12)

andrejcremoznik avatar andrejcremoznik commented on July 24, 2024 2

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.

robin-scott avatar robin-scott commented on July 24, 2024 2

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.

bueltge avatar bueltge commented on July 24, 2024 1

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.

justinpicard avatar justinpicard commented on July 24, 2024

@andrejcremoznik any idea how to implement this?

from wordpress-widget-boilerplate.

andrejcremoznik avatar andrejcremoznik commented on July 24, 2024

@justinpicard I don't follow. Working example is in the comment above in case you missed it.

from wordpress-widget-boilerplate.

justinpicard avatar justinpicard commented on July 24, 2024

@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.

justinpicard avatar justinpicard commented on July 24, 2024

Thanks! I figured it out. Now the widget is showing without any errors in the backend :-)

from wordpress-widget-boilerplate.

riyazie avatar riyazie commented on July 24, 2024

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.

bueltge avatar bueltge commented on July 24, 2024

@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.

ciprianimike avatar ciprianimike commented on July 24, 2024

will a version with this fix be released?

from wordpress-widget-boilerplate.

riyazie avatar riyazie commented on July 24, 2024

from wordpress-widget-boilerplate.

bueltge avatar bueltge commented on July 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.