PluginProbe
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO / 2.7.0
ThinkRank AI SEO – AI SEO Plugin for WordPress: Schema, XML Sitemaps, Meta Tags, Search Console & Local SEO v2.7.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 1.25.0 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.10.0 All 48 releases
← All changes | includes/api/class-pillar-content-endpoint.php +15 -0 1.10.02.7.0 View file →
@@ -19,8 +19,13 @@
19 19 use WP_REST_Response;
20 20 use WP_Query;
21 21 use WP_Error;
22 22
23 +// Prevent direct access
24 +if (!defined('ABSPATH')) {
25 + exit;
26 +}
27 +
23 28 /**
24 29 * Pillar Content API Endpoint Class
25 30 *
26 31 * @since 1.0.0
@@ -109,8 +114,9 @@
109 114 }
110 115
111 116 $taxonomies = get_object_taxonomies($post_type);
112 117 $tax_query = [];
118 + $has_terms = false;
113 119
114 120 if (!empty($taxonomies)) {
115 121 $tax_query['relation'] = 'OR';
116 122
@@ -129,12 +135,20 @@
129 135 }
130 136 }
131 137 }
132 138
139 + // Without this the query kept a tax_query holding nothing but
140 + // 'relation' => 'OR' whenever the post had no terms — $has_terms was
141 + // assigned and never read.
142 + if (!$has_terms) {
143 + $tax_query = [];
144 + }
145 +
133 146 $args = [
134 147 'post_type' => $post_type,
135 148 'posts_per_page' => 5,
136 149 'post__not_in' => [$post_id],
150 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- admin-only endpoint listing pillar posts; there is no taxonomy to key this on.
137 151 'meta_query' => [
138 152 [
139 153 'key' => '_thinkrank_pillar_content',
140 154 'value' => '1',
@@ -140,8 +154,9 @@
140 154 'value' => '1',
141 155 'compare' => '=',
142 156 ]
143 157 ],
158 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- admin-only endpoint, optional filter.
144 159 'tax_query' => $tax_query,
145 160 'fields' => 'ids'
146 161 ];
147 162