| @@ -10,8 +10,9 @@ | ||
| 10 | 10 | * @package PropertyHive/Classes |
| 11 | 11 | * @category Class |
| 12 | 12 | * @author PropertyHive |
| 13 | 13 | */ |
| 14 | +// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Preserve the existing public PH_Template_Loader class name for plugin and extension compatibility. | |
| 14 | 15 | class PH_Template_Loader { |
| 15 | 16 | |
| 16 | 17 | /** |
| 17 | 18 | * Constructor |
| @@ -73,8 +74,9 @@ | ||
| 73 | 74 | 'fields' => 'ids', |
| 74 | 75 | 'no_found_rows' => true, |
| 75 | 76 | 'update_post_meta_cache' => false, |
| 76 | 77 | 'update_post_term_cache' => false, |
| 78 | + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Divi template lookup uses posts_per_page=1, fields=ids, no_found_rows and cache suppression. Fixed builder metadata predicates; one template is enough for the Divi branch. | |
| 77 | 79 | 'meta_query' => array( |
| 78 | 80 | array( |
| 79 | 81 | 'key' => '_et_enabled', |
| 80 | 82 | 'value' => '1', |
| @@ -110,17 +112,20 @@ | ||
| 110 | 112 | { |
| 111 | 113 | $template_query = new WP_Query( |
| 112 | 114 | array( |
| 113 | 115 | 'post_type' => BRICKS_DB_TEMPLATE_SLUG, |
| 116 | + 'posts_per_page' => -1, | |
| 114 | 117 | 'post_status' => 'publish', |
| 115 | 118 | 'fields' => 'ids', |
| 116 | 119 | 'no_found_rows' => true, |
| 117 | 120 | 'update_post_meta_cache' => false, |
| 118 | 121 | 'update_post_term_cache' => false, |
| 122 | + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Bricks stores template types in metadata; inspect every candidate of the correct type because its property assignment is stored separately in template conditions. | |
| 119 | 123 | 'meta_query' => array( |
| 120 | 124 | array( |
| 121 | 125 | 'key' => '_bricks_template_type', |
| 122 | - 'compare' => 'content', | |
| 126 | + 'value' => 'content', | |
| 127 | + 'compare' => '=', | |
| 123 | 128 | ), |
| 124 | 129 | ), |
| 125 | 130 | ) |
| 126 | 131 | ); |
| @@ -238,17 +243,20 @@ | ||
| 238 | 243 | { |
| 239 | 244 | $template_query = new WP_Query( |
| 240 | 245 | array( |
| 241 | 246 | 'post_type' => BRICKS_DB_TEMPLATE_SLUG, |
| 247 | + 'posts_per_page' => -1, | |
| 242 | 248 | 'post_status' => 'publish', |
| 243 | 249 | 'fields' => 'ids', |
| 244 | 250 | 'no_found_rows' => true, |
| 245 | 251 | 'update_post_meta_cache' => false, |
| 246 | 252 | 'update_post_term_cache' => false, |
| 253 | + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Bricks stores template types in metadata; inspect every candidate of the correct type because its property assignment is stored separately in template conditions. | |
| 247 | 254 | 'meta_query' => array( |
| 248 | 255 | array( |
| 249 | 256 | 'key' => '_bricks_template_type', |
| 250 | - 'compare' => 'archive', | |
| 257 | + 'value' => 'archive', | |
| 258 | + 'compare' => '=', | |
| 251 | 259 | ), |
| 252 | 260 | ), |
| 253 | 261 | ) |
| 254 | 262 | ); |
| @@ -271,8 +279,9 @@ | ||
| 271 | 279 | { |
| 272 | 280 | if ( |
| 273 | 281 | isset($templateCondition['main']) && |
| 274 | 282 | $templateCondition['main'] == 'archiveType' && |
| 283 | + isset($templateCondition['archiveType'], $templateCondition['archivePostTypes']) && | |
| 275 | 284 | is_array($templateCondition['archiveType']) && |
| 276 | 285 | in_array('postType', $templateCondition['archiveType']) && |
| 277 | 286 | is_array($templateCondition['archivePostTypes']) && |
| 278 | 287 | in_array('property', $templateCondition['archivePostTypes']) |
| @@ -283,8 +292,9 @@ | ||
| 283 | 292 | } |
| 284 | 293 | } |
| 285 | 294 | } |
| 286 | 295 | } |
| 296 | + wp_reset_postdata(); | |
| 287 | 297 | } |
| 288 | 298 | |
| 289 | 299 | if ( $use_property_hive_template ) |
| 290 | 300 | { |
| @@ -310,5 +320,5 @@ | ||
| 310 | 320 | } |
| 311 | 321 | |
| 312 | 322 | } |
| 313 | 323 | |
| 314 | -new PH_Template_Loader(); | |
| 324 | +new PH_Template_Loader(); | |