PluginProbe
Bogo / 2.6
Bogo v2.6
3.9.3 trunk 1.0 1.1 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5 2.6 2.6.1 2.7 2.8 2.8.1 2.9 3.0 3.0.1 All 52 releases
← All changes | includes/query.php +46 -19 2.32.6 View file →
@@ -4,10 +4,11 @@
4 4
5 5 function bogo_parse_query( $query ) {
6 6 $qv = &$query->query_vars;
7 7
8 - if ( ! empty( $qv['bogo_suppress_locale_query'] ) )
8 + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) {
9 9 return;
10 + }
10 11
11 12 if ( isset( $qv['post_type'] ) && 'any' != $qv['post_type'] ) {
12 13 $localizable = array_filter( (array) $qv['post_type'], 'bogo_is_localizable_post_type' );
13 14
@@ -21,15 +22,17 @@
21 22
22 23 if ( is_admin() ) {
23 24 $locale = $lang;
24 25 } else {
25 - if ( $lang )
26 + if ( $lang ) {
26 27 $locale = bogo_get_closest_locale( $lang );
27 - else
28 + } else {
28 29 $locale = get_locale();
30 + }
29 31
30 - if ( empty( $locale ) )
32 + if ( empty( $locale ) ) {
31 33 $locale = bogo_get_default_locale();
34 + }
32 35 }
33 36
34 37 if ( empty( $locale ) || ! bogo_is_available_locale( $locale ) ) {
35 38 $qv['bogo_suppress_locale_query'] = true;
@@ -37,10 +40,11 @@
37 40 }
38 41
39 42 $qv['lang'] = $locale;
40 43
41 - if ( is_admin() )
44 + if ( is_admin() ) {
42 45 return;
46 + }
43 47
44 48 if ( $query->is_home && 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) ) {
45 49 $query_keys = array_keys( wp_parse_args( $query->query ) );
46 50 $query_keys = array_diff( $query_keys,
@@ -61,14 +65,15 @@
61 65
62 66 if ( '' != $qv['pagename'] ) {
63 67 $query->queried_object = bogo_get_page_by_path( $qv['pagename'], $locale );
64 68
65 - if ( ! empty( $query->queried_object ) )
69 + if ( ! empty( $query->queried_object ) ) {
66 70 $query->queried_object_id = (int) $query->queried_object->ID;
67 - else
71 + } else {
68 72 unset( $query->queried_object );
73 + }
69 74
70 - if ( 'page' == get_option( 'show_on_front' )
75 + if ( 'page' == get_option( 'show_on_front' )
71 76 && isset( $query->queried_object_id )
72 77 && $query->queried_object_id == get_option( 'page_for_posts' ) ) {
73 78 $query->is_page = false;
74 79 $query->is_home = true;
@@ -74,8 +79,22 @@
74 79 $query->is_home = true;
75 80 $query->is_posts_page = true;
76 81 }
77 82 }
83 +
84 + if ( isset( $qv['post_type'] )
85 + && 'any' != $qv['post_type']
86 + && ! is_array( $qv['post_type'] )
87 + && '' != $qv['name'] ) {
88 + $query->queried_object = bogo_get_page_by_path(
89 + $qv['name'], $locale, $qv['post_type'] );
90 +
91 + if ( ! empty( $query->queried_object ) ) {
92 + $query->queried_object_id = (int) $query->queried_object->ID;
93 + } else {
94 + unset( $query->queried_object );
95 + }
96 + }
78 97 }
79 98
80 99 add_filter( 'posts_join', 'bogo_posts_join', 10, 2 );
81 100
@@ -83,18 +102,21 @@
83 102 global $wpdb;
84 103
85 104 $qv = &$query->query_vars;
86 105
87 - if ( ! empty( $qv['bogo_suppress_locale_query'] ) )
106 + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) {
88 107 return $join;
108 + }
89 109
90 110 $locale = empty( $qv['lang'] ) ? '' : $qv['lang'];
91 111
92 - if ( ! bogo_is_available_locale( $locale ) )
112 + if ( ! bogo_is_available_locale( $locale ) ) {
93 113 return $join;
114 + }
94 115
95 - if ( ! $meta_table = _get_meta_table( 'post' ) )
116 + if ( ! $meta_table = _get_meta_table( 'post' ) ) {
96 117 return $join;
118 + }
97 119
98 120 $join .= " LEFT JOIN $meta_table AS postmeta_bogo ON ($wpdb->posts.ID = postmeta_bogo.post_id AND postmeta_bogo.meta_key = '_locale')";
99 121
100 122 return $join;
@@ -106,25 +128,29 @@
106 128 global $wpdb;
107 129
108 130 $qv = &$query->query_vars;
109 131
110 - if ( ! empty( $qv['bogo_suppress_locale_query'] ) )
132 + if ( ! empty( $qv['bogo_suppress_locale_query'] ) ) {
111 133 return $where;
134 + }
112 135
113 136 $locale = empty( $qv['lang'] ) ? '' : $qv['lang'];
114 137
115 - if ( ! bogo_is_available_locale( $locale ) )
138 + if ( ! bogo_is_available_locale( $locale ) ) {
116 139 return $where;
140 + }
117 141
118 - if ( ! $meta_table = _get_meta_table( 'post' ) )
142 + if ( ! $meta_table = _get_meta_table( 'post' ) ) {
119 143 return $where;
144 + }
120 145
121 146 $where .= " AND (1=0";
122 147
123 148 $where .= $wpdb->prepare( " OR postmeta_bogo.meta_value LIKE %s", $locale );
124 149
125 - if ( bogo_is_default_locale( $locale ) )
150 + if ( bogo_is_default_locale( $locale ) ) {
126 151 $where .= " OR postmeta_bogo.meta_id IS NULL";
152 + }
127 153
128 154 $where .= ")";
129 155
130 156 return $where;
@@ -132,10 +158,11 @@
132 158
133 159 add_filter( 'option_sticky_posts', 'bogo_option_sticky_posts' );
134 160
135 161 function bogo_option_sticky_posts( $posts ) {
136 - if ( is_admin() )
162 + if ( is_admin() ) {
137 163 return $posts;
164 + }
138 165
139 166 $locale = get_locale();
140 167
141 168 foreach ( $posts as $key => $post_id ) {
@@ -180,8 +207,9 @@
180 207 $q .= " ON posts.ID = pm1.post_id AND pm1.meta_key = '_original_post'";
181 208 $q .= " LEFT JOIN $wpdb->postmeta AS pm2";
182 209 $q .= " ON posts.ID = pm2.post_id AND pm2.meta_key = '_locale'";
183 210 $q .= " WHERE 1=1";
211 + $q .= " AND post_status = 'publish'";
184 212 $q .= $wpdb->prepare( " AND post_type = %s", $post_type );
185 213 $q .= $wpdb->prepare( " AND (ID = %d OR pm1.meta_value = %d)",
186 214 $original, $original );
187 215 $q .= " AND (1=0";
@@ -190,11 +218,10 @@
190 218 $q .= ")";
191 219
192 220 $translation = absint( $wpdb->get_var( $q ) );
193 221
194 - if ( $translation )
222 + if ( $translation ) {
195 223 return $translation;
224 + }
196 225
197 226 return $post_id;
198 227 }
199 -
200 -?>