I have made a custom post type named as: slider, in my plugin class, I am adding a filter
which calls the method remove_row_action that unsets view links from actions
add_filter('post_row_actions', array(&$this, 'remove_row_actions'), 10, 1);
public function remove_row_actions($action) {
if (isset($_GET['post_type']) && $_GET['post_type'] == 'slider')) {
unset($action['view']);
return $action;
}else{
return $action;
}
}
It works perfectly well, but I believe there must be a cleaner way in which the add_filter only applies for the custom post type, instead of me checking it by the GET variable
Yes, you’re right. There is a clever way. post_row_actions filter can accept also second param $post from which you can get it’s post_type. See the code:
Just inspect the
get_current_screen()
object. It will tell you what you got. The same goes for the$query
argument that you can find inside theparse_request
andpre_get_posts
filters.