Skip to content

Commit

Permalink
Merge pull request #16 from donnapep/chore/release-2.3.2
Browse files Browse the repository at this point in the history
Fix adding a new link in the Book Review Settings
  • Loading branch information
Donna Peplinskie committed Jan 17, 2016
2 parents 85fe066 + 88068fc commit d995dff
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 3 additions & 3 deletions admin/class-book-review-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion book-review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion includes/class-book-review-activator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion includes/class-book-review.php
Original file line number Diff line number Diff line change
Expand Up @@ -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__ ) ) );
Expand Down
4 changes: 2 additions & 2 deletions languages/book-review.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
13 changes: 12 additions & 1 deletion tests/test-book-review-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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';
Expand All @@ -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' );
Expand All @@ -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';
Expand Down

0 comments on commit d995dff

Please sign in to comment.