Skip to content

Commit

Permalink
Merge pull request #273 from publishpress/release-v3.8.1
Browse files Browse the repository at this point in the history
Release v3.8.1
  • Loading branch information
andergmartins authored Nov 5, 2020
2 parents d155631 + 13c6894 commit 3b33a61
Show file tree
Hide file tree
Showing 12 changed files with 808 additions and 483 deletions.
1,021 changes: 663 additions & 358 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.8.0');
define('PP_AUTHORS_VERSION', '3.8.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
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.8.0
* Version: 3.8.1
* Text Domain: publishpress-authors
*
* ------------------------------------------------------------------------------
Expand Down
8 changes: 7 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.5
Stable tag: 3.8.0
Stable tag: 3.8.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -127,6 +127,12 @@ There are two ways to install the PublishPress Authors plugin:
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning v2.0.0](https://semver.org/spec/v2.0.0.html).

= [3.8.1] - 2020-11-05 =

* Fixed: Fixed the consistency of avatar dimensions between the img tag attributes and the CSS, #258;
* Fixed: Fixed edit_posts permission check for the PublishPress calendar, #264;
* Fixed: Restored the post count column in the Authors list, #95;

= [3.8.0] - 2020-10-08 =

* Fixed: Fixed PHP warning about undefined "default_author_for_new_posts" attribute for the module options;
Expand Down
218 changes: 111 additions & 107 deletions src/core/Authors_Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,136 +8,140 @@
*/

namespace MultipleAuthors;

use WP_Widget;

class Authors_Widget extends WP_Widget {
class Authors_Widget extends WP_Widget
{

/**
* Sets up the widgets name etc
*/
* Sets up the widgets name etc
*/
public function __construct()
{
$this->title = esc_html__( 'Authors List', 'publishpress-authors' );
Parent::__construct(
'multiple_authors_list_widget',
$this->title,
array(
'classname' => 'multiple_authors_authors-list_widget',
'description' => esc_html__(
'Display authors list.',
'publishpress-authors'
),
)
);
$this->title = esc_html__('Authors List', 'publishpress-authors');
Parent::__construct(
'multiple_authors_list_widget',
$this->title,
array(
'classname' => 'multiple_authors_authors-list_widget',
'description' => esc_html__(
'Display authors list.',
'publishpress-authors'
),
)
);
}

/**
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget( $args, $instance )
{

$instance = wp_parse_args(
(array) $instance,
array(
'title' => $this->title,
)
);

/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
$output = '';


$output .= $this->get_author_box_markup( $args, $instance );
if ( ! empty( $output ) ) {
* Outputs the content of the widget
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
$instance = wp_parse_args(
(array)$instance,
array(
'title' => $this->title,
)
);

/** This filter is documented in core/src/wp-includes/default-widgets.php */
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
$output = '';


$output .= $this->get_author_box_markup($args, $instance);
if (!empty($output)) {
echo $args['before_widget'];
echo $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title'];
echo $args['before_title'] . apply_filters('widget_title', $title) . $args['after_title'];
echo $output;
echo $args['after_widget'];
}
}

/**
* Outputs the options form on admin
*
* @param array $instance The widget options
*/
public function form( $instance )
{
$legacyPlugin = Factory::getLegacyPlugin();

$instance = wp_parse_args(
(array) $instance,
array(
'title' => $this->title,
/**
* Outputs the options form on admin
*
* @param array $instance The widget options
*/
public function form($instance)
{
$legacyPlugin = Factory::getLegacyPlugin();

$instance = wp_parse_args(
(array)$instance,
array(
'title' => $this->title,
'layout' => $legacyPlugin->modules->multiple_authors->options->layout,
'show_empty' => true
)
);

$title = strip_tags( $instance['title'] );
$layout = strip_tags( $instance['layout'] );
$showEmpty = isset( $instance['show_empty'] ) ? (bool) $instance['show_empty'] : false;
$context = array(
'labels' => array(
'title' => esc_html__( 'Title', 'publishpress-authors' ),
'layout' => esc_html__( 'Layout', 'publishpress-authors' ),
'show_empty' => esc_html__( 'Display All Authors (including those who have not written any posts)', 'publishpress-authors' )
),
'ids' => array(
'title' => $this->get_field_id( 'title' ),
'layout' => $this->get_field_id( 'layout' ),
'show_empty' => $this->get_field_id( 'show_empty' )
),
'names' => array(
'title' => $this->get_field_name( 'title' ),
'layout' => $this->get_field_name( 'layout' ),
'show_empty' => $this->get_field_name( 'show_empty' )
),
'values' => array(
'title' => $title,
)
);

$title = strip_tags($instance['title']);
$layout = strip_tags($instance['layout']);
$showEmpty = isset($instance['show_empty']) ? (bool)$instance['show_empty'] : false;
$context = array(
'labels' => array(
'title' => esc_html__('Title', 'publishpress-authors'),
'layout' => esc_html__('Layout', 'publishpress-authors'),
'show_empty' => esc_html__(
'Display All Authors (including those who have not written any posts)',
'publishpress-authors'
)
),
'ids' => array(
'title' => $this->get_field_id('title'),
'layout' => $this->get_field_id('layout'),
'show_empty' => $this->get_field_id('show_empty')
),
'names' => array(
'title' => $this->get_field_name('title'),
'layout' => $this->get_field_name('layout'),
'show_empty' => $this->get_field_name('show_empty')
),
'values' => array(
'title' => $title,
'layout' => $layout,
'show_empty' => $showEmpty
),
'layouts' => apply_filters( 'pp_multiple_authors_author_layouts', array() ),
);

$container = Factory::get_container();

echo $container['twig']->render( 'authors-list-widget-form.twig', $context );
}

/**
* Processing widget options on save
*
* @param array $new_instance The new options
* @param array $old_instance The previous options
*/
public function update( $new_instance, $old_instance )
{
$instance = array();

$instance['title'] = sanitize_text_field( $new_instance['title'] );
$instance['layout'] = sanitize_text_field( $new_instance['layout'] );
$instance['show_empty'] = isset( $new_instance['show_empty'] ) ? (bool) $new_instance['show_empty'] : false;
$layouts = apply_filters( 'pp_multiple_authors_author_layouts', array() );

if ( ! array_key_exists( $instance['layout'], $layouts ) ) {
$instance['layout'] = 'simple_list';
}

return $instance;
),
'layouts' => apply_filters('pp_multiple_authors_author_layouts', array()),
);

$container = Factory::get_container();

echo $container['twig']->render('authors-list-widget-form.twig', $context);
}

/**
* Processing widget options on save
*
* @param array $new_instance The new options
* @param array $old_instance The previous options
*/
public function update($new_instance, $old_instance)
{
$instance = array();

$instance['title'] = sanitize_text_field($new_instance['title']);
$instance['layout'] = sanitize_text_field($new_instance['layout']);
$instance['show_empty'] = isset($new_instance['show_empty']) ? (bool)$new_instance['show_empty'] : false;
$layouts = apply_filters('pp_multiple_authors_author_layouts', array());

if (!array_key_exists($instance['layout'], $layouts)) {
$instance['layout'] = 'simple_list';
}

return $instance;
}


/**
* Get HTML markdown
*
* @param array $args The args.
* @param array $args The args.
* @param array $instance The object instance.
*
* @return string $html The html.
Expand Down Expand Up @@ -184,7 +188,7 @@ private function get_author_box_markup(
$show_site = isset($legacyPlugin->modules->multiple_authors->options->show_site_link)
? 'yes' === $legacyPlugin->modules->multiple_authors->options->show_site_link : true;

$showEmpty = isset( $instance['show_empty'] ) ? $instance['show_empty'] : false;
$showEmpty = isset($instance['show_empty']) ? $instance['show_empty'] : false;

$args = [
'show_title' => false,
Expand Down Expand Up @@ -216,4 +220,4 @@ private function get_author_box_markup(
return $html;
}

}
}
16 changes: 11 additions & 5 deletions src/core/Classes/Author_Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public static function filter_manage_edit_author_columns($columns)
unset($columns['description']);
}

// Remove the posts count to replace with a correct number
if (isset($columns['posts'])) {
unset($columns['posts']);
}

// Add our own columns too.
$new_columns = [];
foreach ($columns as $key => $title) {
Expand All @@ -51,6 +46,10 @@ public static function filter_manage_edit_author_columns($columns)
}
}

if (isset($new_columns['posts'])) {
$new_columns['posts'] = __('Published Posts', 'publishpress-authors');
}

return $new_columns;
}

Expand Down Expand Up @@ -529,6 +528,10 @@ public static function filter_author_bulk_actions($bulk_actions)
'Convert into guest author',
'publishpress-authors'
);
$bulk_actions['update_post_count'] = __(
'Update post count',
'publishpress-authors'
);

return $bulk_actions;
}
Expand All @@ -547,6 +550,7 @@ public static function handle_author_bulk_actions($redirect_to, $do_action, $ter
$bulkActions = [
'update_mapped_author_data',
'convert_into_guest_author',
'update_post_count',
];

if (empty($terms_ids) || !in_array($do_action, $bulkActions, true)) {
Expand All @@ -566,6 +570,8 @@ public static function handle_author_bulk_actions($redirect_to, $do_action, $ter
Author::update_author_from_user($term_id, $author->user_id);
} elseif ($do_action === 'convert_into_guest_author') {
Author::convert_into_guest_author($term_id);
} elseif ($do_action === 'update_post_count') {
wp_update_term_count($term_id, 'author');
}

$updated++;
Expand Down
6 changes: 5 additions & 1 deletion src/functions/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ function get_multiple_authors($post = 0, $filter_the_author = true, $archive = f
if (is_object($post)) {
$post = $post->ID;
} elseif (empty($post)) {
$post = get_post()->ID;
$post = get_post();

if (is_object($post) && !is_wp_error($post)) {
$post = $post->ID;
}
}

$postId = (int)$post;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/multiple-authors/multiple-authors.php
Original file line number Diff line number Diff line change
Expand Up @@ -2191,8 +2191,8 @@ public function publishpressAuthorCanEditPosts($canEdit, $authorId)
$user = $author->get_user_object();
$canEdit = $user->has_cap('edit_posts');
} else {
$author = Author::get_by_term_id($authorId);
$canEdit = $author->is_guest();
$author = Author::get_by_term_id($authorId * -1);
$canEdit = $author->is_guest() ? true : $author->get_user_object()->has_cap('edit_posts');
}
} catch (Exception $e) {
}
Expand Down
4 changes: 2 additions & 2 deletions src/twig/author_layout/boxed.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{% for author in authors %}
<li class="author_index_{{ loop.index }}">
{% if author.get_avatar %}
{{ author.get_avatar(160)|raw }}
{{ author.get_avatar(80)|raw }}
{% else %}
{{ get_avatar(author.user_email, 160)|raw }}
{{ get_avatar(author.user_email, 80)|raw }}
{% endif %}
<a href="{{ author.link }}" class="{{ item_class }}" rel="author">{{ author.display_name }}</a>
<p class="multiple-authors-description">{{ author.description|raw }}</p>
Expand Down
4 changes: 2 additions & 2 deletions src/twig/author_layout/centered.twig
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
{% for author in authors %}
<li class="author_index_{{ loop.index }}">
{% if author.get_avatar %}
{{ author.get_avatar(160)|raw }}
{{ author.get_avatar(80)|raw }}
{% else %}
{{ get_avatar(author.user_email, 160)|raw }}
{{ get_avatar(author.user_email, 80)|raw }}
{% endif %}
<p>
<a href="{{ author.link }}" class="{{ item_class }}" rel="author">{{ author.display_name }}</a>
Expand Down
Loading

0 comments on commit 3b33a61

Please sign in to comment.