Complianz Privacy Suite

Adding functionalities in functions.php

Rogier Lankhorst

Rogier Lankhorst

Categories

Popular articles

Editing Legal Documents

The legal documents are generated by the Wizard and will show up under ‘Pages’ with a shortcode in the content. This shortcode is used to

Read More

CNIL updated privacy guidelines

While the much-anticipated ePrivacy directive seems to be postponed for some years, local Data Protection Authorities formulate their statements, which provide us with concrete guidelines

Read More
Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

A quick introduction

WordPress offers filter hooks to allow plugins to modify various types of internal data at runtime.

A plugin can modify data by binding a callback to a filter hook. When the filter is later applied, each bound callback is run in order of priority, and given the opportunity to modify a value by returning a new value.

The following example shows how a callback function is bound to a filter hook.

Note that $example is passed to the callback, (maybe) modified, then returned:

function example_callback( $example ) {
    // Maybe modify $example in some way.
    return $example;
}
add_filter( 'example_filter', 'example_callback' );

If you want to know more, before adding your first add_filter(), see below source. If it’s now your first time, see our collection of filters below.

source: https://developer.wordpress.org/reference/functions/add_filter/

If you have never used add_filter() or other functions to modify .php files in your theme or plugin files. Please make sure you have a back-up of the file you’re modifying and quick access to your FTP to revert back if anything goes wrong.

Adding your filters with Must-Use Plugins. It’s really simple!

Adding filters and hooks for our plugin might look difficult, but it can be done quite easy. Copy/Paste below the needed snippet below in your favorite text editor and follow the instructions in our article about MU Plugins.

[av_button label=’Adding a Filter with MU Plugins’ link=’manually,https://complianz.io/adding-filters-with-mu-plugins-quick-easy/’ link_target=’_blank’ size=’large’ position=’left’ label_display=” icon_select=’no’ icon=’ue800′ font=’entypo-fontello’ color=’custom’ custom_bg=’#2daee1′ custom_font=’#ffffff’ av_uid=’av-rqorno’ custom_class=” admin_preview_bg=”]

Our collection of prefilled add_filter()

Related articles