Update WP and plugins
This commit is contained in:
parent
10a4713229
commit
1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions
|
@ -11,98 +11,98 @@
|
|||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_NONE', 0);
|
||||
define( 'EP_NONE', 0 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for Permalink.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_PERMALINK', 1);
|
||||
define( 'EP_PERMALINK', 1 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for Attachment.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_ATTACHMENT', 2);
|
||||
define( 'EP_ATTACHMENT', 2 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for date.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_DATE', 4);
|
||||
define( 'EP_DATE', 4 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for year
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_YEAR', 8);
|
||||
define( 'EP_YEAR', 8 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for month.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_MONTH', 16);
|
||||
define( 'EP_MONTH', 16 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for day.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_DAY', 32);
|
||||
define( 'EP_DAY', 32 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for root.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_ROOT', 64);
|
||||
define( 'EP_ROOT', 64 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for comments.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_COMMENTS', 128);
|
||||
define( 'EP_COMMENTS', 128 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for searches.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_SEARCH', 256);
|
||||
define( 'EP_SEARCH', 256 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for categories.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_CATEGORIES', 512);
|
||||
define( 'EP_CATEGORIES', 512 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for tags.
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
define('EP_TAGS', 1024);
|
||||
define( 'EP_TAGS', 1024 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for authors.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_AUTHORS', 2048);
|
||||
define( 'EP_AUTHORS', 2048 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for pages.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*/
|
||||
define('EP_PAGES', 4096);
|
||||
define( 'EP_PAGES', 4096 );
|
||||
|
||||
/**
|
||||
* Endpoint Mask for all archive views.
|
||||
|
@ -158,8 +158,9 @@ function add_rewrite_rule( $regex, $query, $after = 'bottom' ) {
|
|||
*/
|
||||
function add_rewrite_tag( $tag, $regex, $query = '' ) {
|
||||
// validate the tag's name
|
||||
if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen($tag) - 1 ] != '%' )
|
||||
if ( strlen( $tag ) < 3 || $tag[0] != '%' || $tag[ strlen( $tag ) - 1 ] != '%' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_rewrite, $wp;
|
||||
|
||||
|
@ -203,10 +204,12 @@ function add_permastruct( $name, $struct, $args = array() ) {
|
|||
global $wp_rewrite;
|
||||
|
||||
// Back-compat for the old parameters: $with_front and $ep_mask.
|
||||
if ( ! is_array( $args ) )
|
||||
if ( ! is_array( $args ) ) {
|
||||
$args = array( 'with_front' => $args );
|
||||
if ( func_num_args() == 4 )
|
||||
}
|
||||
if ( func_num_args() == 4 ) {
|
||||
$args['ep_mask'] = func_get_arg( 3 );
|
||||
}
|
||||
|
||||
$wp_rewrite->add_permastruct( $name, $struct, $args );
|
||||
}
|
||||
|
@ -266,7 +269,7 @@ function add_feed( $feedname, $function ) {
|
|||
* @global WP_Rewrite $wp_rewrite
|
||||
*
|
||||
* @param bool $hard Whether to update .htaccess (hard flush) or just update
|
||||
* rewrite_rules transient (soft flush). Default is true (hard).
|
||||
* rewrite_rules transient (soft flush). Default is true (hard).
|
||||
*/
|
||||
function flush_rewrite_rules( $hard = true ) {
|
||||
global $wp_rewrite;
|
||||
|
@ -322,7 +325,7 @@ function add_rewrite_endpoint( $name, $places, $query_var = true ) {
|
|||
* @return string
|
||||
*/
|
||||
function _wp_filter_taxonomy_base( $base ) {
|
||||
if ( !empty( $base ) ) {
|
||||
if ( ! empty( $base ) ) {
|
||||
$base = preg_replace( '|^/index\.php/|', '', $base );
|
||||
$base = trim( $base, '/' );
|
||||
}
|
||||
|
@ -480,31 +483,34 @@ function url_to_postid( $url ) {
|
|||
}
|
||||
|
||||
// First, check to see if there is a 'p=N' or 'page_id=N' to match against
|
||||
if ( preg_match('#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values) ) {
|
||||
$id = absint($values[2]);
|
||||
if ( $id )
|
||||
if ( preg_match( '#[?&](p|page_id|attachment_id)=(\d+)#', $url, $values ) ) {
|
||||
$id = absint( $values[2] );
|
||||
if ( $id ) {
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
|
||||
// Get rid of the #anchor
|
||||
$url_split = explode('#', $url);
|
||||
$url = $url_split[0];
|
||||
$url_split = explode( '#', $url );
|
||||
$url = $url_split[0];
|
||||
|
||||
// Get rid of URL ?query=string
|
||||
$url_split = explode('?', $url);
|
||||
$url = $url_split[0];
|
||||
$url_split = explode( '?', $url );
|
||||
$url = $url_split[0];
|
||||
|
||||
// Set the correct URL scheme.
|
||||
$scheme = parse_url( home_url(), PHP_URL_SCHEME );
|
||||
$url = set_url_scheme( $url, $scheme );
|
||||
$url = set_url_scheme( $url, $scheme );
|
||||
|
||||
// Add 'www.' if it is absent and should be there
|
||||
if ( false !== strpos(home_url(), '://www.') && false === strpos($url, '://www.') )
|
||||
$url = str_replace('://', '://www.', $url);
|
||||
if ( false !== strpos( home_url(), '://www.' ) && false === strpos( $url, '://www.' ) ) {
|
||||
$url = str_replace( '://', '://www.', $url );
|
||||
}
|
||||
|
||||
// Strip 'www.' if it is present and shouldn't be
|
||||
if ( false === strpos(home_url(), '://www.') )
|
||||
$url = str_replace('://www.', '://', $url);
|
||||
if ( false === strpos( home_url(), '://www.' ) ) {
|
||||
$url = str_replace( '://www.', '://', $url );
|
||||
}
|
||||
|
||||
if ( trim( $url, '/' ) === home_url() && 'page' == get_option( 'show_on_front' ) ) {
|
||||
$page_on_front = get_option( 'page_on_front' );
|
||||
|
@ -518,44 +524,48 @@ function url_to_postid( $url ) {
|
|||
$rewrite = $wp_rewrite->wp_rewrite_rules();
|
||||
|
||||
// Not using rewrite rules, and 'p=N' and 'page_id=N' methods failed, so we're out of options
|
||||
if ( empty($rewrite) )
|
||||
if ( empty( $rewrite ) ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Strip 'index.php/' if we're not using path info permalinks
|
||||
if ( !$wp_rewrite->using_index_permalinks() )
|
||||
if ( ! $wp_rewrite->using_index_permalinks() ) {
|
||||
$url = str_replace( $wp_rewrite->index . '/', '', $url );
|
||||
}
|
||||
|
||||
if ( false !== strpos( trailingslashit( $url ), home_url( '/' ) ) ) {
|
||||
// Chop off http://domain.com/[path]
|
||||
$url = str_replace(home_url(), '', $url);
|
||||
$url = str_replace( home_url(), '', $url );
|
||||
} else {
|
||||
// Chop off /path/to/blog
|
||||
$home_path = parse_url( home_url( '/' ) );
|
||||
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '' ;
|
||||
$url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
|
||||
$home_path = isset( $home_path['path'] ) ? $home_path['path'] : '';
|
||||
$url = preg_replace( sprintf( '#^%s#', preg_quote( $home_path ) ), '', trailingslashit( $url ) );
|
||||
}
|
||||
|
||||
// Trim leading and lagging slashes
|
||||
$url = trim($url, '/');
|
||||
$url = trim( $url, '/' );
|
||||
|
||||
$request = $url;
|
||||
$request = $url;
|
||||
$post_type_query_vars = array();
|
||||
|
||||
foreach ( get_post_types( array() , 'objects' ) as $post_type => $t ) {
|
||||
if ( ! empty( $t->query_var ) )
|
||||
foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) {
|
||||
if ( ! empty( $t->query_var ) ) {
|
||||
$post_type_query_vars[ $t->query_var ] = $post_type;
|
||||
}
|
||||
}
|
||||
|
||||
// Look for matches.
|
||||
$request_match = $request;
|
||||
foreach ( (array)$rewrite as $match => $query) {
|
||||
foreach ( (array) $rewrite as $match => $query ) {
|
||||
|
||||
// If the requesting file is the anchor of the match, prepend it
|
||||
// to the path info.
|
||||
if ( !empty($url) && ($url != $request) && (strpos($match, $url) === 0) )
|
||||
if ( ! empty( $url ) && ( $url != $request ) && ( strpos( $match, $url ) === 0 ) ) {
|
||||
$request_match = $url . '/' . $request;
|
||||
}
|
||||
|
||||
if ( preg_match("#^$match#", $request_match, $matches) ) {
|
||||
if ( preg_match( "#^$match#", $request_match, $matches ) ) {
|
||||
|
||||
if ( $wp_rewrite->use_verbose_page_rules && preg_match( '/pagename=\$matches\[([0-9]+)\]/', $query, $varmatch ) ) {
|
||||
// This is a verbose page match, let's check to be sure about it.
|
||||
|
@ -573,21 +583,21 @@ function url_to_postid( $url ) {
|
|||
|
||||
// Got a match.
|
||||
// Trim the query of everything up to the '?'.
|
||||
$query = preg_replace("!^.+\?!", '', $query);
|
||||
$query = preg_replace( '!^.+\?!', '', $query );
|
||||
|
||||
// Substitute the substring matches into the query.
|
||||
$query = addslashes(WP_MatchesMapRegex::apply($query, $matches));
|
||||
$query = addslashes( WP_MatchesMapRegex::apply( $query, $matches ) );
|
||||
|
||||
// Filter out non-public query vars
|
||||
global $wp;
|
||||
parse_str( $query, $query_vars );
|
||||
$query = array();
|
||||
foreach ( (array) $query_vars as $key => $value ) {
|
||||
if ( in_array( $key, $wp->public_query_vars ) ){
|
||||
$query[$key] = $value;
|
||||
if ( isset( $post_type_query_vars[$key] ) ) {
|
||||
$query['post_type'] = $post_type_query_vars[$key];
|
||||
$query['name'] = $value;
|
||||
if ( in_array( $key, $wp->public_query_vars ) ) {
|
||||
$query[ $key ] = $value;
|
||||
if ( isset( $post_type_query_vars[ $key ] ) ) {
|
||||
$query['post_type'] = $post_type_query_vars[ $key ];
|
||||
$query['name'] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -597,10 +607,11 @@ function url_to_postid( $url ) {
|
|||
|
||||
// Do the query
|
||||
$query = new WP_Query( $query );
|
||||
if ( ! empty( $query->posts ) && $query->is_singular )
|
||||
if ( ! empty( $query->posts ) && $query->is_singular ) {
|
||||
return $query->post->ID;
|
||||
else
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue