Created
July 24, 2023 11:23
-
-
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.
This file contains 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 | |
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;">✓</div>'; | |
} else { | |
echo '<div style="color: red; text-align:center;">✗</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