WordPress.org

Plugin Directory

Changeset 582310


Ignore:
Timestamp:
08/06/12 15:06:17 (21 months ago)
Author:
jbrinley
Message:

merged updates from github

Location:
wp-router/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-router/trunk/WP_Router_Page.class.php

    r569749 r582310  
    11<?php 
    2 /** 
    3  * User: jbrinley 
    4  * Date: 5/18/11 
    5  * Time: 2:31 PM 
    6  */ 
    72 
    83class WP_Router_Page extends WP_Router_Utility { 
     
    1510    protected $title = ''; 
    1611    protected $template = ''; 
     12    protected $meta = array(); 
    1713 
    1814    public static function init() { 
     
    10096        add_filter('single_post_title', array($this, 'get_single_post_title'), 10, 2); 
    10197        add_filter('redirect_canonical', array($this, 'override_redirect'), 10, 2); 
     98        add_filter('get_post_metadata', array($this, 'set_post_meta'), 10, 4); 
     99        add_filter('post_type_link', array($this, 'override_permalink'), 10, 4); 
    102100        if ( $this->template ) { 
    103101            add_filter('template_include', array($this, 'override_template'), 10, 1); 
     
    198196        return $redirect_url; 
    199197    } 
     198 
     199    /** 
     200     * Some plugins expect certain data in post meta. It obviously 
     201     * won't be there for the placeholder page. Let's pretend 
     202     * it is there. 
     203     * 
     204     * @param array|null $meta 
     205     * @param int $post_id 
     206     * @param string $meta_key 
     207     * @param bool $single 
     208     * @return array 
     209     */ 
     210    public function set_post_meta( $meta, $post_id, $meta_key, $single ) { 
     211        if ( $post_id == self::get_post_id() ) { 
     212            if ( empty($this->meta) ) { 
     213                $this->meta = array( 
     214                    '_yoast_wpseo_title' => array($this->get_title('', $post_id)), 
     215                ); 
     216                $this->meta = apply_filters('wp_router_placeholder_postmeta', $this->meta); 
     217            } 
     218            if ( $meta_key ) { 
     219                if ( empty($this->meta[$meta_key]) ) { 
     220                    return NULL; 
     221                } 
     222                return $this->meta[$meta_key]; 
     223            } 
     224            return $this->meta; 
     225        } 
     226        return $meta; 
     227    } 
     228 
     229    public function override_permalink( $post_link, $post, $leavename, $sample ) { 
     230        if ( $post->ID == self::get_post_id() ) { 
     231            if ( $post->ID == get_queried_object_id() ) { 
     232                global $wp; 
     233                return home_url($wp->request); 
     234            } 
     235        } 
     236        return $post_link; 
     237    } 
    200238} 
  • wp-router/trunk/readme.txt

    r569752 r582310  
    143143== Changelog == 
    144144 
    145 = 0.1 = 
     145= 0.5 = 
    146146 
    147 * Initial version 
     147* Filter get_permalink on router pages to point to the requested URI 
     148* Filter post meta for the placeholder page when on a router page to provide a title to WP SEO 
     149* Added `wp_router_placeholder_postmeta` filter for adding additional meta to the placeholder page 
    148150 
    149 = 0.2 = 
     151= 0.4 = 
    150152 
    151 * Added the `template` argument 
     153* Prevent redirect from route pages with the "page" or "paged" query arg 
     154 
     155= 0.3.3 = 
     156 
     157* Prevent redirect from all route pages when %category% is in the permastruct 
     158* Redirect placeholder page to the blog front page 
     159* Fix usage of translation functions 
     160 
     161= 0.3.2 = 
     162 
     163* Make $arguments param optional for WP_Router::get_url() and WP_Router::url() 
     164 
     165= 0.3.1 = 
     166 
     167* Added WP_Router::get_url() 
     168* Added WP_Route::url() 
    152169 
    153170= 0.3 = 
     
    158175* Added WP_Router::get_url() function 
    159176 
    160 = 0.3.1 = 
     177= 0.2 = 
    161178 
    162 * Added WP_Router::get_url() 
    163 * Added WP_Route::url() 
     179* Added the `template` argument 
    164180 
    165 = 0.3.2 = 
     181= 0.1 = 
    166182 
    167 * Make $arguments param optional for WP_Router::get_url() and WP_Router::url() 
    168  
    169 = 0.3.3 = 
    170  
    171 * Prevent redirect from all route pages when %category% is in the permastruct 
    172 * Redirect placeholder page to the blog front page 
    173 * Fix usage of translation functions 
    174  
    175 = 0.4 = 
    176  
    177 * Prevent redirect from route pages with the "page" or "paged" query arg 
     183* Initial version 
  • wp-router/trunk/wp-router.php

    r569749 r582310  
    66Author: Flightless 
    77Author URI: http://flightless.us/ 
    8 Version: 0.4 
     8Version: 0.5 
    99*/ 
    1010/* 
Note: See TracChangeset for help on using the changeset viewer.