Jump to content

Incorrect Php-generated Links


valerie
 Share

Recommended Posts

I'm trying to get a wordpress plugin called PlugInstaller running on my wordpress site. The links generated by the plugin all point to the domain root and so I get 404s since my blog is located at example.com/blog. I asked the plugin author about this and he thought it might be something with my hosting. Maybe I need php5? Here's what he said:

 

>When you click the links, the variable $location (which should point to “plugins.php” and the __FILE__ php constant don’t seem to be parsed. This seems to me like a problem with your php parser. Do such problems also occur with other plugins you have installed? Maybe you have set some directive within your php.ini that does not allow the direct usage of variables in the form < ?=$variable?> (instead of < ?php echo $variable; ?>), as this is exactly what is being output to the url - %3C?= stands for “<?=” which should normally have php print the value of the following variable (in this case, the $location variable containing the current file name) or to use double quotes on strings to have php replace all variables within the string with their values. I don’t think this is a subdirectory problem, as subdirectories should be correctly recognized.

.

 

---

Note: I do not have trouble with any other plugins.

Edited by valerie
Link to comment
Share on other sites

I hate to dispute the plugin author, but he's incorrect. The plugin is in fact hardcoded for configurations where WordPress is stored in the site root.

 

Line 128 of pluginst.php defines the variable $toggle, which is then output on line 148 as part of the Uninstall table. Here's line 128:

 

>$toggle = "<a href='/wp-admin/plugins.php?page=".$_GET['page']."&uninstall=".$plugin_file."'>".__('Uninstall')."</a>";

 

As you can see, the link will always point to your website's root. To get the plugin to work properly, change line 128 to this:

 

>$toggle = "<a href='" . get_bloginfo('wpurl') . "/wp-admin/plugins.php?page=".$_GET['page']."&uninstall=".$plugin_file."'>".__('Uninstall')."</a>";

 

get_bloginfo('wpurl') will return the location of the WP installation, as you've defined it under Options -> General in the "WordPress address (URL):" field. I'm not sure, but I believe 'wpurl' is only available in WP2.1 and higher. For older versions, you'll need to use something like get_bloginfo('siteurl').

 

Anyway, I made this change and was able to use this plugin to both install and uninstall other plugins under WP 2.2RC1.

 

 

Edit: fixed typo. Oops.

Edited by joefish
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...