Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
Bulk Actions Cron Offload
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
Bulk Actions Cron Offload
Commits
430910ab
Commit
430910ab
authored
8 years ago
by
Erick Hitter
Browse files
Options
Downloads
Patches
Plain Diff
Scaffolding to intercept bulk-edit request
parent
e9586c65
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bulk-edit-cron-offload.php
+4
-0
4 additions, 0 deletions
bulk-edit-cron-offload.php
includes/abstract-class-singleton.php
+33
-0
33 additions, 0 deletions
includes/abstract-class-singleton.php
includes/class-main.php
+129
-5
129 additions, 5 deletions
includes/class-main.php
with
166 additions
and
5 deletions
bulk-edit-cron-offload.php
+
4
−
0
View file @
430910ab
...
...
@@ -10,4 +10,8 @@
namespace
Automattic\WP\Bulk_Edit_Cron_Offload
;
// Plugin dependencies
require
__DIR__
.
'/includes/abstract-class-singleton.php'
;
// Plugin functionality
require
__DIR__
.
'/includes/class-main.php'
;
This diff is collapsed.
Click to expand it.
includes/abstract-class-singleton.php
0 → 100644
+
33
−
0
View file @
430910ab
<?php
namespace
Automattic\WP\Bulk_Edit_Cron_Offload
;
abstract
class
Singleton
{
/**
* Class instance
*/
private
static
$__instances
=
array
();
public
static
function
instance
()
{
$caller
=
get_called_class
();
if
(
!
isset
(
self
::
$__instances
[
$caller
]
)
)
{
self
::
$__instances
[
$caller
]
=
new
$caller
();
self
::
$__instances
[
$caller
]
->
class_init
();
}
return
self
::
$__instances
[
$caller
];
}
protected
function
__construct
()
{}
/**
* PLUGIN SETUP
*/
/**
* Register hooks
*/
protected
function
class_init
()
{}
}
This diff is collapsed.
Click to expand it.
includes/class-main.php
+
129
−
5
View file @
430910ab
...
...
@@ -2,13 +2,137 @@
namespace
Automattic\WP\Bulk_Edit_Cron_Offload
;
class
Main
{
class
Main
extends
Singleton
{
/**
*
*
Requested action
*/
static
function
load
()
{
// filters!
private
$action
=
null
;
/**
* Posts to process
*/
private
$posts
=
null
;
/**
* Taxonomy terms to add
*/
private
$tax_input
=
null
;
/**
* Post author to set
*/
private
$post_author
=
null
;
/**
* Comment status to set
*/
private
$comment_status
=
null
;
/**
* Ping status to set
*/
private
$ping_status
=
null
;
/**
* New post status
*/
private
$post_status
=
null
;
/**
* Posts' stick status
*/
private
$post_sticky
=
null
;
/**
* Posts' format
*/
private
$post_format
=
null
;
/**
* Register action
*/
public
function
class_init
()
{
add_action
(
'load-edit.php'
,
array
(
$this
,
'intercept'
)
);
}
/**
* Call appropriate handler
*/
public
function
intercept
()
{
// Nothing to do
if
(
!
isset
(
$_REQUEST
[
'action'
]
)
)
{
return
;
}
// Parse request to determine what to do
$this
->
populate_vars
();
// Now what?
switch
(
$this
->
action
)
{
case
'delete_all'
:
break
;
case
'trash'
:
break
;
case
'untrash'
:
break
;
case
'delete'
:
break
;
case
'edit'
:
break
;
// How did you get here?
default
:
return
;
break
;
}
}
/**
* Capture relevant variables to be stored in cron events
*/
private
function
populate_vars
()
{
$this
->
action
=
$_REQUEST
[
'action'
];
if
(
isset
(
$_REQUEST
[
'post'
]
)
&&
is_array
(
$_REQUEST
[
'post'
]
)
)
{
$this
->
posts
=
array_map
(
'absint'
,
$_REQUEST
[
'post'
]
);
}
if
(
isset
(
$_REQUEST
[
'tax_input'
]
)
&&
is_array
(
$_REQUEST
[
'tax_input'
]
)
)
{
$this
->
tax_input
=
$_REQUEST
[
'tax_input'
];
}
if
(
isset
(
$_REQUEST
[
'post_author'
]
)
&&
-
1
===
(
int
)
$_REQUEST
[
'post_author'
]
)
{
$this
->
post_author
=
$_REQUEST
[
'post_author'
];
}
if
(
isset
(
$_REQUEST
[
'comment_status'
]
)
&&
!
empty
(
$_REQUEST
[
'comment_status'
]
)
)
{
$this
->
comment_status
=
$_REQUEST
[
'comment_status'
];
}
if
(
isset
(
$_REQUEST
[
'ping_status'
]
)
&&
!
empty
(
$_REQUEST
[
'ping_status'
]
)
)
{
$this
->
ping_status
=
$_REQUEST
[
'ping_status'
];
}
if
(
isset
(
$_REQUEST
[
'_status'
]
)
&&
-
1
!==
(
int
)
$_REQUEST
[
'_status'
]
)
{
$this
->
post_status
=
$_REQUEST
[
'_status'
];
}
if
(
isset
(
$_REQUEST
[
'sticky'
]
)
&&
-
1
!==
(
int
)
$_REQUEST
[
'sticky'
]
)
{
$this
->
post_sticky
=
$_REQUEST
[
'sticky'
];
}
if
(
isset
(
$_REQUEST
[
'post_format'
]
)
&&
-
1
!==
(
int
)
$_REQUEST
[
'post_format'
]
)
{
$this
->
post_format
=
$_REQUEST
[
'post_format'
];
}
// Stop Core from processing bulk request
unset
(
$_REQUEST
[
'action'
]
);
unset
(
$_REQUEST
[
'action2'
]
);
}
}
Main
::
load
();
Main
::
instance
();
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