@@ -19,40 +19,40 @@ discard block |
||
19 | 19 | |
20 | 20 | public function testPostTypeArgsAreCorrect() { |
21 | 21 | |
22 | - $this->assertEquals( 'hello', $this->cpts['hello']->post_type ); |
|
23 | - $this->assertEquals( 'hellos', $this->cpts['hello']->post_slug ); |
|
24 | - $this->assertEquals( 'Hello', $this->cpts['hello']->post_singular ); |
|
25 | - $this->assertEquals( 'Hellos', $this->cpts['hello']->post_plural ); |
|
26 | - $this->assertEquals( 'hello', $this->cpts['hello']->post_singular_low ); |
|
27 | - $this->assertEquals( 'hellos', $this->cpts['hello']->post_plural_low ); |
|
28 | - |
|
29 | - $this->assertEquals( 'person', $this->cpts['person']->post_type ); |
|
30 | - $this->assertEquals( 'people', $this->cpts['person']->post_slug ); |
|
31 | - $this->assertEquals( 'Person', $this->cpts['person']->post_singular ); |
|
32 | - $this->assertEquals( 'People', $this->cpts['person']->post_plural ); |
|
33 | - $this->assertEquals( 'person', $this->cpts['person']->post_singular_low ); |
|
34 | - $this->assertEquals( 'people', $this->cpts['person']->post_plural_low ); |
|
35 | - |
|
36 | - $this->assertEquals( 'nice-thing', $this->cpts['nice-thing']->post_type ); |
|
37 | - $this->assertEquals( 'things', $this->cpts['nice-thing']->post_slug ); |
|
38 | - $this->assertEquals( 'Nice Thing', $this->cpts['nice-thing']->post_singular ); |
|
39 | - $this->assertEquals( 'Nice Things', $this->cpts['nice-thing']->post_plural ); |
|
40 | - $this->assertEquals( 'nice thing', $this->cpts['nice-thing']->post_singular_low ); |
|
41 | - $this->assertEquals( 'nice things', $this->cpts['nice-thing']->post_plural_low ); |
|
42 | - |
|
43 | - $this->assertEquals( 'foo', $this->cpts['foo']->post_type ); |
|
44 | - $this->assertEquals( 'foos', $this->cpts['foo']->post_slug ); |
|
45 | - $this->assertEquals( 'Bar', $this->cpts['foo']->post_singular ); |
|
46 | - $this->assertEquals( 'Bars', $this->cpts['foo']->post_plural ); |
|
47 | - $this->assertEquals( 'bar', $this->cpts['foo']->post_singular_low ); |
|
48 | - $this->assertEquals( 'bars', $this->cpts['foo']->post_plural_low ); |
|
49 | - |
|
50 | - $this->assertEquals( 'bar', $this->cpts['bar']->post_type ); |
|
51 | - $this->assertEquals( 'slug', $this->cpts['bar']->post_slug ); |
|
52 | - $this->assertEquals( 'Singular', $this->cpts['bar']->post_singular ); |
|
53 | - $this->assertEquals( 'Plural', $this->cpts['bar']->post_plural ); |
|
54 | - $this->assertEquals( 'singular', $this->cpts['bar']->post_singular_low ); |
|
55 | - $this->assertEquals( 'plural', $this->cpts['bar']->post_plural_low ); |
|
22 | + $this->assertEquals( 'hello', $this->cpts[ 'hello' ]->post_type ); |
|
23 | + $this->assertEquals( 'hellos', $this->cpts[ 'hello' ]->post_slug ); |
|
24 | + $this->assertEquals( 'Hello', $this->cpts[ 'hello' ]->post_singular ); |
|
25 | + $this->assertEquals( 'Hellos', $this->cpts[ 'hello' ]->post_plural ); |
|
26 | + $this->assertEquals( 'hello', $this->cpts[ 'hello' ]->post_singular_low ); |
|
27 | + $this->assertEquals( 'hellos', $this->cpts[ 'hello' ]->post_plural_low ); |
|
28 | + |
|
29 | + $this->assertEquals( 'person', $this->cpts[ 'person' ]->post_type ); |
|
30 | + $this->assertEquals( 'people', $this->cpts[ 'person' ]->post_slug ); |
|
31 | + $this->assertEquals( 'Person', $this->cpts[ 'person' ]->post_singular ); |
|
32 | + $this->assertEquals( 'People', $this->cpts[ 'person' ]->post_plural ); |
|
33 | + $this->assertEquals( 'person', $this->cpts[ 'person' ]->post_singular_low ); |
|
34 | + $this->assertEquals( 'people', $this->cpts[ 'person' ]->post_plural_low ); |
|
35 | + |
|
36 | + $this->assertEquals( 'nice-thing', $this->cpts[ 'nice-thing' ]->post_type ); |
|
37 | + $this->assertEquals( 'things', $this->cpts[ 'nice-thing' ]->post_slug ); |
|
38 | + $this->assertEquals( 'Nice Thing', $this->cpts[ 'nice-thing' ]->post_singular ); |
|
39 | + $this->assertEquals( 'Nice Things', $this->cpts[ 'nice-thing' ]->post_plural ); |
|
40 | + $this->assertEquals( 'nice thing', $this->cpts[ 'nice-thing' ]->post_singular_low ); |
|
41 | + $this->assertEquals( 'nice things', $this->cpts[ 'nice-thing' ]->post_plural_low ); |
|
42 | + |
|
43 | + $this->assertEquals( 'foo', $this->cpts[ 'foo' ]->post_type ); |
|
44 | + $this->assertEquals( 'foos', $this->cpts[ 'foo' ]->post_slug ); |
|
45 | + $this->assertEquals( 'Bar', $this->cpts[ 'foo' ]->post_singular ); |
|
46 | + $this->assertEquals( 'Bars', $this->cpts[ 'foo' ]->post_plural ); |
|
47 | + $this->assertEquals( 'bar', $this->cpts[ 'foo' ]->post_singular_low ); |
|
48 | + $this->assertEquals( 'bars', $this->cpts[ 'foo' ]->post_plural_low ); |
|
49 | + |
|
50 | + $this->assertEquals( 'bar', $this->cpts[ 'bar' ]->post_type ); |
|
51 | + $this->assertEquals( 'slug', $this->cpts[ 'bar' ]->post_slug ); |
|
52 | + $this->assertEquals( 'Singular', $this->cpts[ 'bar' ]->post_singular ); |
|
53 | + $this->assertEquals( 'Plural', $this->cpts[ 'bar' ]->post_plural ); |
|
54 | + $this->assertEquals( 'singular', $this->cpts[ 'bar' ]->post_singular_low ); |
|
55 | + $this->assertEquals( 'plural', $this->cpts[ 'bar' ]->post_plural_low ); |
|
56 | 56 | |
57 | 57 | } |
58 | 58 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | $this->assertTrue( $hello->public ); |
64 | 64 | $this->assertTrue( $hello->hierarchical ); |
65 | 65 | $this->assertTrue( $hello->has_archive ); |
66 | - $this->assertEquals( 'hi', $hello->query_var ); |
|
66 | + $this->assertEquals( 'hi', $hello->query_var ); |
|
67 | 67 | $this->assertEquals( 'page', $hello->capability_type ); |
68 | 68 | |
69 | 69 | $bar = get_post_type_object( 'bar' ); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->assertFalse( $bar->has_archive ); |
74 | 74 | $this->assertFalse( $bar->rewrite ); |
75 | 75 | // This should be boolean false, but it's not: |
76 | - $this->assertEquals( 'bar', $bar->query_var ); |
|
76 | + $this->assertEquals( 'bar', $bar->query_var ); |
|
77 | 77 | $this->assertEquals( 'page', $bar->capability_type ); |
78 | 78 | |
79 | 79 | $baz = get_post_type_object( 'baz' ); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | $this->assertTrue( $baz->hierarchical ); |
83 | 83 | $this->assertFalse( $baz->has_archive ); |
84 | 84 | $this->assertEquals( 'page', $baz->capability_type ); |
85 | - $this->assertEquals( 'baz', $baz->query_var ); |
|
85 | + $this->assertEquals( 'baz', $baz->query_var ); |
|
86 | 86 | |
87 | 87 | } |
88 | 88 | |
@@ -126,49 +126,49 @@ discard block |
||
126 | 126 | |
127 | 127 | public function testArchiveLinksAreCorrect() { |
128 | 128 | |
129 | - $link = get_post_type_archive_link( $this->cpts['hello']->post_type ); |
|
129 | + $link = get_post_type_archive_link( $this->cpts[ 'hello' ]->post_type ); |
|
130 | 130 | $this->assertEquals( user_trailingslashit( home_url( 'hellos' ) ), $link ); |
131 | 131 | |
132 | - $link = get_post_type_archive_link( $this->cpts['person']->post_type ); |
|
132 | + $link = get_post_type_archive_link( $this->cpts[ 'person' ]->post_type ); |
|
133 | 133 | $this->assertEquals( user_trailingslashit( home_url( 'team' ) ), $link ); |
134 | 134 | |
135 | - $link = get_post_type_archive_link( $this->cpts['nice-thing']->post_type ); |
|
135 | + $link = get_post_type_archive_link( $this->cpts[ 'nice-thing' ]->post_type ); |
|
136 | 136 | $this->assertEquals( user_trailingslashit( home_url( 'things' ) ), $link ); |
137 | 137 | |
138 | - $link = get_post_type_archive_link( $this->cpts['foo']->post_type ); |
|
138 | + $link = get_post_type_archive_link( $this->cpts[ 'foo' ]->post_type ); |
|
139 | 139 | $this->assertEquals( user_trailingslashit( home_url( 'foos' ) ), $link ); |
140 | 140 | |
141 | - $link = get_post_type_archive_link( $this->cpts['bar']->post_type ); |
|
141 | + $link = get_post_type_archive_link( $this->cpts[ 'bar' ]->post_type ); |
|
142 | 142 | $this->assertFalse( $link ); |
143 | 143 | |
144 | - $link = get_post_type_archive_link( $this->cpts['baz']->post_type ); |
|
144 | + $link = get_post_type_archive_link( $this->cpts[ 'baz' ]->post_type ); |
|
145 | 145 | $this->assertFalse( $link ); |
146 | 146 | |
147 | 147 | } |
148 | 148 | |
149 | 149 | public function testPermalinksAreCorrect() { |
150 | 150 | |
151 | - $post = get_post( $this->posts['hello'][0] ); |
|
151 | + $post = get_post( $this->posts[ 'hello' ][ 0 ] ); |
|
152 | 152 | $link = get_permalink( $post ); |
153 | 153 | $this->assertEquals( user_trailingslashit( home_url( sprintf( 'hellos/%s', $post->post_name ) ) ), $link ); |
154 | 154 | |
155 | - $post = get_post( $this->posts['person'][0] ); |
|
155 | + $post = get_post( $this->posts[ 'person' ][ 0 ] ); |
|
156 | 156 | $link = get_permalink( $post ); |
157 | 157 | $this->assertEquals( user_trailingslashit( home_url( sprintf( 'people/%s', $post->post_name ) ) ), $link ); |
158 | 158 | |
159 | - $post = get_post( $this->posts['nice-thing'][0] ); |
|
159 | + $post = get_post( $this->posts[ 'nice-thing' ][ 0 ] ); |
|
160 | 160 | $link = get_permalink( $post ); |
161 | 161 | $this->assertEquals( user_trailingslashit( home_url( sprintf( 'things/%s', $post->post_name ) ) ), $link ); |
162 | 162 | |
163 | - $post = get_post( $this->posts['foo'][0] ); |
|
163 | + $post = get_post( $this->posts[ 'foo' ][ 0 ] ); |
|
164 | 164 | $link = get_permalink( $post ); |
165 | 165 | $this->assertEquals( user_trailingslashit( home_url( sprintf( 'foo/admin/delta/%s', $post->post_name ) ) ), $link ); |
166 | 166 | |
167 | - $post = get_post( $this->posts['bar'][0] ); |
|
167 | + $post = get_post( $this->posts[ 'bar' ][ 0 ] ); |
|
168 | 168 | $link = get_permalink( $post ); |
169 | 169 | $this->assertEquals( add_query_arg( 'bar', $post->post_name, user_trailingslashit( home_url() ) ), $link ); |
170 | 170 | |
171 | - $post = get_post( $this->posts['baz'][0] ); |
|
171 | + $post = get_post( $this->posts[ 'baz' ][ 0 ] ); |
|
172 | 172 | $link = get_permalink( $post ); |
173 | 173 | $this->assertEquals( user_trailingslashit( home_url( sprintf( 'baz/%s', $post->post_name ) ) ), $link ); |
174 | 174 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | |
11 | 11 | $this->assertEquals( 1, $query->found_posts ); |
12 | 12 | |
13 | - $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
13 | + $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
14 | 14 | $this->assertSame( 'DESC', $query->get( 'order' ) ); |
15 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
16 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
17 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
15 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
16 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
17 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
18 | 18 | |
19 | - $this->assertEquals( $this->posts['post'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
19 | + $this->assertEquals( $this->posts[ 'post' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | 'post_type' => 'hello', |
27 | 27 | ) ); |
28 | 28 | |
29 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
29 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
30 | 30 | |
31 | 31 | $this->assertSame( 'menu_order title', $query->get( 'orderby' ) ); |
32 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
33 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
34 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
35 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
32 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
33 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
34 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
35 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
36 | 36 | |
37 | - $this->assertEquals( $this->posts['hello'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
37 | + $this->assertEquals( $this->posts[ 'hello' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | 'order' => 'ASC', |
47 | 47 | ) ); |
48 | 48 | |
49 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
49 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
50 | 50 | |
51 | 51 | $this->assertSame( 'post_name', $query->get( 'orderby' ) ); |
52 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
53 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
54 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
55 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
52 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
53 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
54 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
55 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
56 | 56 | |
57 | 57 | $this->assertEquals( array( |
58 | - $this->posts['hello'][0], |
|
59 | - $this->posts['hello'][2], |
|
60 | - $this->posts['hello'][1], |
|
61 | - $this->posts['hello'][3], |
|
58 | + $this->posts[ 'hello' ][ 0 ], |
|
59 | + $this->posts[ 'hello' ][ 2 ], |
|
60 | + $this->posts[ 'hello' ][ 1 ], |
|
61 | + $this->posts[ 'hello' ][ 3 ], |
|
62 | 62 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
63 | 63 | |
64 | 64 | } |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | |
74 | 74 | $this->assertEquals( 3, $query->found_posts ); |
75 | 75 | |
76 | - $this->assertSame( 'meta_value', $query->get( 'orderby' ) ); |
|
77 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
76 | + $this->assertSame( 'meta_value', $query->get( 'orderby' ) ); |
|
77 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
78 | 78 | $this->assertSame( 'test_meta_key', $query->get( 'meta_key' ) ); |
79 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
80 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
79 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
80 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
81 | 81 | |
82 | 82 | $this->assertEquals( array( |
83 | - $this->posts['hello'][1], |
|
84 | - $this->posts['hello'][2], |
|
85 | - $this->posts['hello'][0], |
|
83 | + $this->posts[ 'hello' ][ 1 ], |
|
84 | + $this->posts[ 'hello' ][ 2 ], |
|
85 | + $this->posts[ 'hello' ][ 0 ], |
|
86 | 86 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
87 | 87 | |
88 | 88 | } |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | 'order' => 'ASC', |
96 | 96 | ) ); |
97 | 97 | |
98 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
98 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
99 | 99 | |
100 | 100 | $this->assertSame( 'name', $query->get( 'orderby' ) ); |
101 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
102 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
103 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
104 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
101 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
102 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
103 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
104 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
105 | 105 | |
106 | 106 | $this->assertEquals( array( |
107 | - $this->posts['hello'][0], |
|
108 | - $this->posts['hello'][2], |
|
109 | - $this->posts['hello'][1], |
|
110 | - $this->posts['hello'][3], |
|
107 | + $this->posts[ 'hello' ][ 0 ], |
|
108 | + $this->posts[ 'hello' ][ 2 ], |
|
109 | + $this->posts[ 'hello' ][ 1 ], |
|
110 | + $this->posts[ 'hello' ][ 3 ], |
|
111 | 111 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
112 | 112 | |
113 | 113 | } |
@@ -120,19 +120,19 @@ discard block |
||
120 | 120 | 'order' => 'DESC', |
121 | 121 | ) ); |
122 | 122 | |
123 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
123 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
124 | 124 | |
125 | 125 | $this->assertSame( 'test_admin_cols_taxonomy', $query->get( 'orderby' ) ); |
126 | - $this->assertSame( 'DESC', $query->get( 'order' ) ); |
|
127 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
128 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
129 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
126 | + $this->assertSame( 'DESC', $query->get( 'order' ) ); |
|
127 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
128 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
129 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
130 | 130 | |
131 | 131 | $this->assertEquals( array( |
132 | - $this->posts['hello'][3], |
|
133 | - $this->posts['hello'][0], |
|
134 | - $this->posts['hello'][2], |
|
135 | - $this->posts['hello'][1], |
|
132 | + $this->posts[ 'hello' ][ 3 ], |
|
133 | + $this->posts[ 'hello' ][ 0 ], |
|
134 | + $this->posts[ 'hello' ][ 2 ], |
|
135 | + $this->posts[ 'hello' ][ 1 ], |
|
136 | 136 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
137 | 137 | |
138 | 138 | } |
@@ -143,15 +143,15 @@ discard block |
||
143 | 143 | 'post_type' => 'person', |
144 | 144 | ) ); |
145 | 145 | |
146 | - $this->assertEquals( count( $this->posts['person'] ), $query->found_posts ); |
|
146 | + $this->assertEquals( count( $this->posts[ 'person' ] ), $query->found_posts ); |
|
147 | 147 | |
148 | 148 | $this->assertSame( 'menu_order title', $query->get( 'orderby' ) ); |
149 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
150 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
151 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
152 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
149 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
150 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
151 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
152 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
153 | 153 | |
154 | - $this->assertEquals( $this->posts['person'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
154 | + $this->assertEquals( $this->posts[ 'person' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
155 | 155 | |
156 | 156 | } |
157 | 157 |
@@ -10,13 +10,13 @@ discard block |
||
10 | 10 | |
11 | 11 | $this->assertEquals( 1, $query->found_posts ); |
12 | 12 | |
13 | - $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
13 | + $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
14 | 14 | $this->assertSame( 'DESC', $query->get( 'order' ) ); |
15 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
16 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
17 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
15 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
16 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
17 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
18 | 18 | |
19 | - $this->assertEquals( $this->posts['post'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
19 | + $this->assertEquals( $this->posts[ 'post' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
20 | 20 | |
21 | 21 | } |
22 | 22 | |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | 'post_type' => 'hello', |
27 | 27 | ) ); |
28 | 28 | |
29 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
29 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
30 | 30 | |
31 | - $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
31 | + $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
32 | 32 | $this->assertSame( 'DESC', $query->get( 'order' ) ); |
33 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
34 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
35 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
33 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
34 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
35 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
36 | 36 | |
37 | - $this->assertEquals( $this->posts['hello'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
37 | + $this->assertEquals( $this->posts[ 'hello' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
38 | 38 | |
39 | 39 | } |
40 | 40 | |
@@ -46,19 +46,19 @@ discard block |
||
46 | 46 | 'order' => 'ASC', |
47 | 47 | ) ); |
48 | 48 | |
49 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
49 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
50 | 50 | |
51 | 51 | $this->assertSame( 'post_name', $query->get( 'orderby' ) ); |
52 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
53 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
54 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
55 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
52 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
53 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
54 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
55 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
56 | 56 | |
57 | 57 | $this->assertEquals( array( |
58 | - $this->posts['hello'][0], |
|
59 | - $this->posts['hello'][2], |
|
60 | - $this->posts['hello'][1], |
|
61 | - $this->posts['hello'][3], |
|
58 | + $this->posts[ 'hello' ][ 0 ], |
|
59 | + $this->posts[ 'hello' ][ 2 ], |
|
60 | + $this->posts[ 'hello' ][ 1 ], |
|
61 | + $this->posts[ 'hello' ][ 3 ], |
|
62 | 62 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
63 | 63 | |
64 | 64 | } |
@@ -73,16 +73,16 @@ discard block |
||
73 | 73 | |
74 | 74 | $this->assertEquals( 3, $query->found_posts ); |
75 | 75 | |
76 | - $this->assertSame( 'meta_value', $query->get( 'orderby' ) ); |
|
77 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
76 | + $this->assertSame( 'meta_value', $query->get( 'orderby' ) ); |
|
77 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
78 | 78 | $this->assertSame( 'test_meta_key', $query->get( 'meta_key' ) ); |
79 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
80 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
79 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
80 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
81 | 81 | |
82 | 82 | $this->assertEquals( array( |
83 | - $this->posts['hello'][1], |
|
84 | - $this->posts['hello'][2], |
|
85 | - $this->posts['hello'][0], |
|
83 | + $this->posts[ 'hello' ][ 1 ], |
|
84 | + $this->posts[ 'hello' ][ 2 ], |
|
85 | + $this->posts[ 'hello' ][ 0 ], |
|
86 | 86 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
87 | 87 | |
88 | 88 | } |
@@ -95,19 +95,19 @@ discard block |
||
95 | 95 | 'order' => 'ASC', |
96 | 96 | ) ); |
97 | 97 | |
98 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
98 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
99 | 99 | |
100 | 100 | $this->assertSame( 'name', $query->get( 'orderby' ) ); |
101 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
102 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
103 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
104 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
101 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
102 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
103 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
104 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
105 | 105 | |
106 | 106 | $this->assertEquals( array( |
107 | - $this->posts['hello'][0], |
|
108 | - $this->posts['hello'][2], |
|
109 | - $this->posts['hello'][1], |
|
110 | - $this->posts['hello'][3], |
|
107 | + $this->posts[ 'hello' ][ 0 ], |
|
108 | + $this->posts[ 'hello' ][ 2 ], |
|
109 | + $this->posts[ 'hello' ][ 1 ], |
|
110 | + $this->posts[ 'hello' ][ 3 ], |
|
111 | 111 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
112 | 112 | |
113 | 113 | } |
@@ -120,19 +120,19 @@ discard block |
||
120 | 120 | 'order' => 'DESC', |
121 | 121 | ) ); |
122 | 122 | |
123 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
123 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
124 | 124 | |
125 | 125 | $this->assertSame( 'test_site_sortables_taxonomy', $query->get( 'orderby' ) ); |
126 | - $this->assertSame( 'DESC', $query->get( 'order' ) ); |
|
127 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
128 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
129 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
126 | + $this->assertSame( 'DESC', $query->get( 'order' ) ); |
|
127 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
128 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
129 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
130 | 130 | |
131 | 131 | $this->assertEquals( array( |
132 | - $this->posts['hello'][3], |
|
133 | - $this->posts['hello'][0], |
|
134 | - $this->posts['hello'][2], |
|
135 | - $this->posts['hello'][1], |
|
132 | + $this->posts[ 'hello' ][ 3 ], |
|
133 | + $this->posts[ 'hello' ][ 0 ], |
|
134 | + $this->posts[ 'hello' ][ 2 ], |
|
135 | + $this->posts[ 'hello' ][ 1 ], |
|
136 | 136 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
137 | 137 | |
138 | 138 | } |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | |
149 | 149 | $this->assertEquals( 1, $query->found_posts ); |
150 | 150 | |
151 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
152 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
153 | - $this->assertSame( 'test_meta_key', $meta_query[0]['key'] ); |
|
154 | - $this->assertSame( 'Alpha', $meta_query[0]['value'] ); |
|
151 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
152 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
153 | + $this->assertSame( 'test_meta_key', $meta_query[ 0 ][ 'key' ] ); |
|
154 | + $this->assertSame( 'Alpha', $meta_query[ 0 ][ 'value' ] ); |
|
155 | 155 | |
156 | 156 | $this->assertEquals( array( |
157 | - $this->posts['hello'][1], |
|
157 | + $this->posts[ 'hello' ][ 1 ], |
|
158 | 158 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
159 | 159 | |
160 | 160 | } |
@@ -177,11 +177,11 @@ discard block |
||
177 | 177 | 'value' => 'B', |
178 | 178 | 'compare' => '>=', |
179 | 179 | 'type' => 'CHAR', |
180 | - ), $meta_query[0] ); |
|
180 | + ), $meta_query[ 0 ] ); |
|
181 | 181 | |
182 | 182 | $this->assertEquals( array( |
183 | - $this->posts['hello'][0], |
|
184 | - $this->posts['hello'][2], |
|
183 | + $this->posts[ 'hello' ][ 0 ], |
|
184 | + $this->posts[ 'hello' ][ 2 ], |
|
185 | 185 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
186 | 186 | |
187 | 187 | } |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $this->assertSame( '', $query->get( 'meta_value' ) ); |
200 | 200 | $this->assertEmpty( $meta_query ); |
201 | 201 | |
202 | - $this->assertEquals( $this->posts['hello'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
202 | + $this->assertEquals( $this->posts[ 'hello' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
203 | 203 | |
204 | 204 | } |
205 | 205 | |
@@ -214,15 +214,15 @@ discard block |
||
214 | 214 | |
215 | 215 | $this->assertEquals( 2, $query->found_posts ); |
216 | 216 | |
217 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
218 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
219 | - $this->assertSame( 'test_meta_key', $meta_query[0]['key'] ); |
|
220 | - $this->assertSame( 'ta', $meta_query[0]['value'] ); |
|
221 | - $this->assertSame( 'LIKE', $meta_query[0]['compare'] ); |
|
217 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
218 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
219 | + $this->assertSame( 'test_meta_key', $meta_query[ 0 ][ 'key' ] ); |
|
220 | + $this->assertSame( 'ta', $meta_query[ 0 ][ 'value' ] ); |
|
221 | + $this->assertSame( 'LIKE', $meta_query[ 0 ][ 'compare' ] ); |
|
222 | 222 | |
223 | 223 | $this->assertEquals( array( |
224 | - $this->posts['hello'][0], |
|
225 | - $this->posts['hello'][2], |
|
224 | + $this->posts[ 'hello' ][ 0 ], |
|
225 | + $this->posts[ 'hello' ][ 2 ], |
|
226 | 226 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
227 | 227 | |
228 | 228 | } |
@@ -238,17 +238,17 @@ discard block |
||
238 | 238 | |
239 | 239 | $this->assertEquals( 3, $query->found_posts ); |
240 | 240 | |
241 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
242 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
243 | - $this->assertSame( 'test_meta_key', $meta_query[0]['key'] ); |
|
244 | - $this->assertSame( 'NOT IN', $meta_query[0]['compare'] ); |
|
241 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
242 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
243 | + $this->assertSame( 'test_meta_key', $meta_query[ 0 ][ 'key' ] ); |
|
244 | + $this->assertSame( 'NOT IN', $meta_query[ 0 ][ 'compare' ] ); |
|
245 | 245 | |
246 | - $this->assertEquals( array( '', '0', 'false', 'null' ), $meta_query[0]['value'] ); |
|
246 | + $this->assertEquals( array( '', '0', 'false', 'null' ), $meta_query[ 0 ][ 'value' ] ); |
|
247 | 247 | |
248 | 248 | $this->assertEquals( array( |
249 | - $this->posts['hello'][0], |
|
250 | - $this->posts['hello'][1], |
|
251 | - $this->posts['hello'][2], |
|
249 | + $this->posts[ 'hello' ][ 0 ], |
|
250 | + $this->posts[ 'hello' ][ 1 ], |
|
251 | + $this->posts[ 'hello' ][ 2 ], |
|
252 | 252 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
253 | 253 | |
254 | 254 | } |
@@ -260,15 +260,15 @@ discard block |
||
260 | 260 | 'test_site_filters_with_cap' => 'Alpha', |
261 | 261 | ) ); |
262 | 262 | |
263 | - $this->assertEquals( count( $this->posts['hello'] ), $query->found_posts ); |
|
263 | + $this->assertEquals( count( $this->posts[ 'hello' ] ), $query->found_posts ); |
|
264 | 264 | |
265 | - $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
265 | + $this->assertSame( '', $query->get( 'orderby' ) ); // date |
|
266 | 266 | $this->assertSame( 'DESC', $query->get( 'order' ) ); |
267 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
268 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
269 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
267 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
268 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
269 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
270 | 270 | |
271 | - $this->assertEquals( $this->posts['hello'], wp_list_pluck( $query->posts, 'ID' ) ); |
|
271 | + $this->assertEquals( $this->posts[ 'hello' ], wp_list_pluck( $query->posts, 'ID' ) ); |
|
272 | 272 | |
273 | 273 | } |
274 | 274 | |
@@ -278,17 +278,17 @@ discard block |
||
278 | 278 | 'post_type' => 'person', |
279 | 279 | ) ); |
280 | 280 | |
281 | - $this->assertEquals( count( $this->posts['person'] ), $query->found_posts ); |
|
281 | + $this->assertEquals( count( $this->posts[ 'person' ] ), $query->found_posts ); |
|
282 | 282 | |
283 | 283 | $this->assertSame( 'name', $query->get( 'orderby' ) ); |
284 | - $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
285 | - $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
286 | - $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
287 | - $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
284 | + $this->assertSame( 'ASC', $query->get( 'order' ) ); |
|
285 | + $this->assertSame( '', $query->get( 'meta_key' ) ); |
|
286 | + $this->assertSame( '', $query->get( 'meta_value' ) ); |
|
287 | + $this->assertSame( '', $query->get( 'meta_query' ) ); |
|
288 | 288 | |
289 | 289 | $this->assertEquals( array( |
290 | - $this->posts['person'][1], |
|
291 | - $this->posts['person'][0], |
|
290 | + $this->posts[ 'person' ][ 1 ], |
|
291 | + $this->posts[ 'person' ][ 0 ], |
|
292 | 292 | ), wp_list_pluck( $query->posts, 'ID' ) ); |
293 | 293 | |
294 | 294 | } |
@@ -97,11 +97,11 @@ discard block |
||
97 | 97 | 'capability_type' => 'page', |
98 | 98 | 'hierarchical' => true, |
99 | 99 | 'supports' => array( 'title', 'editor', 'thumbnail' ), |
100 | - 'site_filters' => null, # Custom arg |
|
101 | - 'site_sortables' => null, # Custom arg |
|
100 | + 'site_filters' => null, # Custom arg |
|
101 | + 'site_sortables' => null, # Custom arg |
|
102 | 102 | 'show_in_feed' => false, # Custom arg |
103 | - 'archive' => null, # Custom arg |
|
104 | - 'featured_image' => null, # Custom arg |
|
103 | + 'archive' => null, # Custom arg |
|
104 | + 'featured_image' => null, # Custom arg |
|
105 | 105 | ); |
106 | 106 | |
107 | 107 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @param array $args The post type arguments. |
135 | 135 | */ |
136 | - $args = apply_filters( "ext-cpts/{$post_type}/args", $args ); |
|
136 | + $args = apply_filters( "ext-cpts/{$post_type}/args", $args ); |
|
137 | 137 | /** |
138 | 138 | * Filter the names for this post type. |
139 | 139 | * |
@@ -143,22 +143,22 @@ discard block |
||
143 | 143 | */ |
144 | 144 | $names = apply_filters( "ext-cpts/{$post_type}/names", $names ); |
145 | 145 | |
146 | - if ( isset( $names['singular'] ) ) { |
|
147 | - $this->post_singular = $names['singular']; |
|
146 | + if ( isset( $names[ 'singular' ] ) ) { |
|
147 | + $this->post_singular = $names[ 'singular' ]; |
|
148 | 148 | } else { |
149 | 149 | $this->post_singular = ucwords( str_replace( array( '-', '_' ), ' ', $post_type ) ); |
150 | 150 | } |
151 | 151 | |
152 | - if ( isset( $names['slug'] ) ) { |
|
153 | - $this->post_slug = $names['slug']; |
|
154 | - } else if ( isset( $names['plural'] ) ) { |
|
155 | - $this->post_slug = $names['plural']; |
|
152 | + if ( isset( $names[ 'slug' ] ) ) { |
|
153 | + $this->post_slug = $names[ 'slug' ]; |
|
154 | + } else if ( isset( $names[ 'plural' ] ) ) { |
|
155 | + $this->post_slug = $names[ 'plural' ]; |
|
156 | 156 | } else { |
157 | 157 | $this->post_slug = $post_type . 's'; |
158 | 158 | } |
159 | 159 | |
160 | - if ( isset( $names['plural'] ) ) { |
|
161 | - $this->post_plural = $names['plural']; |
|
160 | + if ( isset( $names[ 'plural' ] ) ) { |
|
161 | + $this->post_plural = $names[ 'plural' ]; |
|
162 | 162 | } else { |
163 | 163 | $this->post_plural = $this->post_singular . 's'; |
164 | 164 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | # Build our labels: |
174 | 174 | # Why aren't these translatable? |
175 | 175 | # Answer: https://github.com/johnbillion/extended-cpts/pull/5#issuecomment-33756474 |
176 | - $this->defaults['labels'] = array( |
|
176 | + $this->defaults[ 'labels' ] = array( |
|
177 | 177 | 'name' => $this->post_plural, |
178 | 178 | 'singular_name' => $this->post_singular, |
179 | 179 | 'menu_name' => $this->post_plural, |
@@ -197,19 +197,19 @@ discard block |
||
197 | 197 | ); |
198 | 198 | |
199 | 199 | # Build the featured image labels: |
200 | - if ( isset( $args['featured_image'] ) ) { |
|
201 | - $featured_image_low = strtolower( $args['featured_image'] ); |
|
202 | - $this->defaults['labels']['featured_image'] = $args['featured_image']; |
|
203 | - $this->defaults['labels']['set_featured_image'] = sprintf( 'Set %s', $featured_image_low ); |
|
204 | - $this->defaults['labels']['remove_featured_image'] = sprintf( 'Remove %s', $featured_image_low ); |
|
205 | - $this->defaults['labels']['use_featured_image'] = sprintf( 'Use as %s', $featured_image_low ); |
|
200 | + if ( isset( $args[ 'featured_image' ] ) ) { |
|
201 | + $featured_image_low = strtolower( $args[ 'featured_image' ] ); |
|
202 | + $this->defaults[ 'labels' ][ 'featured_image' ] = $args[ 'featured_image' ]; |
|
203 | + $this->defaults[ 'labels' ][ 'set_featured_image' ] = sprintf( 'Set %s', $featured_image_low ); |
|
204 | + $this->defaults[ 'labels' ][ 'remove_featured_image' ] = sprintf( 'Remove %s', $featured_image_low ); |
|
205 | + $this->defaults[ 'labels' ][ 'use_featured_image' ] = sprintf( 'Use as %s', $featured_image_low ); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | # Only set default rewrites if we need them |
209 | - if ( isset( $args['public'] ) && ! $args['public'] ) { |
|
210 | - $this->defaults['rewrite'] = false; |
|
209 | + if ( isset( $args[ 'public' ] ) && ! $args[ 'public' ] ) { |
|
210 | + $this->defaults[ 'rewrite' ] = false; |
|
211 | 211 | } else { |
212 | - $this->defaults['rewrite'] = array( |
|
212 | + $this->defaults[ 'rewrite' ] = array( |
|
213 | 213 | 'slug' => $this->post_slug, |
214 | 214 | 'with_front' => false, |
215 | 215 | ); |
@@ -226,40 +226,40 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | # Enable post type archives by default |
229 | - if ( ! isset( $this->args['has_archive'] ) ) { |
|
230 | - $this->args['has_archive'] = $this->args['public']; |
|
229 | + if ( ! isset( $this->args[ 'has_archive' ] ) ) { |
|
230 | + $this->args[ 'has_archive' ] = $this->args[ 'public' ]; |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | # Front-end sortables: |
234 | - if ( $this->args['site_sortables'] && ! is_admin() ) { |
|
234 | + if ( $this->args[ 'site_sortables' ] && ! is_admin() ) { |
|
235 | 235 | add_filter( 'pre_get_posts', array( $this, 'maybe_sort_by_fields' ) ); |
236 | 236 | add_filter( 'posts_clauses', array( $this, 'maybe_sort_by_taxonomy' ), 10, 2 ); |
237 | 237 | } |
238 | 238 | |
239 | 239 | # Front-end filters: |
240 | - if ( $this->args['site_filters'] && ! is_admin() ) { |
|
240 | + if ( $this->args[ 'site_filters' ] && ! is_admin() ) { |
|
241 | 241 | add_action( 'pre_get_posts', array( $this, 'maybe_filter' ) ); |
242 | - add_filter( 'query_vars', array( $this, 'add_query_vars' ) ); |
|
242 | + add_filter( 'query_vars', array( $this, 'add_query_vars' ) ); |
|
243 | 243 | } |
244 | 244 | |
245 | 245 | # Post type in the site's main feed: |
246 | - if ( $this->args['show_in_feed'] ) { |
|
246 | + if ( $this->args[ 'show_in_feed' ] ) { |
|
247 | 247 | add_filter( 'request', array( $this, 'add_to_feed' ) ); |
248 | 248 | } |
249 | 249 | |
250 | 250 | # Post type archive query vars: |
251 | - if ( $this->args['archive'] && ! is_admin() ) { |
|
251 | + if ( $this->args[ 'archive' ] && ! is_admin() ) { |
|
252 | 252 | add_filter( 'parse_request', array( $this, 'override_private_query_vars' ), 1 ); |
253 | 253 | } |
254 | 254 | |
255 | 255 | # Custom post type permastruct: |
256 | - if ( $this->args['rewrite'] && ! empty( $this->args['rewrite']['permastruct'] ) ) { |
|
256 | + if ( $this->args[ 'rewrite' ] && ! empty( $this->args[ 'rewrite' ][ 'permastruct' ] ) ) { |
|
257 | 257 | add_action( 'registered_post_type', array( $this, 'registered_post_type' ), 1, 2 ); |
258 | - add_filter( 'post_type_link', array( $this, 'post_type_link' ), 1, 4 ); |
|
258 | + add_filter( 'post_type_link', array( $this, 'post_type_link' ), 1, 4 ); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | # Rewrite testing: |
262 | - if ( $this->args['rewrite'] ) { |
|
262 | + if ( $this->args[ 'rewrite' ] ) { |
|
263 | 263 | add_filter( 'rewrite_testing_tests', array( $this, 'rewrite_testing_tests' ), 1 ); |
264 | 264 | } |
265 | 265 | |
@@ -281,11 +281,11 @@ discard block |
||
281 | 281 | */ |
282 | 282 | public function maybe_filter( WP_Query $wp_query ) { |
283 | 283 | |
284 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
284 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
285 | 285 | return; |
286 | 286 | } |
287 | 287 | |
288 | - $vars = Extended_CPT::get_filter_vars( $wp_query->query, $this->args['site_filters'] ); |
|
288 | + $vars = Extended_CPT::get_filter_vars( $wp_query->query, $this->args[ 'site_filters' ] ); |
|
289 | 289 | |
290 | 290 | if ( empty( $vars ) ) { |
291 | 291 | return; |
@@ -311,25 +311,25 @@ discard block |
||
311 | 311 | */ |
312 | 312 | public function maybe_sort_by_fields( WP_Query $wp_query ) { |
313 | 313 | |
314 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
314 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
315 | 315 | return; |
316 | 316 | } |
317 | 317 | |
318 | 318 | // If we've not specified an order: |
319 | - if ( empty( $wp_query->query['orderby'] ) ) { |
|
319 | + if ( empty( $wp_query->query[ 'orderby' ] ) ) { |
|
320 | 320 | |
321 | 321 | // Loop over our sortables to find the default sort field (if there is one): |
322 | - foreach ( $this->args['site_sortables'] as $id => $col ) { |
|
323 | - if ( is_array( $col ) && isset( $col['default'] ) ) { |
|
322 | + foreach ( $this->args[ 'site_sortables' ] as $id => $col ) { |
|
323 | + if ( is_array( $col ) && isset( $col[ 'default' ] ) ) { |
|
324 | 324 | // @TODO Don't set 'order' if 'orderby' is an array (WP 4.0+) |
325 | - $wp_query->query['orderby'] = $id; |
|
326 | - $wp_query->query['order'] = ( 'desc' === strtolower( $col['default'] ) ? 'desc' : 'asc' ); |
|
325 | + $wp_query->query[ 'orderby' ] = $id; |
|
326 | + $wp_query->query[ 'order' ] = ( 'desc' === strtolower( $col[ 'default' ] ) ? 'desc' : 'asc' ); |
|
327 | 327 | break; |
328 | 328 | } |
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | - $sort = Extended_CPT::get_sort_field_vars( $wp_query->query, $this->args['site_sortables'] ); |
|
332 | + $sort = Extended_CPT::get_sort_field_vars( $wp_query->query, $this->args[ 'site_sortables' ] ); |
|
333 | 333 | |
334 | 334 | if ( empty( $sort ) ) { |
335 | 335 | return; |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | */ |
351 | 351 | public function maybe_sort_by_taxonomy( array $clauses, WP_Query $wp_query ) { |
352 | 352 | |
353 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
353 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
354 | 354 | return $clauses; |
355 | 355 | } |
356 | 356 | |
357 | - $sort = Extended_CPT::get_sort_taxonomy_clauses( $clauses, $wp_query->query, $this->args['site_sortables'] ); |
|
357 | + $sort = Extended_CPT::get_sort_taxonomy_clauses( $clauses, $wp_query->query, $this->args[ 'site_sortables' ] ); |
|
358 | 358 | |
359 | 359 | if ( empty( $sort ) ) { |
360 | 360 | return $clauses; |
@@ -382,22 +382,22 @@ discard block |
||
382 | 382 | if ( ! isset( $query[ $filter_key ] ) || ( '' === $query[ $filter_key ] ) ) { |
383 | 383 | continue; |
384 | 384 | } |
385 | - if ( isset( $filter['cap'] ) && ! current_user_can( $filter['cap'] ) ) { |
|
385 | + if ( isset( $filter[ 'cap' ] ) && ! current_user_can( $filter[ 'cap' ] ) ) { |
|
386 | 386 | continue; |
387 | 387 | } |
388 | 388 | |
389 | - if ( isset( $filter['meta_key'] ) ) { |
|
389 | + if ( isset( $filter[ 'meta_key' ] ) ) { |
|
390 | 390 | $meta_query = array( |
391 | - 'key' => $filter['meta_key'], |
|
391 | + 'key' => $filter[ 'meta_key' ], |
|
392 | 392 | 'value' => wp_unslash( $query[ $filter_key ] ), |
393 | 393 | ); |
394 | - } else if ( isset( $filter['meta_search_key'] ) ) { |
|
394 | + } else if ( isset( $filter[ 'meta_search_key' ] ) ) { |
|
395 | 395 | $meta_query = array( |
396 | - 'key' => $filter['meta_search_key'], |
|
396 | + 'key' => $filter[ 'meta_search_key' ], |
|
397 | 397 | 'value' => wp_unslash( $query[ $filter_key ] ), |
398 | 398 | 'compare' => 'LIKE', |
399 | 399 | ); |
400 | - } else if ( isset( $filter['meta_exists'] ) ) { |
|
400 | + } else if ( isset( $filter[ 'meta_exists' ] ) ) { |
|
401 | 401 | $meta_query = array( |
402 | 402 | 'key' => wp_unslash( $query[ $filter_key ] ), |
403 | 403 | 'compare' => 'NOT IN', |
@@ -407,12 +407,12 @@ discard block |
||
407 | 407 | continue; |
408 | 408 | } |
409 | 409 | |
410 | - if ( isset( $filter['meta_query'] ) ) { |
|
411 | - $meta_query = array_merge( $meta_query, $filter['meta_query'] ); |
|
410 | + if ( isset( $filter[ 'meta_query' ] ) ) { |
|
411 | + $meta_query = array_merge( $meta_query, $filter[ 'meta_query' ] ); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | if ( ! empty( $meta_query ) ) { |
415 | - $return['meta_query'][] = $meta_query; |
|
415 | + $return[ 'meta_query' ][ ] = $meta_query; |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -431,35 +431,35 @@ discard block |
||
431 | 431 | */ |
432 | 432 | public static function get_sort_field_vars( array $vars, array $sortables ) { |
433 | 433 | |
434 | - if ( ! isset( $vars['orderby'] ) ) { |
|
434 | + if ( ! isset( $vars[ 'orderby' ] ) ) { |
|
435 | 435 | return array(); |
436 | 436 | } |
437 | - if ( ! isset( $sortables[ $vars['orderby'] ] ) ) { |
|
437 | + if ( ! isset( $sortables[ $vars[ 'orderby' ] ] ) ) { |
|
438 | 438 | return array(); |
439 | 439 | } |
440 | 440 | |
441 | - $orderby = $sortables[ $vars['orderby'] ]; |
|
441 | + $orderby = $sortables[ $vars[ 'orderby' ] ]; |
|
442 | 442 | |
443 | 443 | if ( ! is_array( $orderby ) ) { |
444 | 444 | return array(); |
445 | 445 | } |
446 | - if ( isset( $orderby['sortable'] ) && ! $orderby['sortable'] ) { |
|
446 | + if ( isset( $orderby[ 'sortable' ] ) && ! $orderby[ 'sortable' ] ) { |
|
447 | 447 | return array(); |
448 | 448 | } |
449 | 449 | |
450 | 450 | $return = array(); |
451 | 451 | |
452 | - if ( isset( $orderby['meta_key'] ) ) { |
|
453 | - $return['meta_key'] = $orderby['meta_key']; |
|
454 | - $return['orderby'] = 'meta_value'; |
|
452 | + if ( isset( $orderby[ 'meta_key' ] ) ) { |
|
453 | + $return[ 'meta_key' ] = $orderby[ 'meta_key' ]; |
|
454 | + $return[ 'orderby' ] = 'meta_value'; |
|
455 | 455 | // @TODO meta_value_num |
456 | - } else if ( isset( $orderby['post_field'] ) ) { |
|
457 | - $field = str_replace( 'post_', '', $orderby['post_field'] ); |
|
458 | - $return['orderby'] = $field; |
|
456 | + } else if ( isset( $orderby[ 'post_field' ] ) ) { |
|
457 | + $field = str_replace( 'post_', '', $orderby[ 'post_field' ] ); |
|
458 | + $return[ 'orderby' ] = $field; |
|
459 | 459 | } |
460 | 460 | |
461 | - if ( isset( $vars['order'] ) ) { |
|
462 | - $return['order'] = $vars['order']; |
|
461 | + if ( isset( $vars[ 'order' ] ) ) { |
|
462 | + $return[ 'order' ] = $vars[ 'order' ]; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | return $return; |
@@ -480,27 +480,27 @@ discard block |
||
480 | 480 | |
481 | 481 | global $wpdb; |
482 | 482 | |
483 | - if ( ! isset( $vars['orderby'] ) ) { |
|
483 | + if ( ! isset( $vars[ 'orderby' ] ) ) { |
|
484 | 484 | return array(); |
485 | 485 | } |
486 | - if ( ! isset( $sortables[ $vars['orderby'] ] ) ) { |
|
486 | + if ( ! isset( $sortables[ $vars[ 'orderby' ] ] ) ) { |
|
487 | 487 | return array(); |
488 | 488 | } |
489 | 489 | |
490 | - $orderby = $sortables[ $vars['orderby'] ]; |
|
490 | + $orderby = $sortables[ $vars[ 'orderby' ] ]; |
|
491 | 491 | |
492 | 492 | if ( ! is_array( $orderby ) ) { |
493 | 493 | return array(); |
494 | 494 | } |
495 | - if ( isset( $orderby['sortable'] ) && ! $orderby['sortable'] ) { |
|
495 | + if ( isset( $orderby[ 'sortable' ] ) && ! $orderby[ 'sortable' ] ) { |
|
496 | 496 | return array(); |
497 | 497 | } |
498 | - if ( ! isset( $orderby['taxonomy'] ) ) { |
|
498 | + if ( ! isset( $orderby[ 'taxonomy' ] ) ) { |
|
499 | 499 | return array(); |
500 | 500 | } |
501 | 501 | |
502 | 502 | # Taxonomy term ordering courtesy of http://scribu.net/wordpress/sortable-taxonomy-columns.html |
503 | - $clauses['join'] .= " |
|
503 | + $clauses[ 'join' ] .= " |
|
504 | 504 | LEFT OUTER JOIN {$wpdb->term_relationships} as ext_cpts_tr |
505 | 505 | ON ( {$wpdb->posts}.ID = ext_cpts_tr.object_id ) |
506 | 506 | LEFT OUTER JOIN {$wpdb->term_taxonomy} as ext_cpts_tt |
@@ -508,10 +508,10 @@ discard block |
||
508 | 508 | LEFT OUTER JOIN {$wpdb->terms} as ext_cpts_t |
509 | 509 | ON ( ext_cpts_tt.term_id = ext_cpts_t.term_id ) |
510 | 510 | "; |
511 | - $clauses['where'] .= $wpdb->prepare( ' AND ( taxonomy = %s OR taxonomy IS NULL )', $orderby['taxonomy'] ); |
|
512 | - $clauses['groupby'] = 'ext_cpts_tr.object_id'; |
|
513 | - $clauses['orderby'] = 'GROUP_CONCAT( ext_cpts_t.name ORDER BY name ASC ) '; |
|
514 | - $clauses['orderby'] .= ( isset( $vars['order'] ) && ( 'ASC' === strtoupper( $vars['order'] ) ) ) ? 'ASC' : 'DESC'; |
|
511 | + $clauses[ 'where' ] .= $wpdb->prepare( ' AND ( taxonomy = %s OR taxonomy IS NULL )', $orderby[ 'taxonomy' ] ); |
|
512 | + $clauses[ 'groupby' ] = 'ext_cpts_tr.object_id'; |
|
513 | + $clauses[ 'orderby' ] = 'GROUP_CONCAT( ext_cpts_t.name ORDER BY name ASC ) '; |
|
514 | + $clauses[ 'orderby' ] .= ( isset( $vars[ 'order' ] ) && ( 'ASC' === strtoupper( $vars[ 'order' ] ) ) ) ? 'ASC' : 'DESC'; |
|
515 | 515 | |
516 | 516 | return $clauses; |
517 | 517 | |
@@ -525,7 +525,7 @@ discard block |
||
525 | 525 | */ |
526 | 526 | public function add_query_vars( array $vars ) { |
527 | 527 | |
528 | - $filters = array_keys( $this->args['site_filters'] ); |
|
528 | + $filters = array_keys( $this->args[ 'site_filters' ] ); |
|
529 | 529 | |
530 | 530 | return array_merge( $vars, $filters ); |
531 | 531 | |
@@ -540,14 +540,14 @@ discard block |
||
540 | 540 | public function add_to_feed( array $vars ) { |
541 | 541 | |
542 | 542 | # If it's not a feed, we're not interested: |
543 | - if ( ! isset( $vars['feed'] ) ) { |
|
543 | + if ( ! isset( $vars[ 'feed' ] ) ) { |
|
544 | 544 | return $vars; |
545 | 545 | } |
546 | 546 | |
547 | - if ( ! isset( $vars['post_type'] ) ) { |
|
548 | - $vars['post_type'] = array( 'post', $this->post_type ); |
|
549 | - } else if ( is_array( $vars['post_type'] ) && ( count( $vars['post_type'] ) > 1 ) ) { |
|
550 | - $vars['post_type'][] = $this->post_type; |
|
547 | + if ( ! isset( $vars[ 'post_type' ] ) ) { |
|
548 | + $vars[ 'post_type' ] = array( 'post', $this->post_type ); |
|
549 | + } else if ( is_array( $vars[ 'post_type' ] ) && ( count( $vars[ 'post_type' ] ) > 1 ) ) { |
|
550 | + $vars[ 'post_type' ][ ] = $this->post_type; |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | return $vars; |
@@ -563,17 +563,17 @@ discard block |
||
563 | 563 | public function override_private_query_vars( WP $wp ) { |
564 | 564 | |
565 | 565 | # If it's not our post type, bail out: |
566 | - if ( ! isset( $wp->query_vars['post_type'] ) || ( $this->post_type !== $wp->query_vars['post_type'] ) ) { |
|
566 | + if ( ! isset( $wp->query_vars[ 'post_type' ] ) || ( $this->post_type !== $wp->query_vars[ 'post_type' ] ) ) { |
|
567 | 567 | return $wp; |
568 | 568 | } |
569 | 569 | |
570 | 570 | # If it's a single post, bail out: |
571 | - if ( isset( $wp->query_vars['name'] ) ) { |
|
571 | + if ( isset( $wp->query_vars[ 'name' ] ) ) { |
|
572 | 572 | return $wp; |
573 | 573 | } |
574 | 574 | |
575 | 575 | # Set the vars: |
576 | - foreach ( $this->args['archive'] as $var => $value ) { |
|
576 | + foreach ( $this->args[ 'archive' ] as $var => $value ) { |
|
577 | 577 | $wp->query_vars[ $var ] = $value; |
578 | 578 | } |
579 | 579 | |
@@ -591,7 +591,7 @@ discard block |
||
591 | 591 | if ( $post_type !== $this->post_type ) { |
592 | 592 | return; |
593 | 593 | } |
594 | - $struct = str_replace( "%{$this->post_type}_slug%", $this->post_slug, $args->rewrite['permastruct'] ); |
|
594 | + $struct = str_replace( "%{$this->post_type}_slug%", $this->post_slug, $args->rewrite[ 'permastruct' ] ); |
|
595 | 595 | $struct = str_replace( '%postname%', "%{$this->post_type}%", $struct ); |
596 | 596 | add_permastruct( $this->post_type, $struct, $args->rewrite ); |
597 | 597 | } |
@@ -614,17 +614,17 @@ discard block |
||
614 | 614 | |
615 | 615 | $date = explode( ' ', mysql2date( 'Y m d H i s', $post->post_date ) ); |
616 | 616 | $replacements = array( |
617 | - '%year%' => $date[0], |
|
618 | - '%monthnum%' => $date[1], |
|
619 | - '%day%' => $date[2], |
|
620 | - '%hour%' => $date[3], |
|
621 | - '%minute%' => $date[4], |
|
622 | - '%second%' => $date[5], |
|
617 | + '%year%' => $date[ 0 ], |
|
618 | + '%monthnum%' => $date[ 1 ], |
|
619 | + '%day%' => $date[ 2 ], |
|
620 | + '%hour%' => $date[ 3 ], |
|
621 | + '%minute%' => $date[ 4 ], |
|
622 | + '%second%' => $date[ 5 ], |
|
623 | 623 | '%post_id%' => $post->ID, |
624 | 624 | ); |
625 | 625 | |
626 | 626 | if ( false !== strpos( $post_link, '%author%' ) ) { |
627 | - $replacements['%author%'] = get_userdata( $post->post_author )->user_nicename; |
|
627 | + $replacements[ '%author%' ] = get_userdata( $post->post_author )->user_nicename; |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | foreach ( get_object_taxonomies( $post ) as $tax ) { |
@@ -699,10 +699,10 @@ discard block |
||
699 | 699 | */ |
700 | 700 | public function register_post_type() { |
701 | 701 | |
702 | - if ( ! isset( $this->args['query_var'] ) || ( true === $this->args['query_var'] ) ) { |
|
702 | + if ( ! isset( $this->args[ 'query_var' ] ) || ( true === $this->args[ 'query_var' ] ) ) { |
|
703 | 703 | $query_var = $this->post_type; |
704 | 704 | } else { |
705 | - $query_var = $this->args['query_var']; |
|
705 | + $query_var = $this->args[ 'query_var' ]; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | $existing = get_post_type_object( $this->post_type ); |
@@ -746,9 +746,9 @@ discard block |
||
746 | 746 | public function extend( $pto ) { |
747 | 747 | |
748 | 748 | # Merge core with overridden labels |
749 | - $this->args['labels'] = array_merge( (array) get_post_type_labels( $pto ), $this->args['labels'] ); |
|
749 | + $this->args[ 'labels' ] = array_merge( (array) get_post_type_labels( $pto ), $this->args[ 'labels' ] ); |
|
750 | 750 | |
751 | - $GLOBALS['wp_post_types'][ $pto->name ]->labels = (object) $this->args['labels']; |
|
751 | + $GLOBALS[ 'wp_post_types' ][ $pto->name ]->labels = (object) $this->args[ 'labels' ]; |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
@@ -794,11 +794,11 @@ discard block |
||
794 | 794 | * @var array |
795 | 795 | */ |
796 | 796 | protected $defaults = array( |
797 | - 'quick_edit' => true, # Custom arg |
|
798 | - 'dashboard_glance' => true, # Custom arg |
|
799 | - 'admin_cols' => null, # Custom arg |
|
800 | - 'admin_filters' => null, # Custom arg |
|
801 | - 'enter_title_here' => null, # Custom arg |
|
797 | + 'quick_edit' => true, # Custom arg |
|
798 | + 'dashboard_glance' => true, # Custom arg |
|
799 | + 'admin_cols' => null, # Custom arg |
|
800 | + 'admin_filters' => null, # Custom arg |
|
801 | + 'enter_title_here' => null, # Custom arg |
|
802 | 802 | ); |
803 | 803 | public $cpt; |
804 | 804 | public $args; |
@@ -819,48 +819,48 @@ discard block |
||
819 | 819 | $this->args = array_merge( $this->defaults, $args ); |
820 | 820 | |
821 | 821 | # Admin columns: |
822 | - if ( $this->args['admin_cols'] ) { |
|
823 | - add_filter( 'manage_posts_columns', array( $this, '_log_default_cols' ), 0 ); |
|
824 | - add_filter( 'manage_pages_columns', array( $this, '_log_default_cols' ), 0 ); |
|
822 | + if ( $this->args[ 'admin_cols' ] ) { |
|
823 | + add_filter( 'manage_posts_columns', array( $this, '_log_default_cols' ), 0 ); |
|
824 | + add_filter( 'manage_pages_columns', array( $this, '_log_default_cols' ), 0 ); |
|
825 | 825 | add_filter( "manage_edit-{$this->cpt->post_type}_sortable_columns", array( $this, 'sortables' ) ); |
826 | - add_filter( "manage_{$this->cpt->post_type}_posts_columns", array( $this, 'cols' ) ); |
|
827 | - add_action( "manage_{$this->cpt->post_type}_posts_custom_column", array( $this, 'col' ) ); |
|
828 | - add_action( 'load-edit.php', array( $this, 'default_sort' ) ); |
|
829 | - add_filter( 'pre_get_posts', array( $this, 'maybe_sort_by_fields' ) ); |
|
830 | - add_filter( 'posts_clauses', array( $this, 'maybe_sort_by_taxonomy' ), 10, 2 ); |
|
826 | + add_filter( "manage_{$this->cpt->post_type}_posts_columns", array( $this, 'cols' ) ); |
|
827 | + add_action( "manage_{$this->cpt->post_type}_posts_custom_column", array( $this, 'col' ) ); |
|
828 | + add_action( 'load-edit.php', array( $this, 'default_sort' ) ); |
|
829 | + add_filter( 'pre_get_posts', array( $this, 'maybe_sort_by_fields' ) ); |
|
830 | + add_filter( 'posts_clauses', array( $this, 'maybe_sort_by_taxonomy' ), 10, 2 ); |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | # Admin filters: |
834 | - if ( $this->args['admin_filters'] ) { |
|
835 | - add_filter( 'pre_get_posts', array( $this, 'maybe_filter' ) ); |
|
836 | - add_filter( 'query_vars', array( $this, 'add_query_vars' ) ); |
|
834 | + if ( $this->args[ 'admin_filters' ] ) { |
|
835 | + add_filter( 'pre_get_posts', array( $this, 'maybe_filter' ) ); |
|
836 | + add_filter( 'query_vars', array( $this, 'add_query_vars' ) ); |
|
837 | 837 | add_action( 'restrict_manage_posts', array( $this, 'filters' ) ); |
838 | 838 | } |
839 | 839 | |
840 | 840 | # 'Enter title here' filter: |
841 | - if ( $this->args['enter_title_here'] ) { |
|
841 | + if ( $this->args[ 'enter_title_here' ] ) { |
|
842 | 842 | add_filter( 'enter_title_here', array( $this, 'enter_title_here' ), 10, 2 ); |
843 | 843 | } |
844 | 844 | |
845 | 845 | # Hide month filter: |
846 | - if ( isset( $this->args['admin_filters']['m'] ) && ! $this->args['admin_filters']['m'] ) { |
|
846 | + if ( isset( $this->args[ 'admin_filters' ][ 'm' ] ) && ! $this->args[ 'admin_filters' ][ 'm' ] ) { |
|
847 | 847 | add_action( 'admin_head-edit.php', array( $this, 'admin_head' ) ); |
848 | 848 | } |
849 | 849 | |
850 | 850 | # Quick Edit: |
851 | - if ( ! $this->args['quick_edit'] ) { |
|
852 | - add_filter( 'post_row_actions', array( $this, 'remove_quick_edit_action' ), 10, 2 ); |
|
853 | - add_filter( 'page_row_actions', array( $this, 'remove_quick_edit_action' ), 10, 2 ); |
|
851 | + if ( ! $this->args[ 'quick_edit' ] ) { |
|
852 | + add_filter( 'post_row_actions', array( $this, 'remove_quick_edit_action' ), 10, 2 ); |
|
853 | + add_filter( 'page_row_actions', array( $this, 'remove_quick_edit_action' ), 10, 2 ); |
|
854 | 854 | add_filter( "bulk_actions-edit-{$this->cpt->post_type}", array( $this, 'remove_quick_edit_menu' ) ); |
855 | 855 | } |
856 | 856 | |
857 | 857 | # 'At a Glance' dashboard panels: |
858 | - if ( $this->args['dashboard_glance'] ) { |
|
859 | - add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), $this->cpt->args['menu_position'] ); |
|
858 | + if ( $this->args[ 'dashboard_glance' ] ) { |
|
859 | + add_filter( 'dashboard_glance_items', array( $this, 'glance_items' ), $this->cpt->args[ 'menu_position' ] ); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | # Post updated messages: |
863 | - add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ), 1 ); |
|
863 | + add_filter( 'post_updated_messages', array( $this, 'post_updated_messages' ), 1 ); |
|
864 | 864 | add_filter( 'bulk_post_updated_messages', array( $this, 'bulk_post_updated_messages' ), 1, 2 ); |
865 | 865 | |
866 | 866 | } |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | } |
876 | 876 | |
877 | 877 | ?> |
878 | - <?php if ( isset( $this->args['admin_filters']['m'] ) && ! $this->args['admin_filters']['m'] ) { ?> |
|
878 | + <?php if ( isset( $this->args[ 'admin_filters' ][ 'm' ] ) && ! $this->args[ 'admin_filters' ][ 'm' ] ) { ?> |
|
879 | 879 | <style type="text/css"> |
880 | 880 | #posts-filter select[name="m"] { |
881 | 881 | display: none; |
@@ -896,15 +896,15 @@ discard block |
||
896 | 896 | } |
897 | 897 | |
898 | 898 | # If we've already ordered the screen, bail out: |
899 | - if ( isset( $_GET['orderby'] ) ) { |
|
899 | + if ( isset( $_GET[ 'orderby' ] ) ) { |
|
900 | 900 | return; |
901 | 901 | } |
902 | 902 | |
903 | 903 | # Loop over our columns to find the default sort column (if there is one): |
904 | - foreach ( $this->args['admin_cols'] as $id => $col ) { |
|
905 | - if ( is_array( $col ) && isset( $col['default'] ) ) { |
|
906 | - $_GET['orderby'] = $id; |
|
907 | - $_GET['order'] = ( 'desc' === strtolower( $col['default'] ) ? 'desc' : 'asc' ); |
|
904 | + foreach ( $this->args[ 'admin_cols' ] as $id => $col ) { |
|
905 | + if ( is_array( $col ) && isset( $col[ 'default' ] ) ) { |
|
906 | + $_GET[ 'orderby' ] = $id; |
|
907 | + $_GET[ 'order' ] = ( 'desc' === strtolower( $col[ 'default' ] ) ? 'desc' : 'asc' ); |
|
908 | 908 | break; |
909 | 909 | } |
910 | 910 | } |
@@ -924,7 +924,7 @@ discard block |
||
924 | 924 | return $title; |
925 | 925 | } |
926 | 926 | |
927 | - return $this->args['enter_title_here']; |
|
927 | + return $this->args[ 'enter_title_here' ]; |
|
928 | 928 | |
929 | 929 | } |
930 | 930 | |
@@ -1005,15 +1005,15 @@ discard block |
||
1005 | 1005 | |
1006 | 1006 | $pto = get_post_type_object( $this->cpt->post_type ); |
1007 | 1007 | |
1008 | - foreach ( $this->args['admin_filters'] as $filter_key => $filter ) { |
|
1008 | + foreach ( $this->args[ 'admin_filters' ] as $filter_key => $filter ) { |
|
1009 | 1009 | |
1010 | - if ( isset( $filter['cap'] ) && ! current_user_can( $filter['cap'] ) ) { |
|
1010 | + if ( isset( $filter[ 'cap' ] ) && ! current_user_can( $filter[ 'cap' ] ) ) { |
|
1011 | 1011 | continue; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - if ( isset( $filter['taxonomy'] ) ) { |
|
1014 | + if ( isset( $filter[ 'taxonomy' ] ) ) { |
|
1015 | 1015 | |
1016 | - $tax = get_taxonomy( $filter['taxonomy'] ); |
|
1016 | + $tax = get_taxonomy( $filter[ 'taxonomy' ] ); |
|
1017 | 1017 | |
1018 | 1018 | if ( empty( $tax ) ) { |
1019 | 1019 | continue; |
@@ -1033,13 +1033,13 @@ discard block |
||
1033 | 1033 | } |
1034 | 1034 | |
1035 | 1035 | # If we haven't specified a title, use the all_items label from the taxonomy: |
1036 | - if ( ! isset( $filter['title'] ) ) { |
|
1037 | - $filter['title'] = $tax->labels->all_items; |
|
1036 | + if ( ! isset( $filter[ 'title' ] ) ) { |
|
1037 | + $filter[ 'title' ] = $tax->labels->all_items; |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | # Output the dropdown: |
1041 | 1041 | wp_dropdown_categories( array( |
1042 | - 'show_option_all' => $filter['title'], |
|
1042 | + 'show_option_all' => $filter[ 'title' ], |
|
1043 | 1043 | 'hide_empty' => false, |
1044 | 1044 | 'hide_if_empty' => true, |
1045 | 1045 | 'hierarchical' => true, |
@@ -1048,23 +1048,23 @@ discard block |
||
1048 | 1048 | 'selected_cats' => get_query_var( $tax->query_var ), |
1049 | 1049 | 'id' => 'filter_' . $filter_key, |
1050 | 1050 | 'name' => $tax->query_var, |
1051 | - 'taxonomy' => $filter['taxonomy'], |
|
1051 | + 'taxonomy' => $filter[ 'taxonomy' ], |
|
1052 | 1052 | 'walker' => $walker, |
1053 | 1053 | ) ); |
1054 | 1054 | |
1055 | - } else if ( isset( $filter['meta_key'] ) ) { |
|
1055 | + } else if ( isset( $filter[ 'meta_key' ] ) ) { |
|
1056 | 1056 | |
1057 | 1057 | # If we haven't specified a title, generate one from the meta key: |
1058 | - if ( ! isset( $filter['title'] ) ) { |
|
1059 | - $filter['title'] = str_replace( array( '-', '_' ), ' ', $filter['meta_key'] ); |
|
1060 | - $filter['title'] = ucwords( $filter['title'] ) . 's'; |
|
1061 | - $filter['title'] = sprintf( 'All %s', $filter['title'] ); |
|
1058 | + if ( ! isset( $filter[ 'title' ] ) ) { |
|
1059 | + $filter[ 'title' ] = str_replace( array( '-', '_' ), ' ', $filter[ 'meta_key' ] ); |
|
1060 | + $filter[ 'title' ] = ucwords( $filter[ 'title' ] ) . 's'; |
|
1061 | + $filter[ 'title' ] = sprintf( 'All %s', $filter[ 'title' ] ); |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | - if ( ! isset( $filter['options'] ) ) { |
|
1064 | + if ( ! isset( $filter[ 'options' ] ) ) { |
|
1065 | 1065 | # Fetch all the values for our meta key: |
1066 | 1066 | # @TODO AND m.meta_value != null ? |
1067 | - $filter['options'] = $wpdb->get_col( $wpdb->prepare( " |
|
1067 | + $filter[ 'options' ] = $wpdb->get_col( $wpdb->prepare( " |
|
1068 | 1068 | SELECT DISTINCT meta_value |
1069 | 1069 | FROM {$wpdb->postmeta} as m |
1070 | 1070 | JOIN {$wpdb->posts} as p ON ( p.ID = m.post_id ) |
@@ -1072,12 +1072,12 @@ discard block |
||
1072 | 1072 | AND m.meta_value != '' |
1073 | 1073 | AND p.post_type = %s |
1074 | 1074 | ORDER BY m.meta_value ASC |
1075 | - ", $filter['meta_key'], $this->cpt->post_type ) ); |
|
1076 | - } else if ( is_callable( $filter['options'] ) ) { |
|
1077 | - $filter['options'] = call_user_func( $filter['options'] ); |
|
1075 | + ", $filter[ 'meta_key' ], $this->cpt->post_type ) ); |
|
1076 | + } else if ( is_callable( $filter[ 'options' ] ) ) { |
|
1077 | + $filter[ 'options' ] = call_user_func( $filter[ 'options' ] ); |
|
1078 | 1078 | } |
1079 | 1079 | |
1080 | - if ( empty( $filter['options'] ) ) { |
|
1080 | + if ( empty( $filter[ 'options' ] ) ) { |
|
1081 | 1081 | continue; |
1082 | 1082 | } |
1083 | 1083 | |
@@ -1085,7 +1085,7 @@ discard block |
||
1085 | 1085 | |
1086 | 1086 | $use_key = false; |
1087 | 1087 | |
1088 | - foreach ( $filter['options'] as $k => $v ) { |
|
1088 | + foreach ( $filter[ 'options' ] as $k => $v ) { |
|
1089 | 1089 | if ( ! is_numeric( $k ) ) { |
1090 | 1090 | $use_key = true; |
1091 | 1091 | break; |
@@ -1095,9 +1095,9 @@ discard block |
||
1095 | 1095 | # Output the dropdown: |
1096 | 1096 | ?> |
1097 | 1097 | <select name="<?php echo esc_attr( $filter_key ); ?>" id="filter_<?php echo esc_attr( $filter_key ); ?>"> |
1098 | - <option value=""><?php echo esc_html( $filter['title'] ); ?></option> |
|
1098 | + <option value=""><?php echo esc_html( $filter[ 'title' ] ); ?></option> |
|
1099 | 1099 | <?php |
1100 | - foreach ( $filter['options'] as $k => $v ) { |
|
1100 | + foreach ( $filter[ 'options' ] as $k => $v ) { |
|
1101 | 1101 | $key = ( $use_key ? $k : $v ); |
1102 | 1102 | ?> |
1103 | 1103 | <option value="<?php echo esc_attr( $key ); ?>" <?php selected( $selected, $key ); ?>><?php echo esc_html( $v ); ?></option> |
@@ -1105,34 +1105,34 @@ discard block |
||
1105 | 1105 | </select> |
1106 | 1106 | <?php |
1107 | 1107 | |
1108 | - } else if ( isset( $filter['meta_search_key'] ) ) { |
|
1108 | + } else if ( isset( $filter[ 'meta_search_key' ] ) ) { |
|
1109 | 1109 | |
1110 | 1110 | # If we haven't specified a title, generate one from the meta key: |
1111 | - if ( ! isset( $filter['title'] ) ) { |
|
1112 | - $filter['title'] = str_replace( array( '-', '_' ), ' ', $filter['meta_search_key'] ); |
|
1113 | - $filter['title'] = ucwords( $filter['title'] ); |
|
1111 | + if ( ! isset( $filter[ 'title' ] ) ) { |
|
1112 | + $filter[ 'title' ] = str_replace( array( '-', '_' ), ' ', $filter[ 'meta_search_key' ] ); |
|
1113 | + $filter[ 'title' ] = ucwords( $filter[ 'title' ] ); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | 1116 | $value = wp_unslash( get_query_var( $filter_key ) ); |
1117 | 1117 | |
1118 | 1118 | # Output the search box: |
1119 | 1119 | ?> |
1120 | - <label><?php printf( '%s:', esc_html( $filter['title'] ) ); ?> <input type="text" name="<?php echo esc_attr( $filter_key ); ?>" id="filter_<?php echo esc_attr( $filter_key ); ?>" value="<?php echo esc_attr( $value ); ?>" /></label> |
|
1120 | + <label><?php printf( '%s:', esc_html( $filter[ 'title' ] ) ); ?> <input type="text" name="<?php echo esc_attr( $filter_key ); ?>" id="filter_<?php echo esc_attr( $filter_key ); ?>" value="<?php echo esc_attr( $value ); ?>" /></label> |
|
1121 | 1121 | <?php |
1122 | 1122 | |
1123 | - } else if ( isset( $filter['meta_exists'] ) ) { |
|
1123 | + } else if ( isset( $filter[ 'meta_exists' ] ) ) { |
|
1124 | 1124 | |
1125 | 1125 | # If we haven't specified a title, use the all_items label from the post type: |
1126 | - if ( ! isset( $filter['title'] ) ) { |
|
1127 | - $filter['title'] = $pto->labels->all_items; |
|
1126 | + if ( ! isset( $filter[ 'title' ] ) ) { |
|
1127 | + $filter[ 'title' ] = $pto->labels->all_items; |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | $selected = wp_unslash( get_query_var( $filter_key ) ); |
1131 | 1131 | |
1132 | - if ( 1 === count( $filter['meta_exists'] ) ) { |
|
1132 | + if ( 1 === count( $filter[ 'meta_exists' ] ) ) { |
|
1133 | 1133 | |
1134 | 1134 | # Output a checkbox: |
1135 | - foreach ( $filter['meta_exists'] as $v => $t ) { |
|
1135 | + foreach ( $filter[ 'meta_exists' ] as $v => $t ) { |
|
1136 | 1136 | ?> |
1137 | 1137 | <label><input type="checkbox" name="<?php echo esc_attr( $filter_key ); ?>" id="filter_<?php echo esc_attr( $filter_key ); ?>" value="<?php echo esc_attr( $v ); ?>" <?php checked( $selected, $v ); ?>> <?php echo esc_html( $t ); ?></label> |
1138 | 1138 | <?php |
@@ -1142,8 +1142,8 @@ discard block |
||
1142 | 1142 | # Output a dropdown: |
1143 | 1143 | ?> |
1144 | 1144 | <select name="<?php echo esc_attr( $filter_key ); ?>" id="filter_<?php echo esc_attr( $filter_key ); ?>"> |
1145 | - <option value=""><?php echo esc_html( $filter['title'] ); ?></option> |
|
1146 | - <?php foreach ( $filter['meta_exists'] as $v => $t ) { ?> |
|
1145 | + <option value=""><?php echo esc_html( $filter[ 'title' ] ); ?></option> |
|
1146 | + <?php foreach ( $filter[ 'meta_exists' ] as $v => $t ) { ?> |
|
1147 | 1147 | <option value="<?php echo esc_attr( $v ); ?>" <?php selected( $selected, $v ); ?>><?php echo esc_html( $t ); ?></option> |
1148 | 1148 | <?php } ?> |
1149 | 1149 | </select> |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | */ |
1164 | 1164 | public function add_query_vars( array $vars ) { |
1165 | 1165 | |
1166 | - $filters = array_keys( $this->args['admin_filters'] ); |
|
1166 | + $filters = array_keys( $this->args[ 'admin_filters' ] ); |
|
1167 | 1167 | |
1168 | 1168 | return array_merge( $vars, $filters ); |
1169 | 1169 | |
@@ -1176,11 +1176,11 @@ discard block |
||
1176 | 1176 | */ |
1177 | 1177 | public function maybe_filter( WP_Query $wp_query ) { |
1178 | 1178 | |
1179 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
1179 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
1180 | 1180 | return; |
1181 | 1181 | } |
1182 | 1182 | |
1183 | - $vars = Extended_CPT::get_filter_vars( $wp_query->query, $this->cpt->args['admin_filters'] ); |
|
1183 | + $vars = Extended_CPT::get_filter_vars( $wp_query->query, $this->cpt->args[ 'admin_filters' ] ); |
|
1184 | 1184 | |
1185 | 1185 | if ( empty( $vars ) ) { |
1186 | 1186 | return; |
@@ -1206,11 +1206,11 @@ discard block |
||
1206 | 1206 | */ |
1207 | 1207 | public function maybe_sort_by_fields( WP_Query $wp_query ) { |
1208 | 1208 | |
1209 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
1209 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
1210 | 1210 | return; |
1211 | 1211 | } |
1212 | 1212 | |
1213 | - $sort = Extended_CPT::get_sort_field_vars( $wp_query->query, $this->cpt->args['admin_cols'] ); |
|
1213 | + $sort = Extended_CPT::get_sort_field_vars( $wp_query->query, $this->cpt->args[ 'admin_cols' ] ); |
|
1214 | 1214 | |
1215 | 1215 | if ( empty( $sort ) ) { |
1216 | 1216 | return; |
@@ -1231,11 +1231,11 @@ discard block |
||
1231 | 1231 | */ |
1232 | 1232 | public function maybe_sort_by_taxonomy( array $clauses, WP_Query $wp_query ) { |
1233 | 1233 | |
1234 | - if ( empty( $wp_query->query['post_type'] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query['post_type'] ) ) { |
|
1234 | + if ( empty( $wp_query->query[ 'post_type' ] ) || ! in_array( $this->cpt->post_type, (array) $wp_query->query[ 'post_type' ] ) ) { |
|
1235 | 1235 | return $clauses; |
1236 | 1236 | } |
1237 | 1237 | |
1238 | - $sort = Extended_CPT::get_sort_taxonomy_clauses( $clauses, $wp_query->query, $this->cpt->args['admin_cols'] ); |
|
1238 | + $sort = Extended_CPT::get_sort_taxonomy_clauses( $clauses, $wp_query->query, $this->cpt->args[ 'admin_cols' ] ); |
|
1239 | 1239 | |
1240 | 1240 | if ( empty( $sort ) ) { |
1241 | 1241 | return $clauses; |
@@ -1274,7 +1274,7 @@ discard block |
||
1274 | 1274 | $text = '<a href="' . esc_url( $url ) . '">' . esc_html( $num . ' ' . $text ) . '</a>'; |
1275 | 1275 | |
1276 | 1276 | # Go! |
1277 | - $items[] = $text; |
|
1277 | + $items[ ] = $text; |
|
1278 | 1278 | |
1279 | 1279 | return $items; |
1280 | 1280 | |
@@ -1318,10 +1318,10 @@ discard block |
||
1318 | 1318 | '%s updated.', |
1319 | 1319 | esc_html( $this->cpt->post_singular ) |
1320 | 1320 | ), |
1321 | - 5 => isset( $_GET['revision'] ) ? sprintf( |
|
1321 | + 5 => isset( $_GET[ 'revision' ] ) ? sprintf( |
|
1322 | 1322 | '%1$s restored to revision from %2$s', |
1323 | 1323 | esc_html( $this->cpt->post_singular ), |
1324 | - wp_post_revision_title( intval( $_GET['revision'] ), false ) |
|
1324 | + wp_post_revision_title( intval( $_GET[ 'revision' ] ), false ) |
|
1325 | 1325 | ) : false, |
1326 | 1326 | 6 => sprintf( |
1327 | 1327 | ( $pto->publicly_queryable ? '%1$s published. <a href="%2$s">View %3$s</a>' : '%1$s published.' ), |
@@ -1377,32 +1377,32 @@ discard block |
||
1377 | 1377 | |
1378 | 1378 | $messages[ $this->cpt->post_type ] = array( |
1379 | 1379 | 'updated' => sprintf( |
1380 | - self::n( '%2$s updated.', '%1$s %3$s updated.', $counts['updated'] ), |
|
1381 | - esc_html( number_format_i18n( $counts['updated'] ) ), |
|
1380 | + self::n( '%2$s updated.', '%1$s %3$s updated.', $counts[ 'updated' ] ), |
|
1381 | + esc_html( number_format_i18n( $counts[ 'updated' ] ) ), |
|
1382 | 1382 | esc_html( $this->cpt->post_singular ), |
1383 | 1383 | esc_html( $this->cpt->post_plural_low ) |
1384 | 1384 | ), |
1385 | 1385 | 'locked' => sprintf( |
1386 | - self::n( '%2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $counts['locked'] ), |
|
1387 | - esc_html( number_format_i18n( $counts['locked'] ) ), |
|
1386 | + self::n( '%2$s not updated, somebody is editing it.', '%1$s %3$s not updated, somebody is editing them.', $counts[ 'locked' ] ), |
|
1387 | + esc_html( number_format_i18n( $counts[ 'locked' ] ) ), |
|
1388 | 1388 | esc_html( $this->cpt->post_singular ), |
1389 | 1389 | esc_html( $this->cpt->post_plural_low ) |
1390 | 1390 | ), |
1391 | 1391 | 'deleted' => sprintf( |
1392 | - self::n( '%2$s permanently deleted.', '%1$s %3$s permanently deleted.', $counts['deleted'] ), |
|
1393 | - esc_html( number_format_i18n( $counts['deleted'] ) ), |
|
1392 | + self::n( '%2$s permanently deleted.', '%1$s %3$s permanently deleted.', $counts[ 'deleted' ] ), |
|
1393 | + esc_html( number_format_i18n( $counts[ 'deleted' ] ) ), |
|
1394 | 1394 | esc_html( $this->cpt->post_singular ), |
1395 | 1395 | esc_html( $this->cpt->post_plural_low ) |
1396 | 1396 | ), |
1397 | 1397 | 'trashed' => sprintf( |
1398 | - self::n( '%2$s moved to the trash.', '%1$s %3$s moved to the trash.', $counts['trashed'] ), |
|
1399 | - esc_html( number_format_i18n( $counts['trashed'] ) ), |
|
1398 | + self::n( '%2$s moved to the trash.', '%1$s %3$s moved to the trash.', $counts[ 'trashed' ] ), |
|
1399 | + esc_html( number_format_i18n( $counts[ 'trashed' ] ) ), |
|
1400 | 1400 | esc_html( $this->cpt->post_singular ), |
1401 | 1401 | esc_html( $this->cpt->post_plural_low ) |
1402 | 1402 | ), |
1403 | 1403 | 'untrashed' => sprintf( |
1404 | - self::n( '%2$s restored from the trash.', '%1$s %3$s restored from the trash.', $counts['untrashed'] ), |
|
1405 | - esc_html( number_format_i18n( $counts['untrashed'] ) ), |
|
1404 | + self::n( '%2$s restored from the trash.', '%1$s %3$s restored from the trash.', $counts[ 'untrashed' ] ), |
|
1405 | + esc_html( number_format_i18n( $counts[ 'untrashed' ] ) ), |
|
1406 | 1406 | esc_html( $this->cpt->post_singular ), |
1407 | 1407 | esc_html( $this->cpt->post_plural_low ) |
1408 | 1408 | ), |
@@ -1420,14 +1420,14 @@ discard block |
||
1420 | 1420 | */ |
1421 | 1421 | public function sortables( array $cols ) { |
1422 | 1422 | |
1423 | - foreach ( $this->args['admin_cols'] as $id => $col ) { |
|
1423 | + foreach ( $this->args[ 'admin_cols' ] as $id => $col ) { |
|
1424 | 1424 | if ( ! is_array( $col ) ) { |
1425 | 1425 | continue; |
1426 | 1426 | } |
1427 | - if ( isset( $col['sortable'] ) && ! $col['sortable'] ) { |
|
1427 | + if ( isset( $col[ 'sortable' ] ) && ! $col[ 'sortable' ] ) { |
|
1428 | 1428 | continue; |
1429 | 1429 | } |
1430 | - if ( isset( $col['meta_key'] ) || isset( $col['taxonomy'] ) || isset( $col['post_field'] ) ) { |
|
1430 | + if ( isset( $col[ 'meta_key' ] ) || isset( $col[ 'taxonomy' ] ) || isset( $col[ 'post_field' ] ) ) { |
|
1431 | 1431 | $cols[ $id ] = $id; |
1432 | 1432 | } |
1433 | 1433 | } |
@@ -1526,13 +1526,13 @@ discard block |
||
1526 | 1526 | |
1527 | 1527 | # Add existing columns we want to keep: |
1528 | 1528 | foreach ( $cols as $id => $title ) { |
1529 | - if ( in_array( $id, $keep ) && ! isset( $this->args['admin_cols'][ $id ] ) ) { |
|
1529 | + if ( in_array( $id, $keep ) && ! isset( $this->args[ 'admin_cols' ][ $id ] ) ) { |
|
1530 | 1530 | $new_cols[ $id ] = $title; |
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | # Add our custom columns: |
1535 | - foreach ( array_filter( $this->args['admin_cols'] ) as $id => $col ) { |
|
1535 | + foreach ( array_filter( $this->args[ 'admin_cols' ] ) as $id => $col ) { |
|
1536 | 1536 | if ( is_string( $col ) && isset( $cols[ $col ] ) ) { |
1537 | 1537 | # Existing (ie. built-in) column with id as the value |
1538 | 1538 | $new_cols[ $col ] = $cols[ $col ]; |
@@ -1549,16 +1549,16 @@ discard block |
||
1549 | 1549 | } |
1550 | 1550 | $new_cols[ $k ] = esc_html__( 'Author' ); |
1551 | 1551 | } else if ( is_array( $col ) ) { |
1552 | - if ( isset( $col['cap'] ) && ! current_user_can( $col['cap'] ) ) { |
|
1552 | + if ( isset( $col[ 'cap' ] ) && ! current_user_can( $col[ 'cap' ] ) ) { |
|
1553 | 1553 | continue; |
1554 | 1554 | } |
1555 | - if ( isset( $col['connection'] ) && ! function_exists( 'p2p_type' ) ) { |
|
1555 | + if ( isset( $col[ 'connection' ] ) && ! function_exists( 'p2p_type' ) ) { |
|
1556 | 1556 | continue; |
1557 | 1557 | } |
1558 | - if ( ! isset( $col['title'] ) ) { |
|
1559 | - $col['title'] = $this->get_item_title( $col ); |
|
1558 | + if ( ! isset( $col[ 'title' ] ) ) { |
|
1559 | + $col[ 'title' ] = $this->get_item_title( $col ); |
|
1560 | 1560 | } |
1561 | - $new_cols[ $id ] = esc_html( $col['title'] ); |
|
1561 | + $new_cols[ $id ] = esc_html( $col[ 'title' ] ); |
|
1562 | 1562 | } |
1563 | 1563 | } |
1564 | 1564 | |
@@ -1578,7 +1578,7 @@ discard block |
||
1578 | 1578 | public function col( $col ) { |
1579 | 1579 | |
1580 | 1580 | # Shorthand: |
1581 | - $c = $this->args['admin_cols']; |
|
1581 | + $c = $this->args[ 'admin_cols' ]; |
|
1582 | 1582 | |
1583 | 1583 | # We're only interested in our custom columns: |
1584 | 1584 | $custom_cols = array_filter( array_keys( $c ) ); |
@@ -1587,26 +1587,26 @@ discard block |
||
1587 | 1587 | return; |
1588 | 1588 | } |
1589 | 1589 | |
1590 | - if ( isset( $c[ $col ]['post_cap'] ) && ! current_user_can( $c[ $col ]['post_cap'], get_the_ID() ) ) { |
|
1590 | + if ( isset( $c[ $col ][ 'post_cap' ] ) && ! current_user_can( $c[ $col ][ 'post_cap' ], get_the_ID() ) ) { |
|
1591 | 1591 | return; |
1592 | 1592 | } |
1593 | 1593 | |
1594 | - if ( ! isset( $c[ $col ]['link'] ) ) { |
|
1595 | - $c[ $col ]['link'] = 'list'; |
|
1594 | + if ( ! isset( $c[ $col ][ 'link' ] ) ) { |
|
1595 | + $c[ $col ][ 'link' ] = 'list'; |
|
1596 | 1596 | } |
1597 | 1597 | |
1598 | - if ( isset( $c[ $col ]['function'] ) ) { |
|
1599 | - call_user_func( $c[ $col ]['function'] ); |
|
1600 | - } else if ( isset( $c[ $col ]['meta_key'] ) ) { |
|
1601 | - $this->col_post_meta( $c[ $col ]['meta_key'], $c[ $col ] ); |
|
1602 | - } else if ( isset( $c[ $col ]['taxonomy'] ) ) { |
|
1603 | - $this->col_taxonomy( $c[ $col ]['taxonomy'], $c[ $col ] ); |
|
1604 | - } else if ( isset( $c[ $col ]['post_field'] ) ) { |
|
1605 | - $this->col_post_field( $c[ $col ]['post_field'], $c[ $col ] ); |
|
1606 | - } else if ( isset( $c[ $col ]['featured_image'] ) ) { |
|
1607 | - $this->col_featured_image( $c[ $col ]['featured_image'], $c[ $col ] ); |
|
1608 | - } else if ( isset( $c[ $col ]['connection'] ) ) { |
|
1609 | - $this->col_connection( $c[ $col ]['connection'], $c[ $col ] ); |
|
1598 | + if ( isset( $c[ $col ][ 'function' ] ) ) { |
|
1599 | + call_user_func( $c[ $col ][ 'function' ] ); |
|
1600 | + } else if ( isset( $c[ $col ][ 'meta_key' ] ) ) { |
|
1601 | + $this->col_post_meta( $c[ $col ][ 'meta_key' ], $c[ $col ] ); |
|
1602 | + } else if ( isset( $c[ $col ][ 'taxonomy' ] ) ) { |
|
1603 | + $this->col_taxonomy( $c[ $col ][ 'taxonomy' ], $c[ $col ] ); |
|
1604 | + } else if ( isset( $c[ $col ][ 'post_field' ] ) ) { |
|
1605 | + $this->col_post_field( $c[ $col ][ 'post_field' ], $c[ $col ] ); |
|
1606 | + } else if ( isset( $c[ $col ][ 'featured_image' ] ) ) { |
|
1607 | + $this->col_featured_image( $c[ $col ][ 'featured_image' ], $c[ $col ] ); |
|
1608 | + } else if ( isset( $c[ $col ][ 'connection' ] ) ) { |
|
1609 | + $this->col_connection( $c[ $col ][ 'connection' ], $c[ $col ] ); |
|
1610 | 1610 | } |
1611 | 1611 | |
1612 | 1612 | } |
@@ -1623,18 +1623,18 @@ discard block |
||
1623 | 1623 | $echo = array(); |
1624 | 1624 | sort( $vals ); |
1625 | 1625 | |
1626 | - if ( isset( $args['date_format'] ) ) { |
|
1626 | + if ( isset( $args[ 'date_format' ] ) ) { |
|
1627 | 1627 | |
1628 | - if ( true === $args['date_format'] ) { |
|
1629 | - $args['date_format'] = get_option( 'date_format' ); |
|
1628 | + if ( true === $args[ 'date_format' ] ) { |
|
1629 | + $args[ 'date_format' ] = get_option( 'date_format' ); |
|
1630 | 1630 | } |
1631 | 1631 | |
1632 | 1632 | foreach ( $vals as $val ) { |
1633 | 1633 | |
1634 | 1634 | if ( is_numeric( $val ) ) { |
1635 | - $echo[] = date( $args['date_format'], $val ); |
|
1635 | + $echo[ ] = date( $args[ 'date_format' ], $val ); |
|
1636 | 1636 | } else if ( ! empty( $val ) ) { |
1637 | - $echo[] = mysql2date( $args['date_format'], $val ); |
|
1637 | + $echo[ ] = mysql2date( $args[ 'date_format' ], $val ); |
|
1638 | 1638 | } |
1639 | 1639 | } |
1640 | 1640 | } else { |
@@ -1642,7 +1642,7 @@ discard block |
||
1642 | 1642 | foreach ( $vals as $val ) { |
1643 | 1643 | |
1644 | 1644 | if ( ! empty( $val ) || ( '0' === $val ) ) { |
1645 | - $echo[] = $val; |
|
1645 | + $echo[ ] = $val; |
|
1646 | 1646 | } |
1647 | 1647 | } |
1648 | 1648 | } |
@@ -1682,29 +1682,29 @@ discard block |
||
1682 | 1682 | |
1683 | 1683 | foreach ( $terms as $term ) { |
1684 | 1684 | |
1685 | - if ( $args['link'] ) { |
|
1685 | + if ( $args[ 'link' ] ) { |
|
1686 | 1686 | |
1687 | - switch ( $args['link'] ) { |
|
1687 | + switch ( $args[ 'link' ] ) { |
|
1688 | 1688 | case 'view': |
1689 | 1689 | if ( $tax->public ) { |
1690 | - $out[] = sprintf( |
|
1690 | + $out[ ] = sprintf( |
|
1691 | 1691 | '<a href="%1$s">%2$s</a>', |
1692 | 1692 | esc_url( get_term_link( $term ) ), |
1693 | 1693 | esc_html( $term->name ) |
1694 | 1694 | ); |
1695 | 1695 | } else { |
1696 | - $out[] = esc_html( $term->name ); |
|
1696 | + $out[ ] = esc_html( $term->name ); |
|
1697 | 1697 | } |
1698 | 1698 | break; |
1699 | 1699 | case 'edit': |
1700 | 1700 | if ( current_user_can( $tax->cap->edit_terms ) ) { |
1701 | - $out[] = sprintf( |
|
1701 | + $out[ ] = sprintf( |
|
1702 | 1702 | '<a href="%1$s">%2$s</a>', |
1703 | 1703 | esc_url( get_edit_term_link( $term, $taxonomy, $post->post_type ) ), |
1704 | 1704 | esc_html( $term->name ) |
1705 | 1705 | ); |
1706 | 1706 | } else { |
1707 | - $out[] = esc_html( $term->name ); |
|
1707 | + $out[ ] = esc_html( $term->name ); |
|
1708 | 1708 | } |
1709 | 1709 | break; |
1710 | 1710 | case 'list': |
@@ -1712,7 +1712,7 @@ discard block |
||
1712 | 1712 | 'post_type' => $post->post_type, |
1713 | 1713 | $taxonomy => $term->slug, |
1714 | 1714 | ), admin_url( 'edit.php' ) ); |
1715 | - $out[] = sprintf( |
|
1715 | + $out[ ] = sprintf( |
|
1716 | 1716 | '<a href="%1$s">%2$s</a>', |
1717 | 1717 | esc_url( $link ), |
1718 | 1718 | esc_html( $term->name ) |
@@ -1721,7 +1721,7 @@ discard block |
||
1721 | 1721 | } |
1722 | 1722 | } else { |
1723 | 1723 | |
1724 | - $out[] = esc_html( $term->name ); |
|
1724 | + $out[ ] = esc_html( $term->name ); |
|
1725 | 1725 | |
1726 | 1726 | } |
1727 | 1727 | } |
@@ -1789,14 +1789,14 @@ discard block |
||
1789 | 1789 | return; |
1790 | 1790 | } |
1791 | 1791 | |
1792 | - if ( isset( $args['width'] ) ) { |
|
1793 | - $width = is_numeric( $args['width'] ) ? sprintf( '%dpx', $args['width'] ) : $args['width']; |
|
1792 | + if ( isset( $args[ 'width' ] ) ) { |
|
1793 | + $width = is_numeric( $args[ 'width' ] ) ? sprintf( '%dpx', $args[ 'width' ] ) : $args[ 'width' ]; |
|
1794 | 1794 | } else { |
1795 | 1795 | $width = 'auto'; |
1796 | 1796 | } |
1797 | 1797 | |
1798 | - if ( isset( $args['height'] ) ) { |
|
1799 | - $height = is_numeric( $args['height'] ) ? sprintf( '%dpx', $args['height'] ) : $args['height']; |
|
1798 | + if ( isset( $args[ 'height' ] ) ) { |
|
1799 | + $height = is_numeric( $args[ 'height' ] ) ? sprintf( '%dpx', $args[ 'height' ] ) : $args[ 'height' ]; |
|
1800 | 1800 | } else { |
1801 | 1801 | $height = 'auto'; |
1802 | 1802 | } |
@@ -1842,13 +1842,13 @@ discard block |
||
1842 | 1842 | $meta = $out = array(); |
1843 | 1843 | $field = 'connected_' . $connection; |
1844 | 1844 | |
1845 | - if ( isset( $args['field'] ) && isset( $args['value'] ) ) { |
|
1845 | + if ( isset( $args[ 'field' ] ) && isset( $args[ 'value' ] ) ) { |
|
1846 | 1846 | $meta = array( |
1847 | 1847 | 'connected_meta' => array( |
1848 | - $args['field'] => $args['value'], |
|
1848 | + $args[ 'field' ] => $args[ 'value' ], |
|
1849 | 1849 | ), |
1850 | 1850 | ); |
1851 | - $field .= sanitize_title( '_' . $args['field'] . '_' . $args['value'] ); |
|
1851 | + $field .= sanitize_title( '_' . $args[ 'field' ] . '_' . $args[ 'value' ] ); |
|
1852 | 1852 | } |
1853 | 1853 | |
1854 | 1854 | if ( ! isset( $_post->$field ) ) { |
@@ -1877,39 +1877,39 @@ discard block |
||
1877 | 1877 | continue; |
1878 | 1878 | } |
1879 | 1879 | |
1880 | - if ( $args['link'] ) { |
|
1880 | + if ( $args[ 'link' ] ) { |
|
1881 | 1881 | |
1882 | - switch ( $args['link'] ) { |
|
1882 | + switch ( $args[ 'link' ] ) { |
|
1883 | 1883 | case 'view': |
1884 | 1884 | |
1885 | 1885 | if ( $pto->public ) { |
1886 | 1886 | if ( $pso->protected ) { |
1887 | - $out[] = sprintf( |
|
1887 | + $out[ ] = sprintf( |
|
1888 | 1888 | '<a href="%1$s">%2$s</a>', |
1889 | 1889 | esc_url( get_preview_post_link() ), |
1890 | 1890 | esc_html( get_the_title() ) |
1891 | 1891 | ); |
1892 | 1892 | } else { |
1893 | - $out[] = sprintf( |
|
1893 | + $out[ ] = sprintf( |
|
1894 | 1894 | '<a href="%1$s">%2$s</a>', |
1895 | 1895 | esc_url( get_permalink() ), |
1896 | 1896 | esc_html( get_the_title() ) |
1897 | 1897 | ); |
1898 | 1898 | } |
1899 | 1899 | } else { |
1900 | - $out[] = esc_html( get_the_title() ); |
|
1900 | + $out[ ] = esc_html( get_the_title() ); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | break; |
1904 | 1904 | case 'edit': |
1905 | 1905 | if ( current_user_can( 'edit_post', $post->ID ) ) { |
1906 | - $out[] = sprintf( |
|
1906 | + $out[ ] = sprintf( |
|
1907 | 1907 | '<a href="%1$s">%2$s</a>', |
1908 | 1908 | esc_url( get_edit_post_link() ), |
1909 | 1909 | esc_html( get_the_title() ) |
1910 | 1910 | ); |
1911 | 1911 | } else { |
1912 | - $out[] = esc_html( get_the_title() ); |
|
1912 | + $out[ ] = esc_html( get_the_title() ); |
|
1913 | 1913 | } |
1914 | 1914 | break; |
1915 | 1915 | case 'list': |
@@ -1918,7 +1918,7 @@ discard block |
||
1918 | 1918 | 'connected_type' => $connection, |
1919 | 1919 | 'connected_items' => $post->ID, |
1920 | 1920 | ), $meta ), admin_url( 'edit.php' ) ); |
1921 | - $out[] = sprintf( |
|
1921 | + $out[ ] = sprintf( |
|
1922 | 1922 | '<a href="%1$s">%2$s</a>', |
1923 | 1923 | esc_url( $link ), |
1924 | 1924 | esc_html( get_the_title() ) |
@@ -1927,7 +1927,7 @@ discard block |
||
1927 | 1927 | } |
1928 | 1928 | } else { |
1929 | 1929 | |
1930 | - $out[] = esc_html( get_the_title() ); |
|
1930 | + $out[ ] = esc_html( get_the_title() ); |
|
1931 | 1931 | |
1932 | 1932 | } |
1933 | 1933 | } |
@@ -1951,7 +1951,7 @@ discard block |
||
1951 | 1951 | return $actions; |
1952 | 1952 | } |
1953 | 1953 | |
1954 | - unset( $actions['inline'], $actions['inline hide-if-no-js'] ); |
|
1954 | + unset( $actions[ 'inline' ], $actions[ 'inline hide-if-no-js' ] ); |
|
1955 | 1955 | return $actions; |
1956 | 1956 | |
1957 | 1957 | } |
@@ -1964,7 +1964,7 @@ discard block |
||
1964 | 1964 | */ |
1965 | 1965 | public function remove_quick_edit_menu( array $actions ) { |
1966 | 1966 | |
1967 | - unset( $actions['edit'] ); |
|
1967 | + unset( $actions[ 'edit' ] ); |
|
1968 | 1968 | return $actions; |
1969 | 1969 | |
1970 | 1970 | } |
@@ -2003,30 +2003,30 @@ discard block |
||
2003 | 2003 | */ |
2004 | 2004 | protected function get_item_title( array $item ) { |
2005 | 2005 | |
2006 | - if ( isset( $item['taxonomy'] ) ) { |
|
2007 | - if ( $tax = get_taxonomy( $item['taxonomy'] ) ) { |
|
2006 | + if ( isset( $item[ 'taxonomy' ] ) ) { |
|
2007 | + if ( $tax = get_taxonomy( $item[ 'taxonomy' ] ) ) { |
|
2008 | 2008 | if ( ! empty( $tax->exclusive ) ) { |
2009 | 2009 | return $tax->labels->singular_name; |
2010 | 2010 | } else { |
2011 | 2011 | return $tax->labels->name; |
2012 | 2012 | } |
2013 | 2013 | } else { |
2014 | - return $item['taxonomy']; |
|
2014 | + return $item[ 'taxonomy' ]; |
|
2015 | 2015 | } |
2016 | - } else if ( isset( $item['post_field'] ) ) { |
|
2017 | - return ucwords( trim( str_replace( array( 'post_', '_' ), ' ', $item['post_field'] ) ) ); |
|
2018 | - } else if ( isset( $item['meta_key'] ) ) { |
|
2019 | - return ucwords( trim( str_replace( array( '_', '-' ), ' ', $item['meta_key'] ) ) ); |
|
2020 | - } else if ( isset( $item['connection'] ) && isset( $item['value'] ) ) { |
|
2021 | - return ucwords( trim( str_replace( array( '_', '-' ), ' ', $item['value'] ) ) ); |
|
2022 | - } else if ( isset( $item['connection'] ) ) { |
|
2023 | - if ( function_exists( 'p2p_type' ) && $this->p2p_connection_exists( $item['connection'] ) ) { |
|
2024 | - if ( $ctype = p2p_type( $item['connection'] ) ) { |
|
2016 | + } else if ( isset( $item[ 'post_field' ] ) ) { |
|
2017 | + return ucwords( trim( str_replace( array( 'post_', '_' ), ' ', $item[ 'post_field' ] ) ) ); |
|
2018 | + } else if ( isset( $item[ 'meta_key' ] ) ) { |
|
2019 | + return ucwords( trim( str_replace( array( '_', '-' ), ' ', $item[ 'meta_key' ] ) ) ); |
|
2020 | + } else if ( isset( $item[ 'connection' ] ) && isset( $item[ 'value' ] ) ) { |
|
2021 | + return ucwords( trim( str_replace( array( '_', '-' ), ' ', $item[ 'value' ] ) ) ); |
|
2022 | + } else if ( isset( $item[ 'connection' ] ) ) { |
|
2023 | + if ( function_exists( 'p2p_type' ) && $this->p2p_connection_exists( $item[ 'connection' ] ) ) { |
|
2024 | + if ( $ctype = p2p_type( $item[ 'connection' ] ) ) { |
|
2025 | 2025 | $other = ( 'from' === $ctype->direction_from_types( 'post', $this->cpt->post_type ) ) ? 'to' : 'from'; |
2026 | 2026 | return $ctype->side[ $other ]->get_title(); |
2027 | 2027 | } |
2028 | 2028 | } |
2029 | - return $item['connection']; |
|
2029 | + return $item[ 'connection' ]; |
|
2030 | 2030 | } |
2031 | 2031 | |
2032 | 2032 | } |
@@ -2068,13 +2068,13 @@ discard block |
||
2068 | 2068 | |
2069 | 2069 | $new = array(); |
2070 | 2070 | $rules = $wp_rewrite->generate_rewrite_rules( |
2071 | - $struct['struct'], |
|
2072 | - $struct['ep_mask'], |
|
2073 | - $struct['paged'], |
|
2074 | - $struct['feed'], |
|
2075 | - $struct['forcomments'], |
|
2076 | - $struct['walk_dirs'], |
|
2077 | - $struct['endpoints'] |
|
2071 | + $struct[ 'struct' ], |
|
2072 | + $struct[ 'ep_mask' ], |
|
2073 | + $struct[ 'paged' ], |
|
2074 | + $struct[ 'feed' ], |
|
2075 | + $struct[ 'forcomments' ], |
|
2076 | + $struct[ 'walk_dirs' ], |
|
2077 | + $struct[ 'endpoints' ] |
|
2078 | 2078 | ); |
2079 | 2079 | $rules = array_merge( $rules, $additional ); |
2080 | 2080 | $feedregex = implode( '|', $wp_rewrite->feeds ); |
@@ -2102,9 +2102,9 @@ discard block |
||
2102 | 2102 | // Change '$2' to '$matches[2]' |
2103 | 2103 | $result = preg_replace( '/\$([0-9]+)/', '\$matches[$1]', $result ); |
2104 | 2104 | $new[ "/{$regex}" ] = $result; |
2105 | - if ( false !== strpos( $regex, $replace['(?:/([0-9]+))?'] ) ) { |
|
2105 | + if ( false !== strpos( $regex, $replace[ '(?:/([0-9]+))?' ] ) ) { |
|
2106 | 2106 | // Add an extra rule for this optional block |
2107 | - $regex = str_replace( $replace['(?:/([0-9]+))?'], '', $regex ); |
|
2107 | + $regex = str_replace( $replace[ '(?:/([0-9]+))?' ], '', $regex ); |
|
2108 | 2108 | $new[ "/{$regex}" ] = $result; |
2109 | 2109 | } |
2110 | 2110 | } |
@@ -2147,9 +2147,9 @@ discard block |
||
2147 | 2147 | |
2148 | 2148 | // Post type archive rewrites are generated separately. See the `has_archive` handling in `register_post_type()`. |
2149 | 2149 | if ( $pto->has_archive ) { |
2150 | - $archive_slug = ( $pto->has_archive === true ) ? $pto->rewrite['slug'] : $pto->has_archive; |
|
2150 | + $archive_slug = ( $pto->has_archive === true ) ? $pto->rewrite[ 'slug' ] : $pto->has_archive; |
|
2151 | 2151 | |
2152 | - if ( $pto->rewrite['with_front'] ) { |
|
2152 | + if ( $pto->rewrite[ 'with_front' ] ) { |
|
2153 | 2153 | $archive_slug = substr( $wp_rewrite->front, 1 ) . $archive_slug; |
2154 | 2154 | } else { |
2155 | 2155 | $archive_slug = $wp_rewrite->root . $archive_slug; |
@@ -2157,12 +2157,12 @@ discard block |
||
2157 | 2157 | |
2158 | 2158 | $additional[ "{$archive_slug}/?$" ] = "index.php?post_type={$this->cpt->post_type}"; |
2159 | 2159 | |
2160 | - if ( $pto->rewrite['feeds'] && $wp_rewrite->feeds ) { |
|
2160 | + if ( $pto->rewrite[ 'feeds' ] && $wp_rewrite->feeds ) { |
|
2161 | 2161 | $feeds = '(' . trim( implode( '|', $wp_rewrite->feeds ) ) . ')'; |
2162 | 2162 | $additional[ "{$archive_slug}/feed/{$feeds}/?$" ] = "index.php?post_type={$this->cpt->post_type}" . '&feed=$matches[1]'; |
2163 | 2163 | $additional[ "{$archive_slug}/{$feeds}/?$" ] = "index.php?post_type={$this->cpt->post_type}" . '&feed=$matches[1]'; |
2164 | 2164 | } |
2165 | - if ( $pto->rewrite['pages'] ) { |
|
2165 | + if ( $pto->rewrite[ 'pages' ] ) { |
|
2166 | 2166 | $additional[ "{$archive_slug}/{$wp_rewrite->pagination_base}/([0-9]{1,})/?$" ] = "index.php?post_type={$this->cpt->post_type}" . '&paged=$matches[1]'; |
2167 | 2167 | } |
2168 | 2168 | } |
@@ -8,7 +8,7 @@ |
||
8 | 8 | <script language="php"> |
9 | 9 | echo $var; |
10 | 10 | </script> |
11 | -<script language='php'>echo $var;</script> |
|
11 | +<script language='php'>echo $var; </script> |
|
12 | 12 | <script type="text/php" language="php"> |
13 | 13 | echo $var; |
14 | 14 | </script> |
@@ -56,10 +56,10 @@ |
||
56 | 56 | ); |
57 | 57 | |
58 | 58 | if ( true === $this->asp_tags ) { |
59 | - $errors[4] = 1; |
|
60 | - $errors[5] = 1; |
|
61 | - $errors[6] = 1; |
|
62 | - $errors[7] = 1; |
|
59 | + $errors[ 4 ] = 1; |
|
60 | + $errors[ 5 ] = 1; |
|
61 | + $errors[ 6 ] = 1; |
|
62 | + $errors[ 7 ] = 1; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | return $errors; |
@@ -23,4 +23,4 @@ |
||
23 | 23 | |
24 | 24 | $title_parts = spliti( ' ', get_the_title(), 4 ); // Bad, spliti also deprecated. Use preg_split instead. |
25 | 25 | |
26 | -sql_regcase( 'Foo - bar.'); // Bad. Deprecated. |
|
26 | +sql_regcase( 'Foo - bar.' ); // Bad. Deprecated. |
@@ -10,8 +10,10 @@ |
||
10 | 10 | |
11 | 11 | |
12 | 12 | // These should all trigger an error. |
13 | -if ( ereg( '[A-Za-z]+', $title, $regs ) ) // Bad, ereg deprecated. Use preg_match instead. |
|
13 | +if ( ereg( '[A-Za-z]+', $title, $regs ) ) { |
|
14 | + // Bad, ereg deprecated. Use preg_match instead. |
|
14 | 15 | die( $regs ); |
16 | +} |
|
15 | 17 | |
16 | 18 | if ( eregi( '[a-z]+', $title, $regs ) ) {} // Bad, eregi deprecated. Use preg_match instead. |
17 | 19 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | } |
37 | 37 | |
38 | 38 | // Make sure the test excludes functions on the conditional check. |
39 | -if ( strtolower( $check ) == $true ) { // Good. |
|
39 | +if ( strtolower( $check ) == $true ) { // Good. |
|
40 | 40 | echo 'True'; |
41 | 41 | } |
42 | 42 | // Makes sure the test excludes variable casting in the conditional check. |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | |
74 | 74 | if ( $foo == $bar ) {} // Ok. |
75 | 75 | |
76 | -$accessibility_mode = ( 'on' === sanitize_key( $_GET['accessibility-mode'] ) ) ? 'on' : 'off'; // Ok. |
|
76 | +$accessibility_mode = ( 'on' === sanitize_key( $_GET[ 'accessibility-mode' ] ) ) ? 'on' : 'off'; // Ok. |
|
77 | 77 | |
78 | 78 | if ( $on !== self::$network_mode ) { // Ok. |
79 | 79 | self::$network_mode = (bool) $on; |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | return 0 == $foo; // Ok. |
84 | 84 | return $foo == 0; // Bad. |
85 | 85 | |
86 | -if ( (int) $a['interval'] === (int) $b['interval'] ) {} // Ok. |
|
86 | +if ( (int) $a[ 'interval' ] === (int) $b[ 'interval' ] ) {} // Ok. |
|
87 | 87 | |
88 | -if ( $GLOBALS['wpdb']->num_rows === 0 ) {} // Bad. |
|
88 | +if ( $GLOBALS[ 'wpdb' ]->num_rows === 0 ) {} // Bad. |
|
89 | 89 | |
90 | 90 | if ( $true == strtolower( $check ) ) {} // Bad. |
91 | 91 |
@@ -1,73 +1,95 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( $true == true || $false == false ) { // Bad x 2 (in an 'if'). |
|
2 | +if ( $true == true || $false == false ) { |
|
3 | +// Bad x 2 (in an 'if'). |
|
3 | 4 | echo 'True'; |
4 | -} elseif ( $true == true && $false == true ) { // Bad x 2 (in an 'elseif'). |
|
5 | +} elseif ( $true == true && $false == true ) { |
|
6 | +// Bad x 2 (in an 'elseif'). |
|
5 | 7 | echo 'False'; |
6 | -} elseif ( false == $true && true == $false ) { // Good - this is the correct way to do conditional checks. |
|
8 | +} elseif ( false == $true && true == $false ) { |
|
9 | +// Good - this is the correct way to do conditional checks. |
|
7 | 10 | echo 'False'; |
8 | 11 | } |
9 | 12 | |
10 | 13 | // Test for 'equals' conditional. |
11 | -if ( $true == true ) { // Bad x 1. |
|
14 | +if ( $true == true ) { |
|
15 | +// Bad x 1. |
|
12 | 16 | echo 'True'; |
13 | -} elseif ( false == $true ) { // Good. |
|
17 | +} elseif ( false == $true ) { |
|
18 | +// Good. |
|
14 | 19 | echo 'False'; |
15 | 20 | } |
16 | 21 | |
17 | 22 | // Test for 'not equals' conditional. |
18 | -if ( $true != true ) { // Bad x 1. |
|
23 | +if ( $true != true ) { |
|
24 | +// Bad x 1. |
|
19 | 25 | echo 'True'; |
20 | -} elseif ( false != $true ) { // Good. |
|
26 | +} elseif ( false != $true ) { |
|
27 | +// Good. |
|
21 | 28 | echo 'False'; |
22 | 29 | } |
23 | 30 | |
24 | 31 | // Test for 'exactly equals' conditional. |
25 | -if ( $true === true ) { // Bad x 1. |
|
32 | +if ( $true === true ) { |
|
33 | +// Bad x 1. |
|
26 | 34 | echo 'True'; |
27 | -} elseif ( false === $true ) { // Good. |
|
35 | +} elseif ( false === $true ) { |
|
36 | +// Good. |
|
28 | 37 | echo 'False'; |
29 | 38 | } |
30 | 39 | |
31 | 40 | // Test for 'not exactly equals' conditional. |
32 | -if ( $true !== true ) { // Bad x 1. |
|
41 | +if ( $true !== true ) { |
|
42 | +// Bad x 1. |
|
33 | 43 | echo 'True'; |
34 | -} elseif ( false !== $true ) { // Good. |
|
44 | +} elseif ( false !== $true ) { |
|
45 | +// Good. |
|
35 | 46 | echo 'False'; |
36 | 47 | } |
37 | 48 | |
38 | 49 | // Make sure the test excludes functions on the conditional check. |
39 | -if ( strtolower( $check ) == $true ) { // Good. |
|
50 | +if ( strtolower( $check ) == $true ) { |
|
51 | +// Good. |
|
40 | 52 | echo 'True'; |
41 | 53 | } |
42 | 54 | // Makes sure the test excludes variable casting in the conditional check. |
43 | -if ( true == (bool) $true ) { // Good. |
|
55 | +if ( true == (bool) $true ) { |
|
56 | +// Good. |
|
44 | 57 | echo 'True'; |
45 | -} elseif ( false == $true ) { // Good. |
|
58 | +} elseif ( false == $true ) { |
|
59 | +// Good. |
|
46 | 60 | echo 'False'; |
47 | 61 | } |
48 | 62 | // Testing for string comparison. |
49 | -if ( $true == 'true' ) { // Bad x 1. |
|
63 | +if ( $true == 'true' ) { |
|
64 | +// Bad x 1. |
|
50 | 65 | echo 'True'; |
51 | -} elseif ( 'false' == $true ) { // Good x 1. |
|
66 | +} elseif ( 'false' == $true ) { |
|
67 | +// Good x 1. |
|
52 | 68 | echo 'False'; |
53 | 69 | } |
54 | 70 | // Testing for integer comparison. |
55 | -if ( $true == 0 ) { // Bad x 1. |
|
71 | +if ( $true == 0 ) { |
|
72 | +// Bad x 1. |
|
56 | 73 | echo 'True'; |
57 | -} elseif ( 1 == $false ) { // Good x 1. |
|
74 | +} elseif ( 1 == $false ) { |
|
75 | +// Good x 1. |
|
58 | 76 | echo 'False'; |
59 | 77 | } |
60 | 78 | |
61 | 79 | // Testing constant comparison. |
62 | -if ( $taxonomy === MyClass::TAXONOMY_SLUG ) { // Bad. |
|
80 | +if ( $taxonomy === MyClass::TAXONOMY_SLUG ) { |
|
81 | +// Bad. |
|
63 | 82 | $link = true; |
64 | -} elseif ( MyClass::TAXONOMY_SLUG === $taxonomy ) { // Ok. |
|
83 | +} elseif ( MyClass::TAXONOMY_SLUG === $taxonomy ) { |
|
84 | +// Ok. |
|
65 | 85 | $link = false; |
66 | 86 | } |
67 | 87 | |
68 | -if ( $foo === FOO_CONSTANT ) { // Bad. |
|
88 | +if ( $foo === FOO_CONSTANT ) { |
|
89 | +// Bad. |
|
69 | 90 | $link = true; |
70 | -} elseif ( FOO_CONSTANT === $foo ) { // Ok. |
|
91 | +} elseif ( FOO_CONSTANT === $foo ) { |
|
92 | +// Ok. |
|
71 | 93 | $link = false; |
72 | 94 | } |
73 | 95 | |
@@ -75,7 +97,8 @@ discard block |
||
75 | 97 | |
76 | 98 | $accessibility_mode = ( 'on' === sanitize_key( $_GET['accessibility-mode'] ) ) ? 'on' : 'off'; // Ok. |
77 | 99 | |
78 | -if ( $on !== self::$network_mode ) { // Ok. |
|
100 | +if ( $on !== self::$network_mode ) { |
|
101 | +// Ok. |
|
79 | 102 | self::$network_mode = (bool) $on; |
80 | 103 | } |
81 | 104 |
@@ -45,7 +45,7 @@ |
||
45 | 45 | register_globals(); // Bad. |
46 | 46 | |
47 | 47 | query_posts( 'post_type=attachment' ); // Bad, use WP_Query instead. |
48 | -while ( have_posts() ){ |
|
48 | +while ( have_posts() ) { |
|
49 | 49 | the_post(); |
50 | 50 | // ... |
51 | 51 | } |
@@ -45,7 +45,7 @@ |
||
45 | 45 | register_globals(); // Bad. |
46 | 46 | |
47 | 47 | query_posts( 'post_type=attachment' ); // Bad, use WP_Query instead. |
48 | -while ( have_posts() ){ |
|
48 | +while ( have_posts() ) { |
|
49 | 49 | the_post(); |
50 | 50 | // ... |
51 | 51 | } |