PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.14.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.14.0
2.14.0 2.13.0 2.12.0 2.11.0 2.10.0 2.9.0 2.8.0 2.7.0 2.6.0 2.5.0 2.4.0 2.3.0 2.2.0 2.1.1 2.1.0 2.0.2 2.0.1 2.0.0 1.32.0 1.31.0 1.30.0 1.29.0 1.28.0 1.27.0 1.26.0 All 55 releases
← All changes | includes/abilities/content/class-faq-ability-base.php +80 -17 2.11.0 → 2.14.0 View file →
@@ -69,15 +69,13 @@
69 69 'description' => __( 'The answer as stored. May contain inline HTML, which the block renders.', 'thinkrank' ),
70 70 ],
71 71 'source' => [
72 72 'type' => 'string',
73 - 'enum' => [
74 - FAQ_Content::SOURCE_BLOCK,
75 - FAQ_Content::SOURCE_ELEMENTOR,
76 - FAQ_Content::SOURCE_BRICKS,
77 - FAQ_Content::SOURCE_BEAVER,
78 - ],
79 - 'description' => __( 'Which editor surface holds this question. Only block items can be written by update-faq.', 'thinkrank' ),
73 + 'enum' => array_merge(
74 + [ FAQ_Content::SOURCE_BLOCK ],
75 + FAQ_Content::builders()
76 + ),
77 + 'description' => __( 'Which editor surface holds this question. Only block items can be written by update-faq. An oxygen or breakdance item comes from that builder\'s own accordion rather than a ThinkRank module, so it contributes to FAQPage only while the accordion setting is on.', 'thinkrank' ),
80 78 ],
81 79 'schema_enabled' => [
82 80 'type' => 'boolean',
83 81 'description' => __( 'False when that producer has its schema toggle off, so the question is on the page but contributes nothing to FAQPage.', 'thinkrank' ),
@@ -88,16 +86,18 @@
88 86 ];
89 87 }
90 88
91 89 /**
92 - * Which builder renders this post, in the shape the schema reports.
90 + * A builder name in the shape the output schema reports.
93 91 *
94 - * @param int $post_id Post ID.
92 + * Takes the detected value rather than a post ID so a caller detects once
93 + * and reports, instead of asking twice and risking two answers.
94 + *
95 + * @since 2.14.0 Takes the builder, not the post ID.
96 + * @param string $builder Builder name from {@see FAQ_Content::builder()}.
95 97 * @return string One of the builder names, or 'none' for the block editor.
96 98 */
97 - protected function builder_name( int $post_id ): string {
98 - $builder = FAQ_Content::builder( $post_id );
99 -
99 + protected function builder_name( string $builder ): string {
100 100 return '' === $builder ? 'none' : $builder;
101 101 }
102 102
103 103 /**
@@ -102,15 +102,78 @@
102 102
103 103 /**
104 104 * The builder names a post can report.
105 105 *
106 + * Derived from `FAQ_Content` rather than listed here. The list was written
107 + * out by hand and then fell behind the detection it describes, so Oxygen had
108 + * no member to report even once it was detected (#831).
109 + *
106 110 * @return string[]
107 111 */
108 112 protected function builder_enum(): array {
109 - return [
110 - 'none',
111 - FAQ_Content::SOURCE_ELEMENTOR,
112 - FAQ_Content::SOURCE_BRICKS,
113 - FAQ_Content::SOURCE_BEAVER,
113 + return array_merge( [ 'none' ], FAQ_Content::builders() );
114 + }
115 +
116 + /**
117 + * A readable name for a builder, for the messages an agent reads.
118 + *
119 + * @since 2.14.0
120 + * @param string $builder Builder key.
121 + * @return string
122 + */
123 + protected function builder_label( string $builder ): string {
124 + $labels = [
125 + FAQ_Content::SOURCE_ELEMENTOR => __( 'Elementor', 'thinkrank' ),
126 + FAQ_Content::SOURCE_BRICKS => __( 'Bricks', 'thinkrank' ),
127 + FAQ_Content::SOURCE_BEAVER => __( 'Beaver Builder', 'thinkrank' ),
128 + FAQ_Content::BUILDER_OXYGEN => __( 'Oxygen', 'thinkrank' ),
129 + FAQ_Content::BUILDER_BREAKDANCE => __( 'Breakdance', 'thinkrank' ),
114 130 ];
131 +
132 + return $labels[ $builder ] ?? $builder;
133 + }
134 +
135 + /**
136 + * Why `update-faq` will or will not write this post.
137 + *
138 + * Four answers, because an agent that cannot tell them apart gives bad
139 + * advice. The block editor renders `post_content`, so the write is safe. A
140 + * builder with a ThinkRank FAQ module renders something else, and the
141 + * questions belong in that module. Oxygen and Breakdance have no module, but
142 + * their own accordion is read, so the questions are real and editable in the
143 + * builder — and whether they reach the FAQPage is a site setting rather than
144 + * a per-element toggle, which the caller has to be told. A builder that is
145 + * recognised and not readable at all is the fourth, where a question count of
146 + * zero means "nothing readable here" rather than "no FAQ" (#831).
147 + *
148 + * @since 2.14.0
149 + * @param string $builder Builder name, or '' for the block editor.
150 + * @return string
151 + */
152 + protected function writable_reason( string $builder ): string {
153 + if ( '' === $builder ) {
154 + return __( 'The block editor renders this post, so update-faq can write a FAQ block into its content.', 'thinkrank' );
155 + }
156 +
157 + if ( FAQ_Content::builder_has_module( $builder ) ) {
158 + return sprintf(
159 + /* translators: %s: page builder name. */
160 + __( '%s renders this post and replaces its content, so a FAQ block written here would never be shown. Add the questions with the ThinkRank FAQ module for that builder; get-faq reads the questions already stored there, and they reach the FAQPage.', 'thinkrank' ),
161 + $this->builder_label( $builder )
162 + );
163 + }
164 +
165 + if ( FAQ_Content::builder_is_readable( $builder ) ) {
166 + return sprintf(
167 + /* translators: %s: page builder name. */
168 + __( '%s renders this post and replaces its content, so a FAQ block written here would never be shown, and ThinkRank has no FAQ module for it. Its own accordion is read instead, and the questions above are what that accordion holds. Edit them in the builder. They reach the FAQPage only while Publish FAQ schema from page-builder accordions is on in Schema Settings, which is off by default.', 'thinkrank' ),
169 + $this->builder_label( $builder )
170 + );
171 + }
172 +
173 + return sprintf(
174 + /* translators: %s: page builder name. */
175 + __( '%s renders this post and replaces its content, so a FAQ block written here would never be shown. ThinkRank has no FAQ module for it and cannot read its stored questions either, so this post is recognised but unsupported: add the questions with the builder\'s own accordion, and read a question count of zero as "not readable" rather than "no FAQ".', 'thinkrank' ),
176 + $this->builder_label( $builder )
177 + );
115 178 }
116 179 }