array( 'name' => $plural, 'singular_name' => $singular, 'add_new' => 'Add New', 'add_new_item' => 'Add New ' . $singular , 'edit' => 'Edit', 'edit_item' => 'Edit' . $singular, 'new' => 'New' . $singular, 'view' => 'View', 'view_item' => 'View' . $singular, 'search_term' => 'Search' . $plural, 'parent' => 'Parent' . $singular, 'not_found' => 'No ' . $plural . ' Found', 'not_found_in_trash' => 'No ' . $plural . ' in Trash', ), 'public' => true, 'public_queryable' => true, 'query_var' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'menu_position' => 10, 'menu_icon' => 'dashicons-businessman', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'has_archive' => false, 'capability_type' => 'page', 'map_meta_cap' => true, 'rewrite' => array( 'slug' => 'artist', 'with_front' => true, 'pages' => true, 'feeds' => false, ), 'supports' => array( 'title', 'thumbnail' ) ) ); $singular = 'Venue'; $plural = 'Venues'; register_post_type( 'venue', array( 'labels' => array( 'name' => $plural, 'singular_name' => $singular, 'add_new' => 'Add New', 'add_new_item' => 'Add New ' . $singular , 'edit' => 'Edit', 'edit_item' => 'Edit ' . $singular, 'new' => 'New' . $singular, 'view' => 'View', 'view_item' => 'View ' . $singular, 'search_term' => 'Search ' . $plural, 'parent' => 'Parent ' . $singular, 'not_found' => 'No ' . $plural . ' Found', 'not_found_in_trash' => 'No ' . $plural . ' in Trash', ), 'public' => false, 'public_queryable' => false, 'exclude_from_search' => true, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'menu_position' => 10, 'menu_icon' => 'dashicons-businessman', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'has_archive' => false, 'query_var' => true, 'capability_type' => 'page', 'map_meta_cap' => true, 'rewrite' => array( 'slug' => 'venue', 'with_front' => true, 'pages' => true, 'feeds' => false, ), 'supports' => array( 'title' ) ) ); $singular = 'Show'; $plural = 'Shows'; register_post_type( 'show', array( 'labels' => array( 'name' => $plural, 'singular_name' => $singular, 'add_new' => 'Add New', 'add_new_item' => 'Add New ' . $singular , 'edit' => 'Edit', 'edit_item' => 'Edit ' . $singular, 'new' => 'New ' . $singular, 'view' => 'View', 'view_item' => 'View ' . $singular, 'search_term' => 'Search ' . $plural, 'parent' => 'Parent ' . $singular, 'not_found' => 'No ' . $plural . ' Found', 'not_found_in_trash' => 'No ' . $plural . ' in Trash', ), 'public' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => true, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'menu_position' => 10, 'menu_icon' => 'dashicons-businessman', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'query_var' => true, 'capability_type' => 'page', 'map_meta_cap' => true, 'rewrite' => array( 'slug' => 'shows', 'with_front' => true, 'pages' => true, 'feeds' => false, ), 'supports' => array( 'title', 'thumbnail' ) ) ); $singular = 'Gallery'; $plural = 'Galleries'; register_post_type( 'artistpress-gallery', array( 'labels' => array( 'name' => $plural, 'singular_name' => $singular, 'add_new' => 'Add New', 'add_new_item' => 'Add New ' . $singular , 'edit' => 'Edit', 'edit_item' => 'Edit ' . $singular, 'new' => 'New ' . $singular, 'view' => 'View', 'view_item' => 'View ' . $singular, 'search_term' => 'Search ' . $plural, 'parent' => 'Parent ' . $singular, 'not_found' => 'No ' . $plural . ' Found', 'not_found_in_trash' => 'No ' . $plural . ' in Trash', ), 'public' => true, 'public_queryable' => true, 'exclude_from_search' => false, 'show_in_nav_menus' => false, 'show_ui' => true, 'show_in_menu' => false, 'show_in_admin_bar' => true, 'menu_position' => 10, 'menu_icon' => 'dashicons-businessman', 'can_export' => true, 'delete_with_user' => false, 'hierarchical' => false, 'has_archive' => false, 'query_var' => true, 'capability_type' => 'page', 'map_meta_cap' => true, 'rewrite' => array( 'slug' => 'artistpress-gallery', 'with_front' => true, 'pages' => true, 'feeds' => false, ), 'supports' => array( 'title', 'thumbnail' ) ) ); } add_action( 'init', 'artistpress_create_post_types' ); /** * Registers the ArtistPress gallery taxonomies * * @author LTDI Studios * @since 1.0.0 * */ function artistpress_gallery_taxonomies() { $labels = array( 'name' => _x( 'Albums', 'taxonomy general name' ), 'singular_name' => _x( 'Album', 'taxonomy singular name' ), 'search_items' => __( 'Search Albums' ), 'all_items' => __( 'All Albums' ), 'edit_item' => __( 'Edit Album' ), 'update_item' => __( 'Update Album' ), 'add_new_item' => __( 'Add New Album' ), 'new_item_name' => __( 'New Album Name'), 'menu_name' => __( 'Gallery Albums' ), ); $args = array( 'hierarchical' => true, 'labels' => $labels, 'show_ui' => true, 'show_admin_column' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'artistpress-album' ), ); register_taxonomy( 'artistpress-album', 'artistpress-gallery', $args ); } add_action( 'init', 'artistpress_gallery_taxonomies', 0 ); /** * Filters the placeholder text for the post type title fields * * @author LTDI Studios * @since 1.0.0 * */ function artistpress_change_title_text( $title ){ $screen = get_current_screen(); if ( 'show' == $screen->post_type ) { $title = 'Enter show title here'; }elseif ( 'artist' == $screen->post_type ) { $title = 'Enter artist name here'; }elseif ( 'venue' == $screen->post_type ) { $title = 'Enter venue name here'; }elseif ( 'artistpress-gallery' == $screen->post_type ) { $title = 'Enter gallery title here'; }elseif ( 'Playlist' == $screen->post_type ) { $title = 'Enter playlist title here'; }else{ $title = $title; } return $title; } add_filter( 'enter_title_here', 'artistpress_change_title_text' ); /** * Redirects the create post button when post creation limits are met * * @author LTDI Studios * @since 1.0.0 * */ function artistpress_redirects(){ global $typenow, $pagenow; if( 'artist' !== $typenow ) return; $total = get_posts( array( 'post_type' => 'artist', 'numberposts' => -1, 'post_status' => 'publish' )); if( $total && (count( $total ) >= 1) ){ wp_safe_redirect( "edit.php?post_type=artist"); } } add_action('load-post-new.php', 'artistpress_redirects' ); /** * Displays the notices on the post type pages * * @author LTDI Studios * @since 1.0.0 * */ function artistpress_notices() { global $typenow, $pagenow; $total = get_posts( array( 'post_type' => 'artist', 'numberposts' => -1, 'post_status' => 'publish' )); if (($typenow == 'artist') && ($pagenow == 'edit.php')){ if( $total && count( $total ) >= 1 ) { echo '

The maximum number of published ArtistPress Artists has been met.

'; } } } add_action('admin_notices','artistpress_notices'); /** * Changes the custom post type settings Artistpress Artists based on the settings * * @author LTDI Studios * @since 1.0.0 * */ $artistOptions = get_option('artistpress_artist_settings'); $artistOptionShortcode = sanitize_text_field( $artistOptions['artist_use_artist_shortcode'] ); if( $artistOptionShortcode == 'yes'){ function artistpress_artist_no_single( $args, $post_type ) { if ( 'artist' !== $post_type ) { return $args; } $artist_args = array( 'publicly_queryable' => false, ); return array_merge( $args, $artist_args ); } add_filter( 'register_post_type_args', 'artistpress_artist_no_single', 10, 2 ); }else{ function artistpress_artist_has_single( $args, $post_type ) { if ( 'artist' !== $post_type ) { return $args; } $artist_args = array( 'public_queryable' => true, ); return array_merge( $args, $artist_args ); } add_filter( 'register_post_type_args', 'artistpress_artist_has_single', 10, 2 ); } /** * Changes the custom post type settings Artistpress Show List based on the settings * * @author LTDI Studios * @since 1.0.0 * */ $artistpress_show_list_settings = get_option('artistpress_show_list_settings'); $showListUseShortcode = sanitize_text_field( $artistpress_show_list_settings['show_list_use_shortcode'] ); if( $showListUseShortcode == 'yes'){ function artistpress_show_no_archive_filter( $args, $post_type ) { if ( 'show' !== $post_type ) { return $args; } $show_args = array( 'has_archive' => false, 'public_queryable' => false, ); return array_merge( $args, $show_args ); } add_filter( 'register_post_type_args', 'artistpress_show_no_archive_filter', 10, 2 ); }else{ function artistpress_show_has_archive_filter( $args, $post_type ) { if ( 'show' !== $post_type ) { return $args; } $show_args = array( 'has_archive' => true, 'public_queryable' => true, ); return array_merge( $args, $show_args ); } add_filter( 'register_post_type_args', 'artistpress_show_has_archive_filter', 10, 2 ); }