plugin development document sample code breaks wordpress
-
I took the sample code from https://developer.www.ads-software.com/plugins/security/nonces/ and created a plugin using but it causes wordpress to crash with the following message:
atal error: Uncaught Error: Call to undefined function wp_get_current_user() in C:\dev\xampp\htdocs\wpSandBox\wp-includes\capabilities.php:652 Stack trace: #0 C:\dev\xampp\htdocs\wpSandBox\wp-content\plugins\marys_sandbox.php(65): current_user_can(‘edit_others_pos…’) #1 C:\dev\xampp\htdocs\wpSandBox\wp-settings.php(360): include_once(‘C:\\dev\\xampp\\ht…’) #2 C:\dev\xampp\htdocs\wpSandBox\wp-config.php(90): require_once(‘C:\\dev\\xampp\\ht…’) #3 C:\dev\xampp\htdocs\wpSandBox\wp-load.php(37): require_once(‘C:\\dev\\xampp\\ht…’) #4 C:\dev\xampp\htdocs\wpSandBox\wp-admin\admin.php(34): require_once(‘C:\\dev\\xampp\\ht…’) #5 C:\dev\xampp\htdocs\wpSandBox\wp-admin\plugins.php(10): require_once(‘C:\\dev\\xampp\\ht…’) #6 {main} thrown in C:\dev\xampp\htdocs\wpSandBox\wp-includes\capabilities.php on line 652
There has been a critical error on your website. Please check your site admin email inbox for instructions.
——-
the line causing the error is if (current_user_can(‘edit_others_posts’))
if i remove the if statement it works fine.sorry i cannot share access to the site as it is on a local installation which i did yesterday so very latest release.
- The topic ‘plugin development document sample code breaks wordpress’ is closed to new replies.