Changeset 1345256
- Timestamp:
- 02/07/2016 03:06:21 PM (10 years ago)
- Location:
- add-page-from-template/trunk
- Files:
-
- 7 edited
-
add-page-from-template.php (modified) (1 diff)
-
includes/class-option.php (modified) (3 diffs)
-
includes/class-template.php (modified) (3 diffs)
-
includes/class-templatestatus.php (modified) (1 diff)
-
readme.txt (modified) (1 diff)
-
tests/pages/page-hoge.php (modified) (1 diff)
-
tests/test-loader.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
add-page-from-template/trunk/add-page-from-template.php
r1345043 r1345256 5 5 * Description(en): Add pages from template files. 6 6 * Description: Creates virtural page from template file. 7 * Version: 0.4. 27 * Version: 0.4.3 8 8 * Author: Yousan_O 9 9 * Author URI: http://www.l2tp.org -
add-page-from-template/trunk/includes/class-option.php
r1345038 r1345256 105 105 'setting_apft', // ID 106 106 __('APFT Custom Settings', 'apft'), // Title 107 array($this, 'print_section_info'), // Callback107 null, // Callback 108 108 'apft-setting-admin' // Page 109 109 ); … … 225 225 <thead> 226 226 <tr class="head" style="cursor: move;"> 227 <th scope="col" title="<?php _e('Put \'Title:\' comment header at template file to set title.', 'apft'); ?>"><?php _e('Title', 'apft'); ?></th> 227 228 <th scope="col"><?php _e('Template Name', 'apft'); ?></th> 228 229 <th scope="col"><?php _e('Status', 'apft'); ?></th> … … 233 234 <?php foreach ($templates as $template) { ?> 234 235 <tr class="nodrag nodrop"> 236 <td><?php echo $template->title; ?></td> 235 237 <td><?php echo $template->slug; ?></td> 236 238 <td class="apft-status-<?php echo $template->status; ?>"> -
add-page-from-template/trunk/includes/class-template.php
r1323814 r1345256 10 10 class AP_Template { 11 11 12 /** 13 * Fullpath 14 * ex.) /path/to/theme/pages/page-hoge.php 15 * 16 * @var string 17 */ 12 18 public $path; 19 20 /** 21 * Filename 22 * ex.) page-hoge.php 23 * 24 * @var string 25 */ 13 26 public $filename; 27 14 28 public $slug = ''; 29 public $title = ''; 15 30 public $status = NULL; 16 31 public $pagename = ''; 17 32 18 public function __construct($path) { 33 /** 34 * Headers for template files. 35 * 36 * @static 37 * @access private 38 * @var array 39 * @see WP_Theme 40 */ 41 private static $file_headers = array( 42 'Title' => 'Title', 43 ); 44 45 46 /** 47 * Header data from the theme's template file. 48 * 49 * @access private 50 * @var array 51 */ 52 private $headers = array(); 53 54 55 56 public function __construct($path) { 19 57 $this->path = $path; 20 58 $this->filename = basename($path); 59 $this->retrieveHeaders(); 21 60 $pattern = '#^(?<path>.*)page-(?<unislug>[^\.]+)\.php$#'; 22 61 … … 39 78 } 40 79 80 private function retrieveHeaders() { 81 $this->headers = get_file_data( $this->path, self::$file_headers ); 82 if ( isset( $this->headers['Title'] ) ) { 83 $this->title = $this->headers['Title']; 84 } 85 } 86 41 87 /** 42 88 * Returns a template slug name. … … 51 97 52 98 private function getStatus() { 99 /** @var WP_Rewrite */ 100 //$wp_rewrite; 53 101 // incomplete 54 102 return AP_TemplateStatus::ENABLED; 55 103 } 104 105 /** 106 * Retrieve title from template file. 107 */ 108 public function getTitle() { 109 return $this->title; 110 } 111 112 /** 113 * Retrieve title from template file. 114 * Returns the first title. 115 * Title: OK! 116 * 117 * @param $content 118 * 119 * @return string 120 * @see get_file_data() 121 * @see WP_Theme::file_headers 122 */ 123 public function retrieveTitle($filepath) { 124 // 125 } 126 56 127 } -
add-page-from-template/trunk/includes/class-templatestatus.php
r1306270 r1345256 12 12 const DISABLED = 'disabled'; 13 13 const CONFLICTED = 'conflicted'; 14 const NOTLOADED = 'notloaded'; 14 15 } -
add-page-from-template/trunk/readme.txt
r1345043 r1345256 53 53 == Changelog == 54 54 55 = Version 0.4.3 = 56 * Upgraded: Show title from template file. 57 55 58 = Version 0.4.2 = 56 59 * Fixed: Removed a warning. -
add-page-from-template/trunk/tests/pages/page-hoge.php
r1345038 r1345256 1 1 <?php 2 2 /** 3 * Title: hogeee 3 4 * Created by PhpStorm. 4 5 * User: yousan -
add-page-from-template/trunk/tests/test-loader.php
r1345038 r1345256 26 26 */ 27 27 public function testRegister_update_rewrite_rules() { 28 $loader = new AP_Loader(); 28 global $wp_query; 29 $loader = new AP_Loader(AP_TemplateSearcher::getTemplates()); 29 30 //$loader-> 30 $this->assertQueryTrue('is_page'); 31 $this->go_to( '/' ); 32 $this->assertQueryTrue('is_home'); 31 33 } 32 34 }
Note: See TracChangeset
for help on using the changeset viewer.