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