From a525caddeac334bfecb494f0d6b170615e8f967c Mon Sep 17 00:00:00 2001 From: Pau Argelaguet Date: Fri, 17 Dec 2021 07:39:04 +0100 Subject: [PATCH] Release 3.0.1 (#548) * Fix metadata on password protected posts (#547) * Fix post trackable status * Fix linting * Adding filter to disable behavior * Update tests/Integration/OtherTest.php Co-authored-by: Jeff Bowen Co-authored-by: Jeff Bowen * Bumping version number * Updating README Co-authored-by: Jeff Bowen --- CHANGELOG.md | 9 ++++++++- README.md | 2 +- src/class-parsely.php | 20 ++++++++++++++++-- tests/Integration/OtherTest.php | 36 +++++++++++++++++++++++++++++++++ wp-parsely.php | 4 ++-- 5 files changed, 65 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e31fc1e4..002539133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.0.1] - 2021-12-17 + +### Fixed + +- Fix metadata on password protected posts [#547](https://github.com/Parsely/wp-parsely/pull/547) + ## [3.0.0] - 2021-12-15 ## Important information about this release @@ -421,8 +427,9 @@ If you are using the plugin without any code-level customizations (for instance, ## [v1.0] - 2012-07-15 - Initial version. -- Add sSupport for parsely-page and JavaScript on home page and published pages and posts as well as archive pages (date/author/category/tag). +- Add support for parsely-page and JavaScript on home page and published pages and posts as well as archive pages (date/author/category/tag). +[3.0.1]: https://github.com/Parsely/wp-parsely/compare/3.0.0...3.0.1 [3.0.0]: https://github.com/Parsely/wp-parsely/compare/2.6.1...3.0.0 [2.6.1]: https://github.com/Parsely/wp-parsely/compare/2.6.0...2.6.1 [2.6.0]: https://github.com/Parsely/wp-parsely/compare/2.5.2...2.6.0 diff --git a/README.md b/README.md index 1c59b11d9..bc87de43c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Parse.ly -Stable tag: 3.0.0 +Stable tag: 3.0.1 Requires at least: 5.0 Tested up to: 5.8 Requires PHP: 7.1 diff --git a/src/class-parsely.php b/src/class-parsely.php index 1f631d17a..06557cc82 100644 --- a/src/class-parsely.php +++ b/src/class-parsely.php @@ -277,6 +277,22 @@ public static function post_has_trackable_status( $post ): bool { return $cache[ $post_id ]; } + /** + * Filters whether the post password check should be skipped when getting the post trackable status. + * + * @since 3.0.1 + * + * @param bool $skip True if the password check should be skipped. + * @param int|WP_Post $post Which post object or ID is being checked. + * + * @returns bool + */ + $skip_password_check = apply_filters( 'wp_parsely_skip_post_password_check', false, $post ); + if ( ! $skip_password_check && post_password_required( $post ) ) { + $cache[ $post_id ] = false; + return false; + } + /** * Filters the statuses that are permitted to be tracked. * @@ -442,11 +458,11 @@ public function construct_parsely_metadata( array $parsely_options, WP_Post $pos $parsely_page['articleSection'] = $category; $author_objects = array(); foreach ( $authors as $author ) { - $author_tag = array( + $author_tag = array( '@type' => 'Person', 'name' => $author, ); - array_push( $author_objects, $author_tag ); + $author_objects[] = $author_tag; } $parsely_page['author'] = $author_objects; $parsely_page['creator'] = $authors; diff --git a/tests/Integration/OtherTest.php b/tests/Integration/OtherTest.php index e70273a7b..cfdab41b3 100644 --- a/tests/Integration/OtherTest.php +++ b/tests/Integration/OtherTest.php @@ -211,4 +211,40 @@ public function test_corrupted_options(): void { $options = self::$parsely->get_options(); self::assertSame( self::EMPTY_DEFAULT_OPTIONS, $options ); } + + /** + * Test if post is trackable when it is password protected. + * + * @since 3.0.1 + * + * @covers \Parsely\Parsely::post_has_trackable_status + */ + public function test_post_has_trackable_status_password_protected(): void { + $post_id = $this->factory->post->create(); + $post = get_post( $post_id ); + + $post->post_password = 'somepassword'; + + $result = Parsely::post_has_trackable_status( $post ); + self::assertFalse( $result ); + } + + /** + * Test if post is trackable when it is password protected and a filter disables it. + * + * @since 3.0.1 + * + * @covers \Parsely\Parsely::post_has_trackable_status + */ + public function test_post_has_trackable_status_password_protected_with_filter(): void { + add_filter( 'wp_parsely_skip_post_password_check', '__return_true' ); + + $post_id = $this->factory->post->create(); + $post = get_post( $post_id ); + + $post->post_password = 'somepassword'; + + $result = Parsely::post_has_trackable_status( $post ); + self::assertTrue( $result ); + } } diff --git a/wp-parsely.php b/wp-parsely.php index 566c165b7..2abc569ea 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -11,7 +11,7 @@ * Plugin Name: Parse.ly * Plugin URI: https://www.parse.ly/help/integration/wordpress * Description: This plugin makes it a snap to add Parse.ly tracking code to your WordPress blog. - * Version: 3.0.0 + * Version: 3.0.1 * Author: Parse.ly * Author URI: https://www.parse.ly * Text Domain: wp-parsely @@ -39,7 +39,7 @@ return; } -const PARSELY_VERSION = '3.0.0'; +const PARSELY_VERSION = '3.0.1'; const PARSELY_FILE = __FILE__; require __DIR__ . '/src/class-parsely.php';