Jump to content

Change all instances of a url inside of a php script with preg_replace


nate_kig

Recommended Posts

Hey guys I have been trying to modify a wordpress plugin (Wordpress.com Stats) so that all links on the dashboard are changed from this:

 

http://blogurl.com/wp-admin/index.php?page=stats&view=referrers&numdays=7&blog=18555781

 

to this:

 

http://blogurl.com/wp-admin/admin.php?page=stats&view=referrers&numdays=7&blog=18555781

 

I cannot find the part that chooses the link urls so I was hoping I could make a preg_replace statement that would replace all instances of "index.php" with "admin.php" that get generated.

 

Is this possible to do?

This changes one URL or string. If you want to do that over a whole file, you'll need to put it in a loop.

Actually it will change every instance in $url, not just the first one.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.