| @@ -25,8 +25,17 @@ | ||
| 25 | 25 | * ThinkRank is actually publishing a FAQPage for the post. The third can be |
| 26 | 26 | * false while the first two are healthy, because the content type has Schema |
| 27 | 27 | * switched off, or because another plugin on the page already publishes its own |
| 28 | 28 | * FAQPage and ThinkRank stands down rather than emit a second one. |
| 29 | + * | |
| 30 | + * `builder` answers which surface, and it has to be able to say more than | |
| 31 | + * "none". Oxygen reported as `none`, which is also what the block editor | |
| 32 | + * reports, so the post came back writable and an agent following that at face | |
| 33 | + * value had `update-faq` store a block Oxygen never renders (#831). Oxygen and | |
| 34 | + * Breakdance are now named, their own accordions are read in place of the FAQ | |
| 35 | + * module they do not have, and `writable_reason` plus `questions_readable` keep | |
| 36 | + * "cannot be written" apart from "cannot be read" — a post can be the first | |
| 37 | + * without being the second. | |
| 29 | 38 | */ |
| 30 | 39 | class Get_FAQ extends FAQ_Ability_Base { |
| 31 | 40 | |
| 32 | 41 | /** |
| @@ -34,9 +43,9 @@ | ||
| 34 | 43 | */ |
| 35 | 44 | public function __construct() { |
| 36 | 45 | $this->id = 'thinkrank/get-faq'; |
| 37 | 46 | $this->label = __( 'Get ThinkRank FAQ', 'thinkrank' ); |
| 38 | - $this->description = __( 'Read the FAQ questions and answers on one post, where they are stored (the ThinkRank FAQ block, or the Elementor, Bricks or Beaver module), and whether ThinkRank is publishing FAQPage schema for the post. Call this before update-faq: it reports which builder renders the post, and update-faq can only write posts built with the block editor. Note that Google shows FAQ rich results only for well-known, authoritative government and health websites, so for most sites the value of an FAQ is being quotable by answer engines, not a rich result.', 'thinkrank' ); | |
| 47 | + $this->description = __( 'Read the FAQ questions and answers on one post, where they are stored (the ThinkRank FAQ block, or the Elementor, Bricks or Beaver module), and whether ThinkRank is publishing FAQPage schema for the post. Call this before update-faq: it reports which builder renders the post, and update-faq can only write posts built with the block editor. Read writable_reason before acting on a post that is not writable, and questions_readable before trusting the question count. Oxygen and Breakdance pages have no ThinkRank FAQ module, so their own accordions are read instead and reported with source oxygen or breakdance; those questions reach FAQPage schema only while the accordion setting in Schema Settings is on, which it is not by default. Note that Google shows FAQ rich results only for well-known, authoritative government and health websites, so for most sites the value of an FAQ is being quotable by answer engines, not a rich result.', 'thinkrank' ); | |
| 39 | 48 | } |
| 40 | 49 | |
| 41 | 50 | /** |
| 42 | 51 | * {@inheritDoc} |
| @@ -80,28 +89,36 @@ | ||
| 80 | 89 | public function get_output_schema() { |
| 81 | 90 | return [ |
| 82 | 91 | 'type' => 'object', |
| 83 | 92 | 'properties' => [ |
| 84 | - 'post_id' => [ 'type' => 'integer' ], | |
| 85 | - 'post_title' => [ 'type' => 'string' ], | |
| 86 | - 'post_type' => [ 'type' => 'string' ], | |
| 87 | - 'permalink' => [ 'type' => 'string' ], | |
| 88 | - 'edit_url' => [ 'type' => 'string' ], | |
| 89 | - 'builder' => [ | |
| 93 | + 'post_id' => [ 'type' => 'integer' ], | |
| 94 | + 'post_title' => [ 'type' => 'string' ], | |
| 95 | + 'post_type' => [ 'type' => 'string' ], | |
| 96 | + 'permalink' => [ 'type' => 'string' ], | |
| 97 | + 'edit_url' => [ 'type' => 'string' ], | |
| 98 | + 'builder' => [ | |
| 90 | 99 | 'type' => 'string', |
| 91 | 100 | 'enum' => $this->builder_enum(), |
| 92 | - 'description' => __( 'Which page builder renders this post. Anything but "none" means update-faq will refuse it.', 'thinkrank' ), | |
| 101 | + 'description' => __( 'Which page builder renders this post. Anything but "none" means update-faq will refuse it. "none" means the block editor, not "no builder was recognised".', 'thinkrank' ), | |
| 93 | 102 | ], |
| 94 | - 'writable' => [ | |
| 103 | + 'writable' => [ | |
| 95 | 104 | 'type' => 'boolean', |
| 96 | 105 | 'description' => __( 'True when update-faq can write this post. False for builder-rendered posts, where a block would be stored but never shown.', 'thinkrank' ), |
| 97 | 106 | ], |
| 98 | - 'faqpage_emitted' => [ | |
| 107 | + 'writable_reason' => [ | |
| 108 | + 'type' => 'string', | |
| 109 | + 'description' => __( 'Why update-faq will or will not write this post, in a sentence. Read this before deciding what to do with a post that is not writable: a builder ThinkRank has a FAQ module for is a different situation from one it only recognises.', 'thinkrank' ), | |
| 110 | + ], | |
| 111 | + 'questions_readable' => [ | |
| 99 | 112 | 'type' => 'boolean', |
| 113 | + 'description' => __( 'Whether ThinkRank can read the questions this post stores. False for a builder with no ThinkRank FAQ module, where total and items describe only what is left in the post content and a count of zero does not mean the page has no FAQ.', 'thinkrank' ), | |
| 114 | + ], | |
| 115 | + 'faqpage_emitted' => [ | |
| 116 | + 'type' => 'boolean', | |
| 100 | 117 | 'description' => __( 'Whether ThinkRank currently publishes FAQPage schema for this post. False with questions present means the post is password protected, the content type has Schema off, a producer has its schema toggle off, or another plugin already publishes its own FAQPage here.', 'thinkrank' ), |
| 101 | 118 | ], |
| 102 | - 'total' => [ 'type' => 'integer' ], | |
| 103 | - 'items' => [ | |
| 119 | + 'total' => [ 'type' => 'integer' ], | |
| 120 | + 'items' => [ | |
| 104 | 121 | 'type' => 'array', |
| 105 | 122 | 'items' => [ |
| 106 | 123 | 'type' => 'object', |
| 107 | 124 | 'properties' => $this->item_properties(), |
| @@ -125,20 +142,22 @@ | ||
| 125 | 142 | return $post; |
| 126 | 143 | } |
| 127 | 144 | |
| 128 | 145 | $items = FAQ_Content::items( $post ); |
| 129 | - $builder = $this->builder_name( (int) $post->ID ); | |
| 146 | + $builder = FAQ_Content::builder( (int) $post->ID ); | |
| 130 | 147 | |
| 131 | 148 | return [ |
| 132 | - 'post_id' => (int) $post->ID, | |
| 133 | - 'post_title' => (string) get_the_title( $post ), | |
| 134 | - 'post_type' => (string) $post->post_type, | |
| 135 | - 'permalink' => (string) get_permalink( $post ), | |
| 136 | - 'edit_url' => (string) get_edit_post_link( $post->ID, 'raw' ), | |
| 137 | - 'builder' => $builder, | |
| 138 | - 'writable' => 'none' === $builder, | |
| 139 | - 'faqpage_emitted' => Schema_Graph::will_emit_faqpage( $post ), | |
| 140 | - 'total' => count( $items ), | |
| 141 | - 'items' => $items, | |
| 149 | + 'post_id' => (int) $post->ID, | |
| 150 | + 'post_title' => (string) get_the_title( $post ), | |
| 151 | + 'post_type' => (string) $post->post_type, | |
| 152 | + 'permalink' => (string) get_permalink( $post ), | |
| 153 | + 'edit_url' => (string) get_edit_post_link( $post->ID, 'raw' ), | |
| 154 | + 'builder' => $this->builder_name( $builder ), | |
| 155 | + 'writable' => '' === $builder, | |
| 156 | + 'writable_reason' => $this->writable_reason( $builder ), | |
| 157 | + 'questions_readable' => FAQ_Content::builder_is_readable( $builder ), | |
| 158 | + 'faqpage_emitted' => Schema_Graph::will_emit_faqpage( $post ), | |
| 159 | + 'total' => count( $items ), | |
| 160 | + 'items' => $items, | |
| 142 | 161 | ]; |
| 143 | 162 | } |
| 144 | 163 | } |