*
* @param string $string URL with or without a trailing slash.
* @param string $type_of_url The type of URL being considered. Accepts 'single', 'single_trackback',
- * 'single_feed', 'single_paged', 'feed', 'category', 'page', 'year',
- * 'month', 'day', 'paged', 'post_type_archive'.
+ * 'single_feed', 'single_paged', 'commentpaged', 'paged', 'home', 'feed',
+ * 'category', 'page', 'year', 'month', 'day', 'post_type_archive'.
*/
return apply_filters( 'user_trailingslashit', $string, $type_of_url );
}
if ( strpos($permalink, '%category%') !== false ) {
$cats = get_the_category($post->ID);
if ( $cats ) {
- usort($cats, '_usort_terms_by_ID'); // order by ID
+ $cats = wp_list_sort( $cats, array(
+ 'term_id' => 'ASC',
+ ) );
/**
* Filters the category that gets used in the %category% permalink token.
*
* @since 3.5.0
*
- * @param stdClass $cat The category to use in the permalink.
- * @param array $cats Array of all categories associated with the post.
+ * @param WP_Term $cat The category to use in the permalink.
+ * @param array $cats Array of all categories (WP_Term objects) associated with the post.
* @param WP_Post $post The post in question.
*/
$category_object = apply_filters( 'post_link_category', $cats[0], $cats, $post );
}
$tax = get_taxonomy( $term->taxonomy );
- if ( ! $tax || ! current_user_can( $tax->cap->edit_terms ) ) {
+ if ( ! $tax || ! current_user_can( 'edit_term', $term->term_id ) ) {
return;
}
return;
$tax = get_taxonomy( $term->taxonomy );
- if ( ! current_user_can( $tax->cap->edit_terms ) )
+ if ( ! current_user_can( 'edit_term', $term->term_id ) ) {
return;
+ }
if ( empty( $link ) )
$link = __('Edit This');
if ( $GLOBALS['wp_query']->max_num_pages > 1 ) {
$args = wp_parse_args( $args, array(
'mid_size' => 1,
- 'prev_text' => _x( 'Previous', 'previous post' ),
- 'next_text' => _x( 'Next', 'next post' ),
+ 'prev_text' => _x( 'Previous', 'previous set of posts' ),
+ 'next_text' => _x( 'Next', 'next set of posts' ),
'screen_reader_text' => __( 'Posts navigation' ),
) );
*
* @since 2.6.0
*
- * @global bool $is_IE Whether the browser matches an Internet Explorer user agent.
- * @global string $wp_version WP version.
- *
- * @global bool $is_IE
- * @global string $wp_version
- * @global WP_Press_This $wp_press_this
- *
- * @return string The Press This bookmarklet link URL.
+ * @global bool $is_IE Whether the browser matches an Internet Explorer user agent.
*/
function get_shortcut_link() {
- global $is_IE, $wp_version;
+ global $is_IE;
include_once( ABSPATH . 'wp-admin/includes/class-wp-press-this.php' );
- $bookmarklet_version = $GLOBALS['wp_press_this']->version;
+
$link = '';
if ( $is_IE ) {
$link = 'javascript:var d=document,w=window,e=w.getSelection,k=d.getSelection,x=d.selection,' .
's=(e?e():(k)?k():(x?x.createRange().text:0)),f=' . $url . ',l=d.location,e=encodeURIComponent,' .
- 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . $bookmarklet_version . '";' .
+ 'u=f+"?u="+e(l.href)+"&t="+e(d.title)+"&s="+e(s)+"&v=' . WP_Press_This::VERSION . '";' .
'a=function(){if(!w.open(u,"t","toolbar=0,resizable=1,scrollbars=1,status=1,width=600,height=700"))l.href=u;};' .
'if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();void(0)';
}
$src = @file_get_contents( ABSPATH . 'wp-admin/js/bookmarklet.min.js' );
if ( $src ) {
- $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . $bookmarklet_version );
+ $url = wp_json_encode( admin_url( 'press-this.php' ) . '?v=' . WP_Press_This::VERSION );
$link = 'javascript:' . str_replace( 'window.pt_url', $url, $src );
}
}
/**
* Retrieves the URL for the current site where the front end is accessible.
*
- * Returns the 'home' option with the appropriate protocol, 'https' if
- * is_ssl() and 'http' otherwise. If `$scheme` is 'http' or 'https',
- * `is_ssl()` is overridden.
+ * Returns the 'home' option with the appropriate protocol. The protocol will be 'https'
+ * if is_ssl() evaluates to true; otherwise, it will be the same as the 'home' option.
+ * If `$scheme` is 'http' or 'https', is_ssl() is overridden.
*
* @since 3.0.0
*
/**
* Retrieves the URL for a given site where the front end is accessible.
*
- * Returns the 'home' option with the appropriate protocol, 'https' if
- * is_ssl() and 'http' otherwise. If `$scheme` is 'http' or 'https',
- * `is_ssl()` is overridden.
+ * Returns the 'home' option with the appropriate protocol. The protocol will be 'https'
+ * if is_ssl() evaluates to true; otherwise, it will be the same as the 'home' option.
+ * If `$scheme` is 'http' or 'https', is_ssl() is overridden.
*
* @since 3.0.0
*
if ( ! is_multisite() )
return site_url($path, $scheme);
- $current_site = get_current_site();
+ $current_network = get_network();
if ( 'relative' == $scheme )
- $url = $current_site->path;
+ $url = $current_network->path;
else
- $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
+ $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
if ( ! is_multisite() )
return home_url($path, $scheme);
- $current_site = get_current_site();
+ $current_network = get_network();
$orig_scheme = $scheme;
if ( ! in_array( $scheme, array( 'http', 'https', 'relative' ) ) )
$scheme = is_ssl() && ! is_admin() ? 'https' : 'http';
if ( 'relative' == $scheme )
- $url = $current_site->path;
+ $url = $current_network->path;
else
- $url = set_url_scheme( 'http://' . $current_site->domain . $current_site->path, $scheme );
+ $url = set_url_scheme( 'http://' . $current_network->domain . $current_network->path, $scheme );
if ( $path && is_string( $path ) )
$url .= ltrim( $path, '/' );
*/
return apply_filters( 'get_avatar_data', $args, $id_or_email );
}
+
+/**
+ * Retrieves the URL of a file in the theme.
+ *
+ * Searches in the stylesheet directory before the template directory so themes
+ * which inherit from a parent theme can just override one file.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to search for in the stylesheet directory.
+ * @return string The URL of the file.
+ */
+function get_theme_file_uri( $file = '' ) {
+ $file = ltrim( $file, '/' );
+
+ if ( empty( $file ) ) {
+ $url = get_stylesheet_directory_uri();
+ } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
+ $url = get_stylesheet_directory_uri() . '/' . $file;
+ } else {
+ $url = get_template_directory_uri() . '/' . $file;
+ }
+
+ /**
+ * Filters the URL to a file in the theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $url The file URL.
+ * @param string $file The requested file to search for.
+ */
+ return apply_filters( 'theme_file_uri', $url, $file );
+}
+
+/**
+ * Retrieves the URL of a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to return the URL for in the template directory.
+ * @return string The URL of the file.
+ */
+function get_parent_theme_file_uri( $file = '' ) {
+ $file = ltrim( $file, '/' );
+
+ if ( empty( $file ) ) {
+ $url = get_template_directory_uri();
+ } else {
+ $url = get_template_directory_uri() . '/' . $file;
+ }
+
+ /**
+ * Filters the URL to a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $url The file URL.
+ * @param string $file The requested file to search for.
+ */
+ return apply_filters( 'parent_theme_file_uri', $url, $file );
+}
+
+/**
+ * Retrieves the path of a file in the theme.
+ *
+ * Searches in the stylesheet directory before the template directory so themes
+ * which inherit from a parent theme can just override one file.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to search for in the stylesheet directory.
+ * @return string The path of the file.
+ */
+function get_theme_file_path( $file = '' ) {
+ $file = ltrim( $file, '/' );
+
+ if ( empty( $file ) ) {
+ $path = get_stylesheet_directory();
+ } elseif ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
+ $path = get_stylesheet_directory() . '/' . $file;
+ } else {
+ $path = get_template_directory() . '/' . $file;
+ }
+
+ /**
+ * Filters the path to a file in the theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $path The file path.
+ * @param string $file The requested file to search for.
+ */
+ return apply_filters( 'theme_file_path', $path, $file );
+}
+
+/**
+ * Retrieves the path of a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $file Optional. File to return the path for in the template directory.
+ * @return string The path of the file.
+ */
+function get_parent_theme_file_path( $file = '' ) {
+ $file = ltrim( $file, '/' );
+
+ if ( empty( $file ) ) {
+ $path = get_template_directory();
+ } else {
+ $path = get_template_directory() . '/' . $file;
+ }
+
+ /**
+ * Filters the path to a file in the parent theme.
+ *
+ * @since 4.7.0
+ *
+ * @param string $path The file path.
+ * @param string $file The requested file to search for.
+ */
+ return apply_filters( 'parent_theme_file_path', $path, $file );
+}