You are already pretty close. Extending your example:
In your plugin put this:
$default_settings = array(
'key_one' => 0,
'key_two' => 1
);
$settings = apply_filters( 'example_filter', $default_settings);
Then a theme can change it like this:
add_filter('example_filter','my_function');
function my_function($settings){
$settings['key_one'] = 1;
return $settings;
}
Related Posts:
- How can I configure Docker for developing and deploying a custom theme?
- Using filters and actions for plugin API?
- Is there widely accepted phpDoc syntax for documenting which hook calls a function?
- How do I Make a Theme “plugin-ready”?
- Custom theme sufficient or custom plugin neccessary for this feature set?
- What’s the difference between hooks, filters and actions? [duplicate]
- How to use filter hook ‘post_updated_messages’ in coherence with action hook ‘save_post’
- How to create custom home page via plugin?
- Featured Image not showing in admin
- How Can I setup WP CLI on Windows development machine running AMPPS?
- WP_LOCALIZE_SCRIPT doesn’t work
- What function to hook for changes made in status and visibility of a post
- Can I differentiate between “Delete Post Permanently” and “Empty Trash” and do something for each accordingly?
- Are we allowed to use the Allman (BSD) indent style when coding WordPress plugins and themes?
- Should action callbacks start with a verb?
- Customizer: widget-synced triggers twice
- WordPress not working on localhost
- How to use a hook to override an update_post_meta call in a plugin?
- WordPress custom taxonomy check box to dropdown
- Custom entity search and display
- Add child pages to submenu automatically
- Why in this archive page that call query_posts() function show only the last 10 posts?
- Why enqueue styles on hook?
- How to remove/replace current page template?
- Setting a post’s category
- Want to know how to reveal a WordPress theme, considering the theme name is hidden?
- Metabox types list
- Rate limiting ajax requests in WordPress
- Does hooking into a plugin action / filter override the plugin’s function for that hook?
- Determine if the current page, is being edited
- Managing Custom Designed Content
- Best practice: What belongs in theme and what in plugin for large eCommerce website
- Adding class to the parent of current-post-ancestor / current-menu-parent / current-post-parent
- how to insert content into wp_head after loop_end
- Is Explicit Versioning a better alternative to Semantic Versioning for wordpress?
- Is there any other ways to replicating changes on live from staging without pushing from git
- How to create an API for my plugin?
- Plugins in symlinked directories?
- How to use PanelColorSettings in custom Gutenberg block?
- What is an alternative method to the WordPress private _doing_it_wrong() function
- Update exisiting site to 3.5 release candidate
- Why does do_action pass a blank string as the first parameter if no $arg is set?
- add_filter and remove_filter added before and after wp_query
- What is the difference between strip_tags and wp_filter_nohtml_kses?
- Call activation hook multiple times
- Having Problem On Getting WP Post Gallery Images URL
- Two-step login process – Is it possible?
- How can I hook into existing WordPress Bulk actions?
- How to bundle a plugin with a theme, or vice versa
- Earliest WP Hook to Safely and Reliably Redirect
- Define a function outside a class and call the function using action or filter hook
- Modify a Free Plugin available on wordpress.org & include with my Premium Theme? [closed]
- Hook into theme-switching later than `setup_theme`
- Best choice of options/settings framework for plugin/theme development
- Is it possible to delay execution of shortcode output callback?
- Why my database table not created on activation?
- Act on user meta updated, but only once
- Is there any way to allow a plugin to write over a previous version?
- Display content from custom post without modifying the single template
- Adding functions to hooks from within a class
- Can I change header.php of current theme through a plugin function?
- get_current_screen() return null
- how to add custom functionality after woocommerce place order button
- Tried in different ways but sidebar not working?
- WP Gutenberg Blocks – How to limit first/root blocks
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- How do I create plugin or theme using MVC pattern?
- Search: how to extend the existing search to include a custom table
- How to Get Current Custom Post Type Associated Taxonomy Term
- Can’t change the style of a submit input type? [closed]
- How to get all queries’s results after they have executed?
- Plugin: database creation
- Loading Modernizr (or other JavaScript libraries) for use in a plugin
- Odd map_meta_cap $args on post edit — sometimes integer, sometimes string
- How can I create a custom plugin that allows anonymous users to signup without registering?
- Issue on Setting $icon_url Parameter on WP add_menu_page()
- Associate multiple email addresses with the same user account, so they can log in with either
- Logout after clicking URL link results in “headers already sent” error
- Custom filter not working
- Configure WordPress to Generate Scheme-less Relative URLs
- Save temporary registration data
- How can the_excerpt (or equivalent) be called on a category description?
- Serial Number from custom table not appear in woocommerce_email_before_order_table action
- Creating posts with links from a txt file
- Change the behaviour of a button
- How to access index file in Block Themes?
- apply_filters() and call_user_func() to define and call a function outside a class
- How to create a custom post-new.php page for plugin , no wp menu
- Redirection from a specific page for users logged in but not with membership
- Plugin Development – Call to undefined function comment_exists()
- Replace “content-area” of themes 404 page with plugin?
- Autoloading & Namespaces in WordPress Plugins & Themes: Can it Work?
- Create Customization panel for Plugins not for theme
- Font Awesome stopped showing icons, shows &# text instead [closed]
- Can I use a hook other than ‘init’ to handle form submissions?
- How do I replace title with my plugin?
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- Woocommerce: block user removing cart item
- Gutenberg text field validation
- how to catch a data from a array in WordPress