diff --git a/CHANGELOG.md b/CHANGELOG.md index d3a8b4c..14bd8d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change Log # +## 2.3.2 ## +* Fix: Add a new link in the *Book Review Settings*. + ## 2.3.1 ## * New: Add new `book_review_links_meta` filter for returning links meta used in the *Book Info* meta box. * Fix: Change `book_review_links` filter to return links HTML. diff --git a/admin/class-book-review-admin.php b/admin/class-book-review-admin.php index a7a36d7..911a3b3 100755 --- a/admin/class-book-review-admin.php +++ b/admin/class-book-review-admin.php @@ -671,9 +671,9 @@ public function sanitize_link_status( $status ) { private function save_link( $id, $text, $url, $active ) { global $wpdb; - if ( ( $id !== 0 ) && ( $text !== '' ) ) { - // Insert a new row. - if ( $id === '' ) { + if ( ( $id !== '' ) && ( $text !== '' ) ) { + // Insert a new row. If $id is 0, it means a new link is being added. + if ( $id === 0 ) { $wpdb->insert( $wpdb->book_review_custom_links, array( diff --git a/book-review.php b/book-review.php index 1385cad..f89f276 100755 --- a/book-review.php +++ b/book-review.php @@ -16,7 +16,7 @@ * Plugin Name: Book Review * Plugin URI: http://wpreviewplugins.com/downloads/book-review/ * Description: Add book information such as title, author, publisher and cover photo to enhance your review posts. - * Version: 2.3.1 + * Version: 2.3.2 * Author: Donna Peplinskie * Author URI: http://donnapeplinskie.com/ * Text Domain: book-review diff --git a/includes/class-book-review-activator.php b/includes/class-book-review-activator.php index 24c749b..aa349d5 100755 --- a/includes/class-book-review-activator.php +++ b/includes/class-book-review-activator.php @@ -28,7 +28,7 @@ class Book_Review_Activator { * @access protected * @var string */ - const VERSION = '2.3.1'; + const VERSION = '2.3.2'; /** * Fired when the plugin is activated. diff --git a/includes/class-book-review.php b/includes/class-book-review.php index 5ce7b18..6e5ac16 100755 --- a/includes/class-book-review.php +++ b/includes/class-book-review.php @@ -91,7 +91,7 @@ public static function get_instance() { */ private function __construct() { $this->plugin_name = 'book-review'; - $this->version = '2.3.1'; + $this->version = '2.3.2'; if ( !defined( 'BOOK_REVIEW_PLUGIN_DIR' ) ) { define( 'BOOK_REVIEW_PLUGIN_DIR', plugin_dir_path( dirname( __FILE__ ) ) ); diff --git a/languages/book-review.pot b/languages/book-review.pot index 075af9a..f18fc51 100644 --- a/languages/book-review.pot +++ b/languages/book-review.pot @@ -2,9 +2,9 @@ # This file is distributed under the same license as the Book Review package. msgid "" msgstr "" -"Project-Id-Version: Book Review 2.3.1\n" +"Project-Id-Version: Book Review 2.3.2\n" "Report-Msgid-Bugs-To: http://wordpress.org/support/plugin/book-review\n" -"POT-Creation-Date: 2016-01-01 16:37:03+00:00\n" +"POT-Creation-Date: 2016-01-17 14:59:34+00:00\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" diff --git a/tests/test-book-review-admin.php b/tests/test-book-review-admin.php index e544df8..75b25f5 100644 --- a/tests/test-book-review-admin.php +++ b/tests/test-book-review-admin.php @@ -553,11 +553,19 @@ public function testSaveInvalidLinkId() { $input[1]['id'] = '-1'; $input[1]['text'] = 'Goodreads'; $input[1]['image'] = 'http://url.to.Goodreads.png'; + $input[1]['active'] = '1'; $this->plugin_admin->save_links( $input ); $results = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'book_review_custom_links' ); - $this->assertEquals( 0, count( $results ) ); + $this->assertEquals( 1, count( $results ) ); + + foreach ( $results as $result ) { + $this->assertEquals( 1, $result->custom_link_id, 'Link ID is correct' ); + $this->assertEquals( $input[1]['text'], $result->text, 'Link text is correct' ); + $this->assertEquals( $input[1]['image'], $result->image_url, 'Link Image URL is correct' ); + $this->assertEquals( 1, $result->active, 'Active is correct' ); + } $this->drop_tables(); } @@ -600,6 +608,7 @@ public function testInsertLink() { $this->create_tables(); // Add row. + $input[1]['id'] = ''; $input[1]['text'] = 'Goodreads'; $input[1]['image'] = 'http://url.to.Goodreads.png'; $input[1]['active'] = '1'; @@ -610,6 +619,7 @@ public function testInsertLink() { $this->assertEquals( 1, count( $results ), 'Single row added to book_review_custom_links' ); foreach ( $results as $result ) { + $this->assertEquals( 1, $result->custom_link_id, 'Link ID is correct' ); $this->assertEquals( $input[1]['text'], $result->text, 'Link text is correct' ); $this->assertEquals( $input[1]['image'], $result->image_url, 'Link Image URL is correct' ); $this->assertEquals( $input[1]['active'], $result->active, 'Active is correct' ); @@ -631,6 +641,7 @@ public function testUpdateLink() { $this->create_tables(); // Add row. + $input[1]['id'] = ''; $input[1]['text'] = 'Goodreads'; $input[1]['image'] = 'http://url.to.Goodreads.png'; $input[1]['active'] = '1';