Make WordPress Core


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/link-template.php

    r19054 r20944  
    508508 *
    509509 * @param string $link_text Descriptive text.
    510  * @param int $post_id Optional post ID.  Default to current post.
     510 * @param int $post_id Optional post ID. Default to current post.
    511511 * @param string $feed Optional. Feed format.
    512512 * @return string Link to the comment feed for the current post.
    … …  
    590590*/
    591591function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) {
    592         global $wp_rewrite;
    593 
    594592        $term_id = ( int ) $term_id;
    595593
    … …  
    631629                $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy );
    632630
    633 
    634631        return $link;
    635632}
    … …  
    13761373 *
    13771374 * @param int $pagenum Optional. Page ID.
    1378  * @return string
    1379  */
    1380 function get_pagenum_link($pagenum = 1) {
     1375 * @param bool $escape Optional. Whether to escape the URL for display, with esc_url(). Defaults to true.
     1376*       Otherwise, prepares the URL with esc_url_raw().
     1377 * @return string
     1378 */
     1379function get_pagenum_link($pagenum = 1, $escape = true ) {
    13811380        global $wp_rewrite;
    13821381
    … …  
    14291428        $result = apply_filters('get_pagenum_link', $result);
    14301429
    1431         return $result;
     1430        if ( $escape )
     1431                return esc_url( $result );
     1432        else
     1433                return esc_url_raw( $result );
    14321434}
    14331435
    … …  
    15671569        if ( !is_single() && $paged > 1 ) {
    15681570                $attr = apply_filters( 'previous_posts_link_attributes', '' );
    1569                 return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/', '&#038;$1', $label ) .'</a>';
     1571                return '<a href="' . previous_posts( false ) . "\" $attr>". preg_replace( '/&([^#])(?![a-z]{1,8};)/i', '&#038;$1', $label ) .'</a>';
    15701572        }
    15711573}
    … …  
    17941796
    17951797/**
    1796  * Retrieve shortcut link.
     1798 * Retrieve the Press This bookmarklet link.
    17971799 *
    17981800 * Use this in 'a' element 'href' attribute.
    … …  
    18031805 */
    18041806function get_shortcut_link() {
     1807        // In case of breaking changes, version this. #WP20071
    18051808        $link = "javascript:
    18061809                        var d=document,
    … …  
    18361839 *
    18371840 * @param  string $path   (optional) Path relative to the home url.
    1838  * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
     1841 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
    18391842 * @return string Home url link with optional path appended.
    18401843*/
    … …  
    18551858 * @param  int $blog_id   (optional) Blog ID. Defaults to current blog.
    18561859 * @param  string $path   (optional) Path relative to the home url.
    1857  * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
     1860 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
    18581861 * @return string Home url link with optional path appended.
    18591862*/
    … …  
    18611864        $orig_scheme = $scheme;
    18621865
    1863         if ( !in_array( $scheme, array( 'http', 'https' ) ) )
     1866        if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
    18641867                $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
    18651868
    … …  
    18691872                $url = get_blog_option( $blog_id, 'home' );
    18701873
    1871         if ( 'http' != $scheme )
     1874        if ( 'relative' == $scheme )
     1875                $url = preg_replace( '#^.+://[^/]*#', '', $url );
     1876        elseif ( 'http' != $scheme )
    18721877                $url = str_replace( 'http://', "$scheme://", $url );
    18731878
    … …  
    18911896 *
    18921897 * @param string $path Optional. Path relative to the site url.
    1893  * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
     1898 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
    18941899 * @return string Site url link with optional path appended.
    18951900*/
    … …  
    19101915 * @param int $blog_id (optional) Blog ID. Defaults to current blog.
    19111916 * @param string $path Optional. Path relative to the site url.
    1912  * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
     1917 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
    19131918 * @return string Site url link with optional path appended.
    19141919*/
    … …  
    19161921        // should the list of allowed schemes be maintained elsewhere?
    19171922        $orig_scheme = $scheme;
    1918         if ( !in_array( $scheme, array( 'http', 'https' ) ) ) {
     1923        if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
    19191924                if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
    19201925                        $scheme = 'https';
    … …  
    19321937                $url = get_blog_option( $blog_id, 'siteurl' );
    19331938
    1934         if ( 'http' != $scheme )
     1939        if ( 'relative' == $scheme )
     1940                $url = preg_replace( '#^.+://[^/]*#', '', $url );
     1941        elseif ( 'http' != $scheme )
    19351942                $url = str_replace( 'http://', "{$scheme}://", $url );
    19361943
    … …  
    20632070 *
    20642071 * @param string $path Optional. Path relative to the site url.
    2065  * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', or 'admin'.
     2072 * @param string $scheme Optional. Scheme to give the site url context. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
    20662073 * @return string Site url link with optional path appended.
    20672074*/
    … …  
    20732080
    20742081        $orig_scheme = $scheme;
    2075         if ( !in_array($scheme, array('http', 'https')) ) {
     2082        if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
    20762083                if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
    20772084                        $scheme = 'https';
    … …  
    20842091        }
    20852092
    2086         $url = $scheme . '://' . $current_site->domain . $current_site->path;
     2093        if ( 'relative' == $scheme )
     2094                $url = $current_site->path;
     2095        else
     2096                $url = $scheme . '://' . $current_site->domain . $current_site->path;
    20872097
    20882098        if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
    … …  
    21032113 *
    21042114 * @param  string $path   (optional) Path relative to the home url.
    2105  * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https'.
     2115 * @param  string $scheme (optional) Scheme to give the home url context. Currently 'http', 'https', or 'relative'.
    21062116 * @return string Home url link with optional path appended.
    21072117*/
    … …  
    21142124        $orig_scheme = $scheme;
    21152125
    2116         if ( !in_array($scheme, array('http', 'https')) )
     2126        if ( !in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
    21172127                $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
    21182128
    2119         $url = $scheme . '://' . $current_site->domain . $current_site->path;
     2129        if ( 'relative' == $scheme )
     2130                $url = $current_site->path;
     2131        else
     2132                $url = $scheme . '://' . $current_site->domain . $current_site->path;
    21202133
    21212134        if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
    … …  
    21862199
    21872200/**
     2201 * Set the scheme for a URL
     2202 *
     2203 * @since 3.4.0
     2204 *
     2205 * @param string $url Absolute url that includes a scheme
     2206 * @param string $scheme Optional. Scheme to give $url. Currently 'http', 'https', 'login', 'login_post', 'admin', or 'relative'.
     2207 * @return string $url URL with chosen scheme.
     2208 */
     2209function set_url_scheme( $url, $scheme = null ) {
     2210        $orig_scheme = $scheme;
     2211        if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) ) {
     2212                if ( ( 'login_post' == $scheme || 'rpc' == $scheme ) && ( force_ssl_login() || force_ssl_admin() ) )
     2213                        $scheme = 'https';
     2214                elseif ( ( 'login' == $scheme ) && force_ssl_admin() )
     2215                        $scheme = 'https';
     2216                elseif ( ( 'admin' == $scheme ) && force_ssl_admin() )
     2217                        $scheme = 'https';
     2218                else
     2219                        $scheme = ( is_ssl() ? 'https' : 'http' );
     2220        }
     2221
     2222        if ( 'relative' == $scheme )
     2223                $url = preg_replace( '#^.+://[^/]*#', '', $url );
     2224        else
     2225                $url = preg_replace( '#^.+://#', $scheme . '://', $url );
     2226
     2227        return apply_filters( 'set_url_scheme', $url, $scheme, $orig_scheme );
     2228}
     2229
     2230/**
    21882231 * Get the URL to the user's dashboard.
    21892232 *
    2190  * If a user does not belong to any site, the global user dashboard is used.  If the user belongs to the current site,
     2233 * If a user does not belong to any site, the global user dashboard is used. If the user belongs to the current site,
    21912234 * the dashboard for the current site is returned. If the user cannot edit the current site, the dashboard to the user's
    21922235 * primary blog is returned.
    … …  
    23652408
    23662409        if ( empty( $title ) )
    2367                 $title = the_title_attribute( array( 'echo' => FALSE ) );
     2410                $title = the_title_attribute( array( 'echo' => false ) );
    23682411
    23692412        $shortlink = wp_get_shortlink( $post->ID );
    … …  
    23752418        }
    23762419}
    2377 
    2378 ?>
Note: See TracChangeset for help on using the changeset viewer.