Skip to content

Commit fc38e49

Browse files
committed
Real-time collaboration: Update "Join" action label in post list if lock expires
When RTC is enabled, let the "Join" action link in the post list turn into "Edit" after the post lock expires. Do this by rendering both "Edit" and "Join" as separate spans and toggling visibility via CSS using the `wp-collaborative-editing` class that heartbeat already manages. Do the same to aria-label with screen-reader-text spans so the accessible name stays in sync with the visible text across lock state changes. Developed in WordPress/wordpress-develop#11346. Follow-up to [62074]. Props shekharnwagh. See #64622. Built from https://develop.svn.wordpress.org/trunk@62146 git-svn-id: http://core.svn.wordpress.org/trunk@61428 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 9edf1b7 commit fc38e49

6 files changed

Lines changed: 64 additions & 20 deletions

File tree

wp-admin/css/list-tables-rtl.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,18 @@ tr.wp-locked .row-actions .trash {
640640
display: block;
641641
}
642642

643+
.join-action-text {
644+
display: none;
645+
}
646+
647+
.wp-collaborative-editing .edit-action-text {
648+
display: none;
649+
}
650+
651+
.wp-collaborative-editing .join-action-text {
652+
display: inline;
653+
}
654+
643655
#menu-locations-wrap .widefat {
644656
width: 60%;
645657
}

wp-admin/css/list-tables-rtl.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-admin/css/list-tables.css

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,18 @@ tr.wp-locked .row-actions .trash {
639639
display: block;
640640
}
641641

642+
.join-action-text {
643+
display: none;
644+
}
645+
646+
.wp-collaborative-editing .edit-action-text {
647+
display: none;
648+
}
649+
650+
.wp-collaborative-editing .join-action-text {
651+
display: inline;
652+
}
653+
642654
#menu-locations-wrap .widefat {
643655
width: 60%;
644656
}

wp-admin/css/list-tables.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

wp-admin/includes/class-wp-posts-list-table.php

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1491,24 +1491,44 @@ protected function handle_row_actions( $item, $column_name, $primary ) {
14911491
$title = _draft_or_post_title();
14921492

14931493
if ( $can_edit_post && 'trash' !== $post->post_status ) {
1494-
$is_rtc_locked = get_option( 'wp_collaboration_enabled' ) && wp_check_post_lock( $post->ID );
1494+
$is_rtc_enabled = (bool) get_option( 'wp_collaboration_enabled' );
14951495

1496-
$actions['edit'] = sprintf(
1497-
'<a href="%s" aria-label="%s">%s</a>',
1498-
get_edit_post_link( $post->ID ),
1499-
esc_attr(
1500-
sprintf(
1501-
$is_rtc_locked
1502-
/* translators: %s: Post title. */
1503-
? __( 'Join editing &#8220;%s&#8221;', 'post list' )
1504-
/* translators: %s: Post title. */
1505-
: __( 'Edit &#8220;%s&#8221;' ),
1506-
$title
1507-
)
1508-
),
1509-
/* translators: Action link text for a singular post in the post list. Can be any type of post. */
1510-
$is_rtc_locked ? _x( 'Join', 'post list' ) : __( 'Edit' )
1511-
);
1496+
/*
1497+
* When RTC is enabled, both "Edit" and "Join" labels are rendered.
1498+
* The visible label is toggled by CSS based on the row's
1499+
* `wp-collaborative-editing` class, which is added or removed by
1500+
* inline-edit-post.js in response to heartbeat ticks.
1501+
*/
1502+
if ( $is_rtc_enabled ) {
1503+
$actions['edit'] = sprintf(
1504+
'<a href="%1$s">'
1505+
. '<span class="edit-action-text">'
1506+
. '<span aria-hidden="true">%2$s</span>'
1507+
. '<span class="screen-reader-text">%3$s</span>'
1508+
. '</span>'
1509+
. '<span class="join-action-text">'
1510+
. '<span aria-hidden="true">%4$s</span>'
1511+
. '<span class="screen-reader-text">%5$s</span>'
1512+
. '</span>'
1513+
. '</a>',
1514+
get_edit_post_link( $post->ID ),
1515+
__( 'Edit' ),
1516+
/* translators: %s: Post title. */
1517+
sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ),
1518+
/* translators: Action link text for a singular post in the post list. Can be any type of post. */
1519+
_x( 'Join', 'post list' ),
1520+
/* translators: %s: Post title. */
1521+
sprintf( __( 'Join editing &#8220;%s&#8221;', 'post list' ), $title )
1522+
);
1523+
} else {
1524+
$actions['edit'] = sprintf(
1525+
'<a href="%s" aria-label="%s">%s</a>',
1526+
get_edit_post_link( $post->ID ),
1527+
/* translators: %s: Post title. */
1528+
esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ),
1529+
__( 'Edit' )
1530+
);
1531+
}
15121532

15131533
/**
15141534
* Filters whether Quick Edit should be enabled for the given post type.

wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.0-RC1-62145';
19+
$wp_version = '7.0-RC1-62146';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)