PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/generators/schema/faq.php +13 -13 18.228.5 View file →
@@ -7,9 +7,9 @@
7 7 */
8 8 class FAQ extends Abstract_Schema_Piece {
9 9
10 10 /**
11 - * Determines whether or not a piece should be added to the graph.
11 + * Determines whether a piece should be added to the graph.
12 12 *
13 13 * @return bool
14 14 */
15 15 public function is_needed() {
@@ -33,13 +33,15 @@
33 33 */
34 34 private function generate_ids() {
35 35 $ids = [];
36 36 foreach ( $this->context->blocks['yoast/faq-block'] as $block ) {
37 - foreach ( $block['attrs']['questions'] as $index => $question ) {
38 - if ( ! isset( $question['jsonAnswer'] ) || empty( $question['jsonAnswer'] ) ) {
39 - continue;
37 + if ( isset( $block['attrs']['questions'] ) ) {
38 + foreach ( $block['attrs']['questions'] as $question ) {
39 + if ( empty( $question['jsonAnswer'] ) ) {
40 + continue;
41 + }
42 + $ids[] = [ '@id' => $this->context->canonical . '#' . \esc_attr( $question['id'] ) ];
40 43 }
41 - $ids[] = [ '@id' => $this->context->canonical . '#' . \esc_attr( $question['id'] ) ];
42 44 }
43 45 }
44 46
45 47 return $ids;
@@ -53,10 +55,12 @@
53 55 public function generate() {
54 56 $graph = [];
55 57
56 58 $questions = [];
57 - foreach ( $this->context->blocks['yoast/faq-block'] as $index => $block ) {
58 - $questions = \array_merge( $questions, $block['attrs']['questions'] );
59 + foreach ( $this->context->blocks['yoast/faq-block'] as $block ) {
60 + if ( isset( $block['attrs']['questions'] ) ) {
61 + $questions = \array_merge( $questions, $block['attrs']['questions'] );
62 + }
59 63 }
60 64 foreach ( $questions as $index => $question ) {
61 65 if ( ! isset( $question['jsonAnswer'] ) || empty( $question['jsonAnswer'] ) ) {
62 66 continue;
@@ -87,11 +91,9 @@
87 91 'answerCount' => 1,
88 92 'acceptedAnswer' => $this->add_accepted_answer_property( $question ),
89 93 ];
90 94
91 - $data = $this->helpers->schema->language->add_piece_language( $data );
92 -
93 - return $data;
95 + return $this->helpers->schema->language->add_piece_language( $data );
94 96 }
95 97
96 98 /**
97 99 * Adds the Questions `acceptedAnswer` property.
@@ -105,9 +107,7 @@
105 107 '@type' => 'Answer',
106 108 'text' => $this->helpers->schema->html->sanitize( $question['jsonAnswer'] ),
107 109 ];
108 110
109 - $data = $this->helpers->schema->language->add_piece_language( $data );
110 -
111 - return $data;
111 + return $this->helpers->schema->language->add_piece_language( $data );
112 112 }
113 113 }