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
cbd0da5d
Commit
cbd0da5d
authored
11 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Start of Ajax handling to purge a post's revisions on demand.
See
#1
.
parent
3c397043
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
js/post.js
+54
-0
54 additions, 0 deletions
js/post.js
wp-revisions-control.php
+12
-1
12 additions, 1 deletion
wp-revisions-control.php
with
66 additions
and
1 deletion
js/post.js
0 → 100644
+
54
−
0
View file @
cbd0da5d
(
function
(
$
)
{
$
(
document
).
ready
(
function
()
{
var
purge_button
=
$
(
'
#wp_revisions_control .button.purge
'
),
post_id
=
null
,
nonce
=
null
,
button_text
=
null
;
$
(
purge_button
).
on
(
'
click
'
,
click_handler_purge
);
/**
*
*/
function
click_handler_purge
()
{
post_id
=
parseInt
(
$
(
this
).
data
(
'
postid
'
)
);
button_text
=
$
(
purge_button
).
text
();
$
(
purge_button
).
text
(
wp_revisions_control
.
processing_text
);
var
confirmed
=
confirm
(
wp_revisions_control
.
ays
);
if
(
confirmed
&&
post_id
)
{
$
.
ajax
({
url
:
ajaxurl
,
cache
:
false
,
data
:
{
action
:
wp_revisions_control
.
processing_text
+
'
_purge
'
,
post_id
:
post_id
,
nonce
:
$
(
this
).
data
(
'
nonce
'
)
},
type
:
'
post
'
,
success
:
ajax_request_success
,
error
:
ajax_request_error
});
}
else
{
$
(
purge_button
).
text
(
button_text
);
}
}
/**
*
*/
function
ajax_request_success
()
{
console
.
log
(
'
Yippee
'
);
$
(
purge_button
).
text
(
button_text
);
}
/**
*
*/
function
ajax_request_error
()
{
console
.
log
(
'
Sad panda
'
);
}
}
);
}
)(
jQuery
);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
wp-revisions-control.php
+
12
−
1
View file @
cbd0da5d
...
...
@@ -232,8 +232,17 @@ class WP_Revisions_Control {
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
)
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'
);
$handle
=
'wp-revisions-control-post'
;
wp_enqueue_script
(
$handle
,
plugins_url
(
'js/post.js'
,
__FILE__
),
array
(
'jquery'
),
'20130706'
,
true
);
wp_localize_script
(
$handle
,
$this
->
settings_section
,
array
(
'action_base'
=>
$this
->
settings_section
,
'processing_text'
=>
__
(
'Processing…'
,
'wp_revisions_control'
),
'ays'
=>
__
(
'Are you sure?'
,
'wp_revisions_control'
)
)
);
}
}
/**
...
...
@@ -245,6 +254,8 @@ class WP_Revisions_Control {
?>
<div
id=
"
<?php
echo
esc_attr
(
$this
->
settings_section
);
?>
"
>
<h4>
WP Revisions Control
</h4>
<span
class=
"button purge"
data-postid=
"
<?php
the_ID
();
?>
"
data-nonce=
"
<?php
echo
esc_attr
(
wp_create_nonce
(
$this
->
settings_section
.
'_purge'
)
);
?>
_purge"
>
<?php
_e
(
'Purge these revisions'
,
'wp_revisions_control'
);
?>
</span>
</div>
<!-- #
<?php
echo
esc_attr
(
$this
->
settings_section
);
?>
-->
<?php
}
...
...
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