From e7bb9f0766c12c609c5593fef744ccba16e4e2ad Mon Sep 17 00:00:00 2001 From: John Bintz Date: Sun, 24 Jan 2010 20:35:26 -0500 Subject: [PATCH] update --- classes/BookmarkWidget.inc | 37 ++++++++++++++++++++----------------- test/BookmarkWidgetTest.php | 28 +++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 18 deletions(-) diff --git a/classes/BookmarkWidget.inc b/classes/BookmarkWidget.inc index 87e2999..ccb2911 100644 --- a/classes/BookmarkWidget.inc +++ b/classes/BookmarkWidget.inc @@ -44,6 +44,17 @@ class ComicPressBookmarkWidget extends WP_Widget { ) ) ); + + $this->default_instance = array( + 'title' => __('Bookmark This Page', 'comicpress'), + 'mode' => array_shift(array_keys($this->text_fields)) + ); + + foreach (array_values($this->text_fields) as $fields) { + foreach ($fields as $field => $info) { + $this->default_instance[$field] = $info['default']; + } + } } function init() {} @@ -69,17 +80,7 @@ class ComicPressBookmarkWidget extends WP_Widget { // @codeCoverageIgnoreEnd function form($instance) { - $instance = (array)$instance; - - $defaults = array('title' => '', 'mode' => 'three-button'); - - foreach (array_values($this->text_fields) as $field => $info) { - if (isset($info['default'])) { - $defaults[$field] = $info['default']; - } - } - - $instance = array_merge($defaults, $instance); ?> + $instance = array_merge($this->default_instance, (array)$instance); ?>