PluginProbe
Meow Gallery / 5.5.5
Meow Gallery v5.5.5
5.5.5 5.5.4 5.5.3 5.5.2 5.5.1 5.5.0 5.4.9 5.4.8 5.4.7 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 All 157 releases
← All changes | classes/orderby.php +42 -8 4.2.45.5.5 View file →
@@ -5,18 +5,52 @@
5 5 public $admin = null;
6 6
7 7 static function run( $images, $orderby = null, $order = 'asc' ) {
8 8 $sqlOrderBy = '';
9 + $order = strtolower( $order );
9 10
10 11 // Check params
11 - if ( $orderby === 'ids' ) {
12 - $images = $order === 'asc' ? sort( $images ) : rsort( $images );
13 - }
14 - else if ( $orderby === 'title' ) {
15 - $sqlOrderBy = $order === 'asc' ? ' ORDER BY p.post_title ASC' : ' ORDER BY p.post_title DESC';
16 - }
17 - else if ( $orderby === 'date' ) {
18 - $sqlOrderBy = $order === 'asc' ? ' ORDER BY p.post_date ASC' : ' ORDER BY p.post_date DESC';
12 + switch ( $orderby ) {
13 + case 'ids':
14 + $order === 'asc' ? sort( $images ) : rsort( $images );
15 + break;
16 +
17 + case 'random':
18 + shuffle( $images );
19 + return $images;
20 + break;
21 +
22 + case 'date':
23 + $sqlOrderBy = $order === 'asc'
24 + ? ' ORDER BY p.post_date ASC'
25 + : ' ORDER BY p.post_date DESC';
26 + break;
27 +
28 + case 'modified':
29 + $sqlOrderBy = $order === 'asc'
30 + ? ' ORDER BY p.post_modified ASC'
31 + : ' ORDER BY p.post_modified DESC';
32 + break;
33 +
34 + case 'filename':
35 + case 'title':
36 + $sqlOrderBy = $order === 'asc'
37 + ? ' ORDER BY p.post_title ASC'
38 + : ' ORDER BY p.post_title DESC';
39 + break;
40 +
41 + case 'menu':
42 + $sqlOrderBy = $order === 'asc'
43 + ? ' ORDER BY p.menu_order ASC'
44 + : ' ORDER BY p.menu_order DESC';
45 + break;
46 +
47 + case 'none':
48 + return $images;
49 +
50 + default:
51 + // no ordering
52 + break;
19 53 }
20 54
21 55 // Apply sort
22 56 if ( !empty( $sqlOrderBy ) ) {