Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

DogByteMarketing
Copy link

@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

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

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.

@codeclimate
Copy link

codeclimate 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
* @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

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

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

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.

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.

1 participant