Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active August 5, 2022 14:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/6892032eeec8d0ad3087ea166eb97b45 to your computer and use it in GitHub Desktop.
Save jchristopher/6892032eeec8d0ad3087ea166eb97b45 to your computer and use it in GitHub Desktop.
<?php
// Custom OrganizeWP Info Column to display Comment count for each entry.
// @link https://organizewp.com/docs/info-columns/
class MyOwpInfoColumnComments extends \OrganizeWP\PostTypeInfoColumn {
function __construct( \OrganizeWP\PostType $post_type ) {
$this->assets();
}
// Markup to display the value for the applicable entry.
function display( \OrganizeWP\Entry $entry ): string {
return '<span class="organizewp-badge my-owp-comment-count">Comments: ' . esc_html( get_comment_count( $entry->ID )['approved'] ) . '</span>';
}
// Custom CSS for our custom Info Column.
function assets() {
add_action( 'admin_footer', function() {
if ( 'toplevel_page_organizewp' !== get_current_screen()->base ) {
return;
}
?>
<style>
.my-owp-comment-count {
text-align: center;
}
</style>
<?php
} );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment