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/FrontEnd/SearchExtender.php +8 -0 4.5.44.9.2 View file →
@@ -1,8 +1,12 @@
1 1 <?php
2 2
3 3 namespace WPDeveloper\BetterDocs\FrontEnd;
4 4
5 +if ( ! defined( 'ABSPATH' ) ) {
6 + exit;
7 +}
8 +
5 9 /**
6 10 * Extends WordPress search SQL on `docs` queries to also match docs whose
7 11 * assigned `doc_tag` or `doc_category` term names contain the search term.
8 12 *
@@ -50,8 +54,11 @@
50 54 $placeholders = implode( ',', array_fill( 0, count( $taxonomies ), '%s' ) );
51 55 $args = $taxonomies;
52 56 $args[] = $like;
53 57
58 + // $placeholders is a generated run of %s tokens bound via $args below; all
59 + // interpolated identifiers are $wpdb core table names, not user input.
60 + // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
54 61 $subquery = $wpdb->prepare(
55 62 "{$wpdb->posts}.ID IN (
56 63 SELECT DISTINCT tr.object_id
57 64 FROM {$wpdb->term_relationships} tr
@@ -60,8 +67,9 @@
60 67 WHERE tt.taxonomy IN ({$placeholders}) AND t.name LIKE %s
61 68 )",
62 69 $args
63 70 );
71 + // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared
64 72
65 73 return preg_replace( '/^\s*AND\s*\(/', " AND ({$subquery} OR ", $search, 1 );
66 74 }
67 75 }