-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable post locking in Gutenberg #4217
Changes from 71 commits
4f38c60
8578fc7
b370721
940f338
18290b2
aa301d2
fbf7d08
e387b39
3a3deb9
6980a89
810119d
c510e37
a9d7922
60c6ccc
c611a7b
7f35914
ca38176
a5d1764
fd8e941
3b500f9
f4aa602
2c3aecc
68f2099
0905e1a
f669682
5515ba1
6fda398
3157fc2
413e75b
d79f3ca
825e0a5
27f45dc
5213a7c
ca04b3d
d48e0f5
9f8882d
ad0c4ae
c2e6d74
560222f
b5c1d48
1514d06
ab79301
784d618
c0a7b53
e5d10d9
a8415e3
9b94b5d
3dfd55b
434f9ff
836ba7a
28490b6
e37b9d5
f168ed3
08f13e6
d7062a0
4efcff1
73c9bc5
d2a971e
c15bddc
30eb346
dcdcd5b
4816d72
4d1437d
c515d54
809a86b
4436ec3
b674cf7
31a5032
cc37e6a
6818df1
2c1fcf0
7e2119e
a7987b8
b9aac75
b7ff092
0476023
ca9fa60
95f5f5c
c03878f
7cdb082
42e45dc
a0c57de
aad9b92
0534539
8d071c1
5d767cb
7e60a81
17803ec
6f30da2
52cb1e6
4b633d8
8378bbe
f6bb6e9
e32ac81
72c15e3
8090483
17a80e1
9315785
6744619
24d9aef
ef2a42c
dff9ec9
5a7f787
93aa165
4f3e67d
413458c
1f53d95
f6d5fc1
d22b48b
10bd363
008872b
6afbc96
3d84894
9611023
1fee125
6bc1196
240f3e7
719175b
f89696c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,8 +24,15 @@ | |
* @since 0.1.0 | ||
*/ | ||
function the_gutenberg_project() { | ||
global $post_type_object; | ||
?> | ||
global $post_type_object, $post; | ||
|
||
if ( ! wp_check_post_lock( $post->ID ) ) { | ||
$active_post_lock = wp_set_post_lock( $post->ID ); | ||
} | ||
|
||
if ( ! empty( $active_post_lock ) ) { ?> | ||
<input type="hidden" id="active_post_lock" value="<?php echo esc_attr( implode( ':', $active_post_lock ) ); ?>" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason to render this in PHP? Can't we render it in JS instead? That way we can keep it in sync using the state? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is essentially used to pass the locking info from php to JS which I already handle directly so i can probably drop this bit (and track the data in state as you suggested above) |
||
<?php } ?> | ||
<div class="gutenberg"> | ||
<h1 class="screen-reader-text"><?php echo esc_html( $post_type_object->labels->edit_item ); ?></h1> | ||
<div id="editor" class="gutenberg__editor"></div> | ||
|
@@ -437,3 +444,15 @@ function toggleDropdown() { | |
function gutenberg_add_admin_body_class( $classes ) { | ||
return "$classes gutenberg-editor-page"; | ||
} | ||
|
||
/** | ||
* Ensure heartbeat interval is low enough to work for post locking. | ||
youknowriad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
* | ||
* @param array $settings Settings. | ||
* @return array Filtered settings. | ||
*/ | ||
function wp_heartbeat_settings_gutenberg( $settings ) { | ||
$settings['interval'] = 15; | ||
return $settings; | ||
} | ||
add_filter( 'heartbeat_settings', 'wp_heartbeat_settings_gutenberg' ); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n'; | |
*/ | ||
import IconButton from '../icon-button'; | ||
|
||
const ModalHeader = ( { icon, title, onClose, closeLabel, headingId } ) => { | ||
const ModalHeader = ( { icon, title, onClose, closeLabel, headingId, isDismissable } ) => { | ||
const label = closeLabel ? closeLabel : __( 'Close dialog' ); | ||
|
||
return ( | ||
|
@@ -18,7 +18,7 @@ const ModalHeader = ( { icon, title, onClose, closeLabel, headingId } ) => { | |
<div className="components-modal__header-heading-container"> | ||
{ icon && | ||
<span className="components-modal__icon-container" aria-hidden> | ||
{ icon } | ||
{ icon && <img alt={ __( 'User avatar' ) } src={ icon } /> } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this is specific to the Post Locking behavior and shouldn't be baked into the generic Modal component. Can't we just pass the entire There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, unless the icon should always have an alt tag for accessibility reasons, maybe it makes more sense to add and require an |
||
</span> | ||
} | ||
{ title && | ||
|
@@ -28,11 +28,13 @@ const ModalHeader = ( { icon, title, onClose, closeLabel, headingId } ) => { | |
</h1> | ||
} | ||
</div> | ||
<IconButton | ||
onClick={ onClose } | ||
icon="no-alt" | ||
label={ label } | ||
/> | ||
{ isDismissable && | ||
<IconButton | ||
onClick={ onClose } | ||
icon="no-alt" | ||
label={ label } | ||
/> | ||
} | ||
</div> | ||
); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably a useless change.