Skip to content

Commit

Permalink
Merge pull request #636 from publishpress/feature/release-v3.16.1
Browse files Browse the repository at this point in the history
Feature/release v3.16.1
  • Loading branch information
ojopaul authored Apr 13, 2022
2 parents af0db0d + fdb577e commit 6e94c71
Show file tree
Hide file tree
Showing 10 changed files with 299 additions and 166 deletions.
333 changes: 196 additions & 137 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion defines.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
defined('ABSPATH') or die('No direct script access allowed.');

if (!defined('PP_AUTHORS_VERSION')) {
define('PP_AUTHORS_VERSION', '3.16.0');
define('PP_AUTHORS_VERSION', '3.16.1');
define('PP_AUTHORS_FILE', 'publishpress-authors/publishpress-authors.php');
define('PP_AUTHORS_BASE_PATH', plugin_dir_path(__DIR__ . '/publishpress-authors.php'));
define('PP_AUTHORS_MODULES_PATH', PP_AUTHORS_BASE_PATH . 'src/modules/');
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion publishpress-authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: PublishPress Authors allows you to add multiple authors and guest authors to WordPress posts
* Author: PublishPress
* Author URI: https://publishpress.com
* Version: 3.16.0
* Version: 3.16.1
* Text Domain: publishpress-authors
*
* ------------------------------------------------------------------------------
Expand Down
10 changes: 9 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Tags: multiple authors, authors, guest authors, author fields, author layouts
Requires at least: 4.7
Requires PHP: 5.6
Tested up to: 5.9
Stable tag: 3.16.0
Stable tag: 3.16.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -224,6 +224,14 @@ There are two ways to install the PublishPress Authors plugin:

== Changelog ==

= [3.16.1] - 13 Apr 2022 =

* Fixed: Fix author mapped to user error when adding new author, #626;
* Fixed: Fix test for checking the author link in the frontend;
* Fixed: Fix Undefined array key "tag-name" when bulk delete all authors, #628;
* Fixed: Fix Fatal error when "Create missed post authors" button is clicked, #623;
* Fixed: Fix author profile allowing to add html tags in the bio text, #619;

= [3.16.0] - 23 Mar 2022 =

* Added: Add option to authors update their own profile, #24;
Expand Down
17 changes: 8 additions & 9 deletions src/core/Classes/Author_Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ public static function get_fields($author)
'description' => [
'label' => esc_html__('Biographical Info', 'publishpress-authors'),
'type' => 'textarea',
'sanitize' => 'sanitize_textarea_field',
'sanitize' => 'wp_kses_post',
'tab' => 'general',
],
];
Expand Down Expand Up @@ -555,7 +555,7 @@ public static function action_edited_author($term_id)
update_term_meta($term_id, $key, $sanitize($_POST['authors-' . $key])); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
}

// If there is a mapper user, make sure the author url (slug) is the same of the user.
// If there is a mapped user, make sure the author url (slug) is the same of the user.
if (isset($_POST['authors-user_id']) && !empty($_POST['authors-user_id'])) {
$user_id = (int)$_POST['authors-user_id'];

Expand Down Expand Up @@ -785,15 +785,16 @@ public static function admin_notices()
*/
public static function filter_pre_insert_term($term, $taxonomy)
{
if ($taxonomy === 'author') {
if ($taxonomy === 'author' && !empty($_POST)) {
/**
* Check if term with this user exist
*/
if (
isset($_POST['authors-new'])
&& $author_id = (int)$_POST['authors-new'] > 0
&& (int)$_POST['authors-new'] > 0
) {
$author = Author::get_by_user_id($author_id);
$author_id = (int)$_POST['authors-new'];
$author = Author::get_by_user_id($author_id);

if (
$author
Expand Down Expand Up @@ -821,13 +822,11 @@ public static function filter_pre_insert_term($term, $taxonomy)
}

$author_slug_user = get_user_by('slug', $slug);
if (
$author_slug_user
if ($author_slug_user
&& is_object($author_slug_user)
&& isset($author_slug_user->ID)
) {
if (
(! isset($_POST['authors-new']))
if ((! isset($_POST['authors-new']))
|| ((int)$author_slug_user->ID != (int)$_POST['authors-new'])
) {
return new WP_Error(
Expand Down
2 changes: 1 addition & 1 deletion src/modules/multiple-authors/multiple-authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ public function handle_maintenance_task()
do_action('multiple_authors_' . $action);

wp_redirect(
admin_ur1l('/admin.php?page=ppma-modules-settings&author_term_reset_notice=success'),
admin_url('/admin.php?page=ppma-modules-settings&author_term_reset_notice=success'),
301
);
exit;
Expand Down
49 changes: 49 additions & 0 deletions tests/codeception/_support/Steps/Authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,53 @@ public function iViewAuthorPageForAuthor($authorSlug)

$this->amOnPage($author->link);
}

/**
* @Given I create a new author :authorSlug
*/
public function iCreateNewAuthor($authorSlug)
{
$authorSlug = sq($authorSlug);

Author::create(
[
'slug' => $authorSlug,
'display_name' => $authorSlug
]
);
}

/**
* @Given I edit author :authorSlug setting biographical info :bioText
*/
public function iEditAuthorSettingBioInfo($authorSlug, $bioText)
{
$authorSlug = sq($authorSlug);

$author = Author::get_by_term_slug($authorSlug);

$this->amOnAdminPage('term.php?taxonomy=author&tag_ID=' . $author->term_id);
$this->fillField('.term-authors-description-wrap textarea', $bioText);
$this->click('Update');
}

/**
* @When I view the author profile :authorSlug
*/
public function iViewAuthorProfile($authorSlug)
{
$authorSlug = sq($authorSlug);

$author = Author::get_by_term_slug($authorSlug);

$this->amOnAdminPage('term.php?taxonomy=author&tag_ID=' . $author->term_id);
}

/**
* @Then I see :bioText in the biographical info field
*/
public function iSeeBioText($bioText)
{
$this->seeInField('.term-authors-description-wrap textarea', $bioText);
}
}
8 changes: 6 additions & 2 deletions tests/codeception/_support/Steps/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ public function iSeeAuthorNameInTheByline($authorName)
*/
public function iSeeTheLinkForAuthorInTheByline($authorSlug)
{
$author = Author::get_by_term_slug(sq($authorSlug));
$expected = sprintf(
'%s/author/%s/',
$_ENV['TEST_SITE_WP_URL'],
sq($authorSlug)
);

$authorLink = $this->grabAttributeFrom('.post-meta .post-author a', 'href');

$this->assertEquals($author->link, $authorLink);
$this->assertEquals($expected, $authorLink);
}

/**
Expand Down
14 changes: 14 additions & 0 deletions tests/codeception/acceptance/Features/Admin/author-profile.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Add and edit author profiles
In order to manage authors
As an admin
I need to be able to add or edit the author profile

Background:
Given the user "admin_user" exists with role "administrator"
And I am logged in as "admin_user"

Scenario: Valid HTML tags are not stripped from author's profile after saving
Given I create a new author "author_1"
And I edit author "author_1" setting biographical info "An <b>awesome<b> writer"
When I view the author profile "author_1"
Then I see "An <b>awesome<b> writer" in the biographical info field

0 comments on commit 6e94c71

Please sign in to comment.