Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save manishsongirkar/d5f15c6e51d35575872a1b8ef717e84a to your computer and use it in GitHub Desktop.
Save manishsongirkar/d5f15c6e51d35575872a1b8ef717e84a to your computer and use it in GitHub Desktop.
Highlight on pages lists in editor if page is having Gutenberg markup or not.
<?php
function ms_filter_posts_columns( $columns ) {
$columns['gutenberg_markup'] = __( 'Gutenberg Markup?', 'text-domain' );
return $columns;
}
function ms_page_column( $column, $post_id ) {
if ( 'gutenberg_markup' === $column ) {
if ( preg_match( '/(wp:paragraph|wp:heading|wp:list|wp:cover|wp:image)/i', get_the_content( $post_id ) ) ) {
echo '<div style="color: green; text-align:center;">&#x2713;</div>';
} else {
echo '<div style="color: red; text-align:center;">&#x2717;</div>';
}
}
}
add_filter( 'manage_page_posts_columns', 'ms_filter_posts_columns' );
add_action( 'manage_page_posts_custom_column', 'ms_page_column', 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment