_x( 'Audio Tracks', 'audiotrack general name' ),
'singular_name' => _x( 'Audio Track', 'audiotrack singular name' ),
'add_new' => _x( 'Add Track', 'audiotrack' ),
'add_new_item' => __( 'Add New Audio Track' ),
'edit_item' => __( 'Edit Audio Track' ),
'new_item' => __( 'New Audio Track' ),
'view_item' => __( 'View Audio Track' ),
'search_items' => __( 'Search Audio Tracks' ),
'not_found' => __( 'No audio tracks found' ),
'not_found_in_trash' => __( 'No audio tracks found in Trash' ),
'parent_item_colon' => '',
'menu_name' => __( 'Audio Tracks' )
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => false,
'show_ui' => true,
'show_in_nav_menus' => true,
'query_var' => true,
'rewrite' => true,
//'taxonomies' => array( 'music_genre' ),
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'thumbnail' )
);
register_post_type( 'audiotrack', $args );
// #TCON Genre
$labels = array(
'name' => _x( 'Genres', 'taxonomy general name' ),
'singular_name' => _x( 'Genre', 'taxonomy singular name' ),
'search_items' => __( 'Search Genres' ),
'all_items' => __( 'All Genres' ),
'parent_item' => __( 'Parent Genre' ),
'parent_item_colon' => __( 'Parent Genre:' ),
'edit_item' => __( 'Edit Genre' ),
'update_item' => __( 'Update Genre' ),
'add_new_item' => __( 'Add New Genre' ),
'new_item_name' => __( 'New Genre Name' ),
'menu_name' => _x( 'Genres', 'taxonomy general name' )
);
register_taxonomy( 'ID3_TCON', array( 'audiotrack' ), array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'audio-genre' ),
) );
// #TALB Album/Movie/Show title
$labels = array(
'name' => _x( 'Albums', 'taxonomy general name' ),
'singular_name' => _x( 'Album', 'taxonomy singular name' ),
'search_items' => __( 'Search Albums' ),
'all_items' => __( 'All Albums' ),
'parent_item' => __( 'Parent Album' ),
'parent_item_colon' => __( 'Parent Album:' ),
'edit_item' => __( 'Edit Album' ),
'update_item' => __( 'Update Album' ),
'add_new_item' => __( 'Add New Album' ),
'new_item_name' => __( 'New Album' ),
'menu_name' => _x( 'Albums', 'taxonomy general name' )
);
register_taxonomy( 'ID3_TALB', array( 'audiotrack' ), array(
'hierarchical' => false,
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'audio-album' ),
) );
}
add_filter( 'post_updated_messages', 'audiotrack_updated_messages' );
function audiotrack_updated_messages( $messages ) {
global $post, $post_ID;
$messages['audiotrack'] = array(
0 => '', // Unused. Messages start at index 1.
1 => sprintf( __('Track updated. View track'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Track updated.'),
/* translators: %s: date and time of the Track */
5 => isset($_GET['revision']) ? sprintf( __('Track restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Track published. View track'), esc_url( get_permalink($post_ID) ) ),
7 => __('Track saved.'),
8 => sprintf( __('Track submitted. Preview track'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Track scheduled for: %1$s. Preview track'),
// translators: Publish box date format, see http://php.net/date
date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('Track draft updated. Preview track'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}
add_action( 'admin_menu', 'audiotrack_add_meta_boxes' );
function audiotrack_add_meta_boxes() {
if ( function_exists( 'add_meta_box' ) ) {
add_meta_box( 'audiotrack_track_meta', 'Track Details', 'audiotrack_track_meta_box_inner', 'audiotrack', 'normal' );
add_meta_box( 'audiotrack_file_meta', 'Audio File', 'audiotrack_file_meta_box_inner', 'audiotrack', 'normal' );
}
}
//http://www.id3.org/id3v2.3.0#head-e4b3c63f836c3eb26a39be082065c21fba4e0acc
function audiotrack_track_meta_box_inner() {
global $post;
$ID3_TPE1 = get_post_meta( $post->ID, 'ID3_TPE1', true );
$ID3_TCOM = get_post_meta( $post->ID, 'ID3_TCOM', true );
//$audio_year = get_post_meta( $post->ID, 'audio_year', true );
//$audio_grouping = get_post_meta( $post->ID, 'audio_grouping', true );
//$audio_duration = get_post_meta( $post->ID, 'audio_duration', true );
//$audio_bpm = get_post_meta( $post->ID, 'audio_bpm', true );
//$audio_compilation = get_post_meta( $post->ID, 'audio_compilation', true );
// Use nonce for verification
echo '';
// The actual fields for data entry
echo ' ';
echo '
';
echo ' ';
echo '
';
/*
echo ' ';
echo '
';
echo ' ';
echo ' Generally used to denote movements within a classical work.
';
echo ' ';
echo '
';
echo ' ';
echo '
';
echo ' ';
echo '
';
echo ' ';
echo ' ';
echo 'of
';
echo ' ';
echo ' ';
echo 'of
';
echo 'Lyrics';
*/
}
function audiotrack_file_meta_box_inner() {
global $post;
$audiotrack_mp3_file = get_post_meta( $post->ID, 'audiotrack_mp3_file', true );
//$audio_kind = get_post_meta( $post->ID, 'audio_kind', true );
//$audio_format = get_post_meta( $post->ID, 'audio_format', true );
//$audio_channels = get_post_meta( $post->ID, 'audio_channels', true );
//$audio_size = get_post_meta( $post->ID, 'audio_size', true );
//$audio_bit_rate = get_post_meta( $post->ID, 'audio_bit_rate', true );
//$audio_sample_rate = get_post_meta( $post->ID, 'audio_sample_rate', true );
// Use nonce for verification
echo '';
// The actual fields for data entry
echo '
'; echo '
'; /* echo ''; echo '
'; echo ''; echo '
'; echo ''; echo '
'; echo ''; echo 'kb
'; echo ''; echo 'kbps
'; echo ''; echo 'kHz
'; */ } add_action( 'save_post', 'audio_save_postdata' ); function audio_save_postdata( $post_id ) { if ( !isset( $_POST['audiotrack_track_noncename'] ) ) { return $post_id; } if ( !wp_verify_nonce( $_POST['audiotrack_file_noncename'], plugin_basename( __FILE__ ) ) ) { return $post_id; } // verify if this is an auto save routine. If it is our form has not been submitted, so we dont want // to do anything if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return $post_id; // Check permissions if ( 'page' == $_POST['post_type'] ) { if ( !current_user_can( 'edit_post', $post_id ) ) return $post_id; } $mydata['ID3_TPE1'] = $_POST['ID3_TPE1']; $mydata['ID3_TCOM'] = $_POST['ID3_TCOM']; $mydata['audiotrack_mp3_file'] = $_POST['audiotrack_mp3_file']; update_post_meta( $post_id, 'ID3_TPE1', $mydata['ID3_TPE1'] ); update_post_meta( $post_id, 'ID3_TCOM', $mydata['ID3_TCOM'] ); update_post_meta( $post_id, 'audiotrack_mp3_file', $mydata['audiotrack_mp3_file'] ); return $mydata; } ?>