Skip to content

Instantly share code, notes, and snippets.

@designbuildtest
Last active August 29, 2015 14:15
Show Gist options
  • Save designbuildtest/2631c0ac1031cdc81dd6 to your computer and use it in GitHub Desktop.
Save designbuildtest/2631c0ac1031cdc81dd6 to your computer and use it in GitHub Desktop.
Custom Manage Testimonials view
// Remove default columns from manage view.
function myplugin_custom_manage_testimonial_columns( $columns ) {
unset( $columns['author'] );
unset( $columns['date'] );
$columns['description'] = __( 'Excerpt' );
//$columns['menu_order_testimonial'] = __( 'Order' );
return $columns;
}
add_filter( 'manage_edit-testimonial_columns', 'myplugin_custom_manage_testimonial_columns' );
function myplugin_testimonial_menu_order_column( $name ) {
global $post;
switch ( $name ) {
case 'description':
echo get_the_excerpt();
break;
case 'menu_order_testimonial':
$order = $post->menu_order;
esc_attr_e( $order );
break;
}
}
add_action( 'manage_testimonial_posts_custom_column','myplugin_testimonial_menu_order_column' );
// Remove Author metabox from Testimonials edit screen
function myplugin_custom_testimonal_post_metabox() {
remove_meta_box( 'authordiv', 'testimonial', 'normal' );
remove_meta_box( 'pageparentdiv', 'testimonial', 'side' );
// Other possible values: 'postexcerpt', 'postimagediv'
add_meta_box('pageparentdiv', __( 'Order' ), 'page_attributes_meta_box', 'testimonial', 'side', 'default' );
// Other possible values: 'post_thumbnail_meta_box', 'post_excerpt_meta_box'
}
add_action( 'do_meta_boxes', 'myplugin_custom_testimonal_post_metabox' );
// Remove default columns from manage view.
function myplugin_custom_manage_page_columns( $columns ) {
unset( $columns['author'] );
unset( $columns['comments'] );
unset( $columns['date'] );
$columns['featured_page'] = __( 'Feature on Homepage' );
if ( current_theme_supports( 'onehundred-testimonials' ) ) {
$columns['testimonial'] = __( 'Testimonial' );
}
$columns['include_in_menu'] = __( 'Include in Navigation' );
//$columns['menu_order'] = __( 'Order' );
return $columns;
}
add_filter( 'manage_edit-page_columns', 'myplugin_custom_manage_page_columns' );
if ( current_theme_supports( 'myplugin-testimonials' ) ) {
$columns['testimonial'] = __( 'Testimonial' );
}
case 'testimonial':
$id = get_post_meta( $post->ID, '_myplugin_testimonial_page_id', true );
$status = get_post_status( $id );
if ( $status == '' ) {
echo __( '—' );
}
elseif ( $id && $status !== 'trash' ) {
echo '<a href="'. admin_url() . 'post.php?post=' . absint( $id ) . '&action=edit">' . esc_attr( get_the_title( $id ) ) . '</a>';
}
else {
echo __( '&mdash;' );
}
break;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment