Proposed Fix: Use of private _device_can_upload() can cause fatal error[!]
-
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 ininclude/palette.php
and that function then runningwp_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
- The topic ‘Proposed Fix: Use of private _device_can_upload() can cause fatal error[!]’ is closed to new replies.