/wp-admin/includes/template.php
PHP | 3560 lines | 2425 code | 446 blank | 689 comment | 465 complexity | 4703f69c51ef6e02df6008c60649cdc6 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /**
- * Template WordPress Administration API.
- *
- * A Big Mess. Also some neat functions that are nicely written.
- *
- * @package WordPress
- * @subpackage Administration
- */
- // Ugly recursive category stuff.
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $parent
- * @param unknown_type $level
- * @param unknown_type $categories
- * @param unknown_type $page
- * @param unknown_type $per_page
- */
- function cat_rows( $parent = 0, $level = 0, $categories = 0, $page = 1, $per_page = 20 ) {
- $count = 0;
- _cat_rows($categories, $count, $parent, $level, $page, $per_page);
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $categories
- * @param unknown_type $count
- * @param unknown_type $parent
- * @param unknown_type $level
- * @param unknown_type $page
- * @param unknown_type $per_page
- * @return unknown
- */
- function _cat_rows( $categories, &$count, $parent = 0, $level = 0, $page = 1, $per_page = 20 ) {
- if ( empty($categories) ) {
- $args = array('hide_empty' => 0);
- if ( !empty($_GET['s']) )
- $args['search'] = $_GET['s'];
- $categories = get_categories( $args );
- }
- if ( !$categories )
- return false;
- $children = _get_term_hierarchy('category');
- $start = ($page - 1) * $per_page;
- $end = $start + $per_page;
- $i = -1;
- ob_start();
- foreach ( $categories as $category ) {
- if ( $count >= $end )
- break;
- $i++;
- if ( $category->parent != $parent )
- continue;
- // If the page starts in a subtree, print the parents.
- if ( $count == $start && $category->parent > 0 ) {
- $my_parents = array();
- while ( $my_parent) {
- $my_parent = get_category($my_parent);
- $my_parents[] = $my_parent;
- if ( !$my_parent->parent )
- break;
- $my_parent = $my_parent->parent;
- }
- $num_parents = count($my_parents);
- while( $my_parent = array_pop($my_parents) ) {
- echo "\t" . _cat_row( $my_parent, $level - $num_parents );
- $num_parents--;
- }
- }
- if ( $count >= $start )
- echo "\t" . _cat_row( $category, $level );
- unset($categories[$i]); // Prune the working set
- $count++;
- if ( isset($children[$category->term_id]) )
- _cat_rows( $categories, $count, $category->term_id, $level + 1, $page, $per_page );
- }
- $output = ob_get_contents();
- ob_end_clean();
- echo $output;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $category
- * @param unknown_type $level
- * @param unknown_type $name_override
- * @return unknown
- */
- function _cat_row( $category, $level, $name_override = false ) {
- static $row_class = '';
- $category = get_category( $category, OBJECT, 'display' );
- $default_cat_id = (int) get_option( 'default_category' );
- $pad = str_repeat( '— ', $level );
- $name = ( $name_override ? $name_override : $pad . ' ' . $category->name );
- $edit_link = "categories.php?action=edit&cat_ID=$category->term_id";
- if ( current_user_can( 'manage_categories' ) ) {
- $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>" . attribute_escape( $name ) . '</a><br />';
- $actions = array();
- $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
- $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
- if ( $default_cat_id != $category->term_id )
- $actions['delete'] = "<a class='delete:the-list:cat-$category->term_id submitdelete' href='" . wp_nonce_url("categories.php?action=delete&cat_ID=$category->term_id", 'delete-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
- $actions = apply_filters('cat_row_actions', $actions, $category);
- $action_count = count($actions);
- $i = 0;
- $edit .= '<div class="row-actions">';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- $edit .= "<span class='$action'>$link$sep</span>";
- }
- $edit .= '</div>';
- } else {
- $edit = $name;
- }
- $row_class = 'alternate' == $row_class ? '' : 'alternate';
- $qe_data = get_category_to_edit($category->term_id);
- $category->count = number_format_i18n( $category->count );
- $posts_count = ( $category->count > 0 ) ? "<a href='edit.php?cat=$category->term_id'>$category->count</a>" : $category->count;
- $output = "<tr id='cat-$category->term_id' class='iedit $row_class'>";
- $columns = get_column_headers('categories');
- $hidden = get_hidden_columns('categories');
- foreach ( $columns as $column_name => $column_display_name ) {
- $class = "class=\"$column_name column-$column_name\"";
- $style = '';
- if ( in_array($column_name, $hidden) )
- $style = ' style="display:none;"';
- $attributes = "$class$style";
- switch ($column_name) {
- case 'cb':
- $output .= "<th scope='row' class='check-column'>";
- if ( $default_cat_id != $category->term_id ) {
- $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
- } else {
- $output .= " ";
- }
- $output .= '</th>';
- break;
- case 'name':
- $output .= "<td $attributes>$edit";
- $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
- $output .= '<div class="name">' . $qe_data->name . '</div>';
- $output .= '<div class="slug">' . $qe_data->slug . '</div>';
- $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
- break;
- case 'description':
- $output .= "<td $attributes>$category->description</td>";
- break;
- case 'slug':
- $output .= "<td $attributes>$category->slug</td>";
- break;
- case 'posts':
- $attributes = 'class="posts column-posts num"' . $style;
- $output .= "<td $attributes>$posts_count</td>\n";
- break;
- default:
- $output .= "<td $attributes>";
- $output .= apply_filters('manage_categories_custom_column', '', $column_name, $category->term_id);
- $output .= "</td>";
- }
- }
- $output .= '</tr>';
- return $output;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since 2.7
- *
- * Outputs the HTML for the hidden table rows used in Categories, Link Caregories and Tags quick edit.
- *
- * @param string $type "tag", "category" or "link-category"
- * @return
- */
- function inline_edit_term_row($type) {
- if ( ! current_user_can( 'manage_categories' ) )
- return;
- $is_tag = $type == 'edit-tags';
- $columns = get_column_headers($type);
- $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($type) ) );
- $col_count = count($columns) - count($hidden);
- ?>
- <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
- <tr id="inline-edit" class="inline-edit-row" style="display: none"><td colspan="<?php echo $col_count; ?>">
- <fieldset><div class="inline-edit-col">
- <h4><?php _e( 'Quick Edit' ); ?></h4>
- <label>
- <span class="title"><?php _e( 'Name' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span>
- </label>
- <label>
- <span class="title"><?php _e( 'Slug' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="slug" class="ptitle" value="" /></span>
- </label>
- <?php if ( 'category' == $type ) : ?>
- <label>
- <span class="title"><?php _e( 'Parent' ); ?></span>
- <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => 1, 'show_option_none' => __('None'))); ?>
- </label>
- <?php endif; // $type ?>
- </div></fieldset>
- <?php
- $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true );
- foreach ( $columns as $column_name => $column_display_name ) {
- if ( isset( $core_columns[$column_name] ) )
- continue;
- do_action( 'quick_edit_custom_box', $column_name, $type );
- }
- ?>
- <p class="inline-edit-save submit">
- <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="cancel button-secondary alignleft"><?php _e('Cancel'); ?></a>
- <?php $update_text = ( $is_tag ) ? __( 'Update Tag' ) : __( 'Update Category' ); ?>
- <a accesskey="s" href="#inline-edit" title="<?php echo attribute_escape( $update_text ); ?>" class="save button-primary alignright"><?php echo $update_text; ?></a>
- <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
- <span class="error" style="display:none;"></span>
- <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?>
- <br class="clear" />
- </p>
- </td></tr>
- </tbody></table></form>
- <?php
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $category
- * @param unknown_type $name_override
- * @return unknown
- */
- function link_cat_row( $category, $name_override = false ) {
- static $row_class = '';
- if ( !$category = get_term( $category, 'link_category', OBJECT, 'display' ) )
- return false;
- if ( is_wp_error( $category ) )
- return $category;
- $default_cat_id = (int) get_option( 'default_link_category' );
- $name = ( $name_override ? $name_override : $category->name );
- $edit_link = "link-category.php?action=edit&cat_ID=$category->term_id";
- if ( current_user_can( 'manage_categories' ) ) {
- $edit = "<a class='row-title' href='$edit_link' title='" . attribute_escape(sprintf(__('Edit "%s"'), $category->name)) . "'>$name</a><br />";
- $actions = array();
- $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
- $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
- if ( $default_cat_id != $category->term_id )
- $actions['delete'] = "<a class='delete:the-list:link-cat-$category->term_id submitdelete' href='" . wp_nonce_url("link-category.php?action=delete&cat_ID=$category->term_id", 'delete-link-category_' . $category->term_id) . "'>" . __('Delete') . "</a>";
- $actions = apply_filters('link_cat_row_actions', $actions, $category);
- $action_count = count($actions);
- $i = 0;
- $edit .= '<div class="row-actions">';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- $edit .= "<span class='$action'>$link$sep</span>";
- }
- $edit .= '</div>';
- } else {
- $edit = $name;
- }
- $row_class = 'alternate' == $row_class ? '' : 'alternate';
- $qe_data = get_term_to_edit($category->term_id, 'link_category');
- $category->count = number_format_i18n( $category->count );
- $count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
- $output = "<tr id='link-cat-$category->term_id' class='iedit $row_class'>";
- $columns = get_column_headers('edit-link-categories');
- $hidden = get_hidden_columns('edit-link-categories');
- foreach ( $columns as $column_name => $column_display_name ) {
- $class = "class=\"$column_name column-$column_name\"";
- $style = '';
- if ( in_array($column_name, $hidden) )
- $style = ' style="display:none;"';
- $attributes = "$class$style";
- switch ($column_name) {
- case 'cb':
- $output .= "<th scope='row' class='check-column'>";
- if ( absint( get_option( 'default_link_category' ) ) != $category->term_id ) {
- $output .= "<input type='checkbox' name='delete[]' value='$category->term_id' />";
- } else {
- $output .= " ";
- }
- $output .= "</th>";
- break;
- case 'name':
- $output .= "<td $attributes>$edit";
- $output .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
- $output .= '<div class="name">' . $qe_data->name . '</div>';
- $output .= '<div class="slug">' . $qe_data->slug . '</div>';
- $output .= '<div class="cat_parent">' . $qe_data->parent . '</div></div></td>';
- break;
- case 'description':
- $output .= "<td $attributes>$category->description</td>";
- break;
- case 'slug':
- $output .= "<td $attributes>$category->slug</td>";
- break;
- case 'links':
- $attributes = 'class="links column-links num"' . $style;
- $output .= "<td $attributes>$count</td>";
- break;
- default:
- $output .= "<td $attributes>";
- $output .= apply_filters('manage_link_categories_custom_column', '', $column_name, $category->term_id);
- $output .= "</td>";
- }
- }
- $output .= '</tr>';
- return $output;
- }
- /**
- * Outputs the html checked attribute.
- *
- * Compares the first two arguments and if identical marks as checked
- *
- * @since unknown
- *
- * @param any $checked One of the values to compare
- * @param any $current (true) The other value to compare if not just true
- * @param bool $echo Whether or not to echo or just return the string
- */
- function checked( $checked, $current = true, $echo = true) {
- return __checked_selected_helper( $checked, $current, $echo, 'checked' );
- }
- /**
- * Outputs the html selected attribute.
- *
- * Compares the first two arguments and if identical marks as selected
- *
- * @since unknown
- *
- * @param any $checked One of the values to compare
- * @param any $current (true) The other value to compare if not just true
- * @param bool $echo Whether or not to echo or just return the string
- */
- function selected( $selected, $current = true, $echo = true) {
- return __checked_selected_helper( $selected, $current, $echo, 'selected' );
- }
- /**
- * Private helper function for checked and selected.
- *
- * Compares the first two arguments and if identical marks as $type
- *
- * @since unknown
- * @access private
- *
- * @param any $checked One of the values to compare
- * @param any $current (true) The other value to compare if not just true
- * @param bool $echo Whether or not to echo or just return the string
- * @param string $type The type of checked|selected we are doing.
- */
- function __checked_selected_helper( $helper, $current, $echo, $type) {
- if ( $helper == $current)
- $result = " $type='$type'";
- else
- $result = '';
-
- if ($echo)
- echo $result;
-
- return $result;
- }
- //
- // Category Checklists
- //
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- * @deprecated Use {@link wp_link_category_checklist()}
- * @see wp_link_category_checklist()
- *
- * @param unknown_type $default
- * @param unknown_type $parent
- * @param unknown_type $popular_ids
- */
- function dropdown_categories( $default = 0, $parent = 0, $popular_ids = array() ) {
- global $post_ID;
- wp_category_checklist($post_ID);
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- */
- class Walker_Category_Checklist extends Walker {
- var $tree_type = 'category';
- var $db_fields = array ('parent' => 'parent', 'id' => 'term_id'); //TODO: decouple this
- function start_lvl(&$output, $depth, $args) {
- $indent = str_repeat("\t", $depth);
- $output .= "$indent<ul class='children'>\n";
- }
- function end_lvl(&$output, $depth, $args) {
- $indent = str_repeat("\t", $depth);
- $output .= "$indent</ul>\n";
- }
- function start_el(&$output, $category, $depth, $args) {
- extract($args);
- $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : '';
- $output .= "\n<li id='category-$category->term_id'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="post_category[]" id="in-category-' . $category->term_id . '"' . (in_array( $category->term_id, $selected_cats ) ? ' checked="checked"' : "" ) . '/> ' . wp_specialchars( apply_filters('the_category', $category->name )) . '</label>';
- }
- function end_el(&$output, $category, $depth, $args) {
- $output .= "</li>\n";
- }
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $post_id
- * @param unknown_type $descendants_and_self
- * @param unknown_type $selected_cats
- * @param unknown_type $popular_cats
- */
- function wp_category_checklist( $post_id = 0, $descendants_and_self = 0, $selected_cats = false, $popular_cats = false, $walker = null ) {
- if ( empty($walker) || !is_a($walker, 'Walker') )
- $walker = new Walker_Category_Checklist;
- $descendants_and_self = (int) $descendants_and_self;
- $args = array();
- if ( is_array( $selected_cats ) )
- $args['selected_cats'] = $selected_cats;
- elseif ( $post_id )
- $args['selected_cats'] = wp_get_post_categories($post_id);
- else
- $args['selected_cats'] = array();
- if ( is_array( $popular_cats ) )
- $args['popular_cats'] = $popular_cats;
- else
- $args['popular_cats'] = get_terms( 'category', array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
- if ( $descendants_and_self ) {
- $categories = get_categories( "child_of=$descendants_and_self&hierarchical=0&hide_empty=0" );
- $self = get_category( $descendants_and_self );
- array_unshift( $categories, $self );
- } else {
- $categories = get_categories('get=all');
- }
- // Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
- $checked_categories = array();
- for ( $i = 0; isset($categories[$i]); $i++ ) {
- if ( in_array($categories[$i]->term_id, $args['selected_cats']) ) {
- $checked_categories[] = $categories[$i];
- unset($categories[$i]);
- }
- }
- // Put checked cats on top
- echo call_user_func_array(array(&$walker, 'walk'), array($checked_categories, 0, $args));
- // Then the rest of them
- echo call_user_func_array(array(&$walker, 'walk'), array($categories, 0, $args));
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $taxonomy
- * @param unknown_type $default
- * @param unknown_type $number
- * @param unknown_type $echo
- * @return unknown
- */
- function wp_popular_terms_checklist( $taxonomy, $default = 0, $number = 10, $echo = true ) {
- global $post_ID;
- if ( $post_ID )
- $checked_categories = wp_get_post_categories($post_ID);
- else
- $checked_categories = array();
- $categories = get_terms( $taxonomy, array( 'orderby' => 'count', 'order' => 'DESC', 'number' => $number, 'hierarchical' => false ) );
- $popular_ids = array();
- foreach ( (array) $categories as $category ) {
- $popular_ids[] = $category->term_id;
- if ( !$echo ) // hack for AJAX use
- continue;
- $id = "popular-category-$category->term_id";
- ?>
- <li id="<?php echo $id; ?>" class="popular-category">
- <label class="selectit">
- <input id="in-<?php echo $id; ?>" type="checkbox" value="<?php echo (int) $category->term_id; ?>" />
- <?php echo wp_specialchars( apply_filters( 'the_category', $category->name ) ); ?>
- </label>
- </li>
- <?php
- }
- return $popular_ids;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- * @deprecated Use {@link wp_link_category_checklist()}
- * @see wp_link_category_checklist()
- *
- * @param unknown_type $default
- */
- function dropdown_link_categories( $default = 0 ) {
- global $link_id;
- wp_link_category_checklist($link_id);
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $link_id
- */
- function wp_link_category_checklist( $link_id = 0 ) {
- $default = 1;
- if ( $link_id ) {
- $checked_categories = wp_get_link_cats($link_id);
- if ( count( $checked_categories ) == 0 ) {
- // No selected categories, strange
- $checked_categories[] = $default;
- }
- } else {
- $checked_categories[] = $default;
- }
- $categories = get_terms('link_category', 'orderby=count&hide_empty=0');
- if ( empty($categories) )
- return;
- foreach ( $categories as $category ) {
- $cat_id = $category->term_id;
- $name = wp_specialchars( apply_filters('the_category', $category->name));
- $checked = in_array( $cat_id, $checked_categories );
- echo '<li id="link-category-', $cat_id, '"><label for="in-link-category-', $cat_id, '" class="selectit"><input value="', $cat_id, '" type="checkbox" name="link_category[]" id="in-link-category-', $cat_id, '"', ($checked ? ' checked="checked"' : "" ), '/> ', $name, "</label></li>";
- }
- }
- // Tag stuff
- // Returns a single tag row (see tag_rows below)
- // Note: this is also used in admin-ajax.php!
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $tag
- * @param unknown_type $class
- * @return unknown
- */
- function _tag_row( $tag, $class = '', $taxonomy = 'post_tag' ) {
- $count = number_format_i18n( $tag->count );
- $count = ( $count > 0 ) ? "<a href='edit.php?tag=$tag->slug'>$count</a>" : $count;
- $name = apply_filters( 'term_name', $tag->name );
- $qe_data = get_term($tag->term_id, $taxonomy, object, 'edit');
- $edit_link = "edit-tags.php?action=edit&taxonomy=$taxonomy&tag_ID=$tag->term_id";
- $out = '';
- $out .= '<tr id="tag-' . $tag->term_id . '"' . $class . '>';
- $columns = get_column_headers('edit-tags');
- $hidden = get_hidden_columns('edit-tags');
- foreach ( $columns as $column_name => $column_display_name ) {
- $class = "class=\"$column_name column-$column_name\"";
- $style = '';
- if ( in_array($column_name, $hidden) )
- $style = ' style="display:none;"';
- $attributes = "$class$style";
- switch ($column_name) {
- case 'cb':
- $out .= '<th scope="row" class="check-column"> <input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" /></th>';
- break;
- case 'name':
- $out .= '<td ' . $attributes . '><strong><a class="row-title" href="' . $edit_link . '" title="' . attribute_escape(sprintf(__('Edit "%s"'), $name)) . '">' . $name . '</a></strong><br />';
- $actions = array();
- $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>';
- $actions['inline hide-if-no-js'] = '<a href="#" class="editinline">' . __('Quick Edit') . '</a>';
- $actions['delete'] = "<a class='delete:the-list:tag-$tag->term_id submitdelete' href='" . wp_nonce_url("edit-tags.php?action=delete&taxonomy=$taxonomy&tag_ID=$tag->term_id", 'delete-tag_' . $tag->term_id) . "'>" . __('Delete') . "</a>";
- $actions = apply_filters('tag_row_actions', $actions, $tag);
- $action_count = count($actions);
- $i = 0;
- $out .= '<div class="row-actions">';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- $out .= "<span class='$action'>$link$sep</span>";
- }
- $out .= '</div>';
- $out .= '<div class="hidden" id="inline_' . $qe_data->term_id . '">';
- $out .= '<div class="name">' . $qe_data->name . '</div>';
- $out .= '<div class="slug">' . $qe_data->slug . '</div></div></td>';
- break;
- case 'slug':
- $out .= "<td $attributes>$tag->slug</td>";
- break;
- case 'posts':
- $attributes = 'class="posts column-posts num"' . $style;
- $out .= "<td $attributes>$count</td>";
- break;
- default:
- $out .= "<td $attributes>";
- $out .= apply_filters("manage_${taxonomy}_custom_column", '', $column_name, $tag->term_id);
- $out .= "</td>";
- }
- }
- $out .= '</tr>';
- return $out;
- }
- // Outputs appropriate rows for the Nth page of the Tag Management screen,
- // assuming M tags displayed at a time on the page
- // Returns the number of tags displayed
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $page
- * @param unknown_type $pagesize
- * @param unknown_type $searchterms
- * @return unknown
- */
- function tag_rows( $page = 1, $pagesize = 20, $searchterms = '', $taxonomy = 'post_tag' ) {
- // Get a page worth of tags
- $start = ($page - 1) * $pagesize;
- $args = array('offset' => $start, 'number' => $pagesize, 'hide_empty' => 0);
- if ( !empty( $searchterms ) ) {
- $args['search'] = $searchterms;
- }
- $tags = get_terms( $taxonomy, $args );
- // convert it to table rows
- $out = '';
- $count = 0;
- foreach( $tags as $tag )
- $out .= _tag_row( $tag, ++$count % 2 ? ' class="iedit alternate"' : ' class="iedit"', $taxonomy );
- // filter and send to screen
- echo $out;
- return $count;
- }
- // define the columns to display, the syntax is 'internal name' => 'display name'
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @return unknown
- */
- function wp_manage_posts_columns() {
- $posts_columns = array();
- $posts_columns['cb'] = '<input type="checkbox" />';
- /* translators: manage posts column name */
- $posts_columns['title'] = _x('Post', 'column name');
- $posts_columns['author'] = __('Author');
- $posts_columns['categories'] = __('Categories');
- $posts_columns['tags'] = __('Tags');
- if ( !isset($_GET['post_status']) || !in_array($_GET['post_status'], array('pending', 'draft', 'future')) )
- $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
- $posts_columns['date'] = __('Date');
- $posts_columns = apply_filters('manage_posts_columns', $posts_columns);
- return $posts_columns;
- }
- // define the columns to display, the syntax is 'internal name' => 'display name'
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @return unknown
- */
- function wp_manage_media_columns() {
- $posts_columns = array();
- $posts_columns['cb'] = '<input type="checkbox" />';
- $posts_columns['icon'] = '';
- /* translators: column name */
- $posts_columns['media'] = _x('File', 'column name');
- $posts_columns['author'] = __('Author');
- //$posts_columns['tags'] = _x('Tags', 'column name');
- /* translators: column name */
- $posts_columns['parent'] = _x('Attached to', 'column name');
- $posts_columns['comments'] = '<div class="vers"><img alt="Comments" src="images/comment-grey-bubble.png" /></div>';
- //$posts_columns['comments'] = __('Comments');
- /* translators: column name */
- $posts_columns['date'] = _x('Date', 'column name');
- $posts_columns = apply_filters('manage_media_columns', $posts_columns);
- return $posts_columns;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @return unknown
- */
- function wp_manage_pages_columns() {
- $posts_columns = array();
- $posts_columns['cb'] = '<input type="checkbox" />';
- $posts_columns['title'] = __('Title');
- $posts_columns['author'] = __('Author');
- $post_status = 'all';
- if ( !empty($_GET['post_status']) )
- $post_status = $_GET['post_status'];
- if ( !in_array($post_status, array('pending', 'draft', 'future')) )
- $posts_columns['comments'] = '<div class="vers"><img alt="" src="images/comment-grey-bubble.png" /></div>';
- $posts_columns['date'] = __('Date');
- $posts_columns = apply_filters('manage_pages_columns', $posts_columns);
- return $posts_columns;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $page
- * @return unknown
- */
- function get_column_headers($page) {
- global $_wp_column_headers;
- if ( !isset($_wp_column_headers) )
- $_wp_column_headers = array();
- // Store in static to avoid running filters on each call
- if ( isset($_wp_column_headers[$page]) )
- return $_wp_column_headers[$page];
- switch ($page) {
- case 'edit':
- $_wp_column_headers[$page] = wp_manage_posts_columns();
- break;
- case 'edit-pages':
- $_wp_column_headers[$page] = wp_manage_pages_columns();
- break;
- case 'edit-comments':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'author' => __('Author'),
- /* translators: column name */
- 'comment' => _x('Comment', 'column name'),
- //'date' => __('Submitted'),
- 'response' => __('In Response To')
- );
- break;
- case 'link-manager':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'name' => __('Name'),
- 'url' => __('URL'),
- 'categories' => __('Categories'),
- 'rel' => __('rel'),
- 'visible' => __('Visible')
- );
- break;
- case 'upload':
- $_wp_column_headers[$page] = wp_manage_media_columns();
- break;
- case 'categories':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'name' => __('Name'),
- 'description' => __('Description'),
- 'slug' => __('Slug'),
- 'posts' => __('Posts')
- );
- break;
- case 'edit-link-categories':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'name' => __('Name'),
- 'description' => __('Description'),
- 'slug' => __('Slug'),
- 'links' => __('Links')
- );
- break;
- case 'edit-tags':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'name' => __('Name'),
- 'slug' => __('Slug'),
- 'posts' => __('Posts')
- );
- break;
- case 'users':
- $_wp_column_headers[$page] = array(
- 'cb' => '<input type="checkbox" />',
- 'username' => __('Username'),
- 'name' => __('Name'),
- 'email' => __('E-mail'),
- 'role' => __('Role'),
- 'posts' => __('Posts')
- );
- break;
- default :
- $_wp_column_headers[$page] = array();
- }
- $_wp_column_headers[$page] = apply_filters('manage_' . $page . '_columns', $_wp_column_headers[$page]);
- return $_wp_column_headers[$page];
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $type
- * @param unknown_type $id
- */
- function print_column_headers( $type, $id = true ) {
- $type = str_replace('.php', '', $type);
- $columns = get_column_headers( $type );
- $hidden = get_hidden_columns($type);
- $styles = array();
- // $styles['tag']['posts'] = 'width: 90px;';
- // $styles['link-category']['links'] = 'width: 90px;';
- // $styles['category']['posts'] = 'width: 90px;';
- // $styles['link']['visible'] = 'text-align: center;';
- foreach ( $columns as $column_key => $column_display_name ) {
- $class = ' class="manage-column';
- $class .= " column-$column_key";
- if ( 'cb' == $column_key )
- $class .= ' check-column';
- elseif ( in_array($column_key, array('posts', 'comments', 'links')) )
- $class .= ' num';
- $class .= '"';
- $style = '';
- if ( in_array($column_key, $hidden) )
- $style = 'display:none;';
- if ( isset($styles[$type]) && isset($styles[$type][$column_key]) )
- $style .= ' ' . $styles[$type][$column_key];
- $style = ' style="' . $style . '"';
- ?>
- <th scope="col" <?php echo $id ? "id=\"$column_key\"" : ""; echo $class; echo $style; ?>><?php echo $column_display_name; ?></th>
- <?php }
- }
- /**
- * Register column headers for a particular screen. The header names will be listed in the Screen Options.
- *
- * @since 2.7.0
- *
- * @param string $screen The handle for the screen to add help to. This is usually the hook name returned by the add_*_page() functions.
- * @param array $columns An array of columns with column IDs as the keys and translated column names as the values
- * @see get_column_headers(), print_column_headers(), get_hidden_columns()
- */
- function register_column_headers($screen, $columns) {
- global $_wp_column_headers;
- if ( !isset($_wp_column_headers) )
- $_wp_column_headers = array();
- $_wp_column_headers[$screen] = $columns;
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $page
- */
- function get_hidden_columns($page) {
- $page = str_replace('.php', '', $page);
- return (array) get_user_option( 'manage-' . $page . '-columns-hidden', 0, false );
- }
- /**
- * {@internal Missing Short Description}}
- *
- * Outputs the quick edit and bulk edit table rows for posts and pages
- *
- * @since 2.7
- *
- * @param string $type 'post' or 'page'
- */
- function inline_edit_row( $type ) {
- global $current_user, $mode;
- $is_page = 'page' == $type;
- if ( $is_page ) {
- $screen = 'edit-pages';
- $post = get_default_page_to_edit();
- } else {
- $screen = 'edit';
- $post = get_default_post_to_edit();
- }
- $columns = $is_page ? wp_manage_pages_columns() : wp_manage_posts_columns();
- $hidden = array_intersect( array_keys( $columns ), array_filter( get_hidden_columns($screen) ) );
- $col_count = count($columns) - count($hidden);
- $m = ( isset($mode) && 'excerpt' == $mode ) ? 'excerpt' : 'list';
- $can_publish = current_user_can("publish_{$type}s");
- $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true );
- ?>
- <form method="get" action=""><table style="display: none"><tbody id="inlineedit">
- <?php
- $bulk = 0;
- while ( $bulk < 2 ) { ?>
- <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$type ";
- echo $bulk ? "bulk-edit-row bulk-edit-row-$type" : "quick-edit-row quick-edit-row-$type";
- ?>" style="display: none"><td colspan="<?php echo $col_count; ?>">
- <fieldset class="inline-edit-col-left"><div class="inline-edit-col">
- <h4><?php echo $bulk ? ( $is_page ? __( 'Bulk Edit Pages' ) : __( 'Bulk Edit Posts' ) ) : __( 'Quick Edit' ); ?></h4>
- <?php if ( $bulk ) : ?>
- <div id="bulk-title-div">
- <div id="bulk-titles"></div>
- </div>
- <?php else : // $bulk ?>
- <label>
- <span class="title"><?php _e( 'Title' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span>
- </label>
- <?php endif; // $bulk ?>
- <?php if ( !$bulk ) : ?>
- <label>
- <span class="title"><?php _e( 'Slug' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="post_name" value="" /></span>
- </label>
- <label><span class="title"><?php _e( 'Date' ); ?></span></label>
- <div class="inline-edit-date">
- <?php touch_time(1, 1, 4, 1); ?>
- </div>
- <br class="clear" />
- <?php endif; // $bulk
- ob_start();
- $authors = get_editable_user_ids( $current_user->id, true, $type ); // TODO: ROLE SYSTEM
- if ( $authors && count( $authors ) > 1 ) :
- $users_opt = array('include' => $authors, 'name' => 'post_author', 'class'=> 'authors', 'multi' => 1);
- if ( $bulk )
- $users_opt['show_option_none'] = __('- No Change -');
- ?>
- <label>
- <span class="title"><?php _e( 'Author' ); ?></span>
- <?php wp_dropdown_users( $users_opt ); ?>
- </label>
- <?php
- endif; // authors
- $authors_dropdown = ob_get_clean();
- ?>
- <?php if ( !$bulk ) : echo $authors_dropdown; ?>
- <div class="inline-edit-group">
- <label class="alignleft">
- <span class="title"><?php _e( 'Password' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span>
- </label>
- <em style="margin:5px 10px 0 0" class="alignleft">
- <?php
- /* translators: Between password field and private checkbox on post quick edit interface */
- echo __( '–OR–' );
- ?>
- </em>
- <label class="alignleft inline-edit-private">
- <input type="checkbox" name="keep_private" value="private" />
- <span class="checkbox-title"><?php echo $is_page ? __('Private page') : __('Private post'); ?></span>
- </label>
- </div>
- <?php endif; ?>
- </div></fieldset>
- <?php if ( !$is_page && !$bulk ) : ?>
- <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col">
- <span class="title inline-edit-categories-label"><?php _e( 'Categories' ); ?>
- <span class="catshow"><?php _e('[more]'); ?></span>
- <span class="cathide" style="display:none;"><?php _e('[less]'); ?></span>
- </span>
- <ul class="cat-checklist">
- <?php wp_category_checklist(); ?>
- </ul>
- </div></fieldset>
- <?php endif; // !$is_page && !$bulk ?>
- <fieldset class="inline-edit-col-right"><div class="inline-edit-col">
- <?php
- if ( $bulk )
- echo $authors_dropdown;
- ?>
- <?php if ( $is_page ) : ?>
- <label>
- <span class="title"><?php _e( 'Parent' ); ?></span>
- <?php
- $dropdown_args = array('selected' => $post->post_parent, 'name' => 'post_parent', 'show_option_none' => __('Main Page (no parent)'), 'option_none_value' => 0, 'sort_column'=> 'menu_order, post_title');
- if ( $bulk )
- $dropdown_args['show_option_no_change'] = __('- No Change -');
- $dropdown_args = apply_filters('quick_edit_dropdown_pages_args', $dropdown_args);
- wp_dropdown_pages($dropdown_args);
- ?>
- </label>
- <?php if ( !$bulk ) : ?>
- <label>
- <span class="title"><?php _e( 'Order' ); ?></span>
- <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span>
- </label>
- <?php endif; // !$bulk ?>
- <label>
- <span class="title"><?php _e( 'Template' ); ?></span>
- <select name="page_template">
- <?php if ( $bulk ) : ?>
- <option value="-1"><?php _e('- No Change -'); ?></option>
- <?php endif; // $bulk ?>
- <option value="default"><?php _e( 'Default Template' ); ?></option>
- <?php page_template_dropdown() ?>
- </select>
- </label>
- <?php elseif ( !$bulk ) : // $is_page ?>
- <label class="inline-edit-tags">
- <span class="title"><?php _e( 'Tags' ); ?></span>
- <textarea cols="22" rows="1" name="tags_input" class="tags_input"></textarea>
- </label>
- <?php endif; // $is_page ?>
- <?php if ( $bulk ) : ?>
- <div class="inline-edit-group">
- <label class="alignleft">
- <span class="title"><?php _e( 'Comments' ); ?></span>
- <select name="comment_status">
- <option value=""><?php _e('- No Change -'); ?></option>
- <option value="open"><?php _e('Allow'); ?></option>
- <option value="closed"><?php _e('Do not allow'); ?></option>
- </select>
- </label>
- <label class="alignright">
- <span class="title"><?php _e( 'Pings' ); ?></span>
- <select name="ping_status">
- <option value=""><?php _e('- No Change -'); ?></option>
- <option value="open"><?php _e('Allow'); ?></option>
- <option value="closed"><?php _e('Do not allow'); ?></option>
- </select>
- </label>
- </div>
- <?php else : // $bulk ?>
- <div class="inline-edit-group">
- <label class="alignleft">
- <input type="checkbox" name="comment_status" value="open" />
- <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span>
- </label>
- <label class="alignleft">
- <input type="checkbox" name="ping_status" value="open" />
- <span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span>
- </label>
- </div>
- <?php endif; // $bulk ?>
- <div class="inline-edit-group">
- <label class="inline-edit-status alignleft">
- <span class="title"><?php _e( 'Status' ); ?></span>
- <select name="_status">
- <?php if ( $bulk ) : ?>
- <option value="-1"><?php _e('- No Change -'); ?></option>
- <?php endif; // $bulk ?>
- <?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review" ?>
- <option value="publish"><?php _e( 'Published' ); ?></option>
- <option value="future"><?php _e( 'Scheduled' ); ?></option>
- <?php if ( $bulk ) : ?>
- <option value="private"><?php _e('Private') ?></option>
- <?php endif; // $bulk ?>
- <?php endif; ?>
- <option value="pending"><?php _e( 'Pending Review' ); ?></option>
- <option value="draft"><?php _e( 'Draft' ); ?></option>
- </select>
- </label>
- <?php if ( !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ) : ?>
- <?php if ( $bulk ) : ?>
- <label class="alignright">
- <span class="title"><?php _e( 'Sticky' ); ?></span>
- <select name="sticky">
- <option value="-1"><?php _e( '- No Change -' ); ?></option>
- <option value="sticky"><?php _e( 'Sticky' ); ?></option>
- <option value="unsticky"><?php _e( 'Not Sticky' ); ?></option>
- </select>
- </label>
- <?php else : // $bulk ?>
- <label class="alignleft">
- <input type="checkbox" name="sticky" value="sticky" />
- <span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span>
- </label>
- <?php endif; // $bulk ?>
- <?php endif; // !$is_page && $can_publish && current_user_can( 'edit_others_posts' ) ?>
- </div>
- </div></fieldset>
- <?php
- foreach ( $columns as $column_name => $column_display_name ) {
- if ( isset( $core_columns[$column_name] ) )
- continue;
- do_action( $bulk ? 'bulk_edit_custom_box' : 'quick_edit_custom_box', $column_name, $type);
- }
- ?>
- <p class="submit inline-edit-save">
- <a accesskey="c" href="#inline-edit" title="<?php _e('Cancel'); ?>" class="button-secondary cancel alignleft"><?php _e('Cancel'); ?></a>
- <?php if ( ! $bulk ) {
- wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
- $update_text = ( $is_page ) ? __( 'Update Page' ) : __( 'Update Post' );
- ?>
- <a accesskey="s" href="#inline-edit" title="<?php _e('Update'); ?>" class="button-primary save alignright"><?php echo attribute_escape( $update_text ); ?></a>
- <img class="waiting" style="display:none;" src="images/loading.gif" alt="" />
- <?php } else {
- $update_text = ( $is_page ) ? __( 'Update Pages' ) : __( 'Update Posts' );
- ?>
- <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo attribute_escape( $update_text ); ?>" />
- <?php } ?>
- <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
- <br class="clear" />
- </p>
- </td></tr>
- <?php
- $bulk++;
- } ?>
- </tbody></table></form>
- <?php
- }
- // adds hidden fields with the data for use in the inline editor for posts and pages
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $post
- */
- function get_inline_data($post) {
- if ( ! current_user_can('edit_' . $post->post_type, $post->ID) )
- return;
- $title = attribute_escape($post->post_title);
- echo '
- <div class="hidden" id="inline_' . $post->ID . '">
- <div class="post_title">' . $title . '</div>
- <div class="post_name">' . $post->post_name . '</div>
- <div class="post_author">' . $post->post_author . '</div>
- <div class="comment_status">' . $post->comment_status . '</div>
- <div class="ping_status">' . $post->ping_status . '</div>
- <div class="_status">' . $post->post_status . '</div>
- <div class="jj">' . mysql2date( 'd', $post->post_date ) . '</div>
- <div class="mm">' . mysql2date( 'm', $post->post_date ) . '</div>
- <div class="aa">' . mysql2date( 'Y', $post->post_date ) . '</div>
- <div class="hh">' . mysql2date( 'H', $post->post_date ) . '</div>
- <div class="mn">' . mysql2date( 'i', $post->post_date ) . '</div>
- <div class="ss">' . mysql2date( 's', $post->post_date ) . '</div>
- <div class="post_password">' . wp_specialchars($post->post_password, 1) . '</div>';
- if( $post->post_type == 'page' )
- echo '
- <div class="post_parent">' . $post->post_parent . '</div>
- <div class="page_template">' . wp_specialchars(get_post_meta( $post->ID, '_wp_page_template', true ), 1) . '</div>
- <div class="menu_order">' . $post->menu_order . '</div>';
- if( $post->post_type == 'post' )
- echo '
- <div class="tags_input">' . wp_specialchars( str_replace( ',', ', ', get_tags_to_edit($post->ID) ), 1) . '</div>
- <div class="post_category">' . implode( ',', wp_get_post_categories( $post->ID ) ) . '</div>
- <div class="sticky">' . (is_sticky($post->ID) ? 'sticky' : '') . '</div>';
- echo '</div>';
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $posts
- */
- function post_rows( $posts = array() ) {
- global $wp_query, $post, $mode;
- add_filter('the_title','wp_specialchars');
- // Create array of post IDs.
- $post_ids = array();
- if ( empty($posts) )
- $posts = &$wp_query->posts;
- foreach ( $posts as $a_post )
- $post_ids[] = $a_post->ID;
- $comment_pending_count = get_pending_comments_num($post_ids);
- if ( empty($comment_pending_count) )
- $comment_pending_count = array();
- foreach ( $posts as $post ) {
- if ( empty($comment_pending_count[$post->ID]) )
- $comment_pending_count[$post->ID] = 0;
- _post_row($post, $comment_pending_count[$post->ID], $mode);
- }
- }
- /**
- * {@internal Missing Short Description}}
- *
- * @since unknown
- *
- * @param unknown_type $a_post
- * @param unknown_type $pending_comments
- * @param unknown_type $mode
- */
- function _post_row($a_post, $pending_comments, $mode) {
- global $post;
- static $rowclass;
- $global_post = $post;
- $post = $a_post;
- setup_postdata($post);
- $rowclass = 'alternate' == $rowclass ? '' : 'alternate';
- global $current_user;
- $post_owner = ( $current_user->ID == $post->post_author ? 'self' : 'other' );
- $edit_link = get_edit_post_link( $post->ID );
- $title = _draft_or_post_title();
- ?>
- <tr id='post-<?php echo $post->ID; ?>' class='<?php echo trim( $rowclass . ' author-' . $post_owner . ' status-' . $post->post_status ); ?> iedit' valign="top">
- <?php
- $posts_columns = get_column_headers('edit');
- $hidden = get_hidden_columns('edit');
- foreach ( $posts_columns as $column_name=>$column_display_name ) {
- $class = "class=\"$column_name column-$column_name\"";
- $style = '';
- if ( in_array($column_name, $hidden) )
- $style = ' style="display:none;"';
- $attributes = "$class$style";
- switch ($column_name) {
- case 'cb':
- ?>
- <th scope="row" class="check-column"><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><input type="checkbox" name="post[]" value="<?php the_ID(); ?>" /><?php } ?></th>
- <?php
- break;
- case 'date':
- if ( '0000-00-00 00:00:00' == $post->post_date && 'date' == $column_name ) {
- $t_time = $h_time = __('Unpublished');
- $time_diff = 0;
- } else {
- $t_time = get_the_time(__('Y/m/d g:i:s A'));
- $m_time = $post->post_date;
- $time = get_post_time('G', true, $post);
- $time_diff = time() - $time;
- if ( $time_diff > 0 && $time_diff < 24*60*60 )
- $h_time = sprintf( __('%s ago'), human_time_diff( $time ) );
- else
- $h_time = mysql2date(__('Y/m/d'), $m_time);
- }
- echo '<td ' . $attributes . '>';
- if ( 'excerpt' == $mode )
- echo apply_filters('post_date_column_time', $t_time, $post, $column_name, $mode);
- else
- echo '<abbr title="' . $t_time . '">' . apply_filters('post_date_column_time', $h_time, $post, $column_name, $mode) . '</abbr>';
- echo '<br />';
- if ( 'publish' == $post->post_status ) {
- _e('Published');
- } elseif ( 'future' == $post->post_status ) {
- if ( $time_diff > 0 )
- echo '<strong class="attention">' . __('Missed schedule') . '</strong>';
- else
- _e('Scheduled');
- } else {
- _e('Last Modified');
- }
- echo '</td>';
- break;
- case 'title':
- $attributes = 'class="post-title column-title"' . $style;
- ?>
- <td <?php echo $attributes ?>><strong><?php if ( current_user_can( 'edit_post', $post->ID ) ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo attribute_escape(sprintf(__('Edit "%s"'), $title)); ?>"><?php echo $title ?></a><?php } else { echo $title; }; _post_states($post); ?></strong>
- <?php
- if ( 'excerpt' == $mode )
- the_excerpt();
- $actions = array();
- if ( current_user_can('edit_post', $post->ID) ) {
- $actions['edit'] = '<a href="' . get_edit_post_link($post->ID, true) . '" title="' . attribute_escape(__('Edit this post')) . '">' . __('Edit') . '</a>';
- $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . attribute_escape(__('Edit this post inline')) . '">' . __('Quick Edit') . '</a>';
- $actions['delete'] = "<a class='submitdelete' title='" . attribute_escape(__('Delete this post')) . "' href='" . wp_nonce_url("post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID) . "' onclick=\"if ( confirm('" . js_escape(sprintf( ('draft' == $post->post_status) ? __("You are about to delete this draft '%s'\n 'Cancel' to stop, 'OK' to delete.") : __("You are about to delete this post '%s'\n 'Cancel' to stop, 'OK' to delete."), $post->post_title )) . "') ) { return true;}return false;\">" . __('Delete') . "</a>";
- }
- if ( in_array($post->post_status, array('pending', 'draft')) ) {
- if ( current_user_can('edit_post', $post->ID) )
- $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('Preview "%s"'), $title)) . '" rel="permalink">' . __('Preview') . '</a>';
- } else {
- $actions['view'] = '<a href="' . get_permalink($post->ID) . '" title="' . attribute_escape(sprintf(__('View "%s"'), $title)) . '" rel="permalink">' . __('View') . '</a>';
- }
- $actions = apply_filters('post_row_actions', $actions, $post);
- $action_count = count($actions);
- $i = 0;
- echo '<div class="row-actions">';
- foreach ( $actions as $action => $link ) {
- ++$i;
- ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
- echo "<span class='$action'>$link$sep</span>";
- }
- echo '</div>';
- get_inline_data($post);
- ?>
- </td>
- <?php
- break;
- case 'categories':
- ?>
- <td <?php echo $attributes ?>><?php
- $categories = get_the_category();
- if ( !empty( $categories ) ) {
- $out = array();
- foreach ( $categories as $c )
- $out[] = "<a href='edit.php?category_name=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'category', 'display')) . "</a>";
- echo join( ', ', $out );
- } else {
- _e('Uncategorized');
- }
- ?></td>
- <?php
- break;
- case 'tags':
- ?>
- <td <?php echo $attributes ?>><?php
- $tags = get_the_tags($post->ID);
- if ( !empty( $tags ) ) {
- $out = array();
- foreach ( $tags as $c )
- $out[] = "<a href='edit.php?tag=$c->slug'> " . wp_specialchars(sanitize_term_field('name', $c->name, $c->term_id, 'post_tag', 'display')) . "</a>";
- echo join( ', ', $out );
- } else {
- _e('No Tags');
- }
- ?></td>
- <?php
- break;
- case 'comments':
- ?>
- <td <?php echo $attributes ?>><div class="post-com-count-wrapper">
- <?php
- $pending_phrase = sprintf( __('%s pending'), number_format( $pending_comments ) );
- if ( $pending_comments )
- echo '<strong>';
- comments_number("<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-comments.php?p=$post->ID' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
- if ( $pending_comments )
- echo '</strong>';
- ?>
- </div></td>
- <?php
- break;
- case 'author':
- ?>
- <td <?php echo $attributes ?>><a href="edit.php?author=<?php the_author_ID(); ?>"><?php the_author() ?></a></td>
- <?php
- break;
- case 'control_view':
- ?>
- <td><a href="<?php the_permalink(); ?>" rel="permalink" class="view"><?php _e('View'); ?></a></td>
- <?php
- break;
- case 'control_edit':
- ?>
- <td><?php if ( current_user_can('edit_post', $post->ID) ) { echo "<a href='$edit_link' class='edit'>" . __('Edit') . "</a>"; } ?></td>
- <?php
- break;
- case 'control_delete':
- ?>
- <td><?php if ( current_user_can('delete_post', $post->ID) ) { echo "<a href='" . wp_nonce_url("post.php?action=delete&post=$id", 'delete-post_' . $post->ID) . "' class='delete'>" . __('Delete') . "</a>"; } ?></td>
- <?php
- break;
- …
Large files files are truncated, but you can click here to view the full file