WordPress.org

Make WordPress Core

Ticket #22352: link-template.php.patch

File link-template.php.patch, 978 bytes (added by doublesharp, 2 years ago)

optional permalink structure argument for get_permalink()

  • link-template.php

     
    7575 * 
    7676 * @param int $id Optional. Post ID. 
    7777 * @param bool $leavename Optional, defaults to false. Whether to keep post name or page name. 
     78 * @param string $permalink_structure Optional, the permalink structure to use instead of the current permalink structure. 
    7879 * @return string 
    7980 */ 
    80 function get_permalink( $id = 0, $leavename = false ) { 
     81function get_permalink( $id = 0, $leavename = false, $permalink_structure = false ) { 
    8182        $rewritecode = array( 
    8283                '%year%', 
    8384                '%monthnum%', 
     
    110111        elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) ) 
    111112                return get_post_permalink($post->ID, $leavename, $sample); 
    112113 
    113         $permalink = get_option('permalink_structure'); 
     114        $permalink = (!empty($permalink_structure))? $permalink_structure : get_option('permalink_structure'); 
    114115 
    115116        $permalink = apply_filters('pre_post_link', $permalink, $post, $leavename); 
    116117