Yes, you can do this like that.
You can call foo_init_setup on init or on wp hook and it will work just fine.
I would call it as late as possible, I guess. This way you won’t affect loading time for requests that don’t end with page rendering (for example when template_redirect is used for redirecting).
PS. There is much bigger problem with your code, though. You create custom table and store only one row with serialized array containing options for your plugin.
It would be much nicer, if you used Options API.
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- WP Rest API: details of latest post including featured media url in one request?
- How do I exclude plugins from getting automatically updated?
- dbDelta only creates the last table
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- How to disable Gutenberg editor?
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- WordPress apply_filters() Arguments Missing
- plugin_action_links Filter Hook Deprecated?
- Filter Hook on plugin update
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Removing user contact methods works from functions.php but not from a plugin
- ob_end_flush error when using wpdb in plugin
- Use external link in the add sub menu
- Is there any multiple filter/criteria plugin for wordpress? [closed]
- How to prepend to the_title for admin-side plugin’s use
- post_content getting cut off on blank space on $wpdb->update
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- plugin_action_links_{$plugin_file} hook not in the main plugin file
- Creating search filter through plugin
- Woocommerce Shipping module available only for type of products [closed]
- Add Fields with Sub-Fields to WP Job Manager
- merging an array to an existing array using add_filter
- add_filter the_content in functions.php not working
- locate_template with multiple categories?
- Gutenberg Blocks – Change EDIT part of the block using editor.BlockEdit filters. How to change the markup?
- WP Job Manager Category Drop-down; Change Placeholder Text Via Filter
- Randomize attachment IDs
- Pass info from functions.php to plugin
- WordPress Social Login > Post to a users Facebook wall
- plugin ajax to external php file always return null
- add_query_arg not working
- Change permalink structure hidden button edit
- Access WordPress database outside of WordPress
- Inserting above the comment template
- Correct way to perform non-cacheable DB query
- Help With MySQL to WPDB Query Conversion
- How to check current user before all actions and filters?
- How do I create a filter feature on WordPress? [closed]
- Create a navbar filter that filters by a custom field
- Change commission_status paid when withdraw_status vendor is completed
- Plugin developer automated documentation
- qTranslate remove default directory from link
- URL parameters causing 404 on home page, but nowhere else
- Which filter affects the ‘entry-title’ post class
- Proper way to replace the_content only for pages created by custom plugin
- Is there a way to figure out which action/filter invoked a function?
- Add sub menu page in your plugin
- after wordpress update to 3.5+ i get many errors in plugin wpdb::prepare()
- Check if variable is set in filter
- Passing stored variables to add_filter
- How to use filter to disable adding a product to wishlist?
- correctness of URL
- How do I change where a plugin pulls updates from?
- what is the point of telling add_filter how many parameters you want passed to the function?
- How to add filter for wordpress plugin?
- Using $wpdb in a plugin, what sort of data does it return?
- WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version [closed]
- Filters on the_content with plugins, pages and shortcode
- Need help creating asynchronous data scraper in WordPress
- Excluding specific post from custom next/previous theme function
- Want to create custom design of progress indicator in wpforms
- Unpublished Pages Failing To Appear On Custom Path
- $wpdb->delete not working for me
- any word search WordPress
- How to securely controlling data without keeping it in postmeta?
- Does having apply_filters in the middle of an array make a difference?
- how can I edit the HTML of yith ajax product filter
- Plugin function in child theme
- Customize plugin’s output: filters or setters: looking for an advice
- Remove action added in plugin class from theme
- Show custom taxonomy in theme
- How to fix slow comment query?
- Using multi-dimensional array with filter
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Add Filter to get_next_posts_link
- Passing a parameter to filter and action functions
- Jetpack Comments Change Placeholder Text
- shortcode which is introduced into entry the blog, and appears in side bar
- Action hook “wp_insert_post” works but not for last imported post
- Use of apply_filter in plugin/widget class
- making a glossary with wordpress
- Adding a Filter to Sidbar Login Plugin to Change Login Button Lable
- get_var result empty for query of custom table in plugin admin
- Simply Exclude – Category feed exclusion is excluding from category feed instead of just the main feed
- How to change response of admin-ajax request?
- Is it safe to increase/alter the size of the wp_post.guid column from VARCHAR(255) to VARCHAR(2048)?
- WordPress plugin add_filter returning a link does not work. What is the correct way?
- $wpdb selects wrong database
- Which action/filter can i use for a Member Plugin [closed]
- Custom priority with the_content filter based on user input
- filter just a portion of plugin function
- How to check record is exist or not in WordPress CRUD Operation with $wpdb
- Deactivated a plugin with a filter, but it still enqueues JS files
- WooCommerce Attribute Mapping
- Hide attributes based on previous selection