Exemplo n.º 1
0
/**
 * Setup archive posts for post types that have support.
 *
 * @since 1.0.0
 */
function audiotheme_archives_init_admin()
{
    if (is_network_admin()) {
        return;
    }
    $archives = array();
    $post_types = array('audiotheme_gig', 'audiotheme_record', 'audiotheme_video');
    // Add an archive if one doesn't exist for whitelisted post types.
    foreach ($post_types as $post_type) {
        $id = audiotheme_archives_create_archive($post_type);
        if ($id) {
            $archives[$post_type] = $id;
        }
    }
    audiotheme_archives_save_active_archives($archives);
    add_action('save_post', 'audiotheme_archive_save_hook', 10, 2);
    add_action('load-post.php', 'audiotheme_archive_help');
    add_action('parent_file', 'audiotheme_archives_parent_file');
    add_filter('post_updated_messages', 'audiotheme_archives_post_updated_messages');
    // Make archive links appear last.
    add_action('admin_menu', 'audiotheme_archives_admin_menu', 100);
    add_action('add_meta_boxes_audiotheme_archive', 'audiotheme_archives_add_meta_boxes');
    add_action('audiotheme_archive_settings_meta_box', 'audiotheme_archive_settings_meta_box_fields', 15, 3);
}
Exemplo n.º 2
0
/**
 * Remove the post type archive reference if it's deleted.
 *
 * @since 1.0.0
 *
 * @param int $post_id Post ID.
 */
function audiotheme_archives_deleted_post($post_id)
{
    if ('audiotheme_archive' !== get_post_type($post_id)) {
        return;
    }
    $active = get_audiotheme_archives();
    if ($key = array_search($active)) {
        unset($active[$key]);
        audiotheme_archives_save_active_archives($active);
    }
}