1010use Yoast \WP \SEO \Surfaces \Values \Meta ;
1111
1212// Fix Schema
13- \add_filter ('wpseo_schema_webpage_type ' , __NAMESPACE__ . '\\fix_schema_webpage_type ' , 10 , 2 );
13+ \add_filter ('wpseo_schema_webpage_type ' , __NAMESPACE__ . '\\fix_schema_webpage_type ' );
14+ /**
15+ * Add CollectionPage schema to custom post type pages
16+ *
17+ * @param string|string[] $type
18+ *
19+ * @return string|string[]
20+ */
1421function fix_schema_webpage_type ($ type )
1522{
1623 $ pfcpt = Plugin::get_instance ();
@@ -37,10 +44,12 @@ function fix_schema_webpage_type($type)
3744/**
3845 * Fix Yoast breadcrumbs on post
3946 *
47+ * @param Indexable[] $indexables
4048 * @param Meta_Tags_Context $context
41- * @return array
49+ *
50+ * @return Indexable[]
4251 */
43- function fix_post_breadcrumbs (array $ indexables , $ context )
52+ function fix_post_breadcrumbs (array $ indexables , $ context ): array
4453{
4554 $ current_post_type = $ context ->indexable ->object_sub_type ?? null ;
4655 if (!$ current_post_type || !\is_singular ($ current_post_type )) {
@@ -78,9 +87,11 @@ function fix_post_breadcrumbs(array $indexables, $context)
7887/**
7988 * Fix Yoast breadcrumbs on taxonomy
8089 *
81- * @return array
90+ * @param Indexable[] $indexables
91+ *
92+ * @return Indexable[]
8293 */
83- function fix_taxonomy_breadcrumbs (array $ indexables , Meta_Tags_Context $ context )
94+ function fix_taxonomy_breadcrumbs (array $ indexables , Meta_Tags_Context $ context ): array
8495{
8596 $ current_taxonomy = $ context ->indexable ->object_sub_type ?? null ;
8697 if (!\is_tax ($ current_taxonomy )) {
@@ -134,10 +145,12 @@ function fix_taxonomy_breadcrumbs(array $indexables, Meta_Tags_Context $context)
134145/**
135146 * Fix Yoast breadcrumbs on home
136147 *
148+ * @param Indexable[] $indexables
137149 * @param Meta_Tags_Context $context
138- * @return array
150+ *
151+ * @return Indexable[]
139152 */
140- function fix_home_breadcrumbs (array $ indexables , $ context )
153+ function fix_home_breadcrumbs (array $ indexables , $ context ): array
141154{
142155 $ pfcpt = Plugin::get_instance ();
143156 if (!$ pfcpt ->is_query_page_for_custom_post_type ()) {
@@ -160,12 +173,12 @@ function fix_home_breadcrumbs(array $indexables, $context)
160173 $ front_page_id = $ yoast ->helpers ->current_page ->get_front_page_id ();
161174 if ($ front_page_id === 0 ) {
162175 $ home_page_ancestor = $ indexable_repository ->find_for_home_page ();
163- if (\is_a ($ home_page_ancestor , Indexable::class)) {
176+ if (! \is_bool ( $ home_page_ancestor ) && \is_a ($ home_page_ancestor , Indexable::class)) {
164177 $ static_ancestors [] = $ home_page_ancestor ;
165178 }
166179 } else {
167180 $ static_ancestor = $ indexable_repository ->find_by_id_and_type ($ front_page_id , 'post ' );
168- if (\is_a ($ static_ancestor , Indexable::class) && $ static_ancestor ->post_status !== 'unindexed ' ) {
181+ if (! \is_bool ( $ static_ancestor ) && \is_a ($ static_ancestor , Indexable::class) && $ static_ancestor ->post_status !== 'unindexed ' ) {
169182 $ static_ancestors [] = $ static_ancestor ;
170183 }
171184 }
@@ -178,16 +191,6 @@ function fix_home_breadcrumbs(array $indexables, $context)
178191 return $ indexables ;
179192}
180193
181- function add_filter_once ($ hook , $ callback , $ priority = 10 , $ args = 1 )
182- {
183- $ singular = function () use ($ hook , $ callback , $ priority , $ args , &$ singular ) {
184- \call_user_func_array ($ callback , \func_get_args ());
185- \remove_filter ($ hook , $ singular , $ priority );
186- };
187-
188- return \add_filter ($ hook , $ singular , $ priority , $ args );
189- }
190-
191194/**
192195 * Shortcircuit get_option to return the page ID for a custom post type
193196 *
0 commit comments