← All changes
|
includes/widgets/TB_Related_Posts/TB_Related_Posts.php
+14
-3
51.1.44
→
51.1.86
View file →
| @@ -47,9 +47,9 @@ | ||
| 47 | 47 | * @return string |
| 48 | 48 | */ |
| 49 | 49 | public function get_icon(): string |
| 50 | 50 | { |
| 51 | - return 'eicon-posts-grid'; | |
| 51 | + return 'king-addons-icon king-addons-tb-related-posts'; | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
| 55 | 55 | * Style dependencies. |
| @@ -77,9 +77,9 @@ | ||
| 77 | 77 | * @return array<int, string> |
| 78 | 78 | */ |
| 79 | 79 | public function get_categories(): array |
| 80 | 80 | { |
| 81 | - return ['king-addons']; | |
| 81 | + return ['king-addons-theme-builder']; | |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * Keywords. |
| @@ -90,9 +90,14 @@ | ||
| 90 | 90 | { |
| 91 | 91 | return ['related', 'posts', 'grid', 'theme builder', 'king-addons']; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - /** | |
| 94 | + public function get_custom_help_url() | |
| 95 | + { | |
| 96 | + return 'mailto:[email protected]?subject=Bug Report - King Addons&body=Please describe the issue'; | |
| 97 | + } | |
| 98 | + | |
| 99 | + /** | |
| 95 | 100 | * Register controls. |
| 96 | 101 | * |
| 97 | 102 | * @return void |
| 98 | 103 | */ |
| @@ -465,8 +470,9 @@ | ||
| 465 | 470 | $args['orderby'] = $orderby; |
| 466 | 471 | |
| 467 | 472 | $source = $settings['kng_source'] ?? 'categories'; |
| 468 | 473 | $tax_query = []; |
| 474 | + $needs_terms = in_array($source, ['categories', 'tags', 'taxonomy'], true); | |
| 469 | 475 | if ('categories' === $source) { |
| 470 | 476 | $terms = wp_get_post_categories($post->ID); |
| 471 | 477 | if (!empty($terms)) { |
| 472 | 478 | $tax_query[] = [ |
| @@ -497,8 +503,13 @@ | ||
| 497 | 503 | } |
| 498 | 504 | |
| 499 | 505 | if (!empty($tax_query)) { |
| 500 | 506 | $args['tax_query'] = $tax_query; |
| 507 | + } elseif ($needs_terms) { | |
| 508 | + // No matching terms is “nothing related”, not “every other post”. | |
| 509 | + // Without this, fallback=hide never ran because the unfiltered query | |
| 510 | + // always found latest posts. | |
| 511 | + $args['post__in'] = [0]; | |
| 501 | 512 | } |
| 502 | 513 | |
| 503 | 514 | return new WP_Query($args); |
| 504 | 515 | } |