Save the priority in your options and pass that value to your add_filter
:
add_action( 'template_redirect', 'wpse_81687_prepare_filter' );
function wpse_81687_prepare_filter()
{
$my_options = get_option( 'my_options' );
$priority = isset ( $my_options['content_filter_priority'] )
? $my_options['content_filter_priority']
: 10;
add_filter( 'the_content', 'ald_crp', $priority );
}
In my example I register the the_content
filter during template_redirect
because it is not needed earlier. You don’t need the filter in wp-admin
or a login page.
You could even use the_post
as hook instead of template_redirect
. But then … another piece of code might call echo apply_filters('the_content', $some_text );
without calling setup_postdata()
before.
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- WP Rest API: details of latest post including featured media url in one request?
- How do I exclude plugins from getting automatically updated?
- Where is the best place to use add_filter
- How to only hook on Single.php after content?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Change Page’s Tag Using functions.php File
- What characters are allowed as a shortcode tag and how should they be sanitized?
- How to disable Gutenberg editor?
- Edit plugin without hooks in functions.php
- How to remove filter added by another plugin in a class
- WordPress apply_filters() Arguments Missing
- plugin_action_links Filter Hook Deprecated?
- Filter Hook on plugin update
- Using add_filter inside another class
- How can I show drafts in wp_dropdown_pages list?
- 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
- Hide WordPress Plugin Deactivation Links
- Alter post slug by a filter that is fired just after a post is created
- Use external link in the add sub menu
- Pass A Value From Outside To A Plugin Variable
- Is there any multiple filter/criteria plugin for wordpress? [closed]
- Failed to invoke other hook from the init hook
- Does the ‘nav_menu_css_class’ filter accept 2 or 3 arguments?
- Very stubborn wp_register_script / add_action vs remove
- How to prepend to the_title for admin-side plugin’s use
- do_action and hook methods
- How can I filter blog name?
- Remove action from a plugin class, forced to use global instance
- why does the add_action(‘the_content’) overwrite my page
- ElasticPress how to Include Meta to the mapping?
- remove filter which calls a public static function
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- There’s some way to add a wrapper around posted images?
- Custom preview_post_link not working for draft post
- 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
- Determine plugin name from within plugin_action_links filter
- merging an array to an existing array using add_filter
- Edit plugin filter
- Add Filter to get_next_posts_link
- Passing a parameter to filter and action functions
- trying to create simple plugin to filter categories from all authors
- Jetpack Comments Change Placeholder Text
- shortcode which is introduced into entry the blog, and appears in side bar
- How do i get all author posts on custom post type list
- How to filter a a variable in a plugin’s function?
- Retrive images from the_content()
- passing ‘&’ in return function of add_filter
- Filter the HTML content of plugin
- apply_filters to content but ignore shortcodes
- Use of apply_filter in plugin/widget class
- change output location of plugin function using a custom hook
- getpost content with all formatting for admin pages
- Filter for modifying image on upload
- making a glossary with wordpress
- Adding a Filter to Sidbar Login Plugin to Change Login Button Lable
- Strip shortcode from excerpt [duplicate]
- Which filters or actions involve with index page for plugin?
- How to add different CSS for galleries
- County Finder form/plugin?
- Simply Exclude – Category feed exclusion is excluding from category feed instead of just the main feed
- Add a filter to a different custom plugin
- How to change response of admin-ajax request?
- add query string to all pages after user logged in
- How to add a filter conditionally based on page related Conditional Tags
- WP Members additional fields on user profile [closed]
- WordPress plugin add_filter returning a link does not work. What is the correct way?
- Order shipped by which driver[hook for woocoomerce order staus changed and popup in admin panel ] [closed]
- Which action/filter can i use for a Member Plugin [closed]
- Unable to pass arguments from plugin form to filter hook using ajax, the data is transferring via ajax but unable to pass as arguments in filter hooks
- How to Add Extra Text In WordPress Title Before Post Publish
- How often should I execute add_filter and function declaration in Code Snippets?
- How to add product thumbnail on orders list on backend?
- filter just a portion of plugin function
- WordPress REST API filter on blank custom ACF
- Selectively override Easy Digital Downloads protection via filter
- Brands Filter Not Working For On Sale Products
- Deactivated a plugin with a filter, but it still enqueues JS files
- FacetWP custom display based on post type [closed]
- Change social icon in twenty twenty three theme
- Removing filters with arguments set in a class
- is_singular() in mu-plugins not working
- Remove wpseo filter from polylang plugin
- WooCommerce Attribute Mapping
- How can we extent core/group or cover block?
- Hide attributes based on previous selection
- Customize WP Filter Hook
- wp_head filter not executed inside custom class
- What is the best way to ignore wordpress administration using add_filter($title) also when Ajax request
- remove filter added by plugin with anonymous function
- How to display title, description etc in block images?
- Possible to overwrite load_template function in plugin using functions.php
- How to customize WP_Error (REST JWT authentication plugin) [closed]