diff --git a/includes/permalink-rewrites/class-permalink-rewrites.php b/includes/permalink-rewrites/class-permalink-rewrites.php index d88de9f9..91b1274d 100644 --- a/includes/permalink-rewrites/class-permalink-rewrites.php +++ b/includes/permalink-rewrites/class-permalink-rewrites.php @@ -3,6 +3,10 @@ use WP_Error; use WP_REST_Request; +/** + * @NOTE: This class is used to filter and structure rewrite rules, tags, and query vars for the PRC Platform. + * You will find most of the rewrite rules in taxonomies/research-teams, as this taxonomy drives most of the custom permalink structure for objects on PRC-Platform. + */ class Permalink_Rewrites { /** * The version of this plugin. @@ -30,7 +34,6 @@ public function __construct( $version, $loader ) { public function init($loader = null) { if ( null !== $loader ) { - $loader->add_filter( 'robots_txt', $this, 'manage_robots_txt', 10, 2 ); $loader->add_action( 'init', $this, 'register_rewrites' ); $loader->add_action( 'init', $this, 'register_tags' ); $loader->add_filter( 'query_vars', $this, 'register_query_vars' ); @@ -38,14 +41,6 @@ public function init($loader = null) { } } - function manage_robots_txt( $output, $public ) { - // Blocking search pages from googlebot - $output .= 'Disallow: /search/' . PHP_EOL; - $output .= 'Disallow: /search' . PHP_EOL; - $output .= 'Disallow: /?s=' . PHP_EOL; - return $output; - } - /** * Registers the rewrite rules for PRC Platform with WordPress. * @hook init diff --git a/includes/taxonomies/class-research-teams.php b/includes/taxonomies/class-research-teams.php index b92daf6d..b03639cd 100644 --- a/includes/taxonomies/class-research-teams.php +++ b/includes/taxonomies/class-research-teams.php @@ -108,15 +108,14 @@ public function add_rewrite_rules($rules) { $new_rules[$term_name . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/embed/?$'] = 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&iframe=true'; $new_rules[$term_name . '/([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/([^/]+)(?:/([0-9]+))?/iframe/?$'] = 'index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&name=$matches[4]&iframe=true'; // Add attachment rule: - $new_rules[$term_name . '/[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?[^/iframe]$'] = 'index.php?attachment=$matches[1]'; + $new_rules[$term_name . '/[0-9]{4}/[0-9]{1,2}/[0-9]{1,2}/[^/]+/([^/]+)/?$'] = 'index.php?attachment=$matches[1]'; } else if ( 'fact-sheet' === $post_type ) { $new_rules[$term_name . '/fact-sheet/([^/]+)/?$'] = 'index.php?post_type=fact-sheet&name=$matches[1]'; // Add attachment rule: $new_rules[$term_name . '/fact-sheet/[^/]+/([^/]+)/?$'] = 'index.php?attachment=$matches[1]'; } else if ( 'quiz' === $post_type ) { + // Add /quiz rules: $new_rules[$term_name . '/quiz/([^/]+)/?$'] = 'index.php?post_type=quiz&name=$matches[1]'; - // Add attachment rule: - $new_rules[$term_name . '/quiz/[^/]+/([^/]+)/?[^/iframe]$'] = 'index.php?attachment=$matches[1]'; // Add /results rules: $new_rules[$term_name . '/quiz/([^/]+)/results/?$'] = 'index.php?post_type=quiz&name=$matches[1]&showResults=1'; // A new, cacheable, results archetype rule. @@ -124,6 +123,8 @@ public function add_rewrite_rules($rules) { // Add iframe and embed rules: $new_rules[$term_name . '/quiz/([^/]+)/embed/?$'] = 'index.php?post_type=quiz&name=$matches[1]&iframe=true'; $new_rules[$term_name . '/quiz/([^/]+)/iframe/?$'] = 'index.php?post_type=quiz&name=$matches[1]&iframe=true'; + // Add attachment rule: + $new_rules[$term_name . '/quiz/[^/]+/([^/]+)/?$'] = 'index.php?attachment=$matches[1]'; } else if ( 'feature' === $post_type ) { $new_rules[$term_name . '/feature/([^/]+)/?$'] = 'index.php?post_type=feature&name=$matches[1]'; // Add attachment rule, very, very specific. This will only hit for attachment names that are 5 or more characters long.