1

I need to make major changes on the way the comments are rendered in backend, from the following file: wp-admin/includes/class-wp-comments-list-table.php

I know editing the WP Core files directly is a bad idea...

Is there a way to create an edited version of this file with custom plugin and let wordpress use the file inside the plugin and not the default class-wp-comments-list-table.php ?

Thank you.

1

The comments are displayed using an instance of the WP_Comments_List_Table class which is defined as the global variable $wp_list_table.

You could extend this class and then use any action after $wp_list_table is defined (admin_head-edit-comments.php would work) to create an instance of your own class, copy all properties of $wp_list_table to the instance of your class and replace $wp_list_table with it.

It's not pretty but it will work and as long as there is no way to override _get_list_table() which defines the original $wp_list_table it's all you've got.

  • Hi Paul Thanks for reply. Can you please give me any code examples to start working with? Lets say I completely duplicate the code from wp_comments_list_table and edit it slightly to change it the way I want it to be. What would be the code / class look like where I insert this edited code from wp_comments_list_table ? Thanks a lot! – Domeniko Feb 21 '14 at 20:56
  • Hi Archie. I've written an example you can find here: gist.github.com/paulvandermeijs/9209651. I assumed you understand how to extend an existing class in PHP. You don't have to completely duplicate the original class (you can find more information on extending classes here: php.net/manual/en/keyword.extends.php). – Paul Feb 25 '14 at 14:28
  • Hi Paul. First of all, sorry for getting back to you so late, and Thanks a million for your efforts!!! I tried this code now, but i get error "Parse error: syntax error, unexpected T_FUNCTION in /home/xxx/public_html/wp-content/plugins/newcomments/new-comments-list-table.php on line 10", as I understand this is a php compatibility problem right? server Im working on is using php 5.2.9 version and for some reasons there is no way to upgrade it to 5.3, is there any way to work around this? – Domeniko Mar 18 '14 at 16:49
  • Or maybe its some other issue not related to php version? I used the code from your github. again, thanks a lot for your help! cheers : )) – Domeniko Mar 18 '14 at 16:50
  • Hi @paul any ideas on this issue? Thanks again for all your efforts : )) – Domeniko Mar 24 '14 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.