edit_flow_enabled()) { add_action('manage_posts_custom_column', array(&$this, 'handle_ef_duedate_column'), 10, 2); add_action('manage_posts_custom_column', array(&$this, 'handle_ef_location_column'), 10, 2); } */ if ($assignment_desk->coauthors_plus_exists()) { add_action('manage_posts_custom_column', array(&$this, 'handle_ad_participants_column'), 10, 2); } if(current_user_can($assignment_desk->define_editor_permissions)){ add_action('manage_posts_custom_column', array(&$this, 'handle_ad_user_type_column'), 10, 2); add_action('manage_posts_custom_column', array(&$this, 'handle_ad_volunteers_column'), 10, 2); add_action('manage_posts_custom_column', array(&$this, 'handle_ad_pitched_by_timestamp_column'), 10, 2); } // Filter by eligible contributor types add_action('restrict_manage_posts', array(&$this, 'add_eligible_contributor_type_filter')); // Sorting add_action('restrict_manage_posts', array(&$this, 'add_sortby_option')); add_action('parse_query', array(&$this, 'parse_query_sortby')); // Filter by assignment status add_action('restrict_manage_posts', array(&$this, 'add_assignment_status_filter')); // Add postmeta to the manage_posts query add_filter('posts_join', array(&$this, 'posts_join_meta' )); // Add the taxonomy tables to the mange_posts query add_filter('posts_join', array(&$this, 'posts_join_taxonomy' )); // Filter by eligible contributor_type add_filter('posts_where', array(&$this, 'posts_contributor_type_where' )); // Workaround to show posts with EF custom statuses when post_status=='all' add_filter('posts_where', array(&$this, 'add_ef_custom_statuses_where_all_filter' ), 20); // Filter by assignment_status add_filter('posts_where', array(&$this, 'add_ad_assignment_statuses_where' ), 20); } /** * Add columns to the manage posts listing. * Wordpress calls this and passes the list of columns. */ function add_manage_post_columns($posts_columns){ global $assignment_desk; // TODO - Specify the column order $custom_fields_to_add = array(); $custom_fields_to_add[_('_ad_assignment_status')] = _('Assignment Status'); /* Disabled 11/11/10 until we can find a better way to manage which metadata appears in columns ^DB if ($assignment_desk->edit_flow_enabled()) { $custom_fields_to_add[_('_ef_duedate')] = __('Due Date'); $custom_fields_to_add[_('_ef_location')] = __('Location'); } */ if($assignment_desk->coauthors_plus_exists()){ $custom_fields_to_add[_('_ad_participants')] = __('Participants'); } if(current_user_can($assignment_desk->define_editor_permissions)){ $custom_fields_to_add[_('_ad_user_type')] = _('Contributor Types'); $custom_fields_to_add[_('_ad_pitched_by_timestamp')] = __('Age'); $custom_fields_to_add[_('_ad_volunteers')] = __('Volunteers'); } $custom_fields_to_add[_('_ad_votes_total')] = _('Votes'); foreach ($custom_fields_to_add as $field => $title) { $posts_columns["$field"] = $title; } return $posts_columns; } function handle_ad_user_type_column( $column_name, $post_id ) { global $assignment_desk; if ( $column_name == _( '_ad_user_type' ) ) { $participant_types = $assignment_desk->custom_taxonomies->get_user_types_for_post($post_id); echo $participant_types['display']; } } /** * Display the Edit-Flow Due Date custom field in the manage_posts view. */ function handle_ef_duedate_column($column_name, $post_id){ if ( $column_name == _('_ef_duedate') ){ // Get the due date, format it and echo. $due_date = get_post_meta($post_id, '_ef_duedate', true); if($due_date){ echo strftime("%b %d, %Y", $due_date); } else { _e('None listed'); } } } /** * Display the Edit-Flow Location custom field in the manage_posts view. */ function handle_ef_location_column($column_name, $post_id){ if ( $column_name == _('_ef_location') ){ // Get the due date, format it and echo. $location = get_post_meta($post_id, '_ef_location', true); if($location){ echo $location; } else { _e('None'); } } } /** * Display the assignment_status custom field in the manage_posts view. */ function handle_ad_assignment_status_column($column_name, $post_id){ global $assignment_desk; if ( $column_name == _('_ad_assignment_status') ) { $current_status = wp_get_object_terms($post_id, $assignment_desk->custom_taxonomies->assignment_status_label); if ($current_status) { echo $current_status[0]->name; } else { _e('None'); } } } /** * Show participants who have accepted by role on the manage_posts view. */ function handle_ad_participants_column($column_name, $post_id){ global $assignment_desk; if ($column_name == _('_ad_participants') ) { $user_roles = $assignment_desk->custom_taxonomies->get_user_roles(array('order' => "-name")); $at_least_one_user = false; foreach($user_roles as $user_role){ $participants = get_post_meta($post_id, "_ad_participant_role_$user_role->term_id", true); if($participants){ $links = ''; foreach($participants as $user => $status){ if($status == 'accepted'){ $at_least_one_user = true; $user = get_userdata($user); $user_name = ($user->display_name)? $user->display_name : $user->user_login; $links .= "$user_name "; } } // Print the role header and user links if($links){ echo "
$user_role->name: $links
"; } } } if (!$at_least_one_user) { _e('None assigned'); } } } /** * Show the age of a post that started as a pitch. */ function handle_ad_pitched_by_timestamp_column($column_name, $post_id){ global $assignment_desk, $wpdb; $volunteers = 0; if ( $column_name == _('_ad_pitched_by_timestamp') ) { $timestamp = (int)get_post_meta($post_id, '_ad_pitched_by_timestamp', true); if ( !$timestamp ) { $age = _("Not a pitch"); } else { $age = human_time_diff($timestamp, current_time('timestamp')); } echo ""; } } /** * Show users who have volunteered for this post. */ function handle_ad_volunteers_column($column_name, $post_id){ global $assignment_desk, $wpdb; $volunteers = 0; if ( $column_name == _('_ad_volunteers') ) { $volunteers = get_post_meta($post_id, '_ad_total_volunteers', true); if ( !$volunteers ) { update_post_meta($post_id, '_ad_total_volunteers', 0); $volunteers = 0; } echo "$volunteers"; } } /** * Show the total votes for this post. */ function handle_ad_votes_total($column_name, $post_id){ if ( $column_name == _('_ad_votes_total') ) { $votes = get_post_meta($post_id, '_ad_votes_total', true); if ( !$votes ) { $votes = 0; } echo $votes; } } /** * Add a dropdown to filter posts by eligible user_types. */ function add_eligible_contributor_type_filter() { global $assignment_desk; $user_types = $assignment_desk->custom_taxonomies->get_user_types(); ?> custom_taxonomies->get_assignment_statuses(); echo "