Forums

WP2.6 and add_options_page() problem (1 post)

  1. rparmentier
    Member
    Posted 1 year ago #

    Hello everyone ! I installed Wordpress 2.6 today, and immediatly had trouble with plugins I have developped. I use the add_options_page() function to add a submenu item in the Settings menu. I get my page URL with this simple line : $options_url = get_bloginfo('wpurl').'/wp-content/plugins/mysuperplugin/options.php';

    The problem is that in the generated <a> tag, the href value now starts with "http:/" and not "http://" (missing slash). The problem is that in modern browsers, this will be interpretated as a link to the root of the server, which means that "http:/localhost/wordpress/wp-content/plugins/mysuperplugin/options.php" will in fact redirect to "http://localhost/localhost/wordpress/wp-content/plugins/mysuperplugin/options.php".

    The problem seems to come from the updated plugin_basename() function in plugin.php.

    Wordpress 2.5

    function plugin_basename($file) {
       $file = str_replace('\\','/',$file); // sanitize for Win32 installs
       $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
       $file = preg_replace('|^.*/' . PLUGINDIR . '/|','',$file); // get relative path from plugins dir
       return $file;
    }

    Wordpress 2.6

    function plugin_basename($file) {
       $file = str_replace('\\','/',$file); // sanitize for Win32 installs
       $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
       $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
       $plugin_dir = preg_replace('|/+|','/', $plugin_dir); // remove any duplicate slash
       $file = preg_replace('|^' . preg_quote($plugin_dir, '|') . '/|','',$file); // get relative path from plugins dir
       return $file;
    }

    How can I fix this ?

Topic Closed

This topic has been closed to new replies.

About this Topic