/** * Get column value of Custom Field * * @since 1.4.6.1 */ protected function get_column_value_authorname($post_id, $column_name) { $type = get_post_type($post_id); // get column $columns = $this->get_stored_columns($type); // get the type of author name $display_as = isset($columns[$column_name]['display_as']) ? $columns[$column_name]['display_as'] : ''; // get the author $post = get_post($post_id); if (!isset($post->post_author)) { return false; } $name = Codepress_Admin_Columns::get_author_field_by_nametype($display_as, $post->post_author); // filter for customization $name = apply_filters('cpac_get_column_value_authorname', $name, $column_name, $post_id); // add link filter $class = isset($_GET['author']) && $_GET['author'] == $userdata->ID ? ' class="current"' : ''; $name = "<a href='edit.php?post_type={$type}&author={$post->post_author}'{$class}>{$name}</a>"; return $name; }
/** * Add taxonomy filters to posts * * @since 1.4.2 */ function callback_restrict_posts() { global $post_type_object; if (!isset($post_type_object->name)) { return false; } // make a filter foreach taxonomy $taxonomies = get_object_taxonomies($post_type_object->name, 'names'); // get stored columns $db_columns = Codepress_Admin_Columns::get_stored_columns($post_type_object->name); if ($taxonomies) { foreach ($taxonomies as $tax) { // ignore core taxonomies if (in_array($tax, array('post_tag', 'category', 'post_format'))) { continue; } // only display taxonomy that is active as a column if (isset($db_columns['column-taxonomy-' . $tax]) && $db_columns['column-taxonomy-' . $tax]['state'] == 'on') { $terms = get_terms($tax); $terms = $this->indent($terms, 0, 'parent', 'term_id'); $terms = $this->apply_dropdown_markup($terms); $select = "<option value=''>" . __('Show all ', CPAC_TEXTDOMAIN) . "{$tax}</option>"; if (!empty($terms)) { foreach ($terms as $term_slug => $term) { $selected = isset($_GET[$tax]) && $term_slug == $_GET[$tax] ? " selected='selected'" : ''; $select .= "<option value='{$term_slug}'{$selected}>{$term}</option>"; } echo "<select class='postform' name='{$tax}'>{$select}</select>"; } } } } }
/** * Strip tags and trim * * @since 1.3 */ protected function strip_trim($string) { return Codepress_Admin_Columns::strip_trim($string); }
/** * Manage custom column for Users. * * @since 1.1 */ public function manage_users_column_value($value, $column_name, $user_id) { $type = $column_name; $userdata = get_userdata($user_id); if (!$userdata) { return false; } // Check for user custom fields: column-meta-[customfieldname] if ($this->is_column_meta($type)) { $type = 'column-user-meta'; } // Check for post count: column-user_postcount-[posttype] if (Codepress_Admin_Columns::get_posttype_by_postcount_column($type)) { $type = 'column-user_postcount'; } // Hook do_action('cpac-manage-users-column', $type, $column_name, $user_id); $result = ''; switch ($type) { // user id case "column-user_id": $result = $user_id; break; // first name // first name case "column-nickname": $result = $userdata->nickname; break; // first name // first name case "column-first_name": $result = $userdata->first_name; break; // last name // last name case "column-last_name": $result = $userdata->last_name; break; // user url // user url case "column-user_url": $result = $userdata->user_url; break; // user registration date // user registration date case "column-user_registered": $result = $userdata->user_registered; break; // user description // user description case "column-user_description": $result = $this->get_shortened_string(get_the_author_meta('user_description', $user_id), $this->excerpt_length); break; // user description // user description case "column-user_postcount": $post_type = Codepress_Admin_Columns::get_posttype_by_postcount_column($column_name); // get post count $count = Codepress_Admin_Columns::get_post_count($post_type, $user_id); // set result $result = $count > 0 ? "<a href='edit.php?post_type={$post_type}&author={$user_id}'>{$count}</a>" : (string) $count; break; // user actions // user actions case "column-actions": $result = $this->get_column_value_actions($user_id, 'users'); break; // user meta data ( custom field ) // user meta data ( custom field ) case "column-user-meta": $result = $this->get_column_value_custom_field($user_id, $column_name, 'user'); break; default: $result = $value; } // Filter for customizing the result output apply_filters('cpac-users-column-result', $result, $type, $column_name, $user_id); return $result; }