wp/wp-admin/includes/class-wp-media-list-table.php
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 11:14:17 +0000
changeset 6 490d5cc509ed
parent 5 5e2f62d02dcd
child 7 cf61fcea0001
permissions -rw-r--r--
update portfolio
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * Media Library List Table class.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage List_Table
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 * @access private
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
class WP_Media_List_Table extends WP_List_Table {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    12
	private $detached;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    13
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    14
	private $is_trash;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    15
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    16
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
	 * Constructor.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    18
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    19
	 * @since 3.1.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
	 * @access public
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    21
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    22
	 * @see WP_List_Table::__construct() for more information on default arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    23
	 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    24
	 * @param array $args An associative array of arguments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    25
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    26
	public function __construct( $args = array() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
		$this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    29
		$this->modes = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    30
			'list' => __( 'List View' ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
			'grid' => __( 'Grid View' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    32
		);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
		parent::__construct( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
			'plural' => 'media',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
	public function ajax_user_can() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
		return current_user_can('upload_files');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    44
	public function prepare_items() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
		global $wp_query, $post_mime_types, $avail_post_mime_types, $mode;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    47
		list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    49
 		$this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' == $_REQUEST['attachment-filter'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
 		$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
		$this->set_pagination_args( array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
			'total_items' => $wp_query->found_posts,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
			'total_pages' => $wp_query->max_num_pages,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
			'per_page' => $wp_query->query_vars['posts_per_page'],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
		) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    60
	protected function get_views() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
		global $wpdb, $post_mime_types, $avail_post_mime_types;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    62
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    63
		$type_links = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    64
		$_num_posts = (array) wp_count_attachments();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
		$_total_posts = array_sum($_num_posts) - $_num_posts['trash'];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
		$total_orphans = $wpdb->get_var( "SELECT COUNT( * ) FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
		$matches = wp_match_mime_types(array_keys($post_mime_types), array_keys($_num_posts));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
		foreach ( $matches as $type => $reals )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
			foreach ( $reals as $real )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
				$num_posts[$type] = ( isset( $num_posts[$type] ) ) ? $num_posts[$type] + $_num_posts[$real] : $_num_posts[$real];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    72
		$selected = empty( $_GET['attachment-filter'] ) ? ' selected="selected"' : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    73
		$type_links['all'] = "<option value=''$selected>" . sprintf( _nx( 'All (%s)', 'All (%s)', $_total_posts, 'uploaded files' ), number_format_i18n( $_total_posts ) ) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
		foreach ( $post_mime_types as $mime_type => $label ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
			if ( !wp_match_mime_types($mime_type, $avail_post_mime_types) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    78
			$selected = '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    79
			if ( !empty( $_GET['attachment-filter'] ) && strpos( $_GET['attachment-filter'], 'post_mime_type:' ) === 0 && wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $_GET['attachment-filter'] ) ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    80
				$selected = ' selected="selected"';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
			if ( !empty( $num_posts[$mime_type] ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    82
				$type_links[$mime_type] = '<option value="post_mime_type:' . esc_attr( $mime_type ) . '"' . $selected . '>' . sprintf( translate_nooped_plural( $label[2], $num_posts[$mime_type] ), number_format_i18n( $num_posts[$mime_type] )) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
		}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    84
		$type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . sprintf( _nx( 'Unattached (%s)', 'Unattached (%s)', $total_orphans, 'detached files' ), number_format_i18n( $total_orphans ) ) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
		if ( !empty($_num_posts['trash']) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    87
			$type_links['trash'] = '<option value="trash"' . ( (isset($_GET['attachment-filter']) && $_GET['attachment-filter'] == 'trash' ) ? ' selected="selected"' : '') . '>' . sprintf( _nx( 'Trash (%s)', 'Trash (%s)', $_num_posts['trash'], 'uploaded files' ), number_format_i18n( $_num_posts['trash'] ) ) . '</option>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    88
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
		return $type_links;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
	protected function get_bulk_actions() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
		$actions = array();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    94
		if ( MEDIA_TRASH ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    95
			if ( $this->is_trash ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
				$actions['untrash'] = __( 'Restore' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    97
				$actions['delete'] = __( 'Delete Permanently' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    98
			} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    99
				$actions['trash'] = __( 'Trash' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   101
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   102
			$actions['delete'] = __( 'Delete Permanently' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   103
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
		if ( $this->detached )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
			$actions['attach'] = __( 'Attach to a post' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   108
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   109
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   110
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
	 * @param string $which
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   113
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   114
	protected function extra_tablenav( $which ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   115
		if ( 'bar' !== $which ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   116
			return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   117
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   119
		<div class="actions">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
<?php
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   121
		if ( ! is_singular() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
			if ( ! $this->is_trash ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   123
				$this->months_dropdown( 'attachment' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   124
			}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   126
			/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
			do_action( 'restrict_manage_posts' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   128
			submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   131
		if ( $this->is_trash && current_user_can( 'edit_others_posts' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
			submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
		} ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
		</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   136
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   138
	public function current_action() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
		if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
			return 'attach';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   142
		if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   143
			return 'detach';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   144
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
		if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
			return 'delete_all';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
		return parent::current_action();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   151
	public function has_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
		return have_posts();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   154
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   155
	public function no_items() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
		_e( 'No media attachments found.' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   157
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   158
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
	 * Override parent views so we can use the filter bar display.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   162
	public function views() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   163
		global $mode;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   164
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   165
		$views = $this->get_views();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   167
<div class="wp-filter">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   168
	<div class="filter-items">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   169
		<?php $this->view_switcher( $mode ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   170
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   171
		<label for="attachment-filter" class="screen-reader-text"><?php _e( 'Filter by type' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   172
		<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   173
			<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   174
			if ( ! empty( $views ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   175
				foreach ( $views as $class => $view ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   176
					echo "\t$view\n";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
				}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   178
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   179
			?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   180
		</select>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   181
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   182
<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   183
		$this->extra_tablenav( 'bar' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   184
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   185
		/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   186
		$views = apply_filters( "views_{$this->screen->id}", array() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   188
		// Back compat for pre-4.0 view links.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   189
		if ( ! empty( $views ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   190
			echo '<ul class="filter-links">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   191
			foreach ( $views as $class => $view ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   192
				echo "<li class='$class'>$view</li>";
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   193
			}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   194
			echo '</ul>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   195
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   196
?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   197
	</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   198
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   199
	<div class="search-form">
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   200
		<label for="media-search-input" class="screen-reader-text"><?php esc_html_e( 'Search Media' ); ?></label>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   201
		<input type="search" placeholder="<?php esc_attr_e( 'Search' ) ?>" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>"></div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   202
	</div>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   203
	<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   204
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   205
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   206
	public function get_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
		$posts_columns = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   208
		$posts_columns['cb'] = '<input type="checkbox" />';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   209
		$posts_columns['icon'] = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   210
		/* translators: column name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
		$posts_columns['title'] = _x( 'File', 'column name' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
		$posts_columns['author'] = __( 'Author' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
		$taxonomies = get_taxonomies_for_attachments( 'objects' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
		$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   217
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   218
		 * Filter the taxonomy columns for attachments in the Media list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   219
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   220
		 * @since 3.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   221
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
		 * @param array  $taxonomies An array of registered taxonomies to show for attachments.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   223
		 * @param string $post_type  The post type. Default 'attachment'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   224
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
		$taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
		$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
		foreach ( $taxonomies as $taxonomy ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
			if ( 'category' == $taxonomy )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
				$column_key = 'categories';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
			elseif ( 'post_tag' == $taxonomy )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
				$column_key = 'tags';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
			else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
				$column_key = 'taxonomy-' . $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
		/* translators: column name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
		if ( !$this->detached ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
			$posts_columns['parent'] = _x( 'Uploaded to', 'column name' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
			if ( post_type_supports( 'attachment', 'comments' ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   243
				$posts_columns['comments'] = '<span class="vers"><span title="' . esc_attr__( 'Comments' ) . '" class="comment-grey-bubble"></span></span>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
		/* translators: column name */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
		$posts_columns['date'] = _x( 'Date', 'column name' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   247
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   248
		 * Filter the Media list table columns.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   249
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   250
		 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   251
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   252
		 * @param array $posts_columns An array of columns displayed in the Media list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   253
		 * @param bool  $detached      Whether the list table contains media not attached
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
		 *                             to any posts. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
		$posts_columns = apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
		return $posts_columns;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   261
	protected function get_sortable_columns() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
		return array(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   263
			'title'    => 'title',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
			'author'   => 'author',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   265
			'parent'   => 'parent',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
			'comments' => 'comment_count',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
			'date'     => array( 'date', true ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
		);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   271
	public function display_rows() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
		global $post;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
		add_filter( 'the_title','esc_html' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
		while ( have_posts() ) : the_post();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
			$user_can_edit = current_user_can( 'edit_post', $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
			if ( $this->is_trash && $post->post_status != 'trash'
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
			||  !$this->is_trash && $post->post_status == 'trash' )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
				continue;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
			$post_owner = ( get_current_user_id() == $post->post_author ) ? 'self' : 'other';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
			$att_title = _draft_or_post_title();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   286
	<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
list( $columns, $hidden ) = $this->get_column_info();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
foreach ( $columns as $column_name => $column_display_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
	$class = "class='$column_name column-$column_name'";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
	$style = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
	if ( in_array( $column_name, $hidden ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
		$style = ' style="display:none;"';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
	$attributes = $class . $style;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
	switch ( $column_name ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
	case 'cb':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
		<th scope="row" class="check-column">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
			<?php if ( $user_can_edit ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
				<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php echo sprintf( __( 'Select %s' ), $att_title );?></label>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
				<input type="checkbox" name="media[]" id="cb-select-<?php the_ID(); ?>" value="<?php the_ID(); ?>" />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
			<?php } ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
		</th>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
	case 'icon':
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
		list( $mime ) = explode( '/', $post->post_mime_type );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
		$attributes = 'class="column-icon media-icon ' . $mime . '-icon"' . $style;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
		<td <?php echo $attributes ?>><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
			if ( $thumb = wp_get_attachment_image( $post->ID, array( 80, 60 ), true ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
				if ( $this->is_trash || ! $user_can_edit ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   319
					echo $thumb;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   320
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
				<a href="<?php echo get_edit_post_link( $post->ID ); ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
					<?php echo $thumb; ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
				</a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   326
<?php			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   327
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
		</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
	case 'title':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
		<td <?php echo $attributes ?>><strong>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
			<?php if ( $this->is_trash || ! $user_can_edit ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
				echo $att_title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
			} else { ?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
			<a href="<?php echo get_edit_post_link( $post->ID ); ?>"
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   340
				title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $att_title ) ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
				<?php echo $att_title; ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
			<?php };
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
			_media_states( $post ); ?></strong>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
			<p class="filename"><?php echo wp_basename( $post->guid ); ?></p>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
		echo $this->row_actions( $this->_get_row_actions( $post, $att_title ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
		</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   349
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   350
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   351
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   352
	case 'author':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   353
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
		<td <?php echo $attributes ?>><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
			printf( '<a href="%s">%s</a>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
				esc_url( add_query_arg( array( 'author' => get_the_author_meta('ID') ), 'upload.php' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
				get_the_author()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   358
			);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
		?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
	case 'desc':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
		<td <?php echo $attributes ?>><?php echo has_excerpt() ? $post->post_excerpt : ''; ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   367
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   368
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   369
	case 'date':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   370
		if ( '0000-00-00 00:00:00' == $post->post_date ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   371
			$h_time = __( 'Unpublished' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
			$m_time = $post->post_date;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
			$time = get_post_time( 'G', true, $post, false );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
			if ( ( abs( $t_diff = time() - $time ) ) < DAY_IN_SECONDS ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   376
				if ( $t_diff < 0 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
					$h_time = sprintf( __( '%s from now' ), human_time_diff( $time ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
				else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
					$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
				$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
		<td <?php echo $attributes ?>><?php echo $h_time ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
	case 'parent':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
		if ( $post->post_parent > 0 )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
			$parent = get_post( $post->post_parent );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
			$parent = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
		if ( $parent ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   396
			$title = _draft_or_post_title( $post->post_parent );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
			$parent_type = get_post_type_object( $parent->post_type );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
			<td <?php echo $attributes ?>><strong>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
				<?php if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) { ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
					<a href="<?php echo get_edit_post_link( $post->post_parent ); ?>">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
						<?php echo $title ?></a><?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
					echo $title;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
				} ?></strong>,
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   406
				<?php echo get_the_time( __( 'Y/m/d' ) ); ?><br />
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   407
				<?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
				if ( $user_can_edit ):
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
					$detach_url = add_query_arg( array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
						'parent_post_id' => $post->post_parent,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
						'media[]' => $post->ID,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
						'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
					), 'upload.php' ); ?>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
				<a class="hide-if-no-js detach-from-parent" href="<?php echo $detach_url ?>"><?php _e( 'Detach' ); ?></a>
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
				<?php endif; ?>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
			</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
		} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
			<td <?php echo $attributes ?>><?php _e( '(Unattached)' ); ?><br />
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
			<?php if ( $user_can_edit ) { ?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
				<a class="hide-if-no-js"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
					onclick="findPosts.open( 'media[]','<?php echo $post->ID ?>' ); return false;"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
					href="#the-list">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
					<?php _e( 'Attach' ); ?></a>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
			<?php } ?></td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
	case 'comments':
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
		$attributes = 'class="comments column-comments num"' . $style;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
		<td <?php echo $attributes ?>>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
			<div class="post-com-count-wrapper">
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
		$pending_comments = get_pending_comments_num( $post->ID );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
		$this->comments_bubble( $post->ID, $pending_comments );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
			</div>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
		</td>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
	default:
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
		if ( 'categories' == $column_name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
			$taxonomy = 'category';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
		elseif ( 'tags' == $column_name )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
			$taxonomy = 'post_tag';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
		elseif ( 0 === strpos( $column_name, 'taxonomy-' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
			$taxonomy = substr( $column_name, 9 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
		else
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
			$taxonomy = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
		if ( $taxonomy ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
			echo '<td ' . $attributes . '>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
			if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
				$out = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
				foreach ( $terms as $t ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
					$posts_in_term_qv = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
					$posts_in_term_qv['taxonomy'] = $taxonomy;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
					$posts_in_term_qv['term'] = $t->slug;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
					$out[] = sprintf( '<a href="%s">%s</a>',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
						esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
						esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
					);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
				/* translators: used between list items, there is a space after the comma */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
				echo join( __( ', ' ), $out );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
			} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
				echo '&#8212;';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
			echo '</td>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
			break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
?>
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   479
		<td <?php echo $attributes ?>><?php
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   480
			/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   481
			 * Fires for each custom column in the Media list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   482
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   483
			 * Custom columns are registered using the 'manage_media_columns' filter.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   484
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   485
			 * @since 2.5.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   486
			 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   487
			 * @param string $column_name Name of the custom column.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   488
			 * @param int    $post_id     Attachment ID.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   489
			 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   490
			do_action( 'manage_media_custom_column', $column_name, $post->ID );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   491
		?></td>
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
		break;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
?>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
	</tr>
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
<?php endwhile;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
	/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   502
	 * @param WP_Post $post
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
	 * @param string  $att_title
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   505
	private function _get_row_actions( $post, $att_title ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
		$actions = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
		if ( $this->detached ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
			if ( current_user_can( 'edit_post', $post->ID ) )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   510
				$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
			if ( current_user_can( 'delete_post', $post->ID ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
				if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
					$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
				} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   515
					$delete_ays = !MEDIA_TRASH ? " onclick='return showNotice.warn();'" : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
					$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
			$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $att_title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
			if ( current_user_can( 'edit_post', $post->ID ) )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
				$actions['attach'] = '<a href="#the-list" onclick="findPosts.open( \'media[]\',\''.$post->ID.'\' );return false;" class="hide-if-no-js">'.__( 'Attach' ).'</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
		else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
			if ( current_user_can( 'edit_post', $post->ID ) && !$this->is_trash )
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
				$actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '">' . __( 'Edit' ) . '</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   525
			if ( current_user_can( 'delete_post', $post->ID ) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
				if ( $this->is_trash )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
					$actions['untrash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=untrash&amp;post=$post->ID", 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
				elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
					$actions['trash'] = "<a class='submitdelete' href='" . wp_nonce_url( "post.php?action=trash&amp;post=$post->ID", 'trash-post_' . $post->ID ) . "'>" . __( 'Trash' ) . "</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
				if ( $this->is_trash || !EMPTY_TRASH_DAYS || !MEDIA_TRASH ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
					$delete_ays = ( !$this->is_trash && !MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
					$actions['delete'] = "<a class='submitdelete'$delete_ays href='" . wp_nonce_url( "post.php?action=delete&amp;post=$post->ID", 'delete-post_' . $post->ID ) . "'>" . __( 'Delete Permanently' ) . "</a>";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
				}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
			if ( !$this->is_trash ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
				$title =_draft_or_post_title( $post->post_parent );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
				$actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
			}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
		/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
		 * Filter the action links for each attachment in the Media list table.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
		 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
		 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   546
		 * @param array   $actions  An array of action links for each attachment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   547
		 *                          Default 'Edit', 'Delete Permanently', 'View'.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   548
		 * @param WP_Post $post     WP_Post object for the current attachment.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   549
		 * @param bool    $detached Whether the list table contains media not attached
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   550
		 *                          to any posts. Default true.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   551
		 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
		$actions = apply_filters( 'media_row_actions', $actions, $post, $this->detached );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
		return $actions;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
}