Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WP Plugins
WP Revisions Control
Commits
3c397043
Commit
3c397043
authored
Jul 06, 2013
by
Erick Hitter
Browse files
Beginning of post-specific controls. So far, only overriding the metabox to add our things to.
See
#1
.
parent
278ed54d
Changes
1
Hide whitespace changes
Inline
Side-by-side
wp-revisions-control.php
View file @
3c397043
...
...
@@ -86,7 +86,7 @@ class WP_Revisions_Control {
}
/**
* Register plugin's settings fields
* Register plugin's settings fields
and meta box
*
* Plugin title is intentionally not translatable.
*
...
...
@@ -99,6 +99,7 @@ class WP_Revisions_Control {
* @return null
*/
public
function
action_admin_init
()
{
// Plugin setting section
register_setting
(
$this
->
settings_page
,
$this
->
settings_section
,
array
(
$this
,
'sanitize_options'
)
);
add_settings_section
(
$this
->
settings_section
,
'WP Revisions Control'
,
array
(
$this
,
'settings_section_intro'
),
$this
->
settings_page
);
...
...
@@ -106,6 +107,9 @@ class WP_Revisions_Control {
foreach
(
$this
->
get_post_types
()
as
$post_type
=>
$name
)
{
add_settings_field
(
$this
->
settings_section
.
'-'
.
$post_type
,
$name
,
array
(
$this
,
'field_post_type'
),
$this
->
settings_page
,
$this
->
settings_section
,
array
(
'post_type'
=>
$post_type
)
);
}
// Post-level functionality
add_action
(
'add_meta_boxes'
,
array
(
$this
,
'action_add_meta_boxes'
),
10
,
2
);
}
/**
...
...
@@ -213,6 +217,38 @@ class WP_Revisions_Control {
return
$qty
;
}
/**
** POST-LEVEL FUNCTIONALITY
**/
/**
* Override Core's revisions metabox
*
* @param string $post_type
* @param object $post
* @action add_meta_boxes
* @return null
*/
public
function
action_add_meta_boxes
(
$post_type
,
$post
)
{
remove_meta_box
(
'revisionsdiv'
,
null
,
'normal'
);
if
(
post_type_supports
(
$post_type
,
'revisions'
)
&&
'auto-draft'
!=
get_post_status
()
&&
count
(
wp_get_post_revisions
(
$post
)
)
>
1
)
add_meta_box
(
'revisionsdiv-wp-rev-ctl'
,
__
(
'Revisions'
),
array
(
$this
,
'revisions_meta_box'
),
null
,
'normal'
,
'core'
);
}
/**
*
*/
public
function
revisions_meta_box
(
$post
)
{
post_revisions_meta_box
(
$post
);
?>
<div
id=
"
<?php
echo
esc_attr
(
$this
->
settings_section
);
?>
"
>
<h4>
WP Revisions Control
</h4>
</div>
<!-- #
<?php
echo
esc_attr
(
$this
->
settings_section
);
?>
-->
<?php
}
/**
** PLUGIN UTILITIES
**/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment