Changeset 1351823
- Timestamp:
- 02/16/2016 01:20:25 PM (10 years ago)
- Location:
- add-page-from-template/trunk
- Files:
-
- 3 edited
-
add-page-from-template.php (modified) (1 diff)
-
includes/class-loader.php (modified) (5 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
add-page-from-template/trunk/add-page-from-template.php
r1351795 r1351823 5 5 * Description(en): Add pages from template files. 6 6 * Description: Creates virtural page from template file. 7 * Version: 0.4.4 7 * Version: 0.4.4.1 8 8 * Author: Yousan_O 9 9 * Author URI: http://www.l2tp.org -
add-page-from-template/trunk/includes/class-loader.php
r1351795 r1351823 47 47 add_action( 'template_redirect', array(self::$instance, 'template_redirect')) ; 48 48 add_action( 'delete_option', array(self::$instance, 'delete_option'), 10, 1 ); 49 add_action( 'parse_query', array(self::$instance, 'set GlobalQuery') );49 add_action( 'parse_query', array(self::$instance, 'setPseudoPage') ); 50 50 } 51 51 … … 59 59 } 60 60 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() { 62 77 /** 63 78 * @var WP_Query $wp_query … … 66 81 global $wp_query, $post; 67 82 68 if ( $wp_query->is_page ) { // void infinite loop69 return;70 }71 72 $this->setTemplate();73 $this->setGlobalPost($this->template);74 $template = $this->template;75 76 83 $args = array( 77 84 'p' => 0, 78 85 'post_parent' => '', 79 86 'name' => '', // must be null. The post will be seen 'post' when this value is set. 80 'pagename' => sanitize_title($t emplate->title),87 'pagename' => sanitize_title($this->template->title), 81 88 'author' => 0, 82 'title' => $t emplate->title,89 'title' => $this->template->title, 83 90 ); 84 91 $wp_query->queried_object = $post; … … 94 101 * @see get_default_post_to_edit() 95 102 */ 96 private function setGlobalPost( AP_Template $template) {103 private function setGlobalPost() { 97 104 /** @var WP_Post */ 98 105 global $post; … … 105 112 $postObj->post_date_gmt = ''; 106 113 $postObj->post_password = ''; 107 $postObj->post_title = $t emplate->title;108 $postObj->post_name = sanitize_title($t emplate->title);114 $postObj->post_title = $this->template->title; 115 $postObj->post_name = sanitize_title($this->template->title); 109 116 $postObj->post_type = 'page'; 110 117 $postObj->post_status = 'publish'; -
add-page-from-template/trunk/readme.txt
r1351795 r1351823 53 53 == Changelog == 54 54 55 = Version 0.4.4.1 = 56 * Fixed: Remove critical bug. 57 55 58 = Version 0.4.4 = 56 59 * Fixed: Set Title when called at wp_title().
Note: See TracChangeset
for help on using the changeset viewer.