Add scheme argument to admin_url() and get_admin_url() to allow forcing a particular scheme.

git-svn-id: https://develop.svn.wordpress.org/trunk@13814 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-03-25 22:00:36 +00:00
parent 450110f9f2
commit 0286b0f2e5
1 changed files with 6 additions and 4 deletions

View File

@ -1915,10 +1915,11 @@ function get_site_url( $blog_id = null, $path = '', $scheme = null ) {
* @since 2.6.0 * @since 2.6.0
* *
* @param string $path Optional path relative to the admin url * @param string $path Optional path relative to the admin url
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended * @return string Admin url link with optional path appended
*/ */
function admin_url( $path = '' ) { function admin_url( $path = '', $scheme = 'admin' ) {
return get_admin_url(null, $path); return get_admin_url(null, $path, $scheme);
} }
/** /**
@ -1929,10 +1930,11 @@ function admin_url( $path = '' ) {
* *
* @param int $blog_id (optional) Blog ID. Defaults to current blog. * @param int $blog_id (optional) Blog ID. Defaults to current blog.
* @param string $path Optional path relative to the admin url * @param string $path Optional path relative to the admin url
* @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
* @return string Admin url link with optional path appended * @return string Admin url link with optional path appended
*/ */
function get_admin_url( $blog_id = null, $path = '' ) { function get_admin_url( $blog_id = null, $path = '', $scheme = 'admin' ) {
$url = get_site_url($blog_id, 'wp-admin/', 'admin'); $url = get_site_url($blog_id, 'wp-admin/', $scheme);
if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
$url .= ltrim($path, '/'); $url .= ltrim($path, '/');