PostResultsTrait.php
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
declare(strict_types=1);
namespace ACP\Sorting\Strategy;
trait PostResultsTrait
{
/**
* For backwards compatibility we need the method `get_results()`
* @depecated 6.3
*/
public function get_results(array $args = []): array
{
_deprecated_function(__METHOD__, '6.3');
global $wp_query;
if ( ! $wp_query) {
return [];
}
$vars = $wp_query->vars ?? [];
if (empty($vars['post_status'])) {
$vars['post_status'] = ['any'];
}
if (isset($vars['orderby'])) {
$vars['orderby'] = false;
}
$vars['post_status'] = apply_filters('acp/sorting/post_status', $vars['post_status'], $this);
$vars['no_found_rows'] = 1;
$vars['fields'] = 'ids';
$vars['posts_per_page'] = -1;
$vars['order'] = 'ASC';
$vars['posts_per_archive_page'] = '';
$vars['nopaging'] = true;
$args = array_merge($args, $vars);
return get_posts($args);
}
}