Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
WP Revisions Control
Manage
Activity
Members
Labels
Plan
Issues
3
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
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
7fd8e1a6
Commit
7fd8e1a6
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
PHPDoc
parent
b8edc98b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
wp-revisions-control.php
+38
-1
38 additions, 1 deletion
wp-revisions-control.php
with
38 additions
and
1 deletion
wp-revisions-control.php
+
38
−
1
View file @
7fd8e1a6
...
...
@@ -71,7 +71,15 @@ class WP_Revisions_Control {
}
/**
* Register plugin's settings fields
*
* @uses register_setting
* @uses add_settings_section
* @uses __
* @uses this::get_post_types
* @uses add_settings_field
* @action admin_init
* @return null
*/
public
function
action_admin_init
()
{
register_setting
(
$this
->
settings_page
,
$this
->
settings_section
,
array
(
$this
,
'sanitize_options'
)
);
...
...
@@ -84,7 +92,10 @@ class WP_Revisions_Control {
}
/**
* Display assistive text in settings section
*
* @uses _e
* @return string
*/
public
function
settings_section_intro
()
{
?>
...
...
@@ -94,17 +105,25 @@ class WP_Revisions_Control {
}
/**
* Render field for each post type
*
* @param array $args
* @uses this::get_revisions_to_keep
* @uses esc_attr
* @return string
*/
public
function
field_post_type
(
$args
)
{
$revisions_to_keep
=
$this
->
get_revisions_to_keep
(
$args
[
'post_type'
],
true
);
?>
<input
type=
"text"
name=
"
<?php
echo
$this
->
settings_section
.
'['
.
$args
[
'post_type'
]
.
']'
;
?>
"
value=
"
<?php
echo
esc_attr
(
$revisions_to_keep
);
?>
"
class=
"small-text"
/>
<input
type=
"text"
name=
"
<?php
echo
esc_attr
(
$this
->
settings_section
.
'['
.
$args
[
'post_type'
]
.
']'
)
;
?>
"
value=
"
<?php
echo
esc_attr
(
$revisions_to_keep
);
?>
"
class=
"small-text"
/>
<?php
}
/**
* Sanitize plugin settings
*
* @param array $options
* @return array
*/
public
function
sanitize_options
(
$options
)
{
$options_sanitized
=
array
();
...
...
@@ -128,7 +147,12 @@ class WP_Revisions_Control {
}
/**
* Override number of revisions to keep using plugin's settings
*
* @uses get_post_type
* @uses this::get_settings
* @filter wp_revisions_to_keep
* @return mixed
*/
public
function
filter_wp_revisions_to_keep
(
$qty
,
$post
)
{
$post_type
=
get_post_type
(
$post
)
?
get_post_type
(
$post
)
:
$post
->
post_type
;
...
...
@@ -141,7 +165,11 @@ class WP_Revisions_Control {
}
/**
* Retrieve plugin settings
*
* @uses this::get_post_types
* @uses get_option
* @return array
*/
private
function
get_settings
()
{
$post_types
=
$this
->
get_post_types
();
...
...
@@ -161,7 +189,12 @@ class WP_Revisions_Control {
}
/**
* Retrieve array of supported post types and their labels
*
* @uses get_post_types
* @uses post_type_supports
* @uses get_post_type_object
* @return array
*/
private
function
get_post_types
()
{
if
(
empty
(
self
::
$post_types
)
)
{
...
...
@@ -187,7 +220,11 @@ class WP_Revisions_Control {
}
/**
* Retrieve number of revisions to keep for a given post type
*
* @uses WP_Post
* @uses wp_revisions_to_keep
* @return mixed
*/
private
function
get_revisions_to_keep
(
$post_type
,
$blank_for_all
=
false
)
{
// wp_revisions_to_keep() accepts a post object, not just the post type
...
...
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