WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#9881 closed defect (bug) (invalid)

Can't toggle the visibilty using jQuery anymore

Reported by: mcosx Owned by: mcosx
Milestone: Priority: normal
Severity: normal Version: 2.8
Component: JavaScript Keywords: reporter-feedback
Focuses: Cc:

Description

I was testing my plugin 'One Word A Day' in WP 2.8 and I cannot toggle the visibility of a div block anymore.

This is the jQuery code ( Line 96: http://svn.wp-plugins.org/one-word-a-day/trunk/classes/class.widget.php ) :

jQuery("#owad_post_settings").toggle("slow");

and this is the div block:

echo '<div id="owad_post_settings" style="';

if( ! $optionsowad_daily_post? )

echo 'display:none;';

echo '">';

some code with ending div tag

I even couldn't save the plugin options. I saw that there is a multiple widget support for plugins so can't I use my old code anymore? What goes wrong?

Attachments (2)

contact-form.zip (7.5 KB) - added by Denis-de-Bernardy 6 years ago.
one-word-a-day.zip (36.9 KB) - added by mcosx 6 years ago.

Download all attachments as: .zip

Change History (16)

comment:1 @Denis-de-Bernardy6 years ago

  • Milestone changed from Unassigned to 2.8

Sounds like you're like me... in for a rewrite of all of your plugins that insert widgets. ;-)

comment:2 follow-up: @azaozz6 years ago

Think there's an error in your selector, jQuery("input[name=owad_daily_post]") should be jQuery("input[name=\'owad_daily_post\']"). Some of this changed in jQuery 1.3.

comment:3 follow-up: @Denis-de-Bernardy6 years ago

@andrew: the other issue is very real, though. If old-style widgets are supposed to work with the new API, the fact of the matter is they do not.

The attached plugin to convince you.

comment:4 in reply to: ↑ 2 @mcosx6 years ago

Replying to azaozz:

Think there's an error in your selector, jQuery("input[name=owad_daily_post]") should be jQuery("input[name=\'owad_daily_post\']"). Some of this changed in jQuery 1.3.

The selector works. If I put "alert();" in the function body the alert window appears. But it appears twice! Using show() instead of toggle() doesn't change anything. I'll check the jQuery 1.3 API for that.

jQuery("input[name=owad_daily_post]").change(function () {

jQuery("#owad_post_settings").toggle("slow");
alert('This message appears so the selector is fine - arg karg');
});

});

The other problem is solved. The submit name changed from save-widgets to savewidget.

comment:5 in reply to: ↑ 3 @azaozz6 years ago

Replying to Denis-de-Bernardy:

The attached plugin to convince you.

It seems that the $control_callback in wp_register_widget_control($id, $name, $control_callback, $options = array()) is not set properly in the attached plugin.

is_callable( $control_callback ) returns false.

comment:6 @Denis-de-Bernardy6 years ago

it would return false when is_admin() returns false, yes, since the class is only around on the widgets.php page. but that shoudn't be an issue, should it?

comment:7 @Denis-de-Bernardy6 years ago

Or then, maybe toss in a do_action("load-widgets.php"); call in admin-ajax.php where needed for backwards compat. I can't possibly be the only one who doesn't stick to loading admin functions when needed.

@mcosx6 years ago

comment:8 @mcosx6 years ago

@ azaozz: This was the first time using trac. Why are you the owner?

@ Whoever is able to: Can anyone split the posts related to Denis-de-Bernardy problem up? My problem is caused by jQuery.

I took a look in the jQuery 1.3 API and toggle() should be valid as I used it.

-> jQuery("#owad_post_settings").toggle("slow");

I've attached my plugin to this thread.

comment:9 @azaozz6 years ago

The plugin throws errors on activation (php4). Tested this with other widgets and all seems to work properly.

comment:10 @azaozz6 years ago

  • Keywords reporter-feedback added; jQuery WordPress plugin removed

comment:11 follow-up: @mcosx6 years ago

  • Keywords reporter-feedback removed
  • Owner changed from azaozz to mcosx
  • Status changed from new to assigned

Please tell me what errors are thrown. PHP5 is available since four or five years :-/

comment:12 @mcosx6 years ago

  • Keywords reporter-feedback added

Sorry for removing the tag. Added again.

comment:13 in reply to: ↑ 11 @azaozz6 years ago

Replying to mcosx:

Please tell me what errors are thrown. PHP5 is available since four or five years :-/

The classes aren't initialized properly. WordPress supports php >= 4.3. If you don't want to support it in your plugin, perhaps do a version check at the beginning and show a warning, etc.

comment:14 @Denis-de-Bernardy6 years ago

  • Milestone 2.8 deleted
  • Resolution set to invalid
  • Status changed from assigned to closed
Note: See TracTickets for help on using tickets.