Current status: Solved. . Done
Require paths in export.php
  • I'm guessing this won't affect many folks, but export.php breaks if the paths from ACF to wp-load.php and wp-admin/admin.php (lines 12-13 of ACF/core/actions/export.php) are not the standard WordPress setup. For instance if you are using this: https://github.com/markjaquith/WordPress-Skeleton

    Maybe there's a quick way to replace `'../../../../..'` with a constant for the WordPress root before requiring those files.
  • Thanks joshquartz,

    I'll look into it
  • Hi joshquartz,

    I've looked for a solution but unfortunately won't be able to provide one. The problem is that if you use this skeleton build, ACF won't know where to find the wp-load.php and /wp-admin/admin.php files.

    As this file is read independently of WP, there are no constants defined. So the first problem is not knowing the path to the root.

    The second problem is that the skeleton build puts all of wp in a "wp" folder. This is unique to that 1 build. If other builds put wp in a different folder, ACF would again, not be able to find it.

    Sorry, but I won't be able to fix this problem, you will need to edit the actions/export.php file if you wish to use WP in this fashion.

    Thanks
  • You could pass the ABSPATH constant as a hidden input on the export form and override the default.

    (Fix below)
  • I've fixed the issue, please review for security purposes...

    After line 332 (form tag) in core/controllers/settings.php add —
        <input type="hidden" name="acf_abspath" value="<?php echo ABSPATH; ?>" />


    Then replace the //includes section in actions/export.php —
    // includes
    $acf_abspath = '../../../../..';
    if(isset($_POST['acf_abspath']) && is_dir($_POST['acf_abspath'])) {
    $acf_abspath = $_POST['acf_abspath'];
    }
     
    require_once( $acf_abspath . '/wp-load.php');
    require_once( $acf_abspath . '/wp-admin/admin.php');


    This maintains compatibility with the old settings form, but to me, you would require acf_abspath to be present to continue like so —
    // includes
    if(!isset($_POST['acf_abspath']) || !is_dir($_POST['acf_abspath'])) {
    die("ABSPATH was not supplied"); // wp_die() not available yet.
    }
    require_once( $_POST['acf_abspath'] . '/wp-load.php');
    require_once( $_POST['acf_abspath'] . '/wp-admin/admin.php');


    A few edits were made after the original posting.
  • Hi @ofdesks,

    Well that's smart. Haha, I'll add that one in.

    Cheers
  • Added in 3.5.0 - out soon
  • Awesome! Glad to help!