2010-10-24 22:57:43 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2015-10-17 11:13:25 -04:00
|
|
|
* List Table API: WP_Media_List_Table class
|
2010-10-24 22:57:43 -04:00
|
|
|
*
|
|
|
|
* @package WordPress
|
2015-10-17 11:13:25 -04:00
|
|
|
* @subpackage Administration
|
|
|
|
* @since 3.1.0
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Core class used to implement displaying media items in a list table.
|
|
|
|
*
|
2010-10-25 00:04:18 -04:00
|
|
|
* @since 3.1.0
|
2015-10-17 11:13:25 -04:00
|
|
|
*
|
|
|
|
* @see WP_List_Table
|
2010-10-24 22:57:43 -04:00
|
|
|
*/
|
2010-11-04 04:07:03 -04:00
|
|
|
class WP_Media_List_Table extends WP_List_Table {
|
2015-09-14 15:25:25 -04:00
|
|
|
/**
|
2015-10-16 14:23:27 -04:00
|
|
|
* Holds the number of pending comments for each post.
|
2015-09-14 15:25:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.4.0
|
|
|
|
* @var array
|
|
|
|
*/
|
2015-10-16 14:23:27 -04:00
|
|
|
protected $comment_pending_count = array();
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-01-12 11:08:21 -05:00
|
|
|
private $detached;
|
|
|
|
|
|
|
|
private $is_trash;
|
|
|
|
|
2014-08-09 22:18:17 -04:00
|
|
|
/**
|
|
|
|
* Constructor.
|
2014-08-20 13:09:15 -04:00
|
|
|
*
|
2014-08-09 22:18:17 -04:00
|
|
|
* @since 3.1.0
|
|
|
|
*
|
|
|
|
* @see WP_List_Table::__construct() for more information on default arguments.
|
|
|
|
*
|
|
|
|
* @param array $args An associative array of arguments.
|
2014-08-20 13:09:15 -04:00
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function __construct( $args = array() ) {
|
2014-08-26 11:58:15 -04:00
|
|
|
$this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2014-11-01 15:56:24 -04:00
|
|
|
$this->modes = array(
|
2020-07-25 17:32:05 -04:00
|
|
|
'list' => __( 'List view' ),
|
|
|
|
'grid' => __( 'Grid view' ),
|
2014-11-01 15:56:24 -04:00
|
|
|
);
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
parent::__construct(
|
|
|
|
array(
|
|
|
|
'plural' => 'media',
|
|
|
|
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
|
|
|
|
)
|
|
|
|
);
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function ajax_user_can() {
|
2017-11-30 18:11:00 -05:00
|
|
|
return current_user_can( 'upload_files' );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
2020-07-10 12:04:05 -04:00
|
|
|
* @global string $mode List table view mode.
|
2019-08-03 21:59:56 -04:00
|
|
|
* @global WP_Query $wp_query WordPress Query object.
|
2015-05-28 17:41:30 -04:00
|
|
|
* @global array $post_mime_types
|
|
|
|
* @global array $avail_post_mime_types
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function prepare_items() {
|
2020-07-10 12:04:05 -04:00
|
|
|
global $mode, $wp_query, $post_mime_types, $avail_post_mime_types;
|
|
|
|
|
|
|
|
$mode = empty( $_REQUEST['mode'] ) ? 'list' : $_REQUEST['mode'];
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2021-01-29 13:54:01 -05:00
|
|
|
/*
|
|
|
|
* Exclude attachments scheduled for deletion in the next two hours
|
|
|
|
* if they are for zip packages for interrupted or failed updates.
|
|
|
|
* See File_Upload_Upgrader class.
|
|
|
|
*/
|
2020-07-10 02:08:06 -04:00
|
|
|
$not_in = array();
|
|
|
|
|
Media: Check the return type of `_get_cron_array()` in `WP_Media_List_Table::prepare_items()`.
The following warnings could, in very select circumstances, be shown:
{{{
// PHP 8.0 and higher:
Warning: foreach() argument must be of type array|object, bool given
// PHP 5.6 – 7.4
Warning: Invalid argument supplied for foreach()
}}}
In `WP_Media_List_Table::prepare_items()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.
However, no type check is done on the return value, and the method just blindly continues by using it in a `foreach`.
Fixed by adding validation for the returned value from `_get_cron_array()` and only running the `foreach` when the returned value is an array.
Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]
Follow-up to [48417].
Props jrf, hellofromTonya, mukesh27.
Fixes #53949.
Built from https://develop.svn.wordpress.org/trunk@51638
git-svn-id: http://core.svn.wordpress.org/trunk@51244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 08:44:57 -04:00
|
|
|
$crons = _get_cron_array();
|
2020-07-10 02:08:06 -04:00
|
|
|
|
Media: Check the return type of `_get_cron_array()` in `WP_Media_List_Table::prepare_items()`.
The following warnings could, in very select circumstances, be shown:
{{{
// PHP 8.0 and higher:
Warning: foreach() argument must be of type array|object, bool given
// PHP 5.6 – 7.4
Warning: Invalid argument supplied for foreach()
}}}
In `WP_Media_List_Table::prepare_items()`, the cron info array is retrieved via a call to `_get_cron_array()`, but as the documentation (correctly) states, the return type of that function is `array|false`, where `false` is returned for a virgin site, with no cron jobs scheduled yet.
However, no type check is done on the return value, and the method just blindly continues by using it in a `foreach`.
Fixed by adding validation for the returned value from `_get_cron_array()` and only running the `foreach` when the returned value is an array.
Reference: [https://developer.wordpress.org/reference/functions/_get_cron_array/ WordPress Developer Resources: _get_cron_array()]
Follow-up to [48417].
Props jrf, hellofromTonya, mukesh27.
Fixes #53949.
Built from https://develop.svn.wordpress.org/trunk@51638
git-svn-id: http://core.svn.wordpress.org/trunk@51244 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-08-19 08:44:57 -04:00
|
|
|
if ( is_array( $crons ) ) {
|
|
|
|
foreach ( $crons as $cron ) {
|
|
|
|
if ( isset( $cron['upgrader_scheduled_cleanup'] ) ) {
|
|
|
|
$details = reset( $cron['upgrader_scheduled_cleanup'] );
|
|
|
|
|
|
|
|
if ( ! empty( $details['args'][0] ) ) {
|
|
|
|
$not_in[] = (int) $details['args'][0];
|
|
|
|
}
|
2020-07-10 02:08:06 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty( $_REQUEST['post__not_in'] ) && is_array( $_REQUEST['post__not_in'] ) ) {
|
|
|
|
$not_in = array_merge( array_values( $_REQUEST['post__not_in'] ), $not_in );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty( $not_in ) ) {
|
|
|
|
$_REQUEST['post__not_in'] = $not_in;
|
|
|
|
}
|
|
|
|
|
2014-08-20 13:09:15 -04:00
|
|
|
list( $post_mime_types, $avail_post_mime_types ) = wp_edit_attachments_query( $_REQUEST );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->is_trash = isset( $_REQUEST['attachment-filter'] ) && 'trash' === $_REQUEST['attachment-filter'];
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$this->set_pagination_args(
|
|
|
|
array(
|
2020-12-01 11:33:05 -05:00
|
|
|
'total_items' => $wp_query->found_posts,
|
|
|
|
'total_pages' => $wp_query->max_num_pages,
|
2017-11-30 18:11:00 -05:00
|
|
|
'per_page' => $wp_query->query_vars['posts_per_page'],
|
|
|
|
)
|
|
|
|
);
|
Media: Use featured image if available for attachment as preview instead of icon.
When rendering a list of attachments in `WP_Media_List_Table` class, none image attachments, show a generic icon. However, attachment types like audio and video support adding a featured image. For attachments that have featured images, us this image instead of the icon. This featured image is a better preview than a generic icon.
Props spacedmonkey, samful, johnbillion, JavierCasares, seanchayes, antpb, cadic, JeffPaul.
Fixes #49852.
Built from https://develop.svn.wordpress.org/trunk@54941
git-svn-id: http://core.svn.wordpress.org/trunk@54493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-06 14:24:19 -05:00
|
|
|
if ( $wp_query->posts ) {
|
|
|
|
update_post_thumbnail_cache( $wp_query );
|
|
|
|
update_post_parent_caches( $wp_query->posts );
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
|
|
|
* @global array $post_mime_types
|
|
|
|
* @global array $avail_post_mime_types
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_views() {
|
2015-09-16 22:30:26 -04:00
|
|
|
global $post_mime_types, $avail_post_mime_types;
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
$type_links = array();
|
2015-09-16 22:30:26 -04:00
|
|
|
|
|
|
|
$filter = empty( $_GET['attachment-filter'] ) ? '' : $_GET['attachment-filter'];
|
|
|
|
|
|
|
|
$type_links['all'] = sprintf(
|
|
|
|
'<option value=""%s>%s</option>',
|
|
|
|
selected( $filter, true, false ),
|
|
|
|
__( 'All media items' )
|
|
|
|
);
|
|
|
|
|
2010-10-24 22:57:43 -04:00
|
|
|
foreach ( $post_mime_types as $mime_type => $label ) {
|
2015-09-16 22:30:26 -04:00
|
|
|
if ( ! wp_match_mime_types( $mime_type, $avail_post_mime_types ) ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
continue;
|
2015-09-16 22:30:26 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-09-16 22:30:26 -04:00
|
|
|
$selected = selected(
|
Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 11:45:22 -04:00
|
|
|
$filter && str_starts_with( $filter, 'post_mime_type:' ) &&
|
2015-09-16 22:30:26 -04:00
|
|
|
wp_match_mime_types( $mime_type, str_replace( 'post_mime_type:', '', $filter ) ),
|
|
|
|
true,
|
2015-09-22 02:06:25 -04:00
|
|
|
false
|
2015-09-16 22:30:26 -04:00
|
|
|
);
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$type_links[ $mime_type ] = sprintf(
|
2015-09-16 22:30:26 -04:00
|
|
|
'<option value="post_mime_type:%s"%s>%s</option>',
|
|
|
|
esc_attr( $mime_type ),
|
|
|
|
$selected,
|
|
|
|
$label[0]
|
|
|
|
);
|
|
|
|
}
|
2018-05-01 17:47:21 -04:00
|
|
|
|
I18N: Add context for some Media Library filter strings:
* Audio
* Video
* Unattached
This allows for more homogeneous translations in languages where keeping a plural form is important.
Follow-up to [6910], [7397], [8901], [9556], [11749], [13100], [12110], [15491], [15578], [22743], [29426], [29625], [34256], [45651], [46437].
Props jdy68, audrasjb, SergeyBiryukov.
Fixes #54238.
Built from https://develop.svn.wordpress.org/trunk@51903
git-svn-id: http://core.svn.wordpress.org/trunk@51496 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-10-12 12:44:01 -04:00
|
|
|
$type_links['detached'] = '<option value="detached"' . ( $this->detached ? ' selected="selected"' : '' ) . '>' . _x( 'Unattached', 'media items' ) . '</option>';
|
2015-09-16 22:30:26 -04:00
|
|
|
|
2018-05-01 17:47:21 -04:00
|
|
|
$type_links['mine'] = sprintf(
|
|
|
|
'<option value="mine"%s>%s</option>',
|
|
|
|
selected( 'mine' === $filter, true, false ),
|
|
|
|
_x( 'Mine', 'media items' )
|
|
|
|
);
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $this->is_trash || ( defined( 'MEDIA_TRASH' ) && MEDIA_TRASH ) ) {
|
2015-09-16 22:30:26 -04:00
|
|
|
$type_links['trash'] = sprintf(
|
|
|
|
'<option value="trash"%s>%s</option>',
|
|
|
|
selected( 'trash' === $filter, true, false ),
|
2015-12-13 14:03:26 -05:00
|
|
|
_x( 'Trash', 'attachment filter' )
|
2015-09-16 22:30:26 -04:00
|
|
|
);
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2018-05-01 11:43:22 -04:00
|
|
|
|
2010-10-24 22:57:43 -04:00
|
|
|
return $type_links;
|
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_bulk_actions() {
|
2010-10-24 22:57:43 -04:00
|
|
|
$actions = array();
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2014-10-01 23:12:18 -04:00
|
|
|
if ( MEDIA_TRASH ) {
|
|
|
|
if ( $this->is_trash ) {
|
|
|
|
$actions['untrash'] = __( 'Restore' );
|
2020-07-06 17:52:21 -04:00
|
|
|
$actions['delete'] = __( 'Delete permanently' );
|
2014-10-01 23:12:18 -04:00
|
|
|
} else {
|
2020-07-23 20:21:03 -04:00
|
|
|
$actions['trash'] = __( 'Move to Trash' );
|
2014-10-01 23:12:18 -04:00
|
|
|
}
|
|
|
|
} else {
|
2020-07-06 17:52:21 -04:00
|
|
|
$actions['delete'] = __( 'Delete permanently' );
|
2014-10-01 23:12:18 -04:00
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $this->detached ) {
|
2015-08-29 23:10:21 -04:00
|
|
|
$actions['attach'] = __( 'Attach' );
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
return $actions;
|
|
|
|
}
|
|
|
|
|
2014-11-30 19:33:23 -05:00
|
|
|
/**
|
|
|
|
* @param string $which
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function extra_tablenav( $which ) {
|
2014-08-26 11:58:15 -04:00
|
|
|
if ( 'bar' !== $which ) {
|
|
|
|
return;
|
|
|
|
}
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2014-08-26 11:58:15 -04:00
|
|
|
<div class="actions">
|
2021-01-18 04:50:10 -05:00
|
|
|
<?php
|
|
|
|
if ( ! $this->is_trash ) {
|
|
|
|
$this->months_dropdown( 'attachment' );
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2021-01-18 04:50:10 -05:00
|
|
|
/** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */
|
|
|
|
do_action( 'restrict_manage_posts', $this->screen->post_type, $which );
|
2015-09-14 15:25:25 -04:00
|
|
|
|
2021-01-18 04:50:10 -05:00
|
|
|
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2021-05-03 09:57:04 -04:00
|
|
|
if ( $this->is_trash && $this->has_items()
|
|
|
|
&& current_user_can( 'edit_others_posts' )
|
|
|
|
) {
|
2021-01-18 04:50:10 -05:00
|
|
|
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
|
|
|
|
}
|
|
|
|
?>
|
2010-10-24 22:57:43 -04:00
|
|
|
</div>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function current_action() {
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['found_post_id'] ) && isset( $_REQUEST['media'] ) ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
return 'attach';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['parent_post_id'] ) && isset( $_REQUEST['media'] ) ) {
|
2015-03-05 00:35:28 -05:00
|
|
|
return 'detach';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2015-03-05 00:35:28 -05:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) {
|
2010-10-24 22:57:43 -04:00
|
|
|
return 'delete_all';
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
|
|
|
return parent::current_action();
|
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return bool
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function has_items() {
|
2010-10-24 22:57:43 -04:00
|
|
|
return have_posts();
|
|
|
|
}
|
|
|
|
|
2015-05-29 17:32:24 -04:00
|
|
|
/**
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
public function no_items() {
|
2020-02-09 23:57:06 -05:00
|
|
|
if ( $this->is_trash ) {
|
|
|
|
_e( 'No media files found in Trash.' );
|
|
|
|
} else {
|
|
|
|
_e( 'No media files found.' );
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2014-08-26 11:58:15 -04:00
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Overrides parent views to use the filter bar display.
|
2015-05-28 17:41:30 -04:00
|
|
|
*
|
2017-03-21 23:47:07 -04:00
|
|
|
* @global string $mode List table view mode.
|
2014-08-26 11:58:15 -04:00
|
|
|
*/
|
|
|
|
public function views() {
|
|
|
|
global $mode;
|
|
|
|
|
|
|
|
$views = $this->get_views();
|
2015-10-06 21:28:25 -04:00
|
|
|
|
|
|
|
$this->screen->render_screen_reader_content( 'heading_views' );
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2021-01-18 04:50:10 -05:00
|
|
|
<div class="wp-filter">
|
|
|
|
<div class="filter-items">
|
|
|
|
<?php $this->view_switcher( $mode ); ?>
|
|
|
|
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
<label for="attachment-filter" class="screen-reader-text">
|
|
|
|
<?php
|
|
|
|
/* translators: Hidden accessibility text. */
|
|
|
|
_e( 'Filter by type' );
|
|
|
|
?>
|
|
|
|
</label>
|
2021-01-18 04:50:10 -05:00
|
|
|
<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
|
|
|
|
<?php
|
|
|
|
if ( ! empty( $views ) ) {
|
|
|
|
foreach ( $views as $class => $view ) {
|
|
|
|
echo "\t$view\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</select>
|
2014-12-10 23:12:23 -05:00
|
|
|
|
2021-01-18 04:50:10 -05:00
|
|
|
<?php
|
|
|
|
$this->extra_tablenav( 'bar' );
|
|
|
|
|
|
|
|
/** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
|
|
|
|
$views = apply_filters( "views_{$this->screen->id}", array() );
|
|
|
|
|
|
|
|
// Back compat for pre-4.0 view links.
|
|
|
|
if ( ! empty( $views ) ) {
|
|
|
|
echo '<ul class="filter-links">';
|
|
|
|
foreach ( $views as $class => $view ) {
|
|
|
|
echo "<li class='$class'>$view</li>";
|
|
|
|
}
|
|
|
|
echo '</ul>';
|
2014-12-10 23:12:23 -05:00
|
|
|
}
|
2021-01-18 04:50:10 -05:00
|
|
|
?>
|
|
|
|
</div>
|
2014-08-26 11:58:15 -04:00
|
|
|
|
2021-01-18 04:50:10 -05:00
|
|
|
<div class="search-form">
|
|
|
|
<label for="media-search-input" class="media-search-input-label"><?php esc_html_e( 'Search' ); ?></label>
|
|
|
|
<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
|
|
|
|
</div>
|
|
|
|
</div>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2014-08-26 11:58:15 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
2023-05-08 18:37:24 -04:00
|
|
|
* @return string[] Array of column titles keyed by their column name.
|
2015-05-29 16:17:26 -04:00
|
|
|
*/
|
2014-07-11 23:27:14 -04:00
|
|
|
public function get_columns() {
|
2017-11-30 18:11:00 -05:00
|
|
|
$posts_columns = array();
|
2010-10-24 22:57:43 -04:00
|
|
|
$posts_columns['cb'] = '<input type="checkbox" />';
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: Column name. */
|
2017-11-30 18:11:00 -05:00
|
|
|
$posts_columns['title'] = _x( 'File', 'column name' );
|
2010-10-24 22:57:43 -04:00
|
|
|
$posts_columns['author'] = __( 'Author' );
|
2012-09-21 18:52:54 -04:00
|
|
|
|
|
|
|
$taxonomies = get_taxonomies_for_attachments( 'objects' );
|
|
|
|
$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' );
|
|
|
|
|
2014-01-07 22:53:14 -05:00
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the taxonomy columns for attachments in the Media list table.
|
2014-01-07 22:53:14 -05:00
|
|
|
*
|
|
|
|
* @since 3.5.0
|
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $taxonomies An array of registered taxonomy names to show for attachments.
|
|
|
|
* @param string $post_type The post type. Default 'attachment'.
|
2014-01-07 22:53:14 -05:00
|
|
|
*/
|
2012-09-21 18:52:54 -04:00
|
|
|
$taxonomies = apply_filters( 'manage_taxonomies_for_attachment_columns', $taxonomies, 'attachment' );
|
|
|
|
$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' );
|
|
|
|
|
|
|
|
foreach ( $taxonomies as $taxonomy ) {
|
2015-09-22 02:06:25 -04:00
|
|
|
if ( 'category' === $taxonomy ) {
|
2012-09-21 18:52:54 -04:00
|
|
|
$column_key = 'categories';
|
2015-09-22 02:06:25 -04:00
|
|
|
} elseif ( 'post_tag' === $taxonomy ) {
|
2012-09-21 18:52:54 -04:00
|
|
|
$column_key = 'tags';
|
2015-09-22 02:06:25 -04:00
|
|
|
} else {
|
2012-09-21 18:52:54 -04:00
|
|
|
$column_key = 'taxonomy-' . $taxonomy;
|
2015-09-22 02:06:25 -04:00
|
|
|
}
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2012-09-21 18:52:54 -04:00
|
|
|
$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
|
|
|
|
}
|
|
|
|
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: Column name. */
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( ! $this->detached ) {
|
2012-11-17 01:56:05 -05:00
|
|
|
$posts_columns['parent'] = _x( 'Uploaded to', 'column name' );
|
2022-05-19 11:54:15 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( post_type_supports( 'attachment', 'comments' ) ) {
|
2022-05-19 11:54:15 -04:00
|
|
|
$posts_columns['comments'] = sprintf(
|
|
|
|
'<span class="vers comment-grey-bubble" title="%1$s" aria-hidden="true"></span><span class="screen-reader-text">%2$s</span>',
|
|
|
|
esc_attr__( 'Comments' ),
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
/* translators: Hidden accessibility text. */
|
2022-05-19 11:54:15 -04:00
|
|
|
__( 'Comments' )
|
|
|
|
);
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: Column name. */
|
2010-10-24 22:57:43 -04:00
|
|
|
$posts_columns['date'] = _x( 'Date', 'column name' );
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2014-01-07 22:53:14 -05:00
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the Media list table columns.
|
2014-01-07 22:53:14 -05:00
|
|
|
*
|
|
|
|
* @since 2.5.0
|
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $posts_columns An array of columns displayed in the Media list table.
|
|
|
|
* @param bool $detached Whether the list table contains media not attached
|
|
|
|
* to any posts. Default true.
|
2014-01-07 22:53:14 -05:00
|
|
|
*/
|
2015-05-29 16:17:26 -04:00
|
|
|
return apply_filters( 'manage_media_columns', $posts_columns, $this->detached );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-29 16:17:26 -04:00
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
protected function get_sortable_columns() {
|
2010-10-24 22:57:43 -04:00
|
|
|
return array(
|
2023-06-21 17:47:23 -04:00
|
|
|
'title' => array( 'title', false, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ),
|
|
|
|
'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ),
|
|
|
|
'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ),
|
|
|
|
'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ),
|
|
|
|
'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ),
|
2010-10-24 22:57:43 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-05-28 17:41:30 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the checkbox column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-05-28 17:41:30 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
* @param WP_Post $item The current WP_Post object.
|
2015-05-28 17:41:30 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_cb()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51735
git-svn-id: http://core.svn.wordpress.org/trunk@51343 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 14:19:56 -04:00
|
|
|
public function column_cb( $item ) {
|
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
|
|
|
$post = $item;
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( current_user_can( 'edit_post', $post->ID ) ) {
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2023-06-20 21:54:19 -04:00
|
|
|
<label class="label-covers-full-cell" for="cb-select-<?php echo $post->ID; ?>">
|
|
|
|
<span class="screen-reader-text">
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
<?php
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
/* translators: Hidden accessibility text. %s: Attachment title. */
|
I18N: Improve translator comments.
* Add missing translator comments.
* Fix placement of some translator comments. Translator comments should be on the line directly above the line containing the translation function call for optimal compatibility with various `.pot` file generation tools. The CS auto-fixing, which changed some inconsistent function calls to multi-line function calls, is part of the reason why this was no longer the case for a select group of translator comments.
Includes minor code layout fixes.
Polyglots, rejoice! All WordPress core files now have translator comments for all strings with placeholders!
Props jrf, subrataemfluence, GaryJ, webdados, Dency, swissspidy, alvarogois, marcomartins, mihaiiceyro, vladwtz, niq1982, flipkeijzer, michielatyoast, chandrapatel, thrijith, joshuanoyce, FesoVik, tessak22, bhaktirajdev, cleancoded, dhavalkasvala, garrett-eclipse, bibliofille, socalchristina, priyankkpatel, 5hel2l2y, adamsilverstein, JeffPaul, pierlo, SergeyBiryukov.
Fixes #44360.
Built from https://develop.svn.wordpress.org/trunk@45926
git-svn-id: http://core.svn.wordpress.org/trunk@45737 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2019-09-01 13:13:59 -04:00
|
|
|
printf( __( 'Select %s' ), _draft_or_post_title() );
|
|
|
|
?>
|
2023-06-20 21:54:19 -04:00
|
|
|
</span>
|
2017-11-30 18:11:00 -05:00
|
|
|
</label>
|
2015-06-13 11:57:27 -04:00
|
|
|
<input type="checkbox" name="media[]" id="cb-select-<?php echo $post->ID; ?>" value="<?php echo $post->ID; ?>" />
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2017-11-30 18:11:00 -05:00
|
|
|
}
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the title column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_title( $post ) {
|
|
|
|
list( $mime ) = explode( '/', $post->post_mime_type );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
Media: Use featured image if available for attachment as preview instead of icon.
When rendering a list of attachments in `WP_Media_List_Table` class, none image attachments, show a generic icon. However, attachment types like audio and video support adding a featured image. For attachments that have featured images, us this image instead of the icon. This featured image is a better preview than a generic icon.
Props spacedmonkey, samful, johnbillion, JavierCasares, seanchayes, antpb, cadic, JeffPaul.
Fixes #49852.
Built from https://develop.svn.wordpress.org/trunk@54941
git-svn-id: http://core.svn.wordpress.org/trunk@54493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-06 14:24:19 -05:00
|
|
|
$attachment_id = $post->ID;
|
|
|
|
|
|
|
|
if ( has_post_thumbnail( $post ) ) {
|
|
|
|
$thumbnail_id = get_post_thumbnail_id( $post );
|
|
|
|
|
|
|
|
if ( ! empty( $thumbnail_id ) ) {
|
|
|
|
$attachment_id = $thumbnail_id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
$title = _draft_or_post_title();
|
Media: Use featured image if available for attachment as preview instead of icon.
When rendering a list of attachments in `WP_Media_List_Table` class, none image attachments, show a generic icon. However, attachment types like audio and video support adding a featured image. For attachments that have featured images, us this image instead of the icon. This featured image is a better preview than a generic icon.
Props spacedmonkey, samful, johnbillion, JavierCasares, seanchayes, antpb, cadic, JeffPaul.
Fixes #49852.
Built from https://develop.svn.wordpress.org/trunk@54941
git-svn-id: http://core.svn.wordpress.org/trunk@54493 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-12-06 14:24:19 -05:00
|
|
|
$thumb = wp_get_attachment_image( $attachment_id, array( 60, 60 ), true, array( 'alt' => '' ) );
|
2019-07-01 08:52:01 -04:00
|
|
|
$link_start = '';
|
|
|
|
$link_end = '';
|
2015-06-13 11:57:27 -04:00
|
|
|
|
2015-07-14 13:24:26 -04:00
|
|
|
if ( current_user_can( 'edit_post', $post->ID ) && ! $this->is_trash ) {
|
2016-01-17 09:46:29 -05:00
|
|
|
$link_start = sprintf(
|
|
|
|
'<a href="%s" aria-label="%s">',
|
|
|
|
get_edit_post_link( $post->ID ),
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Attachment title. */
|
2016-01-17 09:46:29 -05:00
|
|
|
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) )
|
|
|
|
);
|
2015-07-14 13:24:26 -04:00
|
|
|
$link_end = '</a>';
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
2015-05-28 22:41:25 -04:00
|
|
|
|
2015-07-14 13:46:24 -04:00
|
|
|
$class = $thumb ? ' class="has-media-icon"' : '';
|
2015-06-13 11:57:27 -04:00
|
|
|
?>
|
2015-07-14 13:46:24 -04:00
|
|
|
<strong<?php echo $class; ?>>
|
2016-01-17 09:46:29 -05:00
|
|
|
<?php
|
|
|
|
echo $link_start;
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $thumb ) :
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2015-07-14 13:24:26 -04:00
|
|
|
<span class="media-icon <?php echo sanitize_html_class( $mime . '-icon' ); ?>"><?php echo $thumb; ?></span>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2017-11-30 18:11:00 -05:00
|
|
|
endif;
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2016-01-17 09:46:29 -05:00
|
|
|
echo $title . $link_end;
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2016-01-17 09:46:29 -05:00
|
|
|
_media_states( $post );
|
|
|
|
?>
|
2015-07-14 13:24:26 -04:00
|
|
|
</strong>
|
2015-09-14 22:50:25 -04:00
|
|
|
<p class="filename">
|
I18N: Mark screen reader strings as such with translator comments.
This aims to provide better context for translators and make it easier to determine that some strings contain hidden accessibility text and are not displayed in the UI.
Props kebbet, mercime, pavelevap, ocean90, swissspidy, Chouby, jipmoors, afercia, desrosj, costdev, audrasjb, SergeyBiryukov.
Fixes #29748.
Built from https://develop.svn.wordpress.org/trunk@55276
git-svn-id: http://core.svn.wordpress.org/trunk@54809 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-02-07 12:10:21 -05:00
|
|
|
<span class="screen-reader-text">
|
|
|
|
<?php
|
|
|
|
/* translators: Hidden accessibility text. */
|
|
|
|
_e( 'File name:' );
|
|
|
|
?>
|
|
|
|
</span>
|
2015-09-16 22:30:26 -04:00
|
|
|
<?php
|
2015-09-14 22:50:25 -04:00
|
|
|
$file = get_attached_file( $post->ID );
|
2016-06-21 10:20:55 -04:00
|
|
|
echo esc_html( wp_basename( $file ) );
|
2015-09-14 22:50:25 -04:00
|
|
|
?>
|
|
|
|
</p>
|
2015-06-13 11:57:27 -04:00
|
|
|
<?php
|
2015-05-28 22:41:25 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the author column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_author( $post ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
printf(
|
|
|
|
'<a href="%s">%s</a>',
|
|
|
|
esc_url( add_query_arg( array( 'author' => get_the_author_meta( 'ID' ) ), 'upload.php' ) ),
|
2015-06-13 11:57:27 -04:00
|
|
|
get_the_author()
|
|
|
|
);
|
2015-05-28 22:41:25 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the description column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
2023-01-28 17:17:16 -05:00
|
|
|
* @deprecated 6.2.0
|
2015-06-13 11:57:27 -04:00
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_desc( $post ) {
|
2023-01-28 17:17:16 -05:00
|
|
|
_deprecated_function( __METHOD__, '6.2.0' );
|
2023-02-07 04:08:20 -05:00
|
|
|
|
|
|
|
echo has_excerpt() ? $post->post_excerpt : '';
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the date column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_date( $post ) {
|
2015-09-22 02:06:25 -04:00
|
|
|
if ( '0000-00-00 00:00:00' === $post->post_date ) {
|
2015-06-13 11:57:27 -04:00
|
|
|
$h_time = __( 'Unpublished' );
|
|
|
|
} else {
|
2019-10-25 08:51:03 -04:00
|
|
|
$time = get_post_timestamp( $post );
|
|
|
|
$time_diff = time() - $time;
|
|
|
|
|
|
|
|
if ( $time && $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
|
|
|
|
/* translators: %s: Human-readable time difference. */
|
|
|
|
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
|
2015-06-13 11:57:27 -04:00
|
|
|
} else {
|
2019-10-25 08:51:03 -04:00
|
|
|
$h_time = get_the_time( __( 'Y/m/d' ), $post );
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2022-03-18 12:39:02 -04:00
|
|
|
/**
|
2022-04-28 05:59:13 -04:00
|
|
|
* Filters the published time of an attachment displayed in the Media list table.
|
2022-03-18 12:39:02 -04:00
|
|
|
*
|
|
|
|
* @since 6.0.0
|
|
|
|
*
|
|
|
|
* @param string $h_time The published time.
|
2022-04-28 05:59:13 -04:00
|
|
|
* @param WP_Post $post Attachment object.
|
2022-03-18 12:39:02 -04:00
|
|
|
* @param string $column_name The column name.
|
|
|
|
*/
|
|
|
|
echo apply_filters( 'media_date_column_time', $h_time, $post, 'date' );
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the parent column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_parent( $post ) {
|
|
|
|
$user_can_edit = current_user_can( 'edit_post', $post->ID );
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
if ( $post->post_parent > 0 ) {
|
|
|
|
$parent = get_post( $post->post_parent );
|
|
|
|
} else {
|
|
|
|
$parent = false;
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
if ( $parent ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$title = _draft_or_post_title( $post->post_parent );
|
2015-06-13 11:57:27 -04:00
|
|
|
$parent_type = get_post_type_object( $parent->post_type );
|
2016-07-10 15:31:31 -04:00
|
|
|
|
2016-07-01 11:07:36 -04:00
|
|
|
if ( $parent_type && $parent_type->show_ui && current_user_can( 'edit_post', $post->post_parent ) ) {
|
2021-01-18 04:50:10 -05:00
|
|
|
printf( '<strong><a href="%s">%s</a></strong>', get_edit_post_link( $post->post_parent ), $title );
|
2016-07-04 15:34:28 -04:00
|
|
|
} elseif ( $parent_type && current_user_can( 'read_post', $post->post_parent ) ) {
|
2021-01-18 04:50:10 -05:00
|
|
|
printf( '<strong>%s</strong>', $title );
|
2015-06-13 11:57:27 -04:00
|
|
|
} else {
|
2016-07-01 11:07:36 -04:00
|
|
|
_e( '(Private post)' );
|
|
|
|
}
|
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
if ( $user_can_edit ) :
|
|
|
|
$detach_url = add_query_arg(
|
|
|
|
array(
|
|
|
|
'parent_post_id' => $post->post_parent,
|
|
|
|
'media[]' => $post->ID,
|
|
|
|
'_wpnonce' => wp_create_nonce( 'bulk-' . $this->_args['plural'] ),
|
2018-08-16 21:51:36 -04:00
|
|
|
),
|
|
|
|
'upload.php'
|
2017-11-30 18:11:00 -05:00
|
|
|
);
|
2016-01-17 09:46:29 -05:00
|
|
|
printf(
|
2016-07-01 11:07:36 -04:00
|
|
|
'<br /><a href="%s" class="hide-if-no-js detach-from-parent" aria-label="%s">%s</a>',
|
2016-01-17 09:46:29 -05:00
|
|
|
$detach_url,
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Title of the post the attachment is attached to. */
|
2016-01-17 09:46:29 -05:00
|
|
|
esc_attr( sprintf( __( 'Detach from “%s”' ), $title ) ),
|
|
|
|
__( 'Detach' )
|
|
|
|
);
|
|
|
|
endif;
|
2015-06-13 11:57:27 -04:00
|
|
|
} else {
|
2017-11-30 18:11:00 -05:00
|
|
|
_e( '(Unattached)' );
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
if ( $user_can_edit ) {
|
2016-01-17 09:46:29 -05:00
|
|
|
$title = _draft_or_post_title( $post->post_parent );
|
|
|
|
printf(
|
2016-07-10 15:31:31 -04:00
|
|
|
'<br /><a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
|
2016-01-17 09:46:29 -05:00
|
|
|
$post->ID,
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Attachment title. */
|
2016-01-17 09:46:29 -05:00
|
|
|
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $title ) ),
|
|
|
|
__( 'Attach' )
|
|
|
|
);
|
|
|
|
}
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles the comments column output.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param WP_Post $post The current WP_Post object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function column_comments( $post ) {
|
|
|
|
echo '<div class="post-com-count-wrapper">';
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-10-16 14:23:27 -04:00
|
|
|
if ( isset( $this->comment_pending_count[ $post->ID ] ) ) {
|
|
|
|
$pending_comments = $this->comment_pending_count[ $post->ID ];
|
2015-09-14 15:25:25 -04:00
|
|
|
} else {
|
|
|
|
$pending_comments = get_pending_comments_num( $post->ID );
|
|
|
|
}
|
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
$this->comments_bubble( $post->ID, $pending_comments );
|
2013-08-27 16:49:10 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
echo '</div>';
|
|
|
|
}
|
2015-05-28 22:41:25 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Handles output for the default column.
|
|
|
|
*
|
2015-06-13 11:57:27 -04:00
|
|
|
* @since 4.3.0
|
2021-09-07 12:57:58 -04:00
|
|
|
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-06-13 11:57:27 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_default()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51728
git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 18:26:56 -04:00
|
|
|
* @param WP_Post $item The current WP_Post object.
|
2015-07-12 14:34:24 -04:00
|
|
|
* @param string $column_name Current column name.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::column_default()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [15632], [30679], [31210], [32740], [32753], [32754], [32755], [32756], [32757].
Props jrf, hellofromTonya, @sergeybiryukov, @azaozz, @desrosj, @johnbillion
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51728
git-svn-id: http://core.svn.wordpress.org/trunk@51334 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-02 18:26:56 -04:00
|
|
|
public function column_default( $item, $column_name ) {
|
|
|
|
// Restores the more descriptive, specific name for use within this method.
|
|
|
|
$post = $item;
|
|
|
|
|
2015-09-22 02:06:25 -04:00
|
|
|
if ( 'categories' === $column_name ) {
|
2015-06-13 11:57:27 -04:00
|
|
|
$taxonomy = 'category';
|
2015-09-22 02:06:25 -04:00
|
|
|
} elseif ( 'tags' === $column_name ) {
|
2015-06-13 11:57:27 -04:00
|
|
|
$taxonomy = 'post_tag';
|
Code Modernization: Replace usage of `strpos()` with `str_starts_with()`.
`str_starts_with()` was introduced in PHP 8.0 to perform a case-sensitive check indicating if the string to search in (haystack) begins with the given substring (needle).
WordPress core includes a polyfill for `str_starts_with()` on PHP < 8.0 as of WordPress 5.9.
This commit replaces `0 === strpos( ... )` with `str_starts_with()` in core files, making the code more readable and consistent, as well as improving performance.
While `strpos()` is slightly faster than the polyfill on PHP < 8.0, `str_starts_with()` is noticeably faster on PHP 8.0+, as it is optimized to avoid unnecessarily searching along the whole haystack if it does not find the needle.
Follow-up to [52039], [52040], [52326].
Props spacedmonkey, costdev, sabernhardt, mukesh27, desrosj, jorbin, TobiasBg, ayeshrajans, lgadzhev, SergeyBiryukov.
Fixes #58012.
Built from https://develop.svn.wordpress.org/trunk@55703
git-svn-id: http://core.svn.wordpress.org/trunk@55215 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-05-02 11:45:22 -04:00
|
|
|
} elseif ( str_starts_with( $column_name, 'taxonomy-' ) ) {
|
2015-06-13 11:57:27 -04:00
|
|
|
$taxonomy = substr( $column_name, 9 );
|
|
|
|
} else {
|
|
|
|
$taxonomy = false;
|
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
if ( $taxonomy ) {
|
|
|
|
$terms = get_the_terms( $post->ID, $taxonomy );
|
2021-05-03 09:57:04 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
if ( is_array( $terms ) ) {
|
Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.
* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.
This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`
Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].
Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071
git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 13:19:09 -04:00
|
|
|
$output = array();
|
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
foreach ( $terms as $t ) {
|
2017-11-30 18:11:00 -05:00
|
|
|
$posts_in_term_qv = array();
|
2015-06-13 11:57:27 -04:00
|
|
|
$posts_in_term_qv['taxonomy'] = $taxonomy;
|
2017-11-30 18:11:00 -05:00
|
|
|
$posts_in_term_qv['term'] = $t->slug;
|
2015-06-13 11:57:27 -04:00
|
|
|
|
Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.
* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.
This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`
Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].
Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071
git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 13:19:09 -04:00
|
|
|
$output[] = sprintf(
|
2017-11-30 18:11:00 -05:00
|
|
|
'<a href="%s">%s</a>',
|
2015-06-13 11:57:27 -04:00
|
|
|
esc_url( add_query_arg( $posts_in_term_qv, 'upload.php' ) ),
|
|
|
|
esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) )
|
|
|
|
);
|
2012-09-21 18:52:54 -04:00
|
|
|
}
|
Coding Standards: Use more meaningful variable names for output in the admin.
This renames some variables for clarity, per the [https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions Naming Conventions]:
> Don’t abbreviate variable names unnecessarily; let the code be unambiguous and self-documenting.
* `$out` is renamed to `$output` in various list table methods and admin functions.
* `$sep` is renamed to `$separator` in various list table methods and admin functions.
This affects:
* `WP_Comments_List_Table::handle_row_actions()`
* `WP_List_Table::row_actions()`
* `WP_Media_List_Table::column_default()`
* `WP_MS_Sites_List_Table::site_states()`
* `WP_MS_Users_List_Table::column_blogs()`
* `WP_Terms_List_Table::column_name()`
* `_wp_dashboard_recent_comments_row()`
* `image_align_input_fields()`
* `image_size_input_fields()`
* `wp_doc_link_parse()`
* `_post_states()`
* `_media_states()`
Follow-up to [8653], [8692], [8864], [8910], [8911], [8916], [9103], [9153], [10607], [15491], [17793], [32644], [54070].
Props mukesh27, costdev.
See #56448, #55647.
Built from https://develop.svn.wordpress.org/trunk@54071
git-svn-id: http://core.svn.wordpress.org/trunk@53630 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2022-09-05 13:19:09 -04:00
|
|
|
|
|
|
|
echo implode( wp_get_list_item_separator(), $output );
|
2015-06-13 11:57:27 -04:00
|
|
|
} else {
|
2015-06-24 20:16:27 -04:00
|
|
|
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . get_taxonomy( $taxonomy )->labels->no_terms . '</span>';
|
2015-06-13 11:57:27 -04:00
|
|
|
}
|
2015-05-28 22:41:25 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
return;
|
2015-05-28 22:41:25 -04:00
|
|
|
}
|
2015-05-29 16:17:26 -04:00
|
|
|
|
2015-06-13 11:57:27 -04:00
|
|
|
/**
|
|
|
|
* Fires for each custom column in the Media list table.
|
|
|
|
*
|
|
|
|
* Custom columns are registered using the {@see 'manage_media_columns'} filter.
|
|
|
|
*
|
|
|
|
* @since 2.5.0
|
|
|
|
*
|
|
|
|
* @param string $column_name Name of the custom column.
|
|
|
|
* @param int $post_id Attachment ID.
|
|
|
|
*/
|
|
|
|
do_action( 'manage_media_custom_column', $column_name, $post->ID );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2015-06-13 11:57:27 -04:00
|
|
|
|
|
|
|
/**
|
2022-10-21 09:35:21 -04:00
|
|
|
* @global WP_Post $post Global post object.
|
|
|
|
* @global WP_Query $wp_query WordPress Query object.
|
2015-06-13 11:57:27 -04:00
|
|
|
*/
|
|
|
|
public function display_rows() {
|
2015-09-14 15:25:25 -04:00
|
|
|
global $post, $wp_query;
|
|
|
|
|
|
|
|
$post_ids = wp_list_pluck( $wp_query->posts, 'ID' );
|
|
|
|
reset( $wp_query->posts );
|
|
|
|
|
2015-10-16 14:23:27 -04:00
|
|
|
$this->comment_pending_count = get_pending_comments_num( $post_ids );
|
2015-06-13 11:57:27 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
add_filter( 'the_title', 'esc_html' );
|
2015-06-13 11:57:27 -04:00
|
|
|
|
2017-11-30 18:11:00 -05:00
|
|
|
while ( have_posts() ) :
|
|
|
|
the_post();
|
2021-04-19 07:41:07 -04:00
|
|
|
|
2021-01-18 04:50:10 -05:00
|
|
|
if ( $this->is_trash && 'trash' !== $post->post_status
|
|
|
|
|| ! $this->is_trash && 'trash' === $post->post_status
|
2015-06-13 11:57:27 -04:00
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
2021-04-19 07:41:07 -04:00
|
|
|
|
|
|
|
$post_owner = ( get_current_user_id() === (int) $post->post_author ) ? 'self' : 'other';
|
2018-08-16 21:51:36 -04:00
|
|
|
?>
|
2015-06-13 11:57:27 -04:00
|
|
|
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo trim( ' author-' . $post_owner . ' status-' . $post->post_status ); ?>">
|
|
|
|
<?php $this->single_row_columns( $post ); ?>
|
|
|
|
</tr>
|
2018-08-16 21:51:36 -04:00
|
|
|
<?php
|
2015-06-13 11:57:27 -04:00
|
|
|
endwhile;
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
|
|
|
|
2015-05-28 22:41:25 -04:00
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Gets the name of the default primary column.
|
2015-05-28 22:41:25 -04:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
|
|
|
*
|
2015-05-30 21:32:26 -04:00
|
|
|
* @return string Name of the default primary column, in this case, 'title'.
|
2015-05-28 22:41:25 -04:00
|
|
|
*/
|
|
|
|
protected function get_default_primary_column_name() {
|
|
|
|
return 'title';
|
|
|
|
}
|
|
|
|
|
2014-11-30 19:33:23 -05:00
|
|
|
/**
|
|
|
|
* @param WP_Post $post
|
|
|
|
* @param string $att_title
|
2015-05-29 16:17:26 -04:00
|
|
|
* @return array
|
2014-11-30 19:33:23 -05:00
|
|
|
*/
|
Add access modifiers to methods and members of list table classes:
* `WP_List_Table` is the base class that implements `__get()` and `__call()` for BC
* Adds unit tests to confirm that subclasses properly inherit magic methods
* Add modifiers to subclasses: `WP_Links_List_Table`, `WP_Media_List_Table`, `WP_MS_Sites_List_Table`, `WP_MS_Themes_List_Table`, `WP_MS_Users_List_Table`, `WP_Plugin_Install_List_Table`, `WP_Plugins_List_Table`, `WP_Posts_List_Table`, `WP_Terms_List_Table`, `WP_Theme_Install_List_Table`, `WP_Themes_List_Table`
See #27881, #22234.
Built from https://develop.svn.wordpress.org/trunk@28493
git-svn-id: http://core.svn.wordpress.org/trunk@28319 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2014-05-18 21:17:15 -04:00
|
|
|
private function _get_row_actions( $post, $att_title ) {
|
2010-11-06 19:00:17 -04:00
|
|
|
$actions = array();
|
2010-10-24 22:57:43 -04:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
if ( ! $this->is_trash && current_user_can( 'edit_post', $post->ID ) ) {
|
|
|
|
$actions['edit'] = sprintf(
|
|
|
|
'<a href="%s" aria-label="%s">%s</a>',
|
|
|
|
esc_url( get_edit_post_link( $post->ID ) ),
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Edit “%s”' ), $att_title ) ),
|
|
|
|
__( 'Edit' )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( current_user_can( 'delete_post', $post->ID ) ) {
|
|
|
|
if ( $this->is_trash ) {
|
|
|
|
$actions['untrash'] = sprintf(
|
|
|
|
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
|
|
|
esc_url( wp_nonce_url( "post.php?action=untrash&post=$post->ID", 'untrash-post_' . $post->ID ) ),
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Attachment title. */
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $att_title ) ),
|
|
|
|
__( 'Restore' )
|
|
|
|
);
|
|
|
|
} elseif ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) {
|
|
|
|
$actions['trash'] = sprintf(
|
|
|
|
'<a href="%s" class="submitdelete aria-button-if-js" aria-label="%s">%s</a>',
|
|
|
|
esc_url( wp_nonce_url( "post.php?action=trash&post=$post->ID", 'trash-post_' . $post->ID ) ),
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $att_title ) ),
|
|
|
|
_x( 'Trash', 'verb' )
|
2016-01-17 09:46:29 -05:00
|
|
|
);
|
|
|
|
}
|
2021-04-19 07:41:07 -04:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
if ( $this->is_trash || ! EMPTY_TRASH_DAYS || ! MEDIA_TRASH ) {
|
|
|
|
$show_confirmation = ( ! $this->is_trash && ! MEDIA_TRASH ) ? " onclick='return showNotice.warn();'" : '';
|
|
|
|
|
|
|
|
$actions['delete'] = sprintf(
|
|
|
|
'<a href="%s" class="submitdelete aria-button-if-js"%s aria-label="%s">%s</a>',
|
|
|
|
esc_url( wp_nonce_url( "post.php?action=delete&post=$post->ID", 'delete-post_' . $post->ID ) ),
|
|
|
|
$show_confirmation,
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $att_title ) ),
|
|
|
|
__( 'Delete Permanently' )
|
|
|
|
);
|
2016-01-17 09:46:29 -05:00
|
|
|
}
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$attachment_url = wp_get_attachment_url( $post->ID );
|
2021-04-19 07:41:07 -04:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
if ( ! $this->is_trash ) {
|
|
|
|
$permalink = get_permalink( $post->ID );
|
|
|
|
|
|
|
|
if ( $permalink ) {
|
2023-02-03 17:25:16 -05:00
|
|
|
$actions['view'] = sprintf(
|
|
|
|
'<a href="%s" aria-label="%s" rel="bookmark">%s</a>',
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
esc_url( $permalink ),
|
2023-02-03 17:25:16 -05:00
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'View “%s”' ), $att_title ) ),
|
|
|
|
__( 'View' )
|
|
|
|
);
|
|
|
|
}
|
2016-01-17 09:46:29 -05:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
$actions['copy'] = sprintf(
|
|
|
|
'<span class="copy-to-clipboard-container"><button type="button" class="button-link copy-attachment-url media-library" data-clipboard-text="%s" aria-label="%s">%s</button><span class="success hidden" aria-hidden="true">%s</span></span>',
|
|
|
|
esc_url( $attachment_url ),
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Copy “%s” URL to clipboard' ), $att_title ) ),
|
|
|
|
__( 'Copy URL' ),
|
|
|
|
__( 'Copied!' )
|
|
|
|
);
|
|
|
|
}
|
2022-03-10 13:24:03 -05:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
$actions['download'] = sprintf(
|
|
|
|
'<a href="%s" aria-label="%s" download>%s</a>',
|
|
|
|
esc_url( $attachment_url ),
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Download “%s”' ), $att_title ) ),
|
|
|
|
__( 'Download file' )
|
|
|
|
);
|
2023-02-02 17:48:16 -05:00
|
|
|
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
if ( $this->detached && current_user_can( 'edit_post', $post->ID ) ) {
|
|
|
|
$actions['attach'] = sprintf(
|
|
|
|
'<a href="#the-list" onclick="findPosts.open( \'media[]\', \'%s\' ); return false;" class="hide-if-no-js aria-button-if-js" aria-label="%s">%s</a>',
|
|
|
|
$post->ID,
|
|
|
|
/* translators: %s: Attachment title. */
|
|
|
|
esc_attr( sprintf( __( 'Attach “%s” to existing content' ), $att_title ) ),
|
|
|
|
__( 'Attach' )
|
|
|
|
);
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2010-11-06 19:00:17 -04:00
|
|
|
|
2014-01-07 22:53:14 -05:00
|
|
|
/**
|
2016-05-22 14:01:30 -04:00
|
|
|
* Filters the action links for each attachment in the Media list table.
|
2014-01-07 22:53:14 -05:00
|
|
|
*
|
|
|
|
* @since 2.8.0
|
|
|
|
*
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param string[] $actions An array of action links for each attachment.
|
Media: Display the “Copy URL” and “Download file” row actions when the “Unattached” filter is applied.
Due to partially duplicated logic for displaying row actions in the Media Library with and without the “Unattached” filter, the “Copy URL” and “Download file” row actions were unintentionally missing with the filter applied.
This commit aims to simplify the logic and bring more consistency to the code.
Includes displaying the “Download file” row action even when the “Trash” filter is applied, giving the user one more chance to download the media file before they delete it.
Follow-up to [8901], [13100], [16227], [16229], [52842], [55198], [55221].
Props kebbet, costdev, pbiron, oglekler, SergeyBiryukov.
Fixes #57890, #57893.
Built from https://develop.svn.wordpress.org/trunk@55949
git-svn-id: http://core.svn.wordpress.org/trunk@55461 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2023-06-20 11:47:21 -04:00
|
|
|
* Includes 'Edit', 'Delete Permanently', 'View',
|
|
|
|
* 'Copy URL' and 'Download file'.
|
2018-03-22 16:27:32 -04:00
|
|
|
* @param WP_Post $post WP_Post object for the current attachment.
|
|
|
|
* @param bool $detached Whether the list table contains media not attached
|
|
|
|
* to any posts. Default true.
|
2014-01-07 22:53:14 -05:00
|
|
|
*/
|
2015-05-29 16:17:26 -04:00
|
|
|
return apply_filters( 'media_row_actions', $actions, $post, $this->detached );
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|
2015-06-16 15:47:24 -04:00
|
|
|
|
|
|
|
/**
|
2015-07-12 14:34:24 -04:00
|
|
|
* Generates and displays row action links.
|
2015-06-16 15:47:24 -04:00
|
|
|
*
|
|
|
|
* @since 4.3.0
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support.
|
2015-06-16 15:47:24 -04:00
|
|
|
*
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
* @param WP_Post $item Attachment being acted upon.
|
2020-10-17 12:05:09 -04:00
|
|
|
* @param string $column_name Current column name.
|
|
|
|
* @param string $primary Primary column name.
|
2020-01-11 12:59:04 -05:00
|
|
|
* @return string Row actions output for media attachments, or an empty string
|
|
|
|
* if the current column is not the primary column.
|
2015-06-16 15:47:24 -04:00
|
|
|
*/
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
protected function handle_row_actions( $item, $column_name, $primary ) {
|
2015-07-14 13:47:24 -04:00
|
|
|
if ( $primary !== $column_name ) {
|
|
|
|
return '';
|
2015-06-16 15:47:24 -04:00
|
|
|
}
|
2015-07-14 13:47:24 -04:00
|
|
|
|
|
|
|
$att_title = _draft_or_post_title();
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
$actions = $this->_get_row_actions(
|
|
|
|
$item, // WP_Post object for an attachment.
|
|
|
|
$att_title
|
|
|
|
);
|
2020-01-11 12:59:04 -05:00
|
|
|
|
Code Modernization: Fix parameter name mismatches for parent/child classes in `WP_List_Table::handle_row_actions()`.
Matches the method signatures of the parent class and each child class.
Why? PHP 8 introduces the ability to pass named arguments to function/method calls. This means the child and parent method signatures (i.e. parameter names) need to match.
For readability:
- `@since` clearly specifies the original parameter name and its new name as well as why the change happened
- in methods longer than a single line, the generic parameter is reassigned to the original parameter restoring it for context for use within the method. An inline comment is added to explain why this reassignment is made.
Follow-up to [32644], [32664], [32798], [38489], [49183], [49197].
Props jrf, hellofromTonya, sergeybiryukov, azaozz, desrosj, johnbillion.
See #51553.
Built from https://develop.svn.wordpress.org/trunk@51737
git-svn-id: http://core.svn.wordpress.org/trunk@51345 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2021-09-07 15:24:53 -04:00
|
|
|
return $this->row_actions( $actions );
|
2015-06-16 15:47:24 -04:00
|
|
|
}
|
2010-10-24 22:57:43 -04:00
|
|
|
}
|