Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if ( function_exists( 'add_theme_support' ) ) {
- add_theme_support( 'post-thumbnails' );
- set_post_thumbnail_size( 280, 210, true ); // Normal post thumbnails
- add_image_size( 'screen-shot', 720, 540 ); // Full size screen
- }
- add_action('init', 'custom_register');
- function custom_register() {
- register_post_type(
- 'portfolio', array(
- 'label' => 'Portfolio',
- 'description' => '',
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'map_meta_cap' => true,
- 'capability_type' => 'post',
- 'hierarchical' => true,
- 'rewrite' => array(
- 'slug' => 'portfolio'),
- 'query_var' => true,
- 'exclude_from_search' => false,
- 'menu_position' => 25,
- 'supports' => array(
- 'title',
- 'editor',
- 'custom-fields',
- 'revisions',
- 'thumbnail',
- 'comments',
- 'author',
- 'page-attributes',),
- 'taxonomies' => array(
- 'styles',),
- 'labels' => array (
- 'name' => 'Portfolios',
- 'singular_name' => 'Portfolio',
- 'menu_name' => 'Portfolios',
- 'add_new' => 'Add Portfolio',
- 'add_new_item' => 'Add New Portfolio',
- 'edit' => 'Edit',
- 'edit_item' => 'Edit Portfolio',
- 'new_item' => 'New Portfolio',
- 'view' => 'View Portfolio',
- 'view_item' => 'View Portfolio',
- 'search_items' => 'Search Portfolios',
- 'not_found' => 'No Portfolios Found',
- 'not_found_in_trash' => 'No Portfolios Found in Trash',
- 'parent' => 'Parent Portfolio',),
- )
- );
- register_post_type(
- 'blacklist', array(
- 'label' => 'Blacklist',
- 'description' => '',
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'map_meta_cap' => true,
- 'capability_type' => 'post',
- 'hierarchical' => true,
- 'rewrite' => array(
- 'slug' => 'blacklist'),
- 'query_var' => true,
- 'exclude_from_search' => false,
- 'menu_position' => 25,
- 'supports' => array(
- 'title',
- 'editor',
- 'custom-fields',
- 'revisions',
- 'thumbnail',
- 'comments',
- 'author',
- 'page-attributes',),
- 'taxonomies' => array(
- 'styles',),
- 'labels' => array (
- 'name' => 'Blacklist',
- 'singular_name' => 'Blacklist',
- 'menu_name' => 'Blacklist',
- 'add_new' => 'Add Blacklist',
- 'add_new_item' => 'Add New Blacklist',
- 'edit' => 'Edit',
- 'edit_item' => 'Edit Blacklist',
- 'new_item' => 'New Blacklist',
- 'view' => 'View Blacklist',
- 'view_item' => 'View Blacklist',
- 'search_items' => 'Search Blacklist',
- 'not_found' => 'No Blacklist Found',
- 'not_found_in_trash' => 'No Blacklist Found in Trash',
- 'parent' => 'Parent Blacklist',),
- )
- );
- register_post_type(
- 'applicant', array(
- 'label' => 'Applicants',
- 'description' => '',
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'map_meta_cap' => true,
- 'capability_type' => 'post',
- 'hierarchical' => true,
- 'rewrite' => array(
- 'slug' => ''),
- 'query_var' => true,
- 'exclude_from_search' => false,
- 'menu_position' => 25,
- 'supports' => array(
- 'title',
- 'editor',
- 'custom-fields',
- 'revisions',
- 'thumbnail',
- 'author',
- 'comments',
- 'page-attributes',),
- 'taxonomies' => array(
- 'styles',),
- 'labels' => array (
- 'name' => 'Applicants',
- 'singular_name' => 'Applicant',
- 'menu_name' => 'Applicants',
- 'add_new' => 'Add Applicant',
- 'add_new_item' => 'Add New Applicant',
- 'edit' => 'Edit',
- 'edit_item' => 'Edit Applicant',
- 'new_item' => 'New Applicant',
- 'view' => 'View Applicant',
- 'view_item' => 'View Applicant',
- 'search_items' => 'Search Applicants',
- 'not_found' => 'No Applicants Found',
- 'not_found_in_trash' => 'No Applicants Found in Trash',
- 'parent' => 'Parent Applicant',),
- )
- );
- register_post_type(
- 'employer', array(
- 'label' => 'Employers',
- 'description' => '',
- 'public' => true,
- 'show_ui' => true,
- 'show_in_menu' => true,
- 'map_meta_cap' => true,
- 'capability_type' => 'post',
- 'hierarchical' => true,
- 'rewrite' => array(
- 'slug' => 'employer'),
- 'query_var' => true,
- 'exclude_from_search' => false,
- 'menu_position' => 25,
- 'supports' => array(
- 'title',
- 'editor',
- 'custom-fields',
- 'revisions',
- 'thumbnail',
- 'author',
- 'comments',
- 'page-attributes',),
- 'taxonomies' => array(
- 'styles',),
- 'labels' => array (
- 'name' => 'Employers',
- 'singular_name' => 'Employer',
- 'menu_name' => 'Employers',
- 'add_new' => 'Add Employer',
- 'add_new_item' => 'Add New Employer',
- 'edit' => 'Edit',
- 'edit_item' => 'Edit Employer',
- 'new_item' => 'New Employer',
- 'view' => 'View Employer',
- 'view_item' => 'View Employer',
- 'search_items' => 'Search Employers',
- 'not_found' => 'No Employers Found',
- 'not_found_in_trash' => 'No Employers Found in Trash',
- 'parent' => 'Parent Employer',),
- )
- );
- }
- // custom taxonomy for portfolio blacklist employer and applicant
- register_taxonomy('job-type', array('portfolio', 'blacklist', 'employer', 'applicant'), array(
- 'label' => __('Job Category'),
- 'singular_label' => __('Job Category'),
- 'hierarchical' => true,
- 'query_var' => 'job-type',
- 'rewrite' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_nav_menus' => false,
- ));
- // custom taxonomy for portfolio blacklist employer and applicant
- register_taxonomy('province', array('portfolio', 'blacklist', 'employer', 'applicant'), array(
- 'label' => __('Provincia'),
- 'singular_label' => __('Provincia'),
- 'hierarchical' => true,
- 'query_var' => 'province',
- 'rewrite' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_nav_menus' => false,
- ));
- // custom taxonomy for portfolio blacklist employer and applicant
- register_taxonomy('location', array('portfolio', 'blacklist', 'employer', 'applicant'), array(
- 'label' => __('Location'),
- 'singular_label' => __('Location'),
- 'hierarchical' => true,
- 'query_var' => 'location',
- 'rewrite' => false,
- 'public' => true,
- 'show_ui' => true,
- 'show_in_nav_menus' => false,
- ));
- add_filter( 'map_meta_cap', 'my_map_meta_cap', 10, 4 );
- function my_map_meta_cap( $caps, $cap, $user_id, $args ) {
- /* If editing, deleting, or reading a portfolio, get the post and post type object. */
- if ( 'edit_portfolio' == $cap || 'delete_portfolio' == $cap || 'read_portfolio' == $cap ) {
- $post = get_post( $args[0] );
- $post_type = get_post_type_object( $post->post_type );
- /* Set an empty array for the caps. */
- $caps = array();
- }
- /* If editing a portfolio, assign the required capability. */
- if ( 'edit_portfolio' == $cap ) {
- if ( $user_id == $post->post_author )
- $caps[] = $post_type->cap->edit_posts;
- else
- $caps[] = $post_type->cap->edit_others_posts;
- }
- /* If deleting a portfolio, assign the required capability. */
- elseif ( 'delete_portfolio' == $cap ) {
- if ( $user_id == $post->post_author )
- $caps[] = $post_type->cap->delete_posts;
- else
- $caps[] = $post_type->cap->delete_others_posts;
- }
- /* If reading a private portfolio, assign the required capability. */
- elseif ( 'read_portfolio' == $cap ) {
- if ( 'private' != $post->post_status )
- $caps[] = 'read';
- elseif ( $user_id == $post->post_author )
- $caps[] = 'read';
- else
- $caps[] = $post_type->cap->read_private_posts;
- }
- /* Return the capabilities required by the user. */
- return $caps;
- }
- add_action("admin_init", "portfolio_meta_box");
- function portfolio_meta_box(){
- add_meta_box("projInfo-meta", "Project Options", "portfolio_meta_options", "portfolio", "side", "low");
- }
- function portfolio_meta_options(){
- global $post;
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) return $post_id;
- $custom = get_post_custom($post->ID);
- $link = $custom["projLink"][0];
- ?>
- <label>Link:</label><input name="projLink" value="<?php echo $link; ?>" />
- <?php
- }
- add_action('save_post', 'save_project_link');
- function save_project_link(){
- global $post;
- if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ){
- return $post_id;
- }else{
- update_post_meta($post->ID, "projLink", $_POST["projLink"]);
- }
- }
- add_filter("manage_edit-portfolio_columns", "project_edit_columns");
- function project_edit_columns($columns){
- $columns = array(
- "cb" => "<input type=\"checkbox\" />",
- "title" => "Project",
- "description" => "Description",
- "link" => "Link",
- "type" => "Type of Project",
- );
- return $columns;
- }
- add_action("manage_posts_custom_column", "project_custom_columns");
- function project_custom_columns($column){
- global $post;
- switch ($column)
- {
- case "description":
- the_excerpt();
- break;
- case "link":
- $custom = get_post_custom();
- echo $custom["projLink"][0];
- break;
- case "type":
- echo get_the_term_list($post->ID, 'project-type', '', ', ','');
- break;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement