Skip to content

Instantly share code, notes, and snippets.

@yousufansa
Created September 22, 2020 07:46
Show Gist options
  • Select an option

  • Save yousufansa/12657cba7ff73ed055ea908efb3cac7e to your computer and use it in GitHub Desktop.

Select an option

Save yousufansa/12657cba7ff73ed055ea908efb3cac7e to your computer and use it in GitHub Desktop.
MAS Videos - Unregister Post Types ( TV Show, TV Show Playlist, Episode, Video, Video Playlist, Person )
if( !function_exists( 'masvideos_child_get_unregister_post_types' ) ) {
function masvideos_child_get_unregister_post_types(){
// Hide the line prevent from remove that post type (currently movie & movies playlist are prevented from remove)
$post_types = [];
// $post_types[] = 'movie'; // Remove Movie Post Type
// $post_types[] = 'movie_playlist'; // Remove Movie Playlist Post Type
$post_types[] = 'tv_show'; // Remove TV Show Post Type
$post_types[] = 'tv_show_playlist'; // Remove TV Show Playlist Post Type
$post_types[] = 'episode'; // Remove Episode Post Type
$post_types[] = 'video'; // Remove Video Post Type
$post_types[] = 'video_playlist'; // Remove Video Playlist Post Type
$post_types[] = 'person'; // Remove Person Post Type
return $post_types;
}
}
if( !function_exists( 'masvideos_child_unregister_post_types' ) ) {
function masvideos_child_unregister_post_types(){
$post_types = masvideos_child_get_unregister_post_types();
foreach ( $post_types as $post_type ) {
unregister_post_type( $post_type );
}
if( in_array( 'video', $post_types ) ) {
add_filter( 'vodi_enable_header_upload_link', '__return_false', 999 );
}
}
}
add_action( 'init','masvideos_child_unregister_post_types' );
function masvideos_child_remove_history_playlist() {
$post_types = masvideos_child_get_unregister_post_types();
if( in_array( 'movie_playlist', $post_types ) ) {
remove_action( 'masvideos_after_single_movie', 'masvideos_set_watched_movie_history_to_playlist', 999 );
}
if( in_array( 'video_playlist', $post_types ) ) {
remove_action( 'masvideos_after_single_video', 'masvideos_set_watched_video_history_to_playlist', 999 );
}
if( in_array( 'tv_show_playlist', $post_types ) ) {
remove_action( 'masvideos_after_single_tv_show', 'masvideos_set_watched_tv_show_history_to_playlist', 999 );
}
}
add_action( 'init', 'masvideos_child_remove_history_playlist', 20 );
if( ! function_exists( 'masvideos_child_mv_customize_account_menu_items' ) ) {
function masvideos_child_mv_customize_account_menu_items( $items, $endpoints ) {
$post_types = masvideos_child_get_unregister_post_types();
if( in_array( 'video', $post_types ) ) {
unset( $items['videos'] );
}
if( in_array( 'video_playlist', $post_types ) ) {
unset( $items['video-playlists'] );
}
if( in_array( 'tv_show_playlist', $post_types ) ) {
unset( $items['tv-show-playlists'] );
}
if( in_array( 'movie_playlist', $post_types ) ) {
unset( $items['movie-playlists'] );
}
return $items;
}
}
add_filter( 'masvideos_account_menu_items', 'masvideos_child_mv_customize_account_menu_items', 20, 2 );
if ( ! function_exists( 'masvideos_child_modify_header_user_account_menu_items' ) ) {
function masvideos_child_modify_header_user_account_menu_items( $items ) {
$post_types = masvideos_child_get_unregister_post_types();
if( in_array( 'video_playlist', $post_types ) ) {
unset( $items['video-playlists'] );
}
if( in_array( 'tv_show_playlist', $post_types ) ) {
unset( $items['tv-show-playlists'] );
}
if( in_array( 'movie_playlist', $post_types ) ) {
unset( $items['movie-playlists'] );
}
return $items;
}
}
add_filter( 'vodi_header_user_account_menu_items', 'masvideos_child_modify_header_user_account_menu_items', 10 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment