PluginProbe
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot / 4.9.2
BetterDocs – AI Documentation, Knowledge Base, MCP Server, Docs, Wikis, FAQ & Chatbot v4.9.2
4.9.2 4.9.1 4.9.0 4.8.2 4.8.1 4.8.0 4.7.0 4.6.2 4.6.1 4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 4.5.1 4.5.0 4.4.1 4.4.0 3.3.4 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 All 200 releases
← All changes | includes/Editors/BlockEditor/Blocks/FAQ.php +22 -6 4.6.14.9.2 View file →
@@ -46,8 +46,9 @@
46 46 'faqSectionText' => 'Frequently Asked Questions',
47 47 'faqSectionTitleTag' => 'h2',
48 48 'faqGroupTitleTag' => 'h3',
49 49 'faqSectionTitleColor' => null,
50 + // JSON string of `[{value:int, label:string}]`; a bare id array (`[5]`) is also accepted since 4.9.0.
50 51 'includeFaqGroup' => '',
51 52 'excludeFaqGroup' => '',
52 53 'faqGroupTitleColor' => null,
53 54 'faqGroupTitleHoverColor' => null,
@@ -96,16 +97,31 @@
96 97 $renderer->suppress_auto_placement();
97 98 $renderer->render_for_product( $product_id, $this->attributes['faqLayout'] ?? null );
98 99 }
99 100
101 + /**
102 + * Flatten a group-selection attribute into a comma separated list of term ids.
103 + *
104 + * The attribute is a JSON string. The editor writes
105 + * `[{"value":5,"label":"Install"}]`; REST clients and other programmatic
106 + * writers commonly write the bare form `[5]`. Both are accepted — before
107 + * 4.9.0 the bare form flattened to an empty string, which
108 + * `Query::faq_terms_query_args()` reads as "no filter", so every group
109 + * rendered and the block warned on every view.
110 + *
111 + * @since 4.9.0 Bare ids are accepted alongside `{ value, label }` objects;
112 + * ids are cast with `absint()` and de-duplicated.
113 + *
114 + * @param mixed $json JSON encoded list of term ids or `{ value, label }` objects.
115 + *
116 + * @return string Comma separated term ids, or '' when there is nothing to filter by.
117 + */
100 118 public function get_groups_ids( $json ) {
101 - $data = json_decode( $json, true );
102 - $ids = '';
103 - if ( $data !== null ) {
104 - $ids = implode( ',', array_column( $data, 'value' ) );
105 - }
119 + $data = is_string( $json ) ? json_decode( $json, true ) : $json;
120 + $ids = array_filter( self::normalize_id_list( $data ), 'is_numeric' );
121 + $ids = array_unique( array_map( 'absint', $ids ) );
106 122
107 - return $ids;
123 + return implode( ',', $ids );
108 124 }
109 125
110 126 public function view_params() {
111 127 $attributes = &$this->attributes;