• Resolved Scott Bowler

    (@scottybowl2)


    For a variety of reasons we need to modify the ajax_url that is defined in the var FlowFlowOpts array. Looking at the code there is an environment variable “FF_AJAX_URL” which would (in theory) allow us to modify the ajax url.

    In flow-flow/includes/FlowFlowActivator.php there is the function beforePluginLoad() where FF_AJAX_URL is checked

    
    protected function beforePluginLoad(){
            parent::beforePluginLoad();
    
            if (! defined('FF_AJAX_URL')) {
                    $admin = function_exists('current_user_can') && current_user_can('manage_options');
                    if (!$admin && defined('FF_ALTERNATE_GET_DATA') && FF_ALTERNATE_GET_DATA){
                            $this->setContextValue('ajax_url', plugins_url( 'ff.php', __FILE__ ));
                    }
                    else {
                            $this->setContextValue('ajax_url', admin_url('admin-ajax.php'));
                    }
            }
    
            new FlowFlowUpdater($this->context);
    }
    

    However, it’s missing the “else” part of the statement where FF_AJAX_URL should be used to define the ajax_url context value, i.e.

    
    protected function beforePluginLoad(){
            parent::beforePluginLoad();
    
            if (! defined('FF_AJAX_URL')) {
                    $admin = function_exists('current_user_can') && current_user_can('manage_options');
                    if (!$admin && defined('FF_ALTERNATE_GET_DATA') && FF_ALTERNATE_GET_DATA){
                            $this->setContextValue('ajax_url', plugins_url( 'ff.php', __FILE__ ));
                    }
                    else {
                            $this->setContextValue('ajax_url', admin_url('admin-ajax.php'));
                    }
            } else {
                $this->setContextValue('ajax_url', FF_AJAX_URL);
            }
    
            new FlowFlowUpdater($this->context);
    }
    

    It’s a pain having to modify this each time the plugin updates, so it would be great if you could incorporate this into core.

    • This topic was modified 6 years, 3 months ago by Scott Bowler.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Bug: FF_AJAX_URL not honored’ is closed to new replies.