From d189d12f0338fb55f5e8b7af37c213d4c208fadd Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sat, 23 Jan 2010 09:59:59 -0500 Subject: [PATCH] ensure BookmarkWidget::wp_head is not added to actions when widget is not active, with associated test --- index.php | 6 +- test/selenium/TestWidgetInitIsCorrect.html | 65 ++++++++++++++++++++++ widgets/BookmarkWidget.inc | 7 +-- 3 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 test/selenium/TestWidgetInitIsCorrect.html diff --git a/index.php b/index.php index 32449c9..de9cd81 100644 --- a/index.php +++ b/index.php @@ -9,13 +9,13 @@ if (have_posts()) { comicpress_display_post(); } - Restore(); - UnProtect(); + Restore(); + UnProtect(); wp_reset_query(); ?> - diff --git a/test/selenium/TestWidgetInitIsCorrect.html b/test/selenium/TestWidgetInitIsCorrect.html new file mode 100644 index 0000000..35803f1 --- /dev/null +++ b/test/selenium/TestWidgetInitIsCorrect.html @@ -0,0 +1,65 @@ + + + + + + +TestWidgetInitIsCorrect + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
TestWidgetInitIsCorrect
open/wp-admin/
clickAndWaitlink=Post Fixtures
clicklink=themes/comicpress-2.8/test/fixtures/destroy-widgets.inc
clickpf[is_ok]
clickAndWait//input[@value='Load Provided Data']
assertTextPresentNew data set loaded into WordPress.
clickAndWaitsite-visit-button
assertElementNotPresent//script[contains(text(), 'var image_root')]
open/wp-admin/
+ + diff --git a/widgets/BookmarkWidget.inc b/widgets/BookmarkWidget.inc index 5327d6f..9ca4a25 100644 --- a/widgets/BookmarkWidget.inc +++ b/widgets/BookmarkWidget.inc @@ -45,12 +45,11 @@ class ComicPressBookmarkWidget extends WP_Widget { ); } - function init() { - add_action('wp_head', array(&$this, 'wp_head')); - } + function init() {} function is_active() { - add_action('template_redirect', array(&$this, 'template_redirect')); + add_action('wp_head', array(&$this, 'wp_head')); + add_action('template_redirect', array(&$this, 'template_redirect')); } function template_redirect() {