filters - Is it possible to apply_filter on a wp_ajax_ action?

I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an appl

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
Add a comment  | 

1 Answer 1

Reset to default 2

The 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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745176339a4615211.html

相关推荐

  • filters - Is it possible to apply_filter on a wp_ajax_ action?

    I'm extending someone else's plugin with an AddOn and register it on their 'AddOn' page with an appl

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信