Skip to content

Commit

Permalink
Merge pull request #1339 from publishpress/release-v4.1.4
Browse files Browse the repository at this point in the history
Release v4.1.4
  • Loading branch information
ojopaul authored May 10, 2023
2 parents 6f145c3 + 9e41dce commit 16eb00a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.
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_LOADED')) {
define('PP_AUTHORS_VERSION', '4.1.3');
define('PP_AUTHORS_VERSION', '4.1.4');
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
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: 4.1.3
* Version: 4.1.4
* Text Domain: publishpress-authors
*
* ------------------------------------------------------------------------------
Expand Down
6 changes: 5 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: 7.2.5
Tested up to: 6.1
Stable tag: 4.1.3
Stable tag: 4.1.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= [4.1.4] - 10 May 2023 =

* Update: Add support legacy layout slug in author boxes, #1334

= [4.1.3] - 9 May 2023 =

* Update: Remove support for legacy layouts and twig dependency, #1204
Expand Down
28 changes: 28 additions & 0 deletions src/modules/author-boxes/author-boxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ public function filterAuthorBoxHtml($html, $args)
$author_box_id = false;
if (substr($layoutName, 0, 10) === self::POST_TYPE_BOXES) {
$author_box_id = preg_replace("/[^0-9]/", "", $layoutName );
} elseif(in_array($layoutName, ['simple_list', 'centered', 'boxed', 'inline', 'inline_avatar'])) {
$author_box_id = $this->getLegacyLayoutAuthorBoxId($layoutName);
} else {
//check in theme boxes template
$theme_boxes = self::getThemeAuthorBoxes();
Expand Down Expand Up @@ -696,6 +698,32 @@ public function filterAuthorBoxHtml($html, $args)
return $html;
}

/**
* Get legacy layout author box ID
*/
public function getLegacyLayoutAuthorBoxId($layout)
{

$args = [
'name' => 'author_boxes_' . $layout,
'post_type' => MA_Author_Boxes::POST_TYPE_BOXES,
'post_status' => 'publish',
'posts_per_page' => 1
];
$layout_post = get_posts($args);
if (empty($layout_post)) {
//recreate default
MA_Author_Boxes::createDefaultAuthorBoxes();
$layout_post = get_posts($args);
}

if (!empty($layout_post)) {
return $layout_post[0]->ID;
}

return 0;
}

/**
* Add editor metabox
*
Expand Down

0 comments on commit 16eb00a

Please sign in to comment.