Plugin Directory

Changeset 1319194


Ignore:
Timestamp:
12/31/2015 12:47:51 PM (10 years ago)
Author:
hogetan
Message:

removed debug code. added pagename.

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

Legend:

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

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

    r1315691 r1319194  
    4242        add_action('template_redirect', array(self::$instance, 'template_redirect'));
    4343        add_action('delete_option', array(self::$instance, 'delete_option'), 10, 1 );
     44        add_action('pre_get_posts', array(self::$instance, 'pre_get_posts'));
     45    }
     46
     47    /**
     48     * queryvarsのpagenameをセット
     49     */
     50    public function pre_get_posts() {
     51        /** @var WP_Query */
     52        global $wp_query;
     53        global $wp_rewrite;
     54        $request_url = $_SERVER['REQUEST_URI'];
     55        $request_url =user_trailingslashit($request_url);
     56        // remove slash   "/hoge/" => "hoge"
     57        $slug = preg_replace('#^/?([^/]+)/?$#', '\\1', $request_url);
     58        $wp_query->set('pagename', $slug);
     59        return $wp_query;
    4460    }
    4561
  • add-page-from-template/trunk/includes/class-option.php

    r1315691 r1319194  
    198198        $link = user_trailingslashit($link, 'page');
    199199        return apply_filters( '_get_page_link', $link, 0 );
    200 
    201200    }
    202201
     
    215214            </thead>
    216215            <tbody>
    217             <?php
    218             $url = $this->getPageLink('hoge');
    219             var_dump($url);
    220             ?>
    221216            <?php foreach ($templates as $template) { ?>
    222217                <tr class="nodrag nodrop">
  • add-page-from-template/trunk/readme.txt

    r1315691 r1319194  
    5353== Changelog ==
    5454
     55= Version 0.3 =
     56* Fixed: Removed debug code.
     57* Fixed: Added pagename when apft virtual page loaded.
     58
    5559= Version 0.2 =
    5660* Fixed: version number.
Note: See TracChangeset for help on using the changeset viewer.