Filters
Adding a filter
Parameters
ACFTableFieldPro.core.addFilter( scope, filterName, handler, priority );
-
scope
The slug of the module
-
filterName
The name of the filter.
-
handler
The callback function.
-
priority
- Defaults: 10
Used to specify the order in which the functions associated with a particular action are executed. Lower numbers correspond with earlier execution, and functions with the same priority are executed in the order in which they were added.
Add a filter in a module example
jQuery.noConflict();
jQuery( document ).ready( function( $ ) {
function ACFTableFieldMyModule() {
var t = this;
t.init = function() {
ACFTableFieldPro.core.addFilter( 'main', 'filtername', t.filterFunction, 20 );
};
t.filterFunction = function( value, param ) {
// additional permanent parameters:
// param.filter.part = 'main'
// param.filter.filter: 'filtername'
return value;
// If the filter should apply only once
return {
applyOnce: true,
value: value
};
}
};
ACFTableFieldPro.mymodule = new ACFTableFieldMyModule();
});
Providing a filter
Provide filter
var value = ACFTableFieldPro.core.doFilter( scope, filterName, value, param );
Example of providing a filter in a moduleā¦
Provide a filter in a module example
jQuery.noConflict();
jQuery( document ).ready( function( $ ) {
function ACFTableFieldMyModule() {
var t = this;
t.init = function() {
var string = '',
param = {
key: 'value'
};
string = ACFTableFieldPro.core.doFilter( 'main', 'filter_string', string, param );
};
};
ACFTableFieldPro.mymodule = new ACFTableFieldMyModule();
});