actions - How can I see exactly what arguments are being passed through a filter so that I may modify them?

I'm having a great deal of trouble phrasing this.If I were to use the filter views_edit-pageHow can I see what exac

I'm having a great deal of trouble phrasing this.

If I were to use the filter

views_edit-page

How can I see what exactly is being passed through the filter so that I may edit them? Normally I would var_dump something similar to this, to get a breakdown of it's contents, but due to it being a filter, this does not seem to work.

For example

add_filter('views_edit-page','addFilter');

function addFilter($views) {
  var_dump($views);
  die();
}

Is what I'd like to do, so that I may see exactly what $views consists of, in order to edit them. However, this does not work, what is a method I can use in order to see the content of $views?

I'm having a great deal of trouble phrasing this.

If I were to use the filter

views_edit-page

How can I see what exactly is being passed through the filter so that I may edit them? Normally I would var_dump something similar to this, to get a breakdown of it's contents, but due to it being a filter, this does not seem to work.

For example

add_filter('views_edit-page','addFilter');

function addFilter($views) {
  var_dump($views);
  die();
}

Is what I'd like to do, so that I may see exactly what $views consists of, in order to edit them. However, this does not work, what is a method I can use in order to see the content of $views?

Share Improve this question asked Jun 5, 2019 at 1:45 peter kpeter k 54 bronze badges 3
  • Do the answers at wordpress.stackexchange/questions/149143/… help? – Nathan Johnson Commented Jun 5, 2019 at 2:24
  • Kind of, It modified the contents of the Filter, but does not provide a way to see what the contents actually are. I don't quite understand how they are able to make modifications to the data of the filter without first being able to see what the data consists of. – peter k Commented Jun 5, 2019 at 3:23
  • Your code works for me. Make sure you're on a page where the hook actually fires. /wp-admin/edit.php?post_type=page. – Nathan Johnson Commented Jun 5, 2019 at 17:05
Add a comment  | 

2 Answers 2

Reset to default 0

Perhaps you could push the variable contents to error log for later inspection? Like so,

function addFilter($views) {
    // error_log is native php function to log stuff
    // print_r prints human-readable information about a variable, 
    // print_r second parameter makes the function return result instead of echoing it
    error_log( print_r( $views, true ) );
    return $views;
}

The views_edit-page filter returns an array of strings. By default this will be something like this:

array (
  'all' => '<a href="edit.php?post_type=page" class="current" aria-current="page">All <span class="count">(1)</span></a>',
  'publish' => '<a href="edit.php?post_status=publish&#038;post_type=page">Published <span class="count">(1)</span></a>'
)

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

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

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

关注微信