user_trailingslashit

The timeline below displays how wordpress function user_trailingslashit has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.2

/**
 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * {@see 'user_trailingslashit'} filter. Will remove trailing slash from string, if
 * site is not set to have them.
 *
 * @since 2.2.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param string $url         URL with or without a trailing slash.
 * @param string $type_of_url Optional. The type of URL being considered (e.g. single, category, etc)
 *                            for use in the filter. Default empty string.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($url, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $url = trailingslashit($url);
    } else {
        $url = untrailingslashit($url);
    }
    /**
     * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes.
     *
     * @since 2.2.0
     *
     * @param string $url         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', 'commentpaged', 'paged', 'home', 'feed',
     *                            'category', 'page', 'year', 'month', 'day', 'post_type_archive'.
     */
    return apply_filters('user_trailingslashit', $url, $type_of_url);
}

WordPress Version: 5.3

/**
 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * {@see 'user_trailingslashit'} filter. Will remove trailing slash from string, if
 * site is not set to have them.
 *
 * @since 2.2.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param string $string      URL with or without a trailing slash.
 * @param string $type_of_url Optional. The type of URL being considered (e.g. single, category, etc)
 *                            for use in the filter. Default empty string.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes.
     *
     * @since 2.2.0
     *
     * @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', 'commentpaged', 'paged', 'home', 'feed',
     *                            'category', 'page', 'year', 'month', 'day', 'post_type_archive'.
     */
    return apply_filters('user_trailingslashit', $string, $type_of_url);
}

WordPress Version: 4.7

/**
 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * {@see 'user_trailingslashit'} filter. Will remove trailing slash from string, if
 * site is not set to have them.
 *
 * @since 2.2.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string $string      URL with or without a trailing slash.
 * @param string $type_of_url Optional. The type of URL being considered (e.g. single, category, etc)
 *                            for use in the filter. Default empty string.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes.
     *
     * @since 2.2.0
     *
     * @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', 'commentpaged', 'paged', 'home', 'feed',
     *                            'category', 'page', 'year', 'month', 'day', 'post_type_archive'.
     */
    return apply_filters('user_trailingslashit', $string, $type_of_url);
}

WordPress Version: 4.6

/**
 * Retrieves a trailing-slashed string if the site is set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * {@see 'user_trailingslashit'} filter. Will remove trailing slash from string, if
 * site is not set to have them.
 *
 * @since 2.2.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string $string      URL with or without a trailing slash.
 * @param string $type_of_url Optional. The type of URL being considered (e.g. single, category, etc)
 *                            for use in the filter. Default empty string.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filters the trailing-slashed string, depending on whether the site is set to use trailing slashes.
     *
     * @since 2.2.0
     *
     * @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'.
     */
    return apply_filters('user_trailingslashit', $string, $type_of_url);
}

WordPress Version: 4.5

/**
 * Retrieve trailing slash string, if site is set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * 'user_trailingslashit' filter. Will remove trailing slash from string, if
 * site is not set to have them.
 *
 * @since 2.2.0
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string $string URL with or without a trailing slash.
 * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filter the trailing slashed string, depending on whether the site is set
     * to use training slashes.
     *
     * @since 2.2.0
     *
     * @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'.
     */
    return apply_filters('user_trailingslashit', $string, $type_of_url);
}

WordPress Version: 4.3

/**
 * Retrieve trailing slash string, if blog set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * 'user_trailingslashit' filter. Will remove trailing slash from string, if
 * blog is not set to have them.
 *
 * @since 2.2.0
 * @global WP_Rewrite $wp_rewrite
 *
 * @param string $string URL with or without a trailing slash.
 * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filter the trailing slashed string, depending on whether the site is set
     * to use training slashes.
     *
     * @since 2.2.0
     *
     * @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'.
     */
    return apply_filters('user_trailingslashit', $string, $type_of_url);
}

WordPress Version: 4.1

/**
 * Retrieve trailing slash string, if blog set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * 'user_trailingslashit' filter. Will remove trailing slash from string, if
 * blog is not set to have them.
 *
 * @since 2.2.0
 * @uses $wp_rewrite
 *
 * @param string $string URL with or without a trailing slash.
 * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
 * @return string The URL with the trailing slash appended or stripped.
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filter the trailing slashed string, depending on whether the site is set
     * to use training slashes.
     *
     * @since 2.2.0
     *
     * @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'.
     */
    $string = apply_filters('user_trailingslashit', $string, $type_of_url);
    return $string;
}

WordPress Version: 3.9

/**
 * Retrieve trailing slash string, if blog set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * 'user_trailingslashit' filter. Will remove trailing slash from string, if
 * blog is not set to have them.
 *
 * @since 2.2.0
 * @uses $wp_rewrite
 *
 * @param string $string URL with or without a trailing slash.
 * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
 * @return string
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    /**
     * Filter the trailing slashed string, depending on whether the site is set
     * to use training slashes.
     *
     * @since 2.2.0
     *
     * @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'.
     */
    $string = apply_filters('user_trailingslashit', $string, $type_of_url);
    return $string;
}

WordPress Version: 3.7

/**
 * Retrieve trailing slash string, if blog set for adding trailing slashes.
 *
 * Conditionally adds a trailing slash if the permalink structure has a trailing
 * slash, strips the trailing slash if not. The string is passed through the
 * 'user_trailingslashit' filter. Will remove trailing slash from string, if
 * blog is not set to have them.
 *
 * @since 2.2.0
 * @uses $wp_rewrite
 *
 * @param string $string URL with or without a trailing slash.
 * @param string $type_of_url The type of URL being considered (e.g. single, category, etc) for use in the filter.
 * @return string
 */
function user_trailingslashit($string, $type_of_url = '')
{
    global $wp_rewrite;
    if ($wp_rewrite->use_trailing_slashes) {
        $string = trailingslashit($string);
    } else {
        $string = untrailingslashit($string);
    }
    // Note that $type_of_url can be one of following:
    // single, single_trackback, single_feed, single_paged, feed, category, page, year, month, day, paged, post_type_archive
    $string = apply_filters('user_trailingslashit', $string, $type_of_url);
    return $string;
}