Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
WP Revisions Control
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WP Plugins
WP Revisions Control
Commits
bfbfd2dc
Commit
bfbfd2dc
authored
4 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Exclude metabox from Gutenberg-enabled posts
parent
35d2ce2a
Branches
Branches containing commit
No related tags found
1 merge request
!12
Introduce native Gutenberg controls
Pipeline
#3533
passed
4 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
inc/class-wp-revisions-control.php
+45
-38
45 additions, 38 deletions
inc/class-wp-revisions-control.php
with
45 additions
and
38 deletions
inc/class-wp-revisions-control.php
+
45
−
38
View file @
bfbfd2dc
...
...
@@ -275,48 +275,55 @@ class WP_Revisions_Control {
/**
* Override Core's revisions metabox.
*
* @param string $post_type Post type.
* @param
objec
t $post Post object.
* @param string
$post_type Post type.
* @param
\WP_Pos
t $post Post object.
*/
public
function
action_add_meta_boxes
(
$post_type
,
$post
)
{
if
(
post_type_supports
(
$post_type
,
'revisions'
)
&&
'auto-draft'
!==
get_post_status
()
&&
count
(
wp_get_post_revisions
(
$post
)
)
>
1
)
{
// Replace the metabox.
remove_meta_box
(
'revisionsdiv'
,
null
,
'normal'
);
add_meta_box
(
'revisionsdiv-wp-rev-ctl'
,
__
(
'Revisions'
,
'wp_revisions_control'
),
array
(
$this
,
'revisions_meta_box'
,
),
null
,
'normal'
,
'core'
);
if
(
use_block_editor_for_post
(
$post
)
||
!
post_type_supports
(
$post_type
,
'revisions'
)
||
'auto-draft'
===
get_post_status
()
||
count
(
wp_get_post_revisions
(
$post
)
)
<
1
)
{
return
;
}
//
A bit of JS for us
.
$handle
=
'wp-revisions-control-post'
;
wp_enqueue_script
(
$handle
,
plugins_url
(
'js/post.js'
,
__DIR__
),
array
(
'jquery'
),
'20131205'
,
true
);
wp_localize_script
(
$handle
,
$this
->
settings_sect
ion
,
array
(
'namespace'
=>
$this
->
settings_section
,
'action_base'
=>
$this
->
settings_section
,
'processing_text'
=>
__
(
'Processing…'
,
'wp_revisions_control'
)
,
'ays'
=>
__
(
'Are you sure you want to remove revisions from this post?'
,
'wp_revisions_control'
)
,
'autosave'
=>
__
(
'Autosave'
,
'wp_revisions_control'
),
'nothing_text'
=>
wpautop
(
__
(
'There are no revisions to remove.'
,
'wp_revisions_control'
)
)
,
'error'
=>
__
(
'An error occurred. Please refresh the page and try again.'
,
'wp_revisions_control'
)
,
)
);
//
Replace the metabox
.
remove_meta_box
(
'revisionsdiv'
,
null
,
'normal'
)
;
add_meta_box
(
'revisionsdiv-wp-rev-ctl'
,
__
(
'Revis
ion
s'
,
'wp_revisions_control'
)
,
array
(
$this
,
'revisions_meta_box'
,
),
null
,
'normal'
,
'core'
);
// Add some styling to our metabox additions.
add_action
(
'admin_head'
,
array
(
$this
,
'action_admin_head'
),
999
);
}
// A bit of JS for us.
$handle
=
'wp-revisions-control-post'
;
wp_enqueue_script
(
$handle
,
plugins_url
(
'js/post.js'
,
__DIR__
),
array
(
'jquery'
),
'20131205'
,
true
);
wp_localize_script
(
$handle
,
$this
->
settings_section
,
array
(
'namespace'
=>
$this
->
settings_section
,
'action_base'
=>
$this
->
settings_section
,
'processing_text'
=>
__
(
'Processing…'
,
'wp_revisions_control'
),
'ays'
=>
__
(
'Are you sure you want to remove revisions from this post?'
,
'wp_revisions_control'
),
'autosave'
=>
__
(
'Autosave'
,
'wp_revisions_control'
),
'nothing_text'
=>
wpautop
(
__
(
'There are no revisions to remove.'
,
'wp_revisions_control'
)
),
'error'
=>
__
(
'An error occurred. Please refresh the page and try again.'
,
'wp_revisions_control'
),
)
);
// Add some styling to our metabox additions.
add_action
(
'admin_head'
,
array
(
$this
,
'action_admin_head'
),
999
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment