Posts in Sidebar 4.7.0 released

After more than 80 commits, many hours of work and a lot of love, Posts in Sidebar 4.7.0 has landed in the WordPress repository! I hope you find useful the new additions and the rest of what has been done. Let’s see what’s new dissecting the changelog.

From the changelog

## 4.7.0
### Added
* Added new option to filter posts in the same category/tag/author/custom-field by searching for the title of the main post.
* Added "Post type", "Relevance (when searching)", and "Preserve post parent order" in "Order posts by" option.
* Added new options when changing the query in single posts or in an archive page. ### Changed
* Now custom post types are supported when changing query in single posts.
* Reorganized some sub-panels and added colors in panel titles.
* Checked all files with WordPress Coding Standard for PHPCS. ### Removed
* Removed old comment for HTML in widget introduction.
### Fixed
* Fixed displaying the query in debug section when the query contains multidimensional arrays.
### Security
* Hardened security.

Added new option to filter posts in the same category/tag/author/custom-field by searching for the title of the main post

Coming from a request in the forum, this option lets you to get posts that:

  • have been published under the same category or tag of the main post or by the same author or that have the same custom field;
  • have a certain relation with the title of the main post.

In other words, while we are reading a post, the sidebar can show the reader a list of posts that are related to the main post because, for example, have the same category and contains something that has to do with the title of the main post.

According to the author of the thread in the forum, this should have a positive impact on the SEO.

Added “Post type”, “Relevance (when searching)”, and “Preserve post parent order” in “Order posts by” option

The new options for sorting the retrieved posts.

In “Getting posts” > “Order posts by” drop-down menu I added new options to sort the retrieved posts. These options are the same as in the WP_Query class:

  • Post type: order by post type;
  • Relevance: when displaying posts based on a search, the posts can be ordered on relevance, like WordPress itself does when you search for something on your site.
  • Preserve post parent order: in conjunction with the option “Getting posts” > “Get posts whose parent is in these IDs”, this option maintains the order in which the IDs were entered.

Added new options when changing the query in single posts or in an archive page

The sections “Change the query when on single posts” and “Change the query when on archive page” have been updated with new options. Now you can sort the posts based on some criteria, almost the same as in the previous paragraph.

Now custom post types are supported when changing the query in single posts

The section Change the query when on single posts supports custom post types now. The only required condition is that the custom post type — displayed in the sidebar — have the same category/tag/author/custom-field of the main post. For this reason, if the user wants to display posts that are under the same category, the custom post type must support the category as taxonomy.

Reorganized some sub-panels and added colors in panel titles

The new colors.

Finally, I made it! The panel of this widget is so full of subpanels that I decided to add some colors to distinguish better the various levels.

Also, I increased the thickness of the border of every panel, so to immediately see where every panel ends.

I chose this hierarchy of colors:

First level

Second level

Third level

I hope you like this visual change.

Checked all files with WordPress Coding Standard for PHPCS

WordPress has a detailed manual for developers, where (almost?) every aspect of writing code is covered. The WordPress Coding Standards are here to help developers to write a more human-readable code. Since humans are not perfect, this set of rules has been made available for PHP Code Sniffer, which checks for code smells on the fly, very handy, especially using a plugin for Atom editor. In the code, there were a lot of unconformities, that have been resolved.

Removed old comment for HTML in widget introduction

As you know, starting with version 4.6.0, the widget introduction accepts more HTML tags. I forgot to remove the old comment from the text field before pushing the final release, but now it has been removed. Sorry about this!

Fixed displaying the query in debug section when the query contains multidimensional arrays

If the query contained a complex query, such as “Custom taxonomy query”, or “Date query”, etc., the debug section (if activated) displayed a string like this:

date_query: Array

The bug has been fixed and now it could display something complex like this:

date_query:
year: 2017
year: 2018
month: 03
day: 01
inclusive: 1
column: post_date

or like this:

meta_query:
relation: AND
key: color
value: red
compare: LIKE
key: size
value: small
compare: NOT LIKE
key: size
value: medium
compare: NOT LIKE

or even more complex queries. The indentation should help you in case you need to investigate.

Hardened security

Security is at the top of every serious developer. WordPress gives them all sort of functions to make sure that every line of code is safe. For this reason, I checked extensively the plugin searching for every possible weakness. The PHPCS and the set of rules of WPCS gave me a huge help on this.


Should you encounter a bug or see that something changed its behavior, please let me know either in GitHub or in the forum.

Enjoy! :)

Posted by aldolat

A WordPress fanatic.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.