The problem is that you aren’t declaring $dg_options
as global here:
define('DG_OPTION_NAME', 'document_gallery');
$dg_options = get_option(DG_OPTION_NAME);
During uninstall you aren’t in the global scope, your file is being included by uninstall_plugin()
.
So you need to add this at the top of the main plugin file:
global $dg_options;
Really, any time you want a variable to be global, you should be sure to use the global
statement. Don’t take scope for granted.
Related Posts:
- How can I see all the actions attached to an “add_action” hook?
- How to include code only on specific pages?
- Changing the “Plugin Activated” Message Default
- Schedule WordPress Auto-Updates to only run during business hours
- Remove action from plugin on other plugin
- How to delete custom taxonomy terms in plugin’s uninstall.php?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Is there any debug toolbar that shows whick hooks are called for the current page in WordPress?
- When can you get current page ID and initialize hooks right after?
- Does plugin uninstall always put WordPress back into original state?
- How can I delete options with register_uninstall_hook?
- What is the ‘admin_action_’ . $_REQUEST[‘action’] hook used for?
- Filter out results from REST API
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- Filter Hook on plugin update
- WordPress Hook that will run when media file deleted
- Disallow a user to post in certain categories
- Intercepting a add_action
- Generic plugin (de)activation hook?
- disable active plugins for specific theme
- Adding a form at the end of the content
- Find out if request is for custom post type archive before query runs
- Use external link in the add sub menu
- Failed to invoke other hook from the init hook
- How can I add a custom meta value on file upload?
- How can I filter blog name?
- Is it possible to remove this action? (as it’s added just before it’s called)
- Woocommerce Shipping module available only for type of products [closed]
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- Determine plugin name from within plugin_action_links filter
- Placement of Code in Plugin for hooking `save_post`
- publish_post plugin hook doesn’t always pass $post->post_content
- How to initialize something in unit test before the init hook being called?
- add action for displaying posts using a shortcode
- Randomize attachment IDs
- ‘wp_login’ action hook not working with wp-login.php file
- Pass info from functions.php to plugin
- Remove rewrite rules generated by plugin during deactivation
- Change permalink structure hidden button edit
- Where (or when) should I register a new taxonomy?
- WordPress filter that hook after each action/filter hook
- When to use action hooks and plugins
- One of my plugins broke when I tried to update it, how do I safely uninstall it?
- Hook (or other way) to find out when another plugin is activated / installed
- Inserting above the comment template
- Insert new user with form submit ‘init’ hook
- How to stop activating a plugin and show admin notice when dependent plugins minimum version is not met
- get current date + 90 days and checking every day
- Calculate price and display on woocommerce product single page under price (simple price, variable price) [closed]
- uninstall.php does not appear to trigger when uninstalling my plugin
- password_reset hook is not working
- Custom message on plugin uninstall
- Hook into existing tinyMCE button
- How to get post ID with hooks publish_post, new_to_publish, etc
- edit_user_profile and show_user_profile are not firing inside a class
- Template filter for custom taxonomy terms
- What exactly happens to function argument availability when using a filter?
- Combining several CSS files into one for optimization
- the_post hook is not firing for me
- Create a post builder skin in a plugin
- Plugin Development – Functions or Hooks?
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Flipping Book PHP Code? Any experience?
- Hook for page Request?
- Display Plugin Panels Outside of Admin Areas
- How to remove js ui library added by default by wordpress
- How to use the pre_option filter before a plugin loads?
- How to remove a class function from a plugin by using remove_action()?
- profile_update hook doesn’t works inside a class
- Plugin: Hooking up classes that have their own hooks
- Hook for altering the content of all wp mails
- What hook can I use to modify custom post data before it is displayed on the page?
- Quick press publish post hook
- How to deactivate my plugin upon deactivation of NextGen
- Creating a plugin that will display text on every page
- Why does “updated_post_meta” did not fire when uploading media other than image?
- Build a must-use plugin that tracks when other plugins are activated or deactivated
- Change Dashboard URL from wp-admin to wp-admin/index.php
- Activation flow of a plugin in a multisite environment
- Callback hooked to post_updated firing on new posts as well
- front end editor creation for Restropress plug in – displaying information from a WP admin area, on a different URL
- Replace plugin HTML to single text using hooks
- How can I disable W3 Total Cache Image Lazy Load for Specific Post Type?
- Customize plugin templates
- wordpress plugin translation not working
- WordPress Boilerplate Plugin doesn’t see callback functions for add_settings_field and add_settings_section
- Hook on widget context plugin to add custom context for widget
- Publish check if the edited content has HTML “div”
- Admin page and admin menu. Permissions plugin
- How should I use a plugin function as a hook?
- Display_rows() and column_cb() strange behaviour
- change output location of plugin function using a custom hook
- Plugin constructor called multiple times
- How to change value of $menu_class in ep_nav_menu?
- How to create and use Custom hooks
- How to remove links generated by SEO-smart-links?
- How to display a link in the footer section
- Can’t use updated variables in handle function
- Suitable hook when creating, updating and deleting posts programmatically