I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an apply_filters .... (if possible)
Their plugin works with Ajax calls on plugin page admin, so when I click on 'AddOn' page it makes an ajax call called 'wp_ajax_checkAddons', which executes a function (that takes no arguments) and gerenates the page HTML.
The question is: Is it possible to hook with apply_filters or add_filters on their function, manipulate it adding HTML to that page?
Exmaple code:
The ajax call:
$.ajax({
type: 'POST',
url: 'admin-ajax.php',
data: 'action=checkAddons',
success: function (response) {
$('.box').html(response);
}
});
The action:
add_action('wp_ajax_checkAddons', array(&$this, 'checkAddons'));
The callback:
function checkAddons() {
$result = theClass::theFunction();
die($result);
}
The function:
class theClass{
public static function theFunction(){
//code
return $code;
}
}
I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an apply_filters .... (if possible)
Their plugin works with Ajax calls on plugin page admin, so when I click on 'AddOn' page it makes an ajax call called 'wp_ajax_checkAddons', which executes a function (that takes no arguments) and gerenates the page HTML.
The question is: Is it possible to hook with apply_filters or add_filters on their function, manipulate it adding HTML to that page?
Exmaple code:
The ajax call:
$.ajax({
type: 'POST',
url: 'admin-ajax.php',
data: 'action=checkAddons',
success: function (response) {
$('.box').html(response);
}
});
The action:
add_action('wp_ajax_checkAddons', array(&$this, 'checkAddons'));
The callback:
function checkAddons() {
$result = theClass::theFunction();
die($result);
}
The function:
class theClass{
public static function theFunction(){
//code
return $code;
}
}
Share
Improve this question
asked Sep 8, 2019 at 1:14
SantoroSantoro
607 bronze badges
1 Answer
Reset to default 2The question is: Is it possible to hook with apply_filters or add_filters on their function, manipulate it adding HTML to that page?
apply_filters
and add_filter()
do two separate things. apply_filters
allows a value to be filtered by add_filter()
. This means that if the original code is 3rd-party, you can only use add_filter()
if that code already has apply_filters()
applied to it. If you're extending another plugin, you will be using add_filter()
, not apply_filters()
.
So you need to check if the original checkAddons
function includes any filters for you to use, by seeing if it uses apply_filters()
anywhere. If it does, then you can filter the value passed to it with add_filter()
. If the filter is properly supported, then ideally the original developer has documented it somewhere.