Skip to content

Commit

Permalink
Merge pull request #82 from interactiv4/feature/M095M01A-26
Browse files Browse the repository at this point in the history
feature/M095M01A-26 [WP]WORDPRESS] When scheduling posts Wordpress pu…
  • Loading branch information
vvuksan authored Jul 30, 2020
2 parents 47193ad + d2765fd commit 3f908a1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/wp-purges.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
class Purgely_Purges
{
private $postIdsProcessed = [];

/**
* The one instance of Purgely_Purges.
*
Expand Down Expand Up @@ -44,8 +46,12 @@ public function __construct()
*/
public function purge($post_id)
{
if (in_array($this->getPostId($post_id), $this->postIdsProcessed)) {
return;
}

if (!in_array(get_post_status($post_id), array('publish', 'trash', 'future', 'draft'))) {
array_push($this->postIdsProcessed, $this->getPostId($post_id));
if (!in_array(get_post_status($post_id), array('publish', 'trash', 'draft'))) {
return;
}

Expand All @@ -68,6 +74,14 @@ public function purge($post_id)
}
}

private function getPostId($post)
{
if ($post instanceof WP_Post) {
return $post->ID;
}
return $post;
}

/**
* A list of actions to purge URLs.
*
Expand Down

0 comments on commit 3f908a1

Please sign in to comment.