Hi Johan,
Here you go:
In /wp-content/plugins/custom-post-widget/post-widget.php:
// Create the Content Block custom post type
add_action( 'init', 'my_content_block_post_type_init' );
function my_content_block_post_type_init() {
$labels = array(
'name' => _x( 'Content Blocks', 'post type general name', 'custom-post-widget' ),
'singular_name' => _x( 'Content Block', 'post type singular name', 'custom-post-widget' ),
'plural_name' => _x( 'Content Blocks', 'post type plural name', 'custom-post-widget' ),
'add_new' => _x( 'Add Content Block', 'block', 'custom-post-widget' ),
'add_new_item' => __( 'Add New Content Block', 'custom-post-widget' ),
'edit_item' => __( 'Edit Content Block', 'custom-post-widget' ),
'new_item' => __( 'New Content Block', 'custom-post-widget' ),
'view_item' => __( 'View Content Block', 'custom-post-widget' ),
'search_items' => __( 'Search Content Blocks', 'custom-post-widget' ),
'not_found' => __( 'No Content Blocks Found', 'custom-post-widget' ),
'not_found_in_trash' => __( 'No Content Blocks found in Trash', 'custom-post-widget' ),
'parent_item_colon' => ''
);
$content_block_public = false;
$options = array(
'labels' => $labels,
'public' => apply_filters( 'content_block_post_type', $content_block_public ),
'publicly_queryable' => false,
'exclude_from_search' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title','editor','revisions','thumbnail','author' )
);
register_post_type( 'content_block',$options );
}
…and then the working filter:
function filter_content_block_init() {
$content_block_public = true;
return $content_block_public;
}
add_filter('content_block_post_type','filter_content_block_init');
Might not be the most elegant (I’m no PHP pro) but it works!