is_needed() ) { return $piece; } } return $this->add_accessibility_feature( $piece, $context ); } /** * Adds the accessibility feature to a schema graph piece. * * @param array $piece The schema piece. * @param Meta_Tags_Context $context The context. * * @return array The graph piece. */ public function add_accessibility_feature( $piece, $context ) { if ( empty( $context->blocks['yoast-seo/table-of-contents'] ) ) { return $piece; } if ( isset( $piece['accessibilityFeature'] ) ) { $piece['accessibilityFeature'][] = 'tableOfContents'; } else { $piece['accessibilityFeature'] = [ 'tableOfContents', ]; } return $piece; } }