PluginProbe
Blocks – Reusable Content, Shortcodes & Site Variables / trunk
Blocks – Reusable Content, Shortcodes & Site Variables vtrunk
26.09.03.15 26.08.31.21 26.08.22.20 26.08.22.22 26.08.22.17 26.08.22.13 26.08.21.19 26.08.07.23 26.07.19.14 26.07.13.21 26.07.13.17 26.07.12.13 026.07.07.21 026.07.05.18 026.06.26.20 026.06.26.21 026.06.08.20 026.05.13.14 026.04.29.10 trunk 026.02.22.22 026.03.16.23 026.04.23.13
blocks / src / WooCommerce / WooPages.php

WooPages.php in Blocks – Reusable Content, Shortcodes & Site Variables trunk, at src/WooCommerce/WooPages.php

42 lines 967 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace RenzoJohnson\Blocks\WooCommerce;
6
7 \defined( 'ABSPATH' ) || exit;
8
9 /** Resolves the WooCommerce pages shared by sitemap and robots guards. */
10 final class WooPages {
11
12 /**
13 * @param array<int, string> $slugs WooCommerce page slugs.
14 * @return array<int, int>
15 */
16 public static function guarded_ids( array $slugs ): array {
17 $ids = array();
18
19 foreach ( $slugs as $slug ) {
20 // wc_get_page_id() returns -1 when the page is not configured.
21 $id = (int) \wc_get_page_id( $slug );
22
23 if ( $id > 0 ) {
24 $ids[] = $id;
25 }
26 }
27
28 /**
29 * Filter the WooCommerce page IDs treated as non-indexable.
30 *
31 * @param array<int, int> $ids Page IDs.
32 */
33 $filtered = \apply_filters( 'blocks_woo_guarded_page_ids', $ids );
34
35 if ( ! \is_array( $filtered ) ) {
36 return $ids;
37 }
38
39 return \array_values( \array_unique( \array_filter( \array_map( '\intval', $filtered ), static fn ( int $id ): bool => $id > 0 ) ) );
40 }
41 }
42