From 8b0772850a640a631945a2b7f7fee4b5f7cc917c Mon Sep 17 00:00:00 2001 From: Abhijit Babasaheb Nage Date: Wed, 24 Mar 2021 19:05:58 +0530 Subject: [PATCH 1/2] Added filter to remove wpseo robot conflict --- README.md | 4 +++- class-unlist-posts.php | 1 + package.json | 2 +- readme.txt | 4 +++- unlist-posts.php | 4 ++-- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index aad4308..ba1b1cb 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** post, unlist posts, hide posts, **Requires at least:** 4.4 **Tested up to:** 5.7 -**Stable tag:** 1.1.4 +**Stable tag:** 1.1.5 **License:** GPLv2 or later **License URI:** http://www.gnu.org/licenses/gpl-2.0.html @@ -36,6 +36,8 @@ Need help with something? Have an issue to report? [Get in touch](https://github Just select option "Unlist Post" in any post of any type and that post will be hidden from the whole site, it can be only accessed if you have the direct link to the post. ## Changelog ## +### 1.1.5 ### +- Fix: Robots tags conflicting with Yoast SEO. ### 1.1.4 ### - Fix: Due to a bug unlisted posts were visible in the search results, which we have fixed now. diff --git a/class-unlist-posts.php b/class-unlist-posts.php index 0d0f80c..d8965a6 100644 --- a/class-unlist-posts.php +++ b/class-unlist-posts.php @@ -175,6 +175,7 @@ public function no_robots_for_unlisted_posts( $robots ) { $hidden_posts = get_option( 'unlist_posts', array() ); if ( in_array( get_the_ID(), $hidden_posts, true ) && false !== get_the_ID() ) { + add_filter( 'wpseo_robots_array', '__return_empty_array' ); return wp_robots_no_robots( $robots ); } return $robots; diff --git a/package.json b/package.json index 79dcceb..6ae6562 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hide-post", - "version": "1.1.4", + "version": "1.1.5", "main": "Gruntfile.js", "author": "Nikhil Chavan", "devDependencies": { diff --git a/readme.txt b/readme.txt index edb6d32..29af232 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.paypal.me/BrainstormForce Tags: post, unlist posts, hide posts, Requires at least: 4.4 Tested up to: 5.7 -Stable tag: 1.1.4 +Stable tag: 1.1.5 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -36,6 +36,8 @@ Need help with something? Have an issue to report? [Get in touch](https://github Just select option "Unlist Post" in any post of any type and that post will be hidden from the whole site, it can be only accessed if you have the direct link to the post. == Changelog == += 1.1.5 = +- Fix: Robots tags conflicting with Yoast SEO. = 1.1.4 = - Fix: Due to a bug unlisted posts were visible in the search results, which we have fixed now. diff --git a/unlist-posts.php b/unlist-posts.php index ed77236..6248cc3 100644 --- a/unlist-posts.php +++ b/unlist-posts.php @@ -7,7 +7,7 @@ * Author URI: https://www.nikhilchavan.com/ * Text Domain: unlist-posts * Domain Path: /languages - * Version: 1.1.4 + * Version: 1.1.5 * * @package Hide_Post */ @@ -16,6 +16,6 @@ define( 'UNLIST_POSTS_DIR', plugin_dir_path( __FILE__ ) ); define( 'UNLIST_POSTS_URI', plugins_url( '/', __FILE__ ) ); -define( 'UNLIST_POSTS_VER', '1.1.4' ); +define( 'UNLIST_POSTS_VER', '1.1.5' ); require_once UNLIST_POSTS_DIR . 'class-unlist-posts.php'; From f06b0db0b3750e1387455b476ef5289e9874e562 Mon Sep 17 00:00:00 2001 From: Abhijit Babasaheb Nage Date: Wed, 24 Mar 2021 20:07:03 +0530 Subject: [PATCH 2/2] added comment and Updated readme --- README.md | 2 +- class-unlist-posts.php | 1 + readme.txt | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ba1b1cb..98294fe 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Just select option "Unlist Post" in any post of any type and that post will be h ## Changelog ## ### 1.1.5 ### -- Fix: Robots tags conflicting with Yoast SEO. +- Fix: Compatibility with Yoast SEO's robots tags options. Robots tags from Unlist Posts will override tag changes from Yoast SEO. ### 1.1.4 ### - Fix: Due to a bug unlisted posts were visible in the search results, which we have fixed now. diff --git a/class-unlist-posts.php b/class-unlist-posts.php index d8965a6..12b1de1 100644 --- a/class-unlist-posts.php +++ b/class-unlist-posts.php @@ -175,6 +175,7 @@ public function no_robots_for_unlisted_posts( $robots ) { $hidden_posts = get_option( 'unlist_posts', array() ); if ( in_array( get_the_ID(), $hidden_posts, true ) && false !== get_the_ID() ) { + // Disable robots tags from Yoast SEO. add_filter( 'wpseo_robots_array', '__return_empty_array' ); return wp_robots_no_robots( $robots ); } diff --git a/readme.txt b/readme.txt index 29af232..43d4122 100644 --- a/readme.txt +++ b/readme.txt @@ -37,7 +37,7 @@ Just select option "Unlist Post" in any post of any type and that post will be h == Changelog == = 1.1.5 = -- Fix: Robots tags conflicting with Yoast SEO. +- Fix: Compatibility with Yoast SEO's robots tags options. Robots tags from Unlist Posts will override tag changes from Yoast SEO. = 1.1.4 = - Fix: Due to a bug unlisted posts were visible in the search results, which we have fixed now.