• Resolved KZeni

    (@kzeni)


    Hi, I have sites running a WordPress Network, and I was unable to access the site admin anymore due to wp_is_mobile() being called before it was available (this causes a fatal PHP error since it’s an undefined function).

    This turns out to be due to _device_can_upload() (a private function WP says to not use) being used in include/palette.php and that function then running wp_is_mobile() before it’s defined for one reason or another.

    My quick fix is to have:

    
    $this->can_upload = !(function_exists('_device_can_upload') && !_device_can_upload());
    

    swapped out for:

    
    if(function_exists('wp_is_mobile')){ // _device_can_upload() is a private WP function that needs wp_is_mobile to be available before running
        $this->can_upload = !(function_exists('_device_can_upload') && !_device_can_upload());
    }else{
        $this->can_upload = true;
    }
    

    in the plugin’s include/palette.php file.

    Unfortunately, private functions are unsupported by WP to be used for a theme/plugin. However, this one check appears to fix the fatal error that this particular instance was causing.

    I would love to see this error resolved in the next version of the plugin as I’d hate to have the plugin be updated and have the issue where nobody can access the site admin at all resurface. Hopefully this resolves the issue for others which might’ve encountered this as well.

    Feel free to use the code I provided or resolve the issue through other means you see as being better (since you know the code better after all).

    Thanks for the great plugin,
    Kurt

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Daniel Men?ies

    (@kungtiger)

    Hi Kurt,

    now that’s embarrasing. I have to admit I didn’t run any tests for a network version of WP. Well I’ve included your suggestion into 1.9.1 so all should be fine ’till the next bug.

    Gara

    Thread Starter KZeni

    (@kzeni)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Proposed Fix: Use of private _device_can_upload() can cause fatal error[!]’ is closed to new replies.