Created
January 17, 2019 18:38
-
-
Save dnavarrojr/f4473fdabc278ce2c57e739b37bfe21b to your computer and use it in GitHub Desktop.
Custom Post Type modify the UI
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 tscpl_pb_edit_titles( $title ) { | |
$screen = get_current_screen(); | |
switch ( $screen->post_type ) { | |
case 'event': | |
case 'eventsregistration': | |
case 'eventsapi': | |
$title = 'Event Title'; | |
break; | |
case 'registration': | |
$title = 'Customer Name'; | |
break; | |
default: | |
$title = $title; | |
} | |
return $title; | |
} | |
add_filter( 'enter_title_here', 'tscpl_pb_edit_titles' ); | |
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/ | |
function tscpl_remove_program_book_post_published( $messages ) { | |
if ( get_post_type() == 'events' ) { | |
unset( $messages[post][10] ); // Post draft updated. Preview post | |
//unset( $messages[post][9] ); // Post scheduled for: Jan 12, 2013 @ 19:03. Preview post | |
//unset( $messages[post][8] ); // Post submitted. Preview post | |
//unset( $messages[post][7] ); // Post saved. | |
unset( $messages[post][6] ); // Post published. View post | |
//unset( $messages[post][4] ); // Post updated. | |
//unset( $messages[post][3] ); // Custom field deleted. | |
//unset( $messages[post][2] ); // Custom field updated. | |
unset( $messages[post][1] ); // Post updated. View post | |
} | |
return $messages; | |
} | |
add_filter( 'post_updated_messages', 'tscpl_remove_program_book_post_published' ); | |
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/ | |
function tscpl_program_book_hide_permalink( $return, $id, $new_title, $new_slug ) { | |
if ( get_post_type() == 'events' ) { | |
$return = ''; | |
$post = get_post( $id ); | |
if ( $post->post_status == 'publish' ) { | |
$link = 'https://tscpl.org/events/'; | |
$return = 'Events Link: <a href="' . $link . '">' . $link . '</a>'; | |
} | |
} | |
return $return; | |
} | |
add_filter( 'get_sample_permalink_html', 'tscpl_program_book_hide_permalink', 15, 4 ); | |
/*---------------------------------------------------------------------------------------------------------------------------------------------------*/ | |
function tscpl_program_book_events_remove_addnew() { | |
//remove_submenu_page( 'edit.php?post_type=events', 'post-new.php?post_type=events' ); | |
remove_submenu_page( 'tscpl-pb-export', 'post-new.php?post_type=events' ); | |
} | |
add_action( 'admin_menu', 'tscpl_program_book_events_remove_addnew', 999 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment