function test_get_custom_field_meta() { $meta = get_custom_field_meta('poster_image'); $this->assertTrue($meta['description'] == 'Main image for this film.'); $meta = get_custom_field_meta('does_not_exist'); $this->assertTrue($meta == 'Invalid field name: does_not_exist'); }
/** * Populate the custom data for a given column. This function should actually * *print* data, not just return it. * Oddly, WP doesn't even send the column this way unless it is something custom. * Note that things get all broken and wonky if you do not include the "post_title" * column, so we rely on the $this->no_title_flag boolean variable (set in __call) * to trigger customizations here which print out the various eye-candy * "Edit/Trash/View" links when the post_title column has been omitted. * * See https://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=443 * * @param string $column name */ public function populate_custom_column_data($column) { // See https://code.google.com/p/wordpress-custom-content-type-manager/wiki/CustomColumns $function_name = 'cctm_custom_column_' . $this->post_type . '_' . $column; if (function_exists($function_name)) { return $function_name(); } global $post; if ($this->last_post != $post->ID) { $this->new_row = true; } // This attaches the Edit/Trash/View links to the first column if the post_title isn't there if ($this->no_title_flag && $this->new_row) { printf('<strong><a class="row-title" href="post.php?post=%s&action=edit">', $post->ID); } $meta = get_custom_field_meta($column); if ($meta['type'] === "image") { $id = get_custom_field($column . ":raw"); printf('<a target="_blank" href="%s">%s</a>', get_edit_post_link($id), wp_get_attachment_image($id, "thumbnail")); } elseif ($meta['type'] === "relation") { $id = get_custom_field($column . ":raw"); printf('<a target="_blank" href="%s">%s</a>', get_edit_post_link($id), get_the_title($id)); } else { print_custom_field($column); } // End the anchor if ($this->no_title_flag && $this->new_row) { print '</a></strong> <div class="row-actions"><span class="edit"><a href="post.php?post=' . $post->ID . '&action=edit" title="' . __('Edit') . '">' . __('Edit') . '</a> | </span> <span class="inline hide-if-no-js"><a href="#" class="editinline">' . __('Quick Edit') . '</a> | </span><span class="trash"><a class="submitdelete" href="' . get_delete_post_link($post->ID) . '">' . __('Trash') . '</a> | </span><span class="view"><a href="' . get_permalink($post->ID) . '" rel="permalink">' . __('View') . '</a></span>'; $this->new_row = false; $this->last_post = $post->ID; } }