WordPress.org

Plugin Directory

Changeset 1605106


Ignore:
Timestamp:
02/28/17 09:44:25 (9 months ago)
Author:
petersplugins
Message:

v 2.4 DEV - current dev state

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 404page/trunk/404page.php

    r1602211 r1605106  
    151151        // as of v2.1 we do not alter the posts argument here because this does not work with SiteOrigin's Page Builder Plugin, template_include filter introduced 
    152152        $this->postid = $pageid; 
    153         $this->template = get_page_template_slug( $pageid ); 
    154         if ( $this->template == '' ) { 
    155           $this->template = get_page_template(); 
    156         } 
     153         
     154        // as of v 2.4 we use the the_posts filter instead of posts_results 
     155        // therefore we have to reset $wp_query  
     156        // resetting $wp_query also forces us to remove the pre_get_posts action plus the get_pages filter 
     157         
     158        remove_action( 'pre_get_posts', array ( $this, 'exclude_404page' ) ); 
     159        remove_filter( 'get_pages', array ( $this, 'remove_404page_from_array' ), 10, 2 ); 
     160         
     161        global $wp_query; 
     162        $wp_query = null; 
     163        $wp_query = new WP_Query(); 
     164        $wp_query->query( 'page_id=' . $pageid ); 
     165        $wp_query->the_post(); 
     166 
     167        $this->template = get_page_template(); 
     168         
     169        $posts = $wp_query->posts; 
     170         
     171        $wp_query->rewind_posts(); 
     172         
     173 
    157174        add_action( 'wp', array( $this, 'do_404_header' ) ); 
    158175        add_filter( 'body_class', array( $this, 'add_404_body_class' ) ); 
    159176        add_filter( 'template_include', array( $this, 'change_404_template' ), 999 ); 
    160          
    161         $posts[] = get_post( $pageid ); 
    162177         
    163178        $this->do_404page_action(); 
     
    200215  // this function overrides the page template in compatibilty mode 
    201216  function change_404_template( $template ) { 
     217     
    202218    // we have to check if the template file is there because if the theme was changed maybe a wrong template is stored in the database 
    203219    $new_template = locate_template( array( $this->template ) ); 
Note: See TracChangeset for help on using the changeset viewer.