File tree Expand file tree Collapse file tree 4 files changed +27
-4
lines changed
Expand file tree Collapse file tree 4 files changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -59,12 +59,18 @@ public function update_stats() {
5959 return ;
6060 }
6161
62+ // Bail if content helpers are not available (can happen during plugin updates).
63+ $ content_helpers = \progress_planner ()->get_activities__content_helpers ();
64+ if ( null === $ content_helpers ) {
65+ return ;
66+ }
67+
6268 // Get posts.
6369 $ posts = \get_posts (
6470 [
6571 'posts_per_page ' => static ::SCAN_POSTS_PER_PAGE ,
6672 'paged ' => $ current_page ,
67- 'post_type ' => \progress_planner ()-> get_activities__content_helpers () ->get_post_types_names (),
73+ 'post_type ' => $ content_helpers ->get_post_types_names (),
6874 'post_status ' => 'publish ' ,
6975 ]
7076 );
@@ -88,9 +94,15 @@ public function update_stats() {
8894 * @return int
8995 */
9096 public function get_total_pages () {
97+ // Bail if content helpers are not available (can happen during plugin updates).
98+ $ content_helpers = \progress_planner ()->get_activities__content_helpers ();
99+ if ( null === $ content_helpers ) {
100+ return 0 ;
101+ }
102+
91103 // Get the total number of posts.
92104 $ total_posts_count = 0 ;
93- foreach ( \progress_planner ()-> get_activities__content_helpers () ->get_post_types_names () as $ post_type ) {
105+ foreach ( $ content_helpers ->get_post_types_names () as $ post_type ) {
94106 $ total_posts_count += \wp_count_posts ( $ post_type )->publish ;
95107 }
96108 // Calculate the total pages to scan.
Original file line number Diff line number Diff line change @@ -157,10 +157,16 @@ public function delete_post( $post_id ) {
157157 * @return bool
158158 */
159159 private function should_skip_saving ( $ post ) {
160+ // Bail if content helpers are not available (can happen during plugin updates).
161+ $ content_helpers = \progress_planner ()->get_activities__content_helpers ();
162+ if ( null === $ content_helpers ) {
163+ return true ;
164+ }
165+
160166 // Bail if the post is not included in the post-types we're tracking.
161167 if ( ! \in_array (
162168 $ post ->post_type ,
163- \progress_planner ()-> get_activities__content_helpers () ->get_post_types_names (),
169+ $ content_helpers ->get_post_types_names (),
164170 true
165171 ) ) {
166172 return true ;
Original file line number Diff line number Diff line change @@ -128,6 +128,11 @@ public function on_switch_theme() {
128128 * @return void
129129 */
130130 protected function create_maintenance_activity ( $ type ) {
131+ // Bail if the class doesn't exist (can happen during plugin updates).
132+ if ( ! \class_exists ( Activities_Maintenance::class ) ) {
133+ return ;
134+ }
135+
131136 $ activity = new Activities_Maintenance ();
132137 $ activity ->type = $ type ;
133138 $ activity ->save ();
Original file line number Diff line number Diff line change 5151 * @method \Progress_Planner\UI\Popover get_ui__popover()
5252 * @method \Progress_Planner\Admin\Widgets\Content_Activity get_admin__widgets__content_activity()
5353 * @method \Progress_Planner\UI\Chart get_ui__chart()
54- * @method \Progress_Planner\Activities\Content_Helpers get_activities__content_helpers()
54+ * @method \Progress_Planner\Activities\Content_Helpers|null get_activities__content_helpers()
5555 * @method \Progress_Planner\Admin\Widgets\Challenge get_admin__widgets__challenge()
5656 * @method \Progress_Planner\Admin\Widgets\Activity_Scores get_admin__widgets__activity_scores()
5757 * @method \Progress_Planner\Utils\Date get_utils__date()
You can’t perform that action at this time.
0 commit comments