Skip to content

Commit 78b068b

Browse files
committed
Start on noindex functionality.
1 parent b762fe3 commit 78b068b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

inc/seo-compat.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
/**
3+
* Simple Search Submission for IndexNow
4+
*
5+
* @package SimpleSearchSubmission
6+
*/
7+
8+
namespace PWCC\SimpleSearchSubmission\SEOCompat;
9+
10+
/**
11+
* Determine if a post is set to noindex by an SEO plugin.
12+
*
13+
* @param \WP_Post|int $post The post object or ID.
14+
* @return bool True if the post is set to noindex, false otherwise.
15+
*/
16+
function is_noindex( $post ) {
17+
$post = get_post( $post );
18+
if ( ! $post ) {
19+
return true; // No post found, treat as noindex.
20+
}
21+
22+
23+
if ( class_exists( 'WPSEO_Meta' ) ) {
24+
// Yoast SEO.
25+
$meta_value = \WPSEO_Meta::get_value( 'meta-robots-noindex', $post->ID );
26+
if ( '1' === $meta_value ) {
27+
return true;
28+
}
29+
}
30+
31+
}

0 commit comments

Comments
 (0)