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
- Custom fields in the billing address section woocommerce
- How to customize password reset message page on success if no error in password reset
- .mo translation strings not loading in PHP scripts that handle AJAX calls
- Is it possible to change a term slug before being saved to the database?
- SQL query for custom taxonomy slugs
- Tried in different ways but sidebar not working?
- Can Page Templates be Applied to Archive and Post Templates?
- Maximum lifetime for nonce
- Clearing caches on plugin uninstall
- External Authentication, session_tokens not destroyed on logout
- Add code inside specific wordpress standard function
- Where to add hooks in a class
- Trying to understand order and frequency of action hooks firing
- Short code not working in boostrap modal dont no why?
- Custom Taxonomy to dropdown box on adminside wordpress
- How to use output buffering in WordPress hooked functions?
- Create a free scripts and styles template within a plugin
- Is there a way to list all actions registered by a plugin or theme?
- Howto: Use Custom Post Types as Submenu Items in Admin
- Conditional hook based on the core function that is calling it
- Adding option to Gallery shortcode
- correct way to call javascript into hook function
- Is there some way to provide the user a list of existing content in a CPT
- Change the look and feel of admin pages
- How to modify the comments to be displayed in a post?
- Extending theme PHP class in plugin
- How to access noticeOperations from withNotices
- How to hook a custom user function to a wordpress core ajax action?
- do_action and add_action on two different installed plugins won’t work
- How can I turn a custom wordpress page into a product page?
- Elementor custom Query with ACF fields to show matching woocommerce products custom fields
- WP Gutenberg Blocks – How to limit first/root blocks
- Prefixing plugin hooks (actions/filters) with a wrapper class or functions
- How to get boolean value from register_meta properly?
- Send push when new post is published in a certain category
- what is the difference between these phares?
- How can we display product price $104 on the cart while the credit card payment method is checked?
- Form doesnt save to database
- Notice: Trying to get property ‘term_id’ of non-object
- Incorporate small angular feature in my wordpress site
- What is the proper method of using global $post?
- How developed with version control word press site on shared host? [closed]
- How to Bind one post object Type with other postobject Type in Advanced Custom field [closed]
- How to export post meta with images in wordpress
- Password field is empty when using wp_signon();
- Best place for short bio,image and button [closed]
- How to change title tag at page after loaded post?
- Following WordPress Markup Is mandatory, got awkward resultyby wordpress standard markup?
- How do I create plugin or theme using MVC pattern?
- How to limit number of number of categories displayed by categories widget
- Search: how to extend the existing search to include a custom table
- Is there documentation reference for forms in menu and setting pages?
- PowerPress mobile media player
- When is the proper time to minify css and js with git workflow?
- Strange Situation When Try To Retrieve Github Gist Using wp_remote_get
- How to hide or rename “X” and “x-child” references in website source?
- template_redirect or admin-ajax.php?
- How to Get Current Custom Post Type Associated Taxonomy Term
- Force HTTPS 301 redirect with hook
- Plugin templates vs Parent Theme
- I have 2 plugins using the same wp_login action hook and one is not working
- Selectively update themes in WordPress multisite
- Widget HTML Display Problem
- Add a new confirmation page before saving