Last active
August 5, 2022 14:35
-
-
Save jchristopher/6892032eeec8d0ad3087ea166eb97b45 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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