• Bakke

    (@bakke)


    Hi,

    giving WordPress its own directory will break this plugin.

    I have my content directory set to /content, while WordPress i located in /wordpress. This will give errors in admin like:

    /wordpress/content/plugins/nextgen-gallery/products/photocrati_nextgen/modules/nextgen_addgallery_page/templates/upload_images.php is not a valid MVC template

    This is because the plugin is using ABSPATH to locate template files, instead of plugin_dir_path() (ABSPATH is for loading WordPress files). The method find_template_abspath() in Mixin_Mvc_View_Instance_Methods, will not be able to locate template files, because $_document_root is wrong!

    The use of ABSPATH to locate plugin files should be completely removed.

    https://www.ads-software.com/plugins/nextgen-gallery/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor photocrati

    (@photocrati)

    @bakke – Have you tried our latest beta version? See this page for more details: https://www.nextgen-gallery.com/nextgen-gallery-latest-beta/

    – Cais.

    Thread Starter Bakke

    (@bakke)

    Yes, I have tried 2.0.55, as well as the “stable” 2.0.40.

    giving WordPress its own directory is not supported at all. This is due to wrong use of the ABSPATH constant (this is used to determine the document root in the plugin, while it actually gives you the location of WordPress, which is not always document root).

    My WordPress-installation is setup like this:
    /path/to/page/wordpress/ – Standard WordPress-installation. No themes or plugins live here.
    /path/to/site/content/ – This is where i keep my themes, plugins and uploads.
    Just as described here.

    NextGen Gallery will go looking for files inside /path/to/page/wordpress/ – because it uses ABSPATH. While it should be looking inside /path/to/site/content/.

    Instead of using ABSPATH as a base for finding files, you should be using constants like WP_CONTENT_DIR, WP_PLUGINS_DIR and functions like plugin_dir_path(). That is the correct way, and would solve this problem.

    Giving WordPress its own directory is becoming more and more popular, and is considered a best practice by many. Supporting this should be a priority.

    Same here, my WordPress has its own dir, I’m getting the same errors.
    Did you find a workaround?

    More specifically, my install is:

    wp-testing/wordpress
    wp-testing/wp-content/plugins/nextgen-gallery

    where wp-testing/wp-config.php starts with:

    define('WP_HOME',    'https://' . $_SERVER['SERVER_NAME']);
    define('WP_SITEURL', 'https://' . $_SERVER['SERVER_NAME'] . '/wordpress');
    define('WP_CONTENT_DIR', realpath($_SERVER['DOCUMENT_ROOT'] . '/wp-content'));
    define('WP_CONTENT_URL', 'https://' . $_SERVER['SERVER_NAME'] . '/wp-content');

    Editing nextgen-gallery/products/photocrati_nextgen/modules/fs/class.fs.php fixes the MVC error:

    class C_Fs extends C_Component {
    [...]
    	function initialize()
    	{
    		parent::initialize();
    		$this->_document_root = $this->set_document_root(WP_CONTENT_DIR);
    	}

    but the path to all internal NextGen CSS/JS files is still incorrect, so there must be another location in NextGen where the plugin path is not computed from the WordPress constants. Actually it seems that ABSPATH is used in many many files, so this is going to be tricky ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error loading MVC templates’ is closed to new replies.