diff --git a/src/wp-admin/includes/class-wp-comments-list-table.php b/src/wp-admin/includes/class-wp-comments-list-table.php
index 904a2dce47..38d7ed36ee 100644
|
a
|
b
|
class WP_Comments_List_Table extends WP_List_Table { |
| 124 | 124 | $start += $_REQUEST['offset']; |
| 125 | 125 | } |
| 126 | 126 | |
| | 127 | if ( ! empty( $_REQUEST['mode'] ) ) { |
| | 128 | $mode = 'extended' === $_REQUEST['mode'] ? 'extended' : 'list'; |
| | 129 | set_user_setting( 'posts_list_mode', $mode ); |
| | 130 | } else { |
| | 131 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 132 | } |
| | 133 | |
| 127 | 134 | $status_map = array( |
| 128 | 135 | 'mine' => '', |
| 129 | 136 | 'moderated' => 'hold', |
| … |
… |
class WP_Comments_List_Table extends WP_List_Table { |
| 751 | 758 | /** This filter is documented in wp-admin/includes/dashboard.php */ |
| 752 | 759 | $actions = apply_filters( 'comment_row_actions', array_filter( $actions ), $comment ); |
| 753 | 760 | |
| | 761 | $always_visible = false; |
| | 762 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 763 | if ( 'extended' === $mode ) { |
| | 764 | $always_visible = true; |
| | 765 | } |
| | 766 | |
| 754 | 767 | $i = 0; |
| 755 | | $out .= '<div class="row-actions">'; |
| | 768 | $out .= '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 756 | 769 | foreach ( $actions as $action => $link ) { |
| 757 | 770 | ++$i; |
| 758 | 771 | ( ( ( 'approve' === $action || 'unapprove' === $action ) && 2 === $i ) || 1 === $i ) ? $sep = '' : $sep = ' | '; |
diff --git a/src/wp-admin/includes/class-wp-list-table.php b/src/wp-admin/includes/class-wp-list-table.php
index e6d829e39f..a2851203e1 100644
|
a
|
b
|
class WP_List_Table { |
| 166 | 166 | |
| 167 | 167 | if ( empty( $this->modes ) ) { |
| 168 | 168 | $this->modes = array( |
| 169 | | 'list' => __( 'List View' ), |
| 170 | | 'excerpt' => __( 'Excerpt View' ), |
| | 169 | 'list' => __( 'Compact View' ), |
| | 170 | 'extended' => __( 'Extended View' ), |
| 171 | 171 | ); |
| 172 | 172 | } |
| 173 | 173 | } |
| … |
… |
class WP_List_Table { |
| 523 | 523 | return ''; |
| 524 | 524 | } |
| 525 | 525 | |
| | 526 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 527 | if ( 'extended' === $mode ) { |
| | 528 | $always_visible = true; |
| | 529 | } |
| | 530 | |
| 526 | 531 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 527 | 532 | foreach ( $actions as $action => $link ) { |
| 528 | 533 | ++$i; |
| … |
… |
class WP_List_Table { |
| 1247 | 1252 | * @return string[] Array of CSS classes for the table tag. |
| 1248 | 1253 | */ |
| 1249 | 1254 | protected function get_table_classes() { |
| 1250 | | return array( 'widefat', 'fixed', 'striped', $this->_args['plural'] ); |
| | 1255 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 1256 | $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-list'; |
| | 1257 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 1258 | /** |
| | 1259 | * Filters the current view mode. |
| | 1260 | * |
| | 1261 | * @since 5.5.0 |
| | 1262 | * |
| | 1263 | * @param string $mode The current selected mode. Default value of |
| | 1264 | * posts_list_mode user setting. |
| | 1265 | */ |
| | 1266 | $mode = apply_filters( 'table_view_mode', $mode ); |
| | 1267 | |
| | 1268 | $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-' . $mode; |
| | 1269 | |
| | 1270 | return array( 'widefat', 'fixed', 'striped', $mode_class, $this->_args['plural'] ); |
| 1251 | 1271 | } |
| 1252 | 1272 | |
| 1253 | 1273 | /** |
diff --git a/src/wp-admin/includes/class-wp-posts-list-table.php b/src/wp-admin/includes/class-wp-posts-list-table.php
index 141ca89a58..b3d9e7da31 100644
|
a
|
b
|
class WP_Posts_List_Table extends WP_List_Table { |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | if ( ! empty( $_REQUEST['mode'] ) ) { |
| 181 | | $mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; |
| | 181 | $mode = 'extended' === $_REQUEST['mode'] ? 'extended' : 'list'; |
| 182 | 182 | set_user_setting( 'posts_list_mode', $mode ); |
| 183 | 183 | } else { |
| 184 | 184 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| … |
… |
class WP_Posts_List_Table extends WP_List_Table { |
| 598 | 598 | * @return array |
| 599 | 599 | */ |
| 600 | 600 | protected function get_table_classes() { |
| 601 | | return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
| | 601 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 602 | $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-list'; |
| | 603 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 604 | /** |
| | 605 | * Filters the current view mode. |
| | 606 | * |
| | 607 | * @since 5.5.0 |
| | 608 | * |
| | 609 | * @param string $mode The current selected mode. Default value of |
| | 610 | * posts_list_mode user setting. |
| | 611 | */ |
| | 612 | $mode = apply_filters( 'table_view_mode', $mode ); |
| | 613 | |
| | 614 | $mode_class = 'extended' === $mode ? 'table-view-extended' : 'table-view-' . $mode; |
| | 615 | |
| | 616 | return array( 'widefat', 'fixed', 'striped', $mode_class, is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
| 602 | 617 | } |
| 603 | 618 | |
| 604 | 619 | /** |
| … |
… |
class WP_Posts_List_Table extends WP_List_Table { |
| 1042 | 1057 | } |
| 1043 | 1058 | echo "</strong>\n"; |
| 1044 | 1059 | |
| 1045 | | if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) { |
| | 1060 | if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'extended' === $mode && current_user_can( 'read_post', $post->ID ) ) { |
| 1046 | 1061 | if ( post_password_required( $post ) ) { |
| 1047 | 1062 | echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; |
| 1048 | 1063 | } else { |
| … |
… |
class WP_Posts_List_Table extends WP_List_Table { |
| 1102 | 1117 | * @param string $status The status text. |
| 1103 | 1118 | * @param WP_Post $post Post object. |
| 1104 | 1119 | * @param string $column_name The column name. |
| 1105 | | * @param string $mode The list display mode ('excerpt' or 'list'). |
| | 1120 | * @param string $mode The list display mode ('extended' or 'list'). |
| 1106 | 1121 | */ |
| 1107 | 1122 | $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); |
| 1108 | 1123 | |
| … |
… |
class WP_Posts_List_Table extends WP_List_Table { |
| 1121 | 1136 | * @param string $t_time The published time. |
| 1122 | 1137 | * @param WP_Post $post Post object. |
| 1123 | 1138 | * @param string $column_name The column name. |
| 1124 | | * @param string $mode The list display mode ('excerpt' or 'list'). |
| | 1139 | * @param string $mode The list display mode ('extended' or 'list'). |
| 1125 | 1140 | */ |
| 1126 | 1141 | echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
| 1127 | 1142 | } |
| … |
… |
class WP_Posts_List_Table extends WP_List_Table { |
| 1491 | 1506 | } |
| 1492 | 1507 | } |
| 1493 | 1508 | |
| 1494 | | $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
| | 1509 | $m = ( isset( $mode ) && 'extended' === $mode ) ? 'extended' : 'list'; |
| 1495 | 1510 | $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
| 1496 | 1511 | $core_columns = array( |
| 1497 | 1512 | 'cb' => true, |
diff --git a/src/wp-admin/includes/class-wp-screen.php b/src/wp-admin/includes/class-wp-screen.php
index e3a2fcd7a6..dace397437 100644
|
a
|
b
|
final class WP_Screen { |
| 1288 | 1288 | public function render_view_mode() { |
| 1289 | 1289 | $screen = get_current_screen(); |
| 1290 | 1290 | |
| 1291 | | // Currently only enabled for posts lists. |
| 1292 | | if ( 'edit' !== $screen->base ) { |
| | 1291 | // Currently only enabled for posts and comments lists. |
| | 1292 | if ( 'edit' !== $screen->base && 'edit-comments' !== $screen->base ) { |
| 1293 | 1293 | return; |
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | | $view_mode_post_types = get_post_types( |
| 1297 | | array( |
| 1298 | | 'hierarchical' => false, |
| 1299 | | 'show_ui' => true, |
| 1300 | | ) |
| 1301 | | ); |
| | 1296 | $view_mode_post_types = get_post_types( array( 'show_ui' => true ) ); |
| 1302 | 1297 | |
| 1303 | 1298 | /** |
| 1304 | 1299 | * Filters the post types that have different view mode options. |
| … |
… |
final class WP_Screen { |
| 1306 | 1301 | * @since 4.4.0 |
| 1307 | 1302 | * |
| 1308 | 1303 | * @param string[] $view_mode_post_types Array of post types that can change view modes. |
| 1309 | | * Default non-hierarchical post types with show_ui on. |
| | 1304 | * Default post types with show_ui on. |
| 1310 | 1305 | */ |
| 1311 | 1306 | $view_mode_post_types = apply_filters( 'view_mode_post_types', $view_mode_post_types ); |
| 1312 | 1307 | |
| 1313 | | if ( ! in_array( $this->post_type, $view_mode_post_types, true ) ) { |
| | 1308 | if ( 'edit' === $screen->base && ! in_array( $this->post_type, $view_mode_post_types, true ) ) { |
| 1314 | 1309 | return; |
| 1315 | 1310 | } |
| 1316 | 1311 | |
| 1317 | | global $mode; |
| | 1312 | $mode = get_user_setting( 'posts_list_mode', 'list' ); |
| | 1313 | |
| | 1314 | // Set 'list' as default value if $mode is not set. |
| | 1315 | $mode = ( isset( $mode ) && 'extended' === $mode ) ? 'extended' : 'list'; |
| | 1316 | |
| | 1317 | /** |
| | 1318 | * Filters the current view mode. |
| | 1319 | * |
| | 1320 | * @since 5.5.0 |
| | 1321 | * |
| | 1322 | * @param string $mode The current selected mode. Default value of |
| | 1323 | * posts_list_mode user setting. |
| | 1324 | */ |
| | 1325 | $mode = apply_filters( 'table_view_mode', $mode ); |
| 1318 | 1326 | |
| 1319 | 1327 | // This needs a submit button. |
| 1320 | 1328 | add_filter( 'screen_options_show_submit', '__return_true' ); |
| … |
… |
final class WP_Screen { |
| 1323 | 1331 | <legend><?php _e( 'View Mode' ); ?></legend> |
| 1324 | 1332 | <label for="list-view-mode"> |
| 1325 | 1333 | <input id="list-view-mode" type="radio" name="mode" value="list" <?php checked( 'list', $mode ); ?> /> |
| 1326 | | <?php _e( 'List View' ); ?> |
| | 1334 | <?php _e( 'Compact view' ); ?> |
| 1327 | 1335 | </label> |
| 1328 | 1336 | <label for="excerpt-view-mode"> |
| 1329 | | <input id="excerpt-view-mode" type="radio" name="mode" value="excerpt" <?php checked( 'excerpt', $mode ); ?> /> |
| 1330 | | <?php _e( 'Excerpt View' ); ?> |
| | 1337 | <input id="excerpt-view-mode" type="radio" name="mode" value="extended" <?php checked( 'extended', $mode ); ?> /> |
| | 1338 | <?php _e( 'Extended View' ); ?> |
| 1331 | 1339 | </label> |
| | 1340 | <?php |
| | 1341 | /** |
| | 1342 | * Fires at the end of the table view modes screen option. |
| | 1343 | * |
| | 1344 | * @since 5.5.0 |
| | 1345 | * |
| | 1346 | * @param string $mode The currently selected mode. |
| | 1347 | */ |
| | 1348 | do_action( 'wp_table_view_modes', $mode ); |
| | 1349 | ?> |
| 1332 | 1350 | </fieldset> |
| 1333 | 1351 | <?php |
| 1334 | 1352 | } |