PluginProbe
Cooked – Recipe Management / trunk
Cooked – Recipe Management vtrunk
1.16.0 1.15.0 trunk 1.10.0 1.11.0 1.11.1 1.11.2 1.11.3 1.11.4 1.12.0 1.13.0 1.14.0 1.7.10 1.7.11 1.7.12 1.7.13 1.7.15.1 1.7.15.3 1.7.15.4 1.8.0 1.8.1 1.8.2 1.8.3 1.8.4 1.8.5 All 36 releases
cooked / includes / class.cooked-post-types.php

class.cooked-post-types.php in Cooked – Recipe Management trunk, at includes/class.cooked-post-types.php

566 lines 23.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post Types
4 *
5 * @package Cooked
6 * @subpackage Post Types
7 * @since 1.0.0
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 /**
14 * Cooked_Post_Types Class
15 *
16 * This class handles the post type creation.
17 *
18 * @since 1.0.0
19 */
20 class Cooked_Post_Types {
21
22 function __construct() {
23 register_activation_hook( COOKED_PLUGIN_FILE, [&$this, 'activation'] );
24
25 add_action( 'init', [&$this, 'init'] );
26 add_filter( 'admin_init', [&$this, 'init_roles'] );
27 add_action( 'after_setup_theme', [&$this, 'image_sizes'] );
28 add_action( 'wp_head', [&$this, 'cooked_meta_tags'], 5 );
29 add_action( 'manage_cp_recipe_posts_custom_column', [&$this, 'custom_columns_data'], 10, 2 );
30
31 add_filter( 'enter_title_here', [&$this, 'change_new_recipe_title'] );
32 add_filter( 'query_vars', [&$this, 'add_query_vars_filter'] );
33 add_filter( 'manage_cp_recipe_posts_columns', [&$this, 'custom_columns'] );
34 add_filter( 'nav_menu_css_class', [&$this, 'cooked_nav_classes'], 10, 2 );
35 add_filter( 'redirect_canonical', [&$this, 'disable_canonical_redirect'], 10, 2 );
36
37 // Taxonomy Titles
38 add_action( 'template_redirect', [&$this, 'remove_default_title_tag'] );
39 add_filter( 'the_title', [&$this, 'taxonomy_page_title'], 10, 2 );
40 add_filter( 'pre_wp_nav_menu', [&$this, 'disable_taxonomy_page_title'], 10, 2 );
41 add_filter( 'wp_nav_menu_items', [&$this, 'enable_taxonomy_page_title'], 10, 2 );
42 add_filter( 'wp_title', [&$this, 'taxonomy_meta_title'], 10 );
43
44 // Add a post display state for special pages.
45 add_filter( 'display_post_states', [&$this, 'add_display_post_states' ], 10, 2 );
46 }
47
48 function disable_taxonomy_page_title( $nav_menu, $args ) {
49 remove_filter( 'the_title', [&$this, 'taxonomy_page_title'], 10 );
50 return $nav_menu;
51 }
52
53 function enable_taxonomy_page_title( $items, $args ) {
54 add_filter( 'the_title', [&$this, 'taxonomy_page_title'], 10, 2 );
55 return $items;
56 }
57
58 function taxonomy_page_title( $title = '', $id = 0 ) {
59 if ( is_admin() ) return $title;
60
61 global $wp_query, $post, $_cooked_settings;
62 $browse_page_id = Cooked_Multilingual::get_browse_page_id();
63
64 if ( is_page( $browse_page_id ) && $id == $browse_page_id && isset($wp_query->query['cp_recipe_category']) && taxonomy_exists('cp_recipe_category') && term_exists( $wp_query->query['cp_recipe_category'], 'cp_recipe_category' ) ):
65 $cooked_term = get_term_by( 'slug', $wp_query->query['cp_recipe_category'], 'cp_recipe_category' );
66 return $cooked_term->name;
67 endif;
68
69 return $title;
70 }
71
72 function taxonomy_meta_title( $title = '' ) {
73 global $wp_query, $post, $_cooked_settings;
74 $browse_page_id = Cooked_Multilingual::get_browse_page_id();
75
76 if ( is_page( $browse_page_id ) && $post->ID == $browse_page_id && isset($wp_query->query['cp_recipe_category']) && taxonomy_exists('cp_recipe_category') && term_exists( $wp_query->query['cp_recipe_category'], 'cp_recipe_category' ) ):
77 $cooked_term = get_term_by( 'slug', $wp_query->query['cp_recipe_category'], 'cp_recipe_category' );
78 return $cooked_term->name;
79 endif;
80
81 return $title;
82 }
83
84 function custom_columns( $columns ) {
85 $new_columns = [];
86 foreach( $columns as $key => $val ):
87 $new_columns[$key] = $val;
88 if ( $key == 'cb' ):
89 $new_columns['featured_image'] = __( 'Photo', 'cooked' );
90 endif;
91 endforeach;
92 return $new_columns;
93 }
94
95 function custom_columns_data( $column, $post_id ) {
96 if ( $column == 'featured_image' ):
97 echo '<span class="cooked-admin-recipes-list-image">';
98 echo the_post_thumbnail( 'thumbnail' );
99 echo '</span>';
100 endif;
101 }
102
103 public static function cooked_nav_classes( $classes, $item ) {
104 global $_cooked_settings;
105 $blog_page_id = get_option( 'page_for_posts', false );
106 $browse_page_id = Cooked_Multilingual::get_browse_page_id();
107
108 if ( ( is_post_type_archive( 'cp_recipe' ) || is_singular( 'cp_recipe' ) )
109 && $item->object_id == $blog_page_id ){
110 $classes = array_diff( $classes, ['current_page_parent'] );
111 }
112
113 if ( ( is_post_type_archive( 'cp_recipe' ) || is_singular( 'cp_recipe' ) )
114 && $item->object_id == $browse_page_id && is_array($classes) && !in_array( 'current_page_parent', $classes ) ){
115 $classes[] = 'current_page_parent';
116 }
117
118 return $classes;
119 }
120
121 public static function cooked_meta_tags() {
122 global $_cooked_settings, $post, $wp_query;
123
124 if ( isset($_cooked_settings['advanced']) && !empty($_cooked_settings['advanced']) && in_array( 'disable_meta_tags', $_cooked_settings['advanced'] ) )
125 return false;
126
127 if ( isset($wp_query->query['cp_recipe_category']) && taxonomy_exists('cp_recipe_category') && term_exists( $wp_query->query['cp_recipe_category'], 'cp_recipe_category' ) ) {
128 $cooked_term = get_term_by( 'slug', $wp_query->query['cp_recipe_category'], 'cp_recipe_category' );
129 }
130
131 // Browse page.
132 if ( isset( $cooked_term ) && $cooked_term->name ) {
133 ?><title><?php echo esc_html($cooked_term->name) . ' / ' . esc_html(get_bloginfo('name')); ?></title>
134 <meta name="description" content="<?php echo esc_attr( $cooked_term->description ); ?>">
135 <meta property="og:title" content="<?php echo esc_attr( $cooked_term->name ); ?>">
136 <meta property="og:description" content="<?php echo esc_attr( $cooked_term->description ); ?>"><?php
137 }
138
139 // Single recipe.
140 if ( isset( $post->post_type ) && $post->post_type == 'cp_recipe' ) {
141 ob_start();
142
143 $recipe = get_post( $post->ID );
144 $recipe_settings = Cooked_Recipes::get( $post->ID, true );
145 $image_url = false;
146
147 if ( has_post_thumbnail($recipe) ) {
148 $image_url = get_the_post_thumbnail_url( $recipe, 'cooked-large' );
149 }
150
151 $description = '';
152 if (!empty($recipe_settings['seo_description'])):
153 $description = wp_strip_all_tags( preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $recipe_settings['seo_description']) ); ;
154 elseif (!empty($recipe_settings['excerpt'])):
155 $description = wp_strip_all_tags( preg_replace("~(?:\[/?)[^/\]]+/?\]~s", '', $recipe_settings['excerpt']) );
156 elseif (!empty($recipe_settings['title'])):
157 $description = $recipe_settings['title'];
158 endif;
159 ?>
160
161 <meta name="description" content="<?php echo esc_attr( $description ); ?>">
162 <meta property="og:type" content="website">
163 <meta property="og:title" content="<?php echo esc_attr( $post->post_title ); ?>">
164 <meta property="og:description" content="<?php echo esc_attr( $description ); ?>">
165 <meta property="og:image" content="<?php echo esc_attr( $image_url ); ?>">
166 <meta property="og:locale" content="<?php echo esc_attr( get_locale() ); ?>">
167 <meta property="og:url" content="<?php echo get_permalink( $post->ID ); ?>"><?php
168
169 echo ob_get_clean();
170 }
171 }
172
173 public static function add_query_vars_filter( $vars ) {
174 $vars[] = 'servings';
175 $vars[] = 'measurement_system';
176
177 return $vars;
178 }
179
180 public function remove_default_title_tag() {
181 global $wp_query;
182 if ( isset($wp_query->query['cp_recipe_category']) && taxonomy_exists('cp_recipe_category') && term_exists( $wp_query->query['cp_recipe_category'], 'cp_recipe_category' ) ) {
183 remove_action( 'wp_head', '_wp_render_title_tag', 1 );
184 }
185 }
186
187 public static function activation() {
188 self::init();
189 self::init_roles();
190 flush_rewrite_rules();
191 }
192
193 public static function init_roles() {
194 // Clean up for any old caps or caps that were inserted incorrectly.
195 if ( $role_object = get_role( 'subscriber' ) ) {
196 if ( $role_object->has_cap( 'edit_cp_recipes' ) ) {
197 Cooked_Roles::clean_caps();
198 }
199 }
200
201 Cooked_Roles::add_roles();
202 Cooked_Roles::add_caps();
203 }
204
205 public static function init() {
206 $_cooked_settings = Cooked_Settings::get();
207 $_cooked_taxonomies = Cooked_Taxonomies::get();
208
209 // Security check: Only allow settings update from admin area with proper permissions
210 if (!empty($_GET['settings-updated']) && is_admin() && current_user_can('manage_options') && isset($_GET['page']) && $_GET['page'] === 'cooked_settings') {
211 // Recipe Permalink
212 $permalink_parts = explode( '/', $_cooked_settings['recipe_permalink'] );
213 if ( isset( $permalink_parts[1] ) ):
214 foreach ( $permalink_parts as $key => $part ):
215 $part = sanitize_title_with_dashes( $part, null, 'save');
216 $permalink_parts[$key] = sanitize_title_with_dashes( $part, null, 'save');
217 endforeach;
218 $recipe_permalink = implode( '/', $permalink_parts );
219 else:
220 $recipe_permalink = sanitize_title_with_dashes( $_cooked_settings['recipe_permalink'], null, 'save');
221 endif;
222
223 // Recipe Author Permalink
224 $permalink_parts = explode( '/', $_cooked_settings['recipe_author_permalink'] );
225 if ( isset( $permalink_parts[1] ) ):
226 foreach( $permalink_parts as $key => $part ):
227 $part = sanitize_title_with_dashes( $part, null, 'save');
228 $permalink_parts[$key] = sanitize_title_with_dashes( $part, null, 'save');
229 endforeach;
230 $recipe_author_permalink = implode( '/', $permalink_parts );
231 else:
232 $recipe_author_permalink = sanitize_title_with_dashes( $_cooked_settings['recipe_author_permalink'], null, 'save');
233 endif;
234
235 // Recipe Category Permalink
236 $permalink_parts = explode( '/', $_cooked_settings['recipe_category_permalink'] );
237 if ( isset( $permalink_parts[1] ) ):
238 foreach ( $permalink_parts as $key => $part ):
239 $part = sanitize_title_with_dashes( $part, null, 'save');
240 $permalink_parts[$key] = sanitize_title_with_dashes( $part, null, 'save');
241 endforeach;
242 $recipe_category_permalink = implode( '/', $permalink_parts );
243 else:
244 $recipe_category_permalink = sanitize_title_with_dashes( $_cooked_settings['recipe_category_permalink'], null, 'save');
245 endif;
246
247 $taxonomy_settings_update = apply_filters( 'cooked_taxonomy_settings_update', [
248 'recipe_permalink' => (!$_cooked_settings['recipe_permalink'] ? 'recipes' : $recipe_permalink),
249 'recipe_author_permalink' => (!$_cooked_settings['recipe_author_permalink'] || 'author' == $_cooked_settings['recipe_author_permalink'] ? 'recipe-author' : $recipe_author_permalink),
250 'recipe_category_permalink' => (!$_cooked_settings['recipe_category_permalink'] ? 'recipe-category' : $recipe_category_permalink)
251 ]);
252
253 foreach ( $taxonomy_settings_update as $setting_key => $setting_value ) {
254 $_cooked_settings[ $setting_key ] = $setting_value;
255 }
256
257 update_option( 'cooked_settings', $_cooked_settings );
258 update_option( 'cooked_settings_saved', true );
259
260 flush_rewrite_rules();
261 }
262
263 global $cooked_taxonomies_for_menu;
264
265 // Register taxonomies first (only once)
266 if ( !empty($_cooked_taxonomies) ) {
267 foreach ( $_cooked_taxonomies as $slug => $args ) {
268 register_taxonomy( $slug, ['cp_recipe'], $args );
269 add_rewrite_tag("%{$slug}%", '([^/]+)');
270
271 $cooked_taxonomies_for_menu[] = [
272 'menu' => 'cooked_recipes_menu',
273 'name' => $args['labels']['menu_name'],
274 'capability' => 'manage_categories',
275 'url' => 'edit-tags.php?taxonomy=' . $slug . '&post_type=cp_recipe'
276 ];
277 }
278 }
279
280 // Get all browse page translations (including default)
281 $browse_pages = Cooked_Multilingual::get_all_browse_pages();
282
283 // Create rewrite rules for each browse page translation
284 foreach ( $browse_pages as $lang => $page_data ) {
285 self::add_browse_page_rewrite_rules( $page_data['id'], $page_data['slug'], $_cooked_taxonomies );
286 }
287
288 add_rewrite_tag('%cooked_search_s%', '([^&]+)');
289 add_rewrite_tag('%cooked_browse_sort_by%', '([^&]+)');
290
291 $post_types = self::get();
292 if ( !empty($post_types) ) {
293 foreach ( $post_types as $slug => $args ) {
294 register_post_type( $slug, $args );
295 }
296 }
297 }
298
299 /**
300 * Add rewrite rules for a specific browse page
301 *
302 * @param int $page_id The browse page ID
303 * @param string|null $page_slug The browse page slug/path (empty string for homepage, null if invalid)
304 * @param array $taxonomies The registered taxonomies
305 */
306 private static function add_browse_page_rewrite_rules( $page_id, $page_slug, $taxonomies ) {
307 // Page ID is required, but slug can be empty string (for homepage)
308 if ( ! $page_id || $page_slug === null ) {
309 return;
310 }
311
312 // Get base path - either parent page slug or empty (for homepage)
313 $base_path = $page_slug !== '' ? $page_slug . '/' : '';
314
315 // Add taxonomy rewrite rules
316 if ( !empty($taxonomies) ) {
317 foreach ( $taxonomies as $slug => $args ) {
318 // Taxonomy search sort pagination
319 add_rewrite_rule(
320 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/search/([^/]*)/sort/([^/]*)/page/([^/]*)/?',
321 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]&cooked_search_s=$matches[2]&cooked_browse_sort_by=$matches[3]&paged=$matches[4]',
322 'top'
323 );
324
325 // Taxonomy search sort
326 add_rewrite_rule(
327 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/search/([^/]*)/sort/([^/]*)/?',
328 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]&cooked_search_s=$matches[2]&cooked_browse_sort_by=$matches[3]',
329 'top'
330 );
331
332 // Taxonomy sort pagination
333 add_rewrite_rule(
334 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/sort/([^/]*)/page/([^/]*)/?',
335 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]&cooked_browse_sort_by=$matches[2]&paged=$matches[3]',
336 'top'
337 );
338
339 // Taxonomy sort
340 add_rewrite_rule(
341 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/sort/([^/]*)/?',
342 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]&cooked_browse_sort_by=$matches[2]',
343 'top'
344 );
345
346 // Taxonomy search
347 add_rewrite_rule(
348 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/search/([^/]*)/?',
349 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]&cooked_search_s=$matches[2]',
350 'top'
351 );
352
353 // Taxonomy pagination
354 add_rewrite_rule(
355 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/page/([^/]*)/?',
356 'index.php?page_id=' . $page_id . '&paged=$matches[2]&' . $slug . '=$matches[1]',
357 'top'
358 );
359
360 // Taxonomy
361 add_rewrite_rule(
362 '^' . $base_path . $args['rewrite']['slug'] . '/([^/]*)/?',
363 'index.php?page_id=' . $page_id . '&' . $slug . '=$matches[1]',
364 'top'
365 );
366 }
367 }
368
369 // Search sort pagination
370 add_rewrite_rule(
371 '^' . $base_path . 'search/([^/]*)/sort/([^/]*)/page/([^/]*)/?',
372 'index.php?page_id=' . $page_id . '&cooked_search_s=$matches[1]&cooked_browse_sort_by=$matches[2]&paged=$matches[3]',
373 'top'
374 );
375
376 // Search sort
377 add_rewrite_rule(
378 '^' . $base_path . 'search/([^/]*)/sort/([^/]*)/?',
379 'index.php?page_id=' . $page_id . '&cooked_search_s=$matches[1]&cooked_browse_sort_by=$matches[2]',
380 'top'
381 );
382
383 // Sort Pagination
384 add_rewrite_rule(
385 '^' . $base_path . 'sort/([^/]*)/page/([^/]*)/?',
386 'index.php?page_id=' . $page_id . '&cooked_browse_sort_by=$matches[1]&paged=$matches[2]',
387 'top'
388 );
389
390 // Sort
391 add_rewrite_rule(
392 '^' . $base_path . 'sort/([^/]*)/?',
393 'index.php?page_id=' . $page_id . '&cooked_browse_sort_by=$matches[1]',
394 'top'
395 );
396
397 // Search
398 add_rewrite_rule(
399 '^' . $base_path . 'search/([^/]*)/?',
400 'index.php?page_id=' . $page_id . '&cooked_search_s=$matches[1]',
401 'top'
402 );
403
404 // Pagination
405 add_rewrite_rule(
406 '^' . $base_path . 'page/([^/]*)/?',
407 'index.php?page_id=' . $page_id . '&paged=$matches[1]',
408 'top'
409 );
410
411 // Plain - only add for non-homepage pages (WordPress handles homepage already)
412 if ( $page_slug !== '' ) {
413 add_rewrite_rule(
414 '^' . $page_slug . '/?$',
415 'index.php?page_id=' . $page_id,
416 'top'
417 );
418 }
419 }
420
421 public static function image_sizes() {
422 add_image_size( 'cooked-profile-photo', 150, 150, true );
423 add_image_size( 'cooked-square', 700, 700, true );
424 add_image_size( 'cooked-medium', 700, 525, true );
425 add_image_size( 'cooked-large', 2000, 2000 );
426 }
427
428 public static function get() {
429 global $_cooked_settings;
430
431 $recipe_permalink = isset($_cooked_settings['recipe_permalink']) && $_cooked_settings['recipe_permalink'] ? $_cooked_settings['recipe_permalink'] : 'recipes';
432 $public_recipes = true;
433 $has_archive_slug = sanitize_title_with_dashes( __('Recipe Archive', 'cooked') );
434 $exclude_from_search = false;
435
436 if ( !isset($_GET['print']) && isset( $_cooked_settings['advanced'] ) && in_array( 'disable_public_recipes', $_cooked_settings['advanced'] ) ) {
437 $public_recipes = false;
438 $has_archive_slug = false;
439 $exclude_from_search = true;
440 }
441
442 if ( isset( $_cooked_settings['advanced'] ) && in_array( 'disable_cp_recipe_archive', $_cooked_settings['advanced'] ) ) {
443 $has_archive_slug = false;
444 }
445
446 $post_types = apply_filters( 'cooked_post_types', [
447 'cp_recipe' => [
448 'labels' => [
449 'name' => _x('Recipes', 'cooked'),
450 'singular_name' => _x('Recipe', 'cooked'),
451 'menu_name' => __('Recipes', 'cooked'),
452 'name_admin_bar' => __('Recipe', 'cooked'),
453 'add_new' => __('Add New', 'cooked'),
454 'add_new_item' => __('Add New Recipe', 'cooked'),
455 'new_item' => __('New Recipe', 'cooked'),
456 'edit_item' => __('Edit Recipe', 'cooked'),
457 'view_item' => __('View Recipe', 'cooked'),
458 'all_items' => __('All Recipes', 'cooked'),
459 'search_items' => __('Search Recipes', 'cooked'),
460 'not_found' => __('No recipes found.', 'cooked'),
461 'not_found_in_trash' => __('No recipes found in trash.', 'cooked')
462 ],
463 'description' => __('Recipes', 'cooked'),
464 'public' => $public_recipes,
465 'show_ui' => true,
466 'show_in_admin_bar' => true,
467 'show_in_menu' => 'cooked_recipes_menu',
468 'show_in_rest' => true,
469 'rest_base' => 'cooked_recipe',
470 'rest_controller_class' => 'WP_REST_Posts_Controller',
471 'exclude_from_search' => $exclude_from_search,
472 'has_archive' => $has_archive_slug,
473 'menu_position' => 25,
474 'supports' => ['title', 'editor', 'thumbnail', 'comments', 'author'],
475 'rewrite' => [
476 'with_front' => false,
477 'slug' => $recipe_permalink
478 ]
479 ]
480 ]
481 );
482
483 return $post_types;
484 }
485
486 public function change_new_recipe_title($title) {
487 $screen = get_current_screen();
488 if ('cp_recipe' == $screen->post_type) {
489 $title = __('Recipe title ...', 'cooked');
490 }
491
492 return $title;
493 }
494
495 /**
496 * Add a post display state for special Cooked pages in the page list table.
497 *
498 * @param array $post_states An array of post display states.
499 * @param WP_Post $post The current post object.
500 */
501 public function add_display_post_states( $post_states, $post ) {
502 global $_cooked_settings;
503
504 // Check both the main browse page and any translations
505 $main_browse_page_id = !empty($_cooked_settings['browse_page']) ? $_cooked_settings['browse_page'] : false;
506 $browse_pages = Cooked_Multilingual::get_all_browse_pages();
507
508 // Check if this post is the main browse page or any translation
509 $is_browse_page = ( $main_browse_page_id == $post->ID );
510 if ( ! $is_browse_page && ! empty( $browse_pages ) ) {
511 foreach ( $browse_pages as $lang => $page_data ) {
512 if ( $page_data['id'] == $post->ID ) {
513 $is_browse_page = true;
514 break;
515 }
516 }
517 }
518
519 if ( $is_browse_page ) {
520 $post_states['cooked_page_for_browse_recipes'] = __( 'Cooked Browse Recipes Page', 'cooked' );
521 }
522
523 return $post_states;
524 }
525
526 /**
527 * Disable canonical redirects for Cooked URLs on the homepage
528 *
529 * @param string $redirect_url The redirect URL
530 * @param string $requested_url The originally requested URL
531 * @return string|bool The redirect URL or false to prevent redirect
532 */
533 public function disable_canonical_redirect($redirect_url, $requested_url) {
534 global $_cooked_settings;
535 $_cooked_taxonomies = Cooked_Taxonomies::get();
536
537 // Only process if this is the homepage
538 if (!is_front_page()) {
539 return $redirect_url;
540 }
541
542 // Check if any Cooked query vars are present
543 $cooked_query_vars = [
544 'cooked_search_s',
545 'cooked_browse_sort_by',
546 'paged'
547 ];
548
549 // Add taxonomy query vars
550 if (!empty($_cooked_taxonomies)) {
551 foreach ( $_cooked_taxonomies as $slug => $args ) {
552 $cooked_query_vars[] = $slug;
553 }
554 }
555
556 foreach ($cooked_query_vars as $var) {
557 if (get_query_var($var)) {
558 return false;
559 }
560 }
561
562 return $redirect_url;
563 }
564
565 }
566