Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adds a custom column to the admin Pages/Posts list indicating if the page was built in Pro. Only use one of these snippets.
<?php
// Add visual indicator to pages and posts built in Pro
// =============================================================================
function bourne_identity_columns( $columns ) {
$myCustomColumns = array(
'probuilder' => __( 'Builder' )
);
$columns = array_merge( $columns, $myCustomColumns );
return $columns;
}
add_filter( 'manage_pages_columns', 'bourne_identity_columns' );
add_filter( 'manage_posts_columns', 'bourne_identity_columns' );
function bourne_identity_column_content( $column_name, $post_id ) {
if ( $column_name == 'probuilder' ) {
$pro = get_post_meta($post_id, '_cornerstone_version', true);
if ( $pro ) {
// this is an SVG of the Pro logo. Swap out for anything you prefer.
echo '<svg class="pro-page-enabled" style="fill: #265998; max-width: 40px; display: block;" viewBox="0 0 281 317" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="pro-solid"><g id="Pro-Logo"><path d="M127.406476,2.7395047 C133.616099,-0.858480949 143.727203,-0.915998835 149.978168,2.60422723 L269.977989,70.1820261 C276.234367,73.7053001 281.306163,82.3896987 281.306163,89.5607286 L281.306163,225.974417 C281.306163,233.153704 276.249926,241.851898 270.007866,245.405149 L149.948291,313.74828 C143.708414,317.300289 133.633456,317.241619 127.435773,313.61169 L11.2142214,245.541739 C5.02077793,241.914293 1.07802775e-13,233.145446 1.03838259e-13,225.974417 L2.84217094e-14,89.5607286 C2.44526274e-14,82.3814407 5.03711142,73.6428704 11.2435182,70.0467487 L127.406476,2.7395047 Z M78.801,128.209 C68.791,128.209 58.781,128.3 48.771,128.3 L48.771,192 L60.783,192 L60.783,173.254 L78.801,173.254 C110.014,173.254 109.923,128.209 78.801,128.209 Z M166.798,191.181 L147.506,169.432 C159.609,166.975 163.613,158.148 163.613,149.412 C163.613,138.401 155.696,128.391 140.681,128.3 C130.58,128.3 120.479,128.209 110.378,128.209 L110.378,192 L122.39,192 L122.39,170.706 L133.947,170.706 L152.511,192 L166.798,192 L166.798,191.181 Z M140.681,139.493 C148.234,139.493 151.601,144.589 151.601,149.685 C151.601,154.781 148.325,159.877 140.681,159.877 L122.39,159.877 L122.39,139.493 L140.681,139.493 Z M80.6799927,138.490005 C88.2327319,138.490005 90.6000061,145.583993 90.6000061,150.679993 C90.6000061,155.775993 88.3237288,162.880005 80.6799927,162.880005 L60.3899994,162.880005 L60.3899994,138.493 L80.6799927,138.490005 Z M201.651,127.026 C179.629,127.026 168.891,143.861 168.891,160.605 C168.891,177.349 179.265,193.456 201.651,193.456 C224.037,193.456 234.138,176.985 234.32,160.514 C234.502,143.861 223.582,127.026 201.651,127.026 Z M201.651,137.946 C216.666,137.946 222.672,149.958 222.49,160.696 C222.308,171.161 216.666,182.445 201.651,182.445 C186.636,182.445 180.994,171.252 180.721,160.787 C180.448,150.049 186.636,137.946 201.651,137.946 Z" id="Combined-Shape"></path></g></g></svg>';
// If you accidently hit the "text" or "visual" tab, it breaks Pro editing. This will indicate if you have done that.
// If you have, it's fixable! Just don't edit any content. Head to the database. Find your post ID in the postmeta table,
// and delete the entire meta entry for _cornerstone_override. Have lots? https://github.com/michaelbourne/Fix-Broken-Cornerstone-Pages
// You're welcome.
if( get_post_meta($post_id, '_cornerstone_override', true) ) {
echo '<small>Broken</small>';
}
}
}
}
add_action( 'manage_pages_custom_column', 'bourne_identity_column_content', 10, 2 );
add_action( 'manage_posts_custom_column', 'bourne_identity_column_content', 10, 2 );
<?php
// Add visual indicator to pages built in Pro
// =============================================================================
function bourne_identity_columns( $columns ) {
$myCustomColumns = array(
'probuilder' => __( 'Builder' )
);
$columns = array_merge( $columns, $myCustomColumns );
return $columns;
}
add_filter( 'manage_pages_columns', 'bourne_identity_columns' );
function bourne_identity_column_content( $column_name, $post_id ) {
if ( $column_name == 'probuilder' ) {
$pro = get_post_meta($post_id, '_cornerstone_version', true);
if ( $pro ) {
// this is an SVG of the Pro logo. Swap out for anything you prefer.
echo '<svg class="pro-page-enabled" style="fill: #265998; max-width: 40px; display: block;" viewBox="0 0 281 317" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><g id="pro-solid"><g id="Pro-Logo"><path d="M127.406476,2.7395047 C133.616099,-0.858480949 143.727203,-0.915998835 149.978168,2.60422723 L269.977989,70.1820261 C276.234367,73.7053001 281.306163,82.3896987 281.306163,89.5607286 L281.306163,225.974417 C281.306163,233.153704 276.249926,241.851898 270.007866,245.405149 L149.948291,313.74828 C143.708414,317.300289 133.633456,317.241619 127.435773,313.61169 L11.2142214,245.541739 C5.02077793,241.914293 1.07802775e-13,233.145446 1.03838259e-13,225.974417 L2.84217094e-14,89.5607286 C2.44526274e-14,82.3814407 5.03711142,73.6428704 11.2435182,70.0467487 L127.406476,2.7395047 Z M78.801,128.209 C68.791,128.209 58.781,128.3 48.771,128.3 L48.771,192 L60.783,192 L60.783,173.254 L78.801,173.254 C110.014,173.254 109.923,128.209 78.801,128.209 Z M166.798,191.181 L147.506,169.432 C159.609,166.975 163.613,158.148 163.613,149.412 C163.613,138.401 155.696,128.391 140.681,128.3 C130.58,128.3 120.479,128.209 110.378,128.209 L110.378,192 L122.39,192 L122.39,170.706 L133.947,170.706 L152.511,192 L166.798,192 L166.798,191.181 Z M140.681,139.493 C148.234,139.493 151.601,144.589 151.601,149.685 C151.601,154.781 148.325,159.877 140.681,159.877 L122.39,159.877 L122.39,139.493 L140.681,139.493 Z M80.6799927,138.490005 C88.2327319,138.490005 90.6000061,145.583993 90.6000061,150.679993 C90.6000061,155.775993 88.3237288,162.880005 80.6799927,162.880005 L60.3899994,162.880005 L60.3899994,138.493 L80.6799927,138.490005 Z M201.651,127.026 C179.629,127.026 168.891,143.861 168.891,160.605 C168.891,177.349 179.265,193.456 201.651,193.456 C224.037,193.456 234.138,176.985 234.32,160.514 C234.502,143.861 223.582,127.026 201.651,127.026 Z M201.651,137.946 C216.666,137.946 222.672,149.958 222.49,160.696 C222.308,171.161 216.666,182.445 201.651,182.445 C186.636,182.445 180.994,171.252 180.721,160.787 C180.448,150.049 186.636,137.946 201.651,137.946 Z" id="Combined-Shape"></path></g></g></svg>';
// If you accidently hit the "text" or "visual" tab, it breaks Pro editing. This will indicate if you have done that.
// If you have, it's fixable! Just don't edit any content. Head to the database. Find your post ID in the postmeta table,
// and delete the entire meta entry for _cornerstone_override. Have lots? https://github.com/michaelbourne/Fix-Broken-Cornerstone-Pages
// You're welcome.
if( get_post_meta($post_id, '_cornerstone_override', true) ) {
echo '<small>Broken</small>';
}
}
}
}
add_action( 'manage_pages_custom_column', 'bourne_identity_column_content', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.