Support » Plugin: WP Photo Album Plus » wp-load.php

  • Resolved nikdow

    (@nikdow)


    Your ajax script loads wp-load.php with this statement:
    require_once ( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . ‘/wp-load.php’ );
    This fails if wp-content/plugins has been moved to a non-standard location. I’ve extracted a few lines from the settings table to illustrate our set up below:
    ABSPATH WP absolute path. /home/lamp/wordpress/core/wp5.2.1/
    WPPA_ABSPATH ABSPATH windows proof /home/lamp/wordpress/core/wp5.2.1/
    WPPA_PATH Path to plugins directory. /home/lamp/wordpress/wp-content/www.otu.asn.au/plugins/wp-photo-album-plus
    WPPA_NAME Plugins directory name. wp-photo-album-plus
    WPPA_URL Plugins directory URL. https://www.otu.asn.au/wp-content/plugins/wp-photo-album-plus
    WPPA_UPLOAD The relative upload directory. wp-content/www.otu.asn.au/uploads
    WPPA_UPLOAD_PATH The upload directory path. /home/lamp/wordpress/core/wp5.2.1/wp-content/www.otu.asn.au/uploads/wppa

    If I replace the above line with
    require_once ( ‘/home/lamp/webroot/otu/wp-load.php’ );
    and in wp-config I add:
    define(‘WPPA_REL_UPLOADS_PATH’, ‘wp-content/www.otu.asn.au/uploads’);
    define(‘WPPA_REL_DEPOT_PATH’, ‘wp-content/www.otu.asn.au’);
    Then everything works.
    So you do have support for moving wp-content/uploads but not support for moving the plugins directory.

    Our set up works with these redirects:
    RewriteCond %{REQUEST_URI} !^/wp-content/www.otu.asn.au/(.*)
    RewriteCond %{REQUEST_URI} ^/wp-content/(.*)
    RewriteRule ^/wp-content/(.*) /wp-content/%{SERVER_NAME}/%1

    We have a large number of small WP websites sharing a server. They share WP core code and some common/large plugins. All this optimises use of OPCache memory.

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Jacob N. Breetvelt

    (@opajaap)

    The problem is that wp-load.php defines ABSPATH, so how should i know where wp-load.php resides? If you know an answer to this, i can change it.

    Could you do some fall-back error handling and check $_SERVER[‘DOCUMENT_ROOT’] if the include fails?

    /** Load WordPress Bootstrap */
    $inc = dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . ‘/wp-load.php’;
    if (file_exists($inc) && is_readable($inc)) {
    require_once( $inc );
    } else {
    require_once( $_SERVER[‘DOCUMENT_ROOT’] . ‘/wp-load.php’ );
    }

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    Using $_SERVER[‘DOCUMENT_ROOT’] is not a good idea.

    On my dev site, $_SERVER['DOCUMENT_ROOT'] is:
    /home/..../http/premium/rid/../../51893315/htdocs
    while ABSPATH is
    /home/..../http/premium/rid/../../51893315/htdocs/opajaap/betatest/

    Why don’t you simply turn off using the front-end ajax interface, falling back to the ‘normal’ wp ajax interface?

    To do so:
    – Untick Table IV-A1.1: Ajax NON Admin Frontend ajax use no admin files.
    – Make sure you do not prevent http access to ABSPATH . 'wp-admin/admin-ajax.php' with your .htaccess files.

    Thanks for your help.

    The error is occuring in a page that is provided by a plugin written by us some time ago. Our plugin uses Angular 1. I had to review our plugin to solve this problem. It contained this code:

    var ajaxurl = $scope.data.siteurl + "/wp-content/plugins/wp-photo-album-plus/wppa-ajax-front.php?action=wppa&wppa-action=render&wppa-cover=0&wppa-album=" + $scope.item.album + "&wppa-occur=1&wppa-size=640";
    wppaDoAjaxRender( 1, ajaxurl, '' )

    I replaced this with

    var ajaxurl = $scope.data.ajaxurl + "?action=wppa&wppa-action=render&wppa-cover=0&wppa-album=" + $scope.item.album + "&wppa-occur=1&wppa-size=640";
    wppaDoAjaxRender( 1, ajaxurl, '' )

    The problem was solved.

    The JS variables are provided by the plugin PHP:

    $data['ajaxurl'] = admin_url('admin-ajax.php');
    $data['siteurl'] = get_site_url();

    Now closed this Topic, thanks for your help which pointed me to the solution.

    Plugin Author Jacob N. Breetvelt

    (@opajaap)

    you’re welcome

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp-load.php’ is closed to new replies.