Plugin Directory

Changeset 1345256


Ignore:
Timestamp:
02/07/2016 03:06:21 PM (10 years ago)
Author:
hogetan
Message:

show title

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

Legend:

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

    r1345043 r1345256  
    55 * Description(en): Add pages from template files.
    66 * Description: Creates virtural page from template file.
    7  * Version: 0.4.2
     7 * Version: 0.4.3
    88 * Author: Yousan_O
    99 * Author URI: http://www.l2tp.org
  • add-page-from-template/trunk/includes/class-option.php

    r1345038 r1345256  
    105105            'setting_apft', // ID
    106106            __('APFT Custom Settings', 'apft'), // Title
    107             array($this, 'print_section_info'), // Callback
     107            null, // Callback
    108108            'apft-setting-admin' // Page
    109109        );
     
    225225            <thead>
    226226            <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>
    227228                <th scope="col"><?php _e('Template Name', 'apft'); ?></th>
    228229                <th scope="col"><?php _e('Status', 'apft'); ?></th>
     
    233234            <?php foreach ($templates as $template) { ?>
    234235                <tr class="nodrag nodrop">
     236                    <td><?php echo $template->title; ?></td>
    235237                    <td><?php echo $template->slug; ?></td>
    236238                    <td class="apft-status-<?php echo $template->status; ?>">
  • add-page-from-template/trunk/includes/class-template.php

    r1323814 r1345256  
    1010class AP_Template {
    1111
     12    /**
     13     * Fullpath
     14     * ex.) /path/to/theme/pages/page-hoge.php
     15     *
     16     * @var string
     17     */
    1218    public $path;
     19
     20    /**
     21     * Filename
     22     * ex.) page-hoge.php
     23     *
     24     * @var string
     25     */
    1326    public $filename;
     27
    1428    public $slug = '';
     29    public $title = '';
    1530    public $status = NULL;
    1631    public $pagename = '';
    1732
    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) {
    1957        $this->path = $path;
    2058        $this->filename = basename($path);
     59        $this->retrieveHeaders();
    2160        $pattern = '#^(?<path>.*)page-(?<unislug>[^\.]+)\.php$#';
    2261
     
    3978    }
    4079
     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
    4187    /**
    4288     * Returns a template slug name.
     
    5197
    5298    private function getStatus() {
     99        /** @var WP_Rewrite */
     100        //$wp_rewrite;
    53101        // incomplete
    54102        return AP_TemplateStatus::ENABLED;
    55103    }
     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
    56127}
  • add-page-from-template/trunk/includes/class-templatestatus.php

    r1306270 r1345256  
    1212    const DISABLED = 'disabled';
    1313    const CONFLICTED = 'conflicted';
     14    const NOTLOADED = 'notloaded';
    1415}
  • add-page-from-template/trunk/readme.txt

    r1345043 r1345256  
    5353== Changelog ==
    5454
     55= Version 0.4.3 =
     56* Upgraded: Show title from template file.
     57
    5558= Version 0.4.2 =
    5659* Fixed: Removed a warning.
  • add-page-from-template/trunk/tests/pages/page-hoge.php

    r1345038 r1345256  
    11<?php
    22/**
     3 * Title: hogeee
    34 * Created by PhpStorm.
    45 * User: yousan
  • add-page-from-template/trunk/tests/test-loader.php

    r1345038 r1345256  
    2626     */
    2727    public function testRegister_update_rewrite_rules() {
    28         $loader = new AP_Loader();
     28        global $wp_query;
     29        $loader = new AP_Loader(AP_TemplateSearcher::getTemplates());
    2930        //$loader->
    30         $this->assertQueryTrue('is_page');
     31        $this->go_to( '/' );
     32        $this->assertQueryTrue('is_home');
    3133    }
    3234}
Note: See TracChangeset for help on using the changeset viewer.