Created
September 28, 2015 18:59
-
-
Save lizkaraffa/d6babd2f3b841fd15ca5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* @author Joachim Kudish | |
* @uses SLD Custom Content Types & Taxonomies | |
* types & taxonomies | |
*/ | |
if (function_exists('sld_register_post_type')) : | |
/* = Homepage Elements | |
----------------------------------------------- */ | |
$singular = 'Homepage Element'; | |
$plural = $singular.'s'; | |
$args = array( | |
'labels' => array( | |
'name' => $plural, | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
'editor', | |
'thumbnail', | |
), | |
'hierarchical' => true, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/homepage.png', | |
'menu_position' => 99, | |
); | |
sld_register_post_type('homepage', $args); | |
/* = Take Action Widgets | |
----------------------------------------------- */ | |
$singular = 'Take Action Widget'; | |
$plural = $singular.'s'; | |
$args = array( | |
'labels' => array( | |
'name' => $plural, | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'hierarchical' => true, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/take-action.png', | |
'menu_position' => 100, | |
); | |
sld_register_post_type('take-action', $args); | |
/* = Issues | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'excerpt', | |
'editor', | |
'page-attributes', | |
), | |
'hierarchical' => true, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/issues.png', | |
'menu_position' => 101, | |
); | |
sld_register_post_type('issue', $args); | |
/* = Programs | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'excerpt', | |
'editor', | |
'page-attributes', | |
), | |
'hierarchical' => true, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/programs.png', | |
'menu_position' => 102, | |
); | |
sld_register_post_type('program', $args); | |
/* = Books | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
'excerpt', | |
'thumbnail', | |
'page-attributes', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/books.png', | |
'menu_position' => 103, | |
); | |
sld_register_post_type('book', $args); | |
/* = Products | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
'thumbnail', | |
), | |
'hierarchical' => true, | |
'rewrite' => array('slug' => 'boutique', 'with_front' => 'false'), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/products.png', | |
'menu_position' => 104, | |
); | |
sld_register_post_type('product', $args); | |
/* = News | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
'excerpt', | |
'thumbnail', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/news.png', | |
'menu_position' => 105, | |
); | |
sld_register_post_type('news', $args, 'news'); | |
/* = Press Releases | |
----------------------------------------------- */ | |
$singular = 'Press Release'; | |
$plural = $singular.'s'; | |
$args = array( | |
'labels' => array( | |
'name' => $plural, | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
'excerpt', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/pressreleases.png', | |
'menu_position' => 106, | |
); | |
sld_register_post_type('pressrelease', $args); | |
/* = Press Coverage | |
----------------------------------------------- */ | |
$singular = 'Press Coverage'; | |
$plural = $singular; | |
$args = array( | |
'labels' => array( | |
'name' => $plural, | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
), | |
'rewrite' => array('slug' => 'press', 'with_front' => false), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/presscoverage.png', | |
'menu_position' => 107, | |
); | |
sld_register_post_type('presscoverage', $args); | |
/* = Testimonials | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/testimonials.png', | |
'menu_position' => 108, | |
); | |
sld_register_post_type('testimonial', $args); | |
/* = Videos | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/video.png', | |
'menu_position' => 109, | |
); | |
sld_register_post_type('video', $args); | |
/* = Publications | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'editor', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/publications.png', | |
'menu_position' => 110, | |
); | |
sld_register_post_type('publication', $args); | |
sld_register_taxonomy('publication_type', 'publication', 'Publication Type'); | |
// Add Publication Custom Columns | |
add_filter('manage_edit-publication_columns', 'add_new_publication_columns'); | |
function add_new_publication_columns() { | |
return array( | |
'cb' => '<input type="checkbox">', | |
'view/edit' => __('View/Edit', 'blueocean'), | |
'publication_type' => __('Publication Types', 'blueocean'), | |
'publication' => __('Publication', 'blueocean'), | |
'date' => __('Date', 'blueocean'), | |
'has_pdf' => __('Has PDF?', 'blueocean'), | |
); | |
} | |
add_action('manage_publication_posts_custom_column', 'manage_publication_columns', 10, 2); | |
function manage_publication_columns($column_name, $post_id) { | |
if ($column_name == 'view/edit') { | |
echo '<a href="'.admin_url('post.php?post='.$post_id.'&action=edit').'">Edit »</a> | <a href="'.get_permalink($post_id).'">View »</a> | <a class="submitdelete" title="'.esc_attr( __( 'Move this item to the Trash' ) ).'" href="'.get_delete_post_link( $post->ID ).'">Delete »</a>'; | |
} | |
if ($column_name == 'publication') { | |
$post = get_post($post_id); | |
echo $post->post_content; | |
} | |
if ($column_name == 'has_pdf') { | |
$documents = new WP_Query(); | |
$documents->query(array('connected_type' => 'publications_to_documents', 'connected_items' => get_queried_object_id())); | |
if (is_array($documents->posts) && !empty($documents->posts)) { | |
echo 'Yes'; | |
} else { | |
echo 'No'; | |
} | |
} | |
} | |
/* = Readers write back | |
----------------------------------------------- */ | |
$singular = 'Feedback'; | |
$plural = 'Feedback'; | |
$args = array( | |
'labels' => array( | |
'name' => 'Readers Write Back', | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/feedback.png', | |
'menu_position' => 111, | |
); | |
sld_register_post_type('feedback', $args, 'feedback'); | |
/* = Diary | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'excerpt', | |
'editor', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/diary.png', | |
'menu_position' => 112, | |
); | |
sld_register_post_type('diary', $args, 'diaries'); | |
/* = Downloads | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'thumbnail', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/downloads.png', | |
'menu_position' => 113, | |
); | |
sld_register_post_type('download', $args); | |
sld_register_taxonomy('download_type', 'download', 'Download Type'); | |
/* = People | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
'excerpt', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/people.png', | |
'menu_position' => 114, | |
); | |
sld_register_post_type('person', $args, 'people'); | |
sld_register_taxonomy('involvement', 'person'); | |
/* = Partners | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'menu_position' => 115, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/partners.png', | |
); | |
sld_register_post_type('partner', $args); | |
/* = Annual Reports | |
----------------------------------------------- */ | |
$singular = 'Report'; | |
$plural = 'Reports'; | |
$args = array( | |
'labels' => array( | |
'name' => 'Annual Reports', | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
), | |
'menu_position' => 116, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/reports.png', | |
); | |
sld_register_post_type('report', $args); | |
/* = Articles | |
----------------------------------------------- */ | |
$singular = 'Article'; | |
$plural = 'Articles'; | |
$args = array( | |
'labels' => array( | |
'name' => 'How To Articles', | |
'singular_name' => $singular, | |
'add_new_item' => 'Add New ' . $singular, | |
'edit_item' => 'Edit ' . $singular, | |
'new_item' => 'New ' . $singular, | |
'view_item' => 'View ' . $singular, | |
'search_items' => 'Search ' . $plural, | |
'not_found' => 'No ' . $plural . ' found', | |
'not_found_in_trash' => 'No ' . $plural . ' found in Trash' | |
), | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'menu_position' => 117, | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/articles.png', | |
); | |
sld_register_post_type('article', $args); | |
/* = Seafood items | |
----------------------------------------------- */ | |
$args = array( | |
'supports' => array( | |
'title', | |
'editor', | |
), | |
'menu_icon' => get_bloginfo('template_url').'/images/icons/seafood.png', | |
'menu_position' => 118, | |
); | |
sld_register_post_type('seafood', $args); | |
sld_register_taxonomy('fish_key', 'seafood', 'Fish Key'); | |
sld_register_taxonomy('fish_flag', 'seafood', 'Fish Flag'); | |
/* = Documents | |
----------------------------------------------- */ | |
sld_unregister_taxonomy( 'workflow_state', 'document' ); | |
endif; | |
/* = Post 2 Post Connections | |
----------------------------------------------- */ | |
add_action('init', 'init_p2p_connections'); | |
function init_p2p_connections() { | |
if (function_exists('p2p_register_connection_type')) { | |
// connect issues to blog posts | |
p2p_register_connection_type( array( | |
'name' => 'posts_to_issues', | |
'from' => 'post', | |
'to' => 'issue', | |
'reciprocal' => true, | |
'title' => array( 'from' => 'Related Issues', 'to' => 'Related Articles' ), | |
) ); | |
// connect issues to programs | |
p2p_register_connection_type( array( | |
'name' => 'programs_to_issues', | |
'from' => 'program', | |
'to' => 'issue', | |
'reciprocal' => true, | |
'title' => array( 'from' => 'Related Issues', 'to' => 'Related Programs' ), | |
) ); | |
// connect issues to take action widgets | |
p2p_register_connection_type( array( | |
'name' => 'issues_take_action', | |
'from' => 'take-action', | |
'to' => 'issue', | |
'reciprocal' => true, | |
'cardinality' => 'one-to-many', | |
'title' => array( 'from' => 'Appears on the following issues', 'to' => 'Take Action widget to show' ), | |
) ); | |
// connect videos to issues | |
p2p_register_connection_type( array( | |
'name' => 'videos_to_issues', | |
'from' => 'video', | |
'to' => 'issue', | |
'reciprocal' => true, | |
'title' => array( 'from' => 'Related Issues', 'to' => 'Related Videos' ), | |
) ); | |
// connect testimonials to books | |
p2p_register_connection_type( array( | |
'name' => 'testimonials_to_books', | |
'from' => 'testimonial', | |
'to' => 'book', | |
'reciprocal' => true, | |
) ); | |
// connect documents to publications | |
p2p_register_connection_type( array( | |
'name' => 'publications_to_documents', | |
'from' => 'publication', | |
'to' => 'document', | |
'reciprocal' => true, | |
'title' => array('from' => 'Documents offered with this publication', 'to' => 'Associated Publications'), | |
'fields' => array( | |
'_title' => 'Download Link/Title', | |
), | |
) ); | |
// connect documents to publications | |
p2p_register_connection_type( array( | |
'name' => 'diary_to_documents', | |
'from' => 'diary', | |
'to' => 'document', | |
'reciprocal' => true, | |
'title' => array('from' => 'Documents offered with this diary', 'to' => 'Associated Diaries'), | |
'fields' => array( | |
'_title' => 'Download Link/Title', | |
), | |
) ); | |
// connect documents to press releases | |
p2p_register_connection_type( array( | |
'name' => 'pressrelease_to_documents', | |
'from' => 'pressrelease', | |
'to' => 'document', | |
'reciprocal' => true, | |
'title' => array('from' => 'Documents offered with this press release', 'to' => 'Associated Press Releases'), | |
'fields' => array( | |
'_title' => 'Download Link/Title', | |
), | |
) ); | |
// connect documents to news | |
p2p_register_connection_type( array( | |
'name' => 'news_to_documents', | |
'from' => 'news', | |
'to' => 'document', | |
'reciprocal' => true, | |
'title' => array('from' => 'Associated Documents', 'to' => 'Associated News Elements'), | |
'fields' => array( | |
'_title' => 'Download Link/Title', | |
), | |
) ); | |
// connect documents to seafood | |
p2p_register_connection_type( array( | |
'name' => 'seafood_to_documents', | |
'from' => 'seafood', | |
'to' => 'document', | |
'reciprocal' => true, | |
'title' => array('from' => 'Associated Documents', 'to' => 'Associated Seafood'), | |
'fields' => array( | |
'_title' => 'Download Link/Title', | |
), | |
) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment