[wp-hackers] how to do a single-instance widget with the new API

Otto otto at ottodestruct.com
Wed Mar 17 17:56:43 UTC 2010


Oops. Forgot. You can reference your number with $this->number.

-Otto



On Wed, Mar 17, 2010 at 12:55 PM, Otto <otto at ottodestruct.com> wrote:
> Firstly, yeah, that's the wrong way to do AJAX. Like he said.
>
> Secondly, single instance widgets are the tool of the devil. Don't do
> it. Make it work multiply.
>
> Third: If you're inheriting from WP_Widget, then you have a $number.
> That $number is something you'll find useful for looking in that
> array.
>
> -Otto
>
>
>
> 2010/3/17 Raphaël Droz <raphael.droz at gmail.com>:
>> Hi,
>> I've just done my first widget using the new API.
>> The abundance of documentation helped a lot anyway I'm now blocked by
>> what, at a first look, didn't seem a huge issue but ...
>>
>> This widget uses jquery to request the server asynchronously.
>> On the server side, in my widget/plugin directory I have an action.php
>> which :
>> define('DOING_AJAX', true);
>> include('../../../wp-config.php');
>> include(WP_CONTENT_DIR . '/../wp-admin/includes/admin.php');
>> # then sends the answer.
>>
>> The problem is that get_option('widget_wpsympa'); returns nested arrays
>> of the (possibly) several instances of the widget while it's aimed to be
>> unique.
>>
>> Should I forget about the new widget API ?
>> Should I wait for a WP 3 new option in $widget_ops ?
>> Or is there a way to obtain the specific instance calling in action.php ?
>>
>> Thank you for your answers.
>>
>> Raph
>> _______________________________________________
>> wp-hackers mailing list
>> wp-hackers at lists.automattic.com
>> http://lists.automattic.com/mailman/listinfo/wp-hackers
>>
>


More information about the wp-hackers mailing list