Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress where the "admin_url" is set?

Tags:

php

wordpress

basically need to change the value that - admin_url() returns any idea?

like image 215
simple Avatar asked Jan 23 '23 07:01

simple


1 Answers

This function is defined in wp-includes/link-template.php, and it offers a filter:

/**
 * Retrieve the url to the admin area.
 *
 * @package WordPress
 * @since 2.6.0
 *
 * @param string $path Optional path relative to the admin url
 * @return string Admin url link with optional path appended
*/
function admin_url($path = '') {
    $url = site_url('wp-admin/', 'admin');

    if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
        $url .= ltrim($path, '/');

    return apply_filters('admin_url', $url, $path);
}

So you can control the output with an own filter function in your themes functions.php:

add_filter('admin_url', 'my_new_admin_url');

function my_new_admin_url()
{
    // Insert the new URL here:
    return 'http://example.org/boss/';
}

Now hope that all plugin authors use this function and not an hard coded path … :)

Addendum

Add this line to your .htaccess:

Redirect permanent /wp-admin/ http://example.org/new_url/
like image 72
fuxia Avatar answered Jan 29 '23 06:01

fuxia