Changeset 4294
- Timestamp:
- 10/25/2016 09:59:19 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/handbook.php
r4036 r4294 123 123 add_action( 'template_redirect', array( $this, 'redirect_handbook_root_page' ) ); 124 124 add_filter( 'template_include', array( $this, 'template_include' ) ); 125 add_filter( 'query_vars', array( $this, 'add_query_vars' ) );126 125 add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) ); 127 126 add_action( 'widgets_init', array( $this, 'handbook_sidebar' ), 11 ); // After P2 … … 274 273 */ 275 274 function redirect_handbook_root_page() { 275 global $wp_query; 276 276 277 if ( is_singular( $this->post_type ) 277 278 && 278 279 ! is_preview() 279 280 && 280 ! get_query_var( 'is_handbook_root' )281 ! $wp_query->is_handbook_root 281 282 && 282 283 in_array( get_query_var( 'name' ), array( $this->post_type, substr( $this->post_type, 0, -9 ) ) ) … … 297 298 */ 298 299 function template_include( $template ) { 300 global $wp_query; 301 299 302 $handbook_templates = array(); 300 303 … … 304 307 } 305 308 // For handbook landing page. 306 elseif ( get_query_var( 'is_handbook_root' )&& get_query_var( 'handbook' ) === $this->post_type ) {309 elseif ( $wp_query->is_handbook_root && get_query_var( 'handbook' ) === $this->post_type ) { 307 310 if ( 'handbook' !== $this->post_type ) { 308 311 $handbook_templates[] = "single-{$this->post_type}.php"; … … 320 323 } 321 324 322 /**323 * Add public query vars for handbooks.324 *325 * @param array $public_query_vars The array of whitelisted query variables.326 * @return array Array with public query vars.327 */328 function add_query_vars( $public_query_vars ) {329 $public_query_vars['is_handbook_root'] = false;330 331 return $public_query_vars;332 }333 334 325 function pre_get_posts( $query ) { 326 $query->is_handbook_root = false; 327 335 328 if ( $query->is_main_query() && ! $query->is_admin && ! $query->is_search && $query->is_post_type_archive( $this->post_type ) ) { 336 329 // If the post type has a page to act as an archive index page, get that. … … 342 335 if ( $page ) { 343 336 $query->set( 'p', $page->ID ); 344 $query-> set('is_handbook_root', true );337 $query->is_handbook_root = true; 345 338 346 339 $query->is_archive = false;
Note: See TracChangeset
for help on using the changeset viewer.