Changeset 27291
- Timestamp:
- 02/26/2014 06:15:03 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/link-template.php
r27288 r27291 1149 1149 * 1150 1150 * Based on the current or specified post, determines either the previous or 1151 * next post based on the criteria specified. Supports retrieving posts with the 1152 * same taxonomy terms and posts that lack specific terms. 1151 * next post based on the criteria specified. Supports retrieving posts with 1152 * the same taxonomy terms and posts that lack specific terms. 1153 * 1154 * @since 3.9.0 1155 * 1156 * @package WordPress 1157 * @subpackage Template 1153 1158 */ 1154 1159 class WP_Adjacent_Post { 1160 1161 /** 1162 * Adjacent post object. 1163 * 1164 * @since 3.9.0 1165 * @access public 1166 * @var null|WP_Adjacent_Post 1167 */ 1155 1168 public $adjacent_post = null; 1156 1169 1170 /** 1171 * Current post object. 1172 * 1173 * @since 3.9.0 1174 * @access protected 1175 * @var bool|WP_Post 1176 */ 1157 1177 protected $current_post = false; 1178 1179 /** 1180 * 'previous' or 'next' type of adjacent post. 1181 * 1182 * @since 3.9.0 1183 * @access protected 1184 * @var string 1185 */ 1158 1186 protected $adjacent = 'previous'; 1187 1159 1188 protected $taxonomy = 'category'; 1189 1190 /** 1191 * Whether the post should be in a same taxonomy term. 1192 * 1193 * @since 3.9.0 1194 * @access protected 1195 * @var string 1196 */ 1160 1197 protected $in_same_term = false; 1198 1199 /** 1200 * Excluded term IDs. 1201 * 1202 * @since 3.9.0 1203 * @access protected 1204 * @var string|array 1205 */ 1161 1206 protected $excluded_terms = ''; 1162 1207 … … 1180 1225 * Allow direct access to adjacent post from the class instance itself 1181 1226 * 1182 * @param string $property 1227 * @param string $property Property to get. 1183 1228 * @return mixed String when adjacent post is found and post property exists. Null when no adjacent post is found. 1184 1229 */ … … 1313 1358 * 1314 1359 * @param array $clauses 1315 * @uses $this->filter_join_and_where()1316 * @uses $this->filter_sort()1317 * @filter post_clauses1318 1360 * @return array 1319 1361 */ 1320 1362 public function filter( $clauses ) { 1321 // Immediately deregister these legacy filters to avoid modifying 1322 // any calls to WP_Query from filter callbacks hooked to WP_Query filters. 1363 /* 1364 * Immediately deregister these legacy filters to avoid modifying 1365 * any calls to WP_Query from filter callbacks hooked to WP_Query filters. 1366 */ 1323 1367 remove_filter( 'posts_clauses', array( $this, 'filter' ) ); 1324 1368 1325 // The `join` and `where` filters are identical in their parameters, 1326 // so we can use the same approach for both. 1369 /* 1370 * The `join` and `where` filters are identical in their parameters, 1371 * so we can use the same approach for both. 1372 */ 1327 1373 foreach ( array( 'join', 'where' ) as $clause ) { 1328 1374 if ( has_filter( 'get_' . $this->adjacent . '_post_' . $clause ) ) { … … 1331 1377 } 1332 1378 1333 // The legacy `sort` filter combined the ORDER BY and LIMIT clauses, 1334 // while `WP_Query` does not, which requires special handling. 1379 /* 1380 * The legacy `sort` filter combined the ORDER BY and LIMIT clauses, 1381 * while `WP_Query` does not, which requires special handling. 1382 */ 1335 1383 if ( has_filter( 'get_' . $this->adjacent . '_post_sort' ) ) { 1336 1384 $sort_clauses = $this->filter_sort( $clauses['orderby'], $clauses['limits'] ); … … 1350 1398 protected function filter_join_and_where( $value, $clause ) { 1351 1399 /** 1400 * @todo Minimal hook docs 1352 1401 * @deprecated 3.9.0 1353 1402 */ … … 1378 1427 // Split the string of one or two clauses into their respective array keys 1379 1428 if ( false !== $has_order_by && false !== $has_limit ) { 1380 // The LIMIT clause cannot appear before the ORDER BY clause in a valid query 1381 // However, since the legacy filter would allow a user to invert the order, we maintain that handling so the same errors are triggered. 1429 /* 1430 * The LIMIT clause cannot appear before the ORDER BY clause in a valid query 1431 * However, since the legacy filter would allow a user to invert the order, 1432 * we maintain that handling so the same errors are triggered. 1433 */ 1382 1434 if ( $has_order_by < $has_limit ) { 1383 1435 $orderby = trim( str_ireplace( 'order by', '', substr( $sort, 0, $has_limit ) ) );
Note: See TracChangeset
for help on using the changeset viewer.