Skip to content

Feature: Checkbox to allow / disallow robots to index#124

Open
DogByteMarketing wants to merge 4 commits into
Nikschavan:masterfrom
DogByteMarketing:master
Open

Feature: Checkbox to allow / disallow robots to index#124
DogByteMarketing wants to merge 4 commits into
Nikschavan:masterfrom
DogByteMarketing:master

Conversation

@DogByteMarketing
Copy link
Copy Markdown

@DogByteMarketing DogByteMarketing commented Sep 15, 2023

Description

Added the ability to set noindex or index via a checkbox below the existing meta box field

Screenshots

image

Types of changes

New feature

How has this been tested?

Checked the box, viewed source code for unlisted page, saw it allowed indexing. Unchecked the box, viewed source code, saw it had noindex again. Repeated process for published pages.

Checklist:

  • My code is tested
  • My code passes the PHPCS tests (It does not appear the configuration in this repo is set properly for this)
  • My code follows accessibility standards
  • My code has proper inline documentation

Added conditionals to hide_post_from_searchengines, change_robots_for_rankmath, and no_robots_for_unlisted_posts properties to check if robots should be enabled
This field is to be used for when setting no index to check if it should be indexed or not.
*
* @return Void
*/
public function save_meta_enable_robots( $post_id ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

*
* @return Void
*/
public function save_meta_enable_robots( $post_id ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function save_meta_enable_robots has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.

@qlty-cloud-legacy
Copy link
Copy Markdown

qlty-cloud-legacy Bot commented Sep 15, 2023

Code Climate has analyzed commit d84857c and detected 6 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2
Duplication 4

View more on Code Climate.

Refactored to be CodeClimate compliant
Comment thread class-unlist-posts.php
* @param array $enable_robots Array of post ids that should allow robots
* @return boolean False - This is the default value. This means that robots are disabled.
*/
private function robots_enabled_check( $hidden_posts, $enable_robots ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function robots_enabled_check has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

Refactored to be CodeClimate compliant
* @param Post $post The current post object.
* @return void
*/
function render_unlist_posts( $post ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

* @param Post $post The current post object.
* @return void
*/
function render_enable_robots( $post ) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar blocks of code found in 2 locations. Consider refactoring.

@dave987321
Copy link
Copy Markdown

I love to see this feature get reviewed and made available. This is a great feature for blogs that we don't want to appear in the blog list, but do want to be indexed. An example would be a complex topic where there is both a summary level blog and a very detailed blog on the same topic. I am putting a link in the summary level blog, but I want both to be indexed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants