Skip to content

Instantly share code, notes, and snippets.

@MjHead
Created October 6, 2020 13:31
Show Gist options
  • Save MjHead/719c2d095d592145f52badfe19535e46 to your computer and use it in GitHub Desktop.
Save MjHead/719c2d095d592145f52badfe19535e46 to your computer and use it in GitHub Desktop.
Add custom callback for the CCT admin column
<?php
/*
form_submissions - replace this with your actual CCT slug
cct_single_post_id - replace this with your actual field name
*/
add_filter( 'jet-engine/custom-content-types/admin-columns', function( $columns, $factory ) {
if ( 'form_submissions' === $factory->get_arg( 'slug' ) && isset( $columns['cct_single_post_id'] ) ) {
$columns['cct_single_post_id']['_cb'] = 'my_get_edit_post_link';
}
return $columns;
}, 10, 2 );
function my_get_edit_post_link( $post_id ) {
$title = get_the_title( $post_id );
if ( current_user_can( 'edit_post', $post_id ) ) {
$post_link = get_edit_post_link( absint( $post_id ), 'url' );
return sprintf( '<a href="%1$s" target="_blank">%2$s</a>', $post_link, $title );
} else {
return $title;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment