Plugin Directory

Changeset 1351823


Ignore:
Timestamp:
02/16/2016 01:20:25 PM (10 years ago)
Author:
hogetan
Message:

fixed critical bug.

Location:
add-page-from-template/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • add-page-from-template/trunk/add-page-from-template.php

    r1351795 r1351823  
    55 * Description(en): Add pages from template files.
    66 * Description: Creates virtural page from template file.
    7  * Version: 0.4.4
     7 * Version: 0.4.4.1
    88 * Author: Yousan_O
    99 * Author URI: http://www.l2tp.org
  • add-page-from-template/trunk/includes/class-loader.php

    r1351795 r1351823  
    4747        add_action( 'template_redirect', array(self::$instance, 'template_redirect')) ;
    4848        add_action( 'delete_option', array(self::$instance, 'delete_option'), 10, 1 );
    49         add_action( 'parse_query', array(self::$instance, 'setGlobalQuery') );
     49        add_action( 'parse_query', array(self::$instance, 'setPseudoPage') );
    5050    }
    5151
     
    5959    }
    6060
    61     public function setGlobalQuery($arg) {
     61    public function setPseudoPage( $arg ) {
     62        /** @var WP_Query */
     63        global $wp_query;
     64
     65        if ( $wp_query->is_page ) { // void infinite loop
     66            return;
     67        }
     68        $this->setTemplate();
     69        if ( !is_null($this->template) ) {
     70            $this->setGlobalPost();
     71            $this->setGlobalQuery();
     72        }
     73
     74    }
     75
     76    public function setGlobalQuery() {
    6277        /**
    6378         * @var WP_Query $wp_query
     
    6681        global $wp_query, $post;
    6782
    68         if ( $wp_query->is_page ) { // void infinite loop
    69             return;
    70         }
    71 
    72         $this->setTemplate();
    73         $this->setGlobalPost($this->template);
    74         $template = $this->template;
    75 
    7683        $args = array(
    7784            'p' => 0,
    7885            'post_parent' => '',
    7986            'name' => '', // must be null. The post will be seen 'post' when this value is set.
    80             'pagename' => sanitize_title($template->title),
     87            'pagename' => sanitize_title($this->template->title),
    8188            'author' => 0,
    82             'title' => $template->title,
     89            'title' => $this->template->title,
    8390        );
    8491        $wp_query->queried_object = $post;
     
    94101     * @see get_default_post_to_edit()
    95102     */
    96     private function setGlobalPost(AP_Template $template) {
     103    private function setGlobalPost() {
    97104        /** @var WP_Post */
    98105        global $post;
     
    105112        $postObj->post_date_gmt = '';
    106113        $postObj->post_password = '';
    107         $postObj->post_title = $template->title;
    108         $postObj->post_name = sanitize_title($template->title);
     114        $postObj->post_title = $this->template->title;
     115        $postObj->post_name = sanitize_title($this->template->title);
    109116        $postObj->post_type = 'page';
    110117        $postObj->post_status = 'publish';
  • add-page-from-template/trunk/readme.txt

    r1351795 r1351823  
    5353== Changelog ==
    5454
     55= Version 0.4.4.1 =
     56* Fixed: Remove critical bug.
     57
    5558= Version 0.4.4 =
    5659* Fixed: Set Title when called at wp_title().
Note: See TracChangeset for help on using the changeset viewer.