Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions classes/actions/class-content-scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,18 @@ public function update_stats() {
return;
}

// Bail if content helpers are not available (can happen during plugin updates).
$content_helpers = \progress_planner()->get_activities__content_helpers();
if ( null === $content_helpers ) {
return;
}

// Get posts.
$posts = \get_posts(
[
'posts_per_page' => static::SCAN_POSTS_PER_PAGE,
'paged' => $current_page,
'post_type' => \progress_planner()->get_activities__content_helpers()->get_post_types_names(),
'post_type' => $content_helpers->get_post_types_names(),
'post_status' => 'publish',
]
);
Expand All @@ -88,9 +94,15 @@ public function update_stats() {
* @return int
*/
public function get_total_pages() {
// Bail if content helpers are not available (can happen during plugin updates).
$content_helpers = \progress_planner()->get_activities__content_helpers();
if ( null === $content_helpers ) {
return 0;
}

// Get the total number of posts.
$total_posts_count = 0;
foreach ( \progress_planner()->get_activities__content_helpers()->get_post_types_names() as $post_type ) {
foreach ( $content_helpers->get_post_types_names() as $post_type ) {
$total_posts_count += \wp_count_posts( $post_type )->publish;
}
// Calculate the total pages to scan.
Expand Down
8 changes: 7 additions & 1 deletion classes/actions/class-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,16 @@ public function delete_post( $post_id ) {
* @return bool
*/
private function should_skip_saving( $post ) {
// Bail if content helpers are not available (can happen during plugin updates).
$content_helpers = \progress_planner()->get_activities__content_helpers();
if ( null === $content_helpers ) {
return true;
}

// Bail if the post is not included in the post-types we're tracking.
if ( ! \in_array(
$post->post_type,
\progress_planner()->get_activities__content_helpers()->get_post_types_names(),
$content_helpers->get_post_types_names(),
true
) ) {
return true;
Expand Down
5 changes: 5 additions & 0 deletions classes/actions/class-maintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ public function on_switch_theme() {
* @return void
*/
protected function create_maintenance_activity( $type ) {
// Bail if the class doesn't exist (can happen during plugin updates).
if ( ! \class_exists( Activities_Maintenance::class ) ) {
return;
}

$activity = new Activities_Maintenance();
$activity->type = $type;
$activity->save();
Expand Down
2 changes: 1 addition & 1 deletion classes/class-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* @method \Progress_Planner\UI\Popover get_ui__popover()
* @method \Progress_Planner\Admin\Widgets\Content_Activity get_admin__widgets__content_activity()
* @method \Progress_Planner\UI\Chart get_ui__chart()
* @method \Progress_Planner\Activities\Content_Helpers get_activities__content_helpers()
* @method \Progress_Planner\Activities\Content_Helpers|null get_activities__content_helpers()
* @method \Progress_Planner\Admin\Widgets\Challenge get_admin__widgets__challenge()
* @method \Progress_Planner\Admin\Widgets\Activity_Scores get_admin__widgets__activity_scores()
* @method \Progress_Planner\Utils\Date get_utils__date()
Expand Down
Loading