WordPress.org

Ready to get started?Download WordPress

Forums

Updating old widgets to the newer API (3 posts)

  1. Thought Police Interactive Studios
    Member
    Posted 2 years ago #

    There are a few plugins I use, as well as old projects, that used the old widget API calling on
    register_sidebar_widget('NAME', array('ID', 'widget'))
    and
    register_widget_control('NAME', array('ID', 'control'))

    I would like to convert them over to the newer widget API to allow their use across multiple widget areas. My various attempts in trying to follow the documentation and examples of newer code have resulted in just no widget showing up or a white screen of death. Does anyone have any pointers? Any links to good tutorials or examples of upgrading the code?

    I'm happy to repay the help by contributing back to the community. If I get it down, I'll bring some of the otherwise functional old plugins up to the new widget API and HTML validation (insufficient image tags are common in old plugins).

  2. Greg McMullen
    Member
    Posted 1 year ago #

    Any development on this? I'm also looking to do some work here.

  3. Greg McMullen
    Member
    Posted 1 year ago #

    I think I figured some of it out already.

    I was looking for a "Recent Photos" using the media library and it was 2 years out of date. I'll post some snippets to hopefully help you (and others) out.

    Replace
    function rp_widget_Admin(){ //Form Code }

    With
    function form($instance) { //Form code }

    Any variables, make sure they are placed in the $instance[''] array and called correctly. What I was using had global $settings = get_option("widget_option");

    I just replaced any $settings tag with instance['VarName'].

    Hope this will help to an extent feel free to contact me if you have some questions.

Topic Closed

This topic has been closed to new replies.

About this Topic