Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Add new constant for plugins/themes to determine where WordPress resides #38

Open
petervanderdoes opened this issue Sep 14, 2013 · 0 comments

Comments

@petervanderdoes
Copy link

Certain plugins load PHP scripts directly, not through WordPress, which means that the constants are not available, yet the file then tries to load WordPress core files.

For example s2member loads a file s2member-o.php
This file tries to load wp-load.php and searches down the tree for wp-settings.php

public static function wp_dir ($starting_dir = FALSE, $alt_starting_dir = FALSE)
{
    foreach(array($starting_dir, $alt_starting_dir) as $directory)
        if($directory && is_string($directory) && is_dir($directory))
            for($i = 0, $dir = $directory; $i <= 20; $i++, $dir = dirname($dir))
                if(file_exists($dir."/wp-settings.php"))
                    return ($wp_dir = $dir);

                header ("HTTP/1.0 500 Error");
                header ("Content-Type: text/plain; charset=UTF-8");
                while (@ob_end_clean ()); // Clean any existing output buffers.
                exit ("ERROR: s2Member® unable to locate WordPress® directory.");
}

Same with the plugin image-pro, it tries to load wp-load and assumes it's path.

I don't think there is way other than patching these plugins but here's a thought:
What if we in WordPress-Skeleton create a file in the root called "wp-skeleton-define.php" this file would look something like this:

<?php
define ('WP_SKELETON', true);

Plugins and themes could check for that file, include it when it exists and then if it's set to true wp can be found in SERVER['DOCUMENT_ROOT'].'/wp' or if it's a string that would be the path.

This can only be done if we get a group supporting this, including the WordPress core developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant