3

Possible Duplicate:
Can I rename the wp-admin folder?

I have applied some mod_rewrite rules to redirect /wp-admin to /my-admin - based on this tutorial.

I also changed the admin url internally by hooking into admin_url and replacing the /wp-admin string:

add_filter('admin_url', 'my_admin_url');
function my_admin_url($path)
{
   return str_replace('wp-admin', 'my-admin', $path);
}

Update #1
In order to not break those (about 200) code parts with hardcoded /wp-admin, I search&replace all relevant $_SERVER attributes with /wp-admin early in my functions.php. This works so far.

Update #2
Rewriting the $_SERVER attributes in functions.php is too late for a correct setup of $current_screen, which might break code parts depending on it. The setup eventually happens in wp-includes/vars.php (by setting the global variable $pagenow), which is too early to hook into by plugins.

I fixed this issue by moving $_SERVER rewrites to wp-config.php - which is early enough. :)


Problems with approach described above ↑

The approach above might not work for conditions which compare admin_url() to one of the $_SERVER attributes (first one points to /my-admin, second one to /wp-admin). However, first tests indicate that none of such conditions are present in the WP core code.

Does anybody see other problems with this approach?

marked as duplicate by Rarst Jun 14 '12 at 11:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    $current_screen just sums up some globals during admin-header.php and earlier. So if this one is wrong, then it's just an indicator that stuff didn't work out. I encourage you to change your question title: »How do I change the wp-admin directory name with the admin_url filter?«. Then just add your function on top and leave the rest as it is. This makes the Q more broad in scope and will maybe bring up better debug backtracing and possibly also other solutions. – kaiser Feb 26 '12 at 16:57
  • Thanks for your help! In fact, if I use set_current_screen() manually for debugging, things get better! But still no posts/pages are displayed, so I think I have to dig deeper into the screen functionality, if it is based on requested pages. Any suggestions where to look for? – johann Feb 26 '12 at 18:35
  • You don't have to modify the current screen object contents. If you "dig deeper", then you're hiding away the problem for yourself and just fill the gap that you encountered with dublicated code. This is just the first step to rebuilding WP - for no reason. You'll have to find out, what exactly the problem is. So far, I guess it's all those places where wp-admin is hard coded into core. I'd start doing a cross file search for this and list the results here. – kaiser Feb 26 '12 at 22:48
  • I have to disagree here. First, I have no intention of rebuilding WP or duplicating code. I am only using regular filters and action hooks. Second, how could you possibly hook into stuff like apply_filters("manage_{$screen->id}_sortable_columns",$this->get_sortable_columns());, without a valid screen object? Anyway, I agree that hardcoded /wp-admin is the problem (which I already solved, please see update above). By "digging deeper" I meant to hook into the right spot and correct the root cause for the invalid $current_screen object. This is still an open issue, I'd appreciate any help. – johann Feb 27 '12 at 8:59
  • 1
    Please see the answer from Dion Hulse on wp-hackers. – kaiser Feb 27 '12 at 10:57