最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

filters - Why does wp_die() not work when inside a namespace?

programmeradmin1浏览0评论

Consider the following code copied from ACF docs, refactored to work inside a namespace:

add_filter('acf/location/rule_match/user', __NAMESPACE__ . '\acf_location_rule_match_user', 10, 4);
function acf_location_rule_match_user($match, $rule, $options, $field_group)
{

    var_dump($options);
    wp_die();

}

The problem is, nothing happens. I confirmed this only occurs when I'm inside a namespace. What am I doing wrong?

Consider the following code copied from ACF docs, refactored to work inside a namespace:

add_filter('acf/location/rule_match/user', __NAMESPACE__ . '\acf_location_rule_match_user', 10, 4);
function acf_location_rule_match_user($match, $rule, $options, $field_group)
{

    var_dump($options);
    wp_die();

}

The problem is, nothing happens. I confirmed this only occurs when I'm inside a namespace. What am I doing wrong?

Share Improve this question edited Jul 30, 2019 at 13:03 Abe Caymo asked Jul 29, 2019 at 12:39 Abe CaymoAbe Caymo 2232 silver badges7 bronze badges 2
  • Did you have added wp_head and wp_footer in header and footer file respectively ? – Tejas Gajjar Commented Jul 29, 2019 at 13:08
  • yes, i think the problem is when used inside a namespace – Abe Caymo Commented Jul 30, 2019 at 13:00
Add a comment  | 

1 Answer 1

Reset to default 0

Alternatively, to dump variables you could use error_log($var) or error_log(print_r($var, 1)) for arrays and objects.

Be sure WP_DEBUG_LOG and WP_DEBUG_DISPLAY constants are defined in your wp-config.php file and debug.log file will appear and update in wp-content folder.

发布评论

评论列表(0)

  1. 暂无评论