* @uses apply_filters() Calls 'the_permalink' filter on the permalink string.
*/
function the_permalink() {
- echo apply_filters('the_permalink', get_permalink());
+ echo esc_url( apply_filters( 'the_permalink', get_permalink() ) );
}
/**
*
* @since 1.5.0
*
- * @param mixed $post Optional. Post ID or object.
+ * @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional, defaults to false. Whether to keep page name.
* @param bool $sample Optional, defaults to false. Is it a sample permalink.
* @return string
* @since 2.1.0
* @access private
*
- * @param mixed $post Optional. Post ID or object.
+ * @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional. Leave name.
* @param bool $sample Optional. Sample permalink.
* @return string
*
* @since 2.0.0
*
- * @param mixed $post Optional. Post ID or object.
+ * @param int|object $post Optional. Post ID or object.
* @param bool $leavename Optional. Leave name.
* @return string
*/
$link = false;
$post = get_post( $post );
+ $parent = ( $post->post_parent > 0 && $post->post_parent != $post->ID ) ? get_post( $post->post_parent ) : false;
- if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
- $parent = get_post($post->post_parent);
+ if ( $wp_rewrite->using_permalinks() && $parent ) {
if ( 'page' == $parent->post_type )
$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
else
if ( ! $link = get_post_type_archive_link( $post_type ) )
return false;
+
$post_type_obj = get_post_type_object( $post_type );
- if ( $post_type_obj->rewrite['feeds'] && get_option( 'permalink_structure' ) ) {
- $link = trailingslashit($link);
+ if ( get_option( 'permalink_structure' ) && is_array( $post_type_obj->rewrite ) && $post_type_obj->rewrite['feeds'] ) {
+ $link = trailingslashit( $link );
$link .= 'feed/';
if ( $feed != $default_feed )
$link .= "$feed/";
if ( ! $post = get_post( $id ) )
return;
- if ( 'display' == $context )
+ if ( 'revision' === $post->post_type )
+ $action = '';
+ elseif ( 'display' == $context )
$action = '&action=edit';
else
$action = '&action=edit';
if ( !$post_type_object )
return;
- if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) )
+ if ( !current_user_can( 'edit_post', $post->ID ) )
return;
return apply_filters( 'get_edit_post_link', admin_url( sprintf($post_type_object->_edit_link . $action, $post->ID) ), $post->ID, $context );
if ( !$post_type_object )
return;
- if ( !current_user_can( $post_type_object->cap->delete_post, $post->ID ) )
+ if ( !current_user_can( 'delete_post', $post->ID ) )
return;
$action = ( $force_delete || !EMPTY_TRASH_DAYS ) ? 'delete' : 'trash';
$where = apply_filters( "get_{$adjacent}_post_where", $wpdb->prepare("WHERE p.post_date $op %s AND p.post_type = %s AND p.post_status = 'publish' $posts_in_ex_cats_sql", $current_post_date, $post->post_type), $in_same_cat, $excluded_categories );
$sort = apply_filters( "get_{$adjacent}_post_sort", "ORDER BY p.post_date $order LIMIT 1" );
- $query = "SELECT p.id FROM $wpdb->posts AS p $join $where $sort";
+ $query = "SELECT p.ID FROM $wpdb->posts AS p $join $where $sort";
$query_key = 'adjacent_post_' . md5($query);
$result = wp_cache_get($query_key, 'counts');
if ( false !== $result ) {
if ( empty($post) )
return;
- if ( empty($post->post_title) )
+ $post_title = the_title_attribute( array( 'echo' => false, 'post' => $post ) );
+
+ if ( empty( $post_title ) )
$post_title = $previous ? __('Previous Post') : __('Next Post');
- else
- $post_title = $post->post_title;
$date = mysql2date(get_option('date_format'), $post->post_date);
$title = str_replace('%title', $post_title, $title);
$title = str_replace('%date', $date, $title);
- $title = apply_filters('the_title', $title, $post->ID);
$link = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
$link .= esc_attr( $title );
}
$request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request);
- $request = preg_replace( '|^index\.php|i', '', $request);
+ $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request);
$request = ltrim($request, '/');
$base = trailingslashit( get_bloginfo( 'url' ) );
if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' != $request ) )
- $base .= 'index.php/';
+ $base .= $wp_rewrite->index . '/';
if ( $pagenum > 1 ) {
$request = ( ( !empty( $request ) ) ? trailingslashit( $request ) : $request ) . user_trailingslashit( $wp_rewrite->pagination_base . "/" . $pagenum, 'paged' );
$url = set_url_scheme( $url, $scheme );
- if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ if ( $path && is_string( $path ) )
$url .= '/' . ltrim( $path, '/' );
return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
$url = set_url_scheme( $url, $scheme );
- if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ if ( $path && is_string( $path ) )
$url .= '/' . ltrim( $path, '/' );
return apply_filters( 'site_url', $url, $path, $scheme, $blog_id );
function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
$url = get_site_url($blog_id, 'wp-admin/', $scheme);
- if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
return apply_filters( 'admin_url', $url, $path, $blog_id );
* @since 2.6.0
*
* @param string $path Optional. Path relative to the includes url.
+ * @param string $scheme Optional. Scheme to give the includes url context.
* @return string Includes url link with optional path appended.
*/
-function includes_url($path = '') {
- $url = site_url() . '/' . WPINC . '/';
+function includes_url( $path = '', $scheme = null ) {
+ $url = site_url( '/' . WPINC . '/', $scheme );
- if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
return apply_filters('includes_url', $url, $path);
function content_url($path = '') {
$url = set_url_scheme( WP_CONTENT_URL );
- if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+ if ( $path && is_string( $path ) )
$url .= '/' . ltrim($path, '/');
return apply_filters('content_url', $url, $path);
$url .= '/' . ltrim($folder, '/');
}
- if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+ if ( $path && is_string( $path ) )
$url .= '/' . ltrim($path, '/');
return apply_filters('plugins_url', $url, $path, $plugin);
else
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
- if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
return apply_filters( 'network_site_url', $url, $path, $scheme );
else
$url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
- if ( ! empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
return apply_filters( 'network_home_url', $url, $path, $orig_scheme);
$url = network_site_url('wp-admin/network/', $scheme);
- if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
return apply_filters('network_admin_url', $url, $path);
function user_admin_url( $path = '', $scheme = 'admin' ) {
$url = network_site_url('wp-admin/user/', $scheme);
- if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
+ if ( $path && is_string( $path ) )
$url .= ltrim($path, '/');
return apply_filters('user_admin_url', $url, $path);