Skip to content

Commit e7bb8fd

Browse files
pfefferleobenland
andauthored
Add: New Health checks (#1524)
* Add: New Health checks To improve the onboarding experience! * no need to deactivate crons * explain the issue with threaded comments * Add changelog * fix phpcs issues * Update includes/wp-admin/class-health-check.php Co-authored-by: Konstantin Obenland <[email protected]> * Update includes/wp-admin/class-health-check.php Co-authored-by: Konstantin Obenland <[email protected]> * simplify text props @obenland * Update includes/wp-admin/class-health-check.php Co-authored-by: Konstantin Obenland <[email protected]> * Update includes/wp-admin/class-health-check.php Co-authored-by: Konstantin Obenland <[email protected]> --------- Co-authored-by: Konstantin Obenland <[email protected]>
1 parent 47e4c5a commit e7bb8fd

File tree

2 files changed

+92
-43
lines changed

2 files changed

+92
-43
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: added
3+
4+
Check if pretty permalinks are enabled and recommend to use threaded comments.

includes/wp-admin/class-health-check.php

Lines changed: 88 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ public static function add_tests( $tests ) {
9494
'test' => array( self::class, 'test_webfinger' ),
9595
);
9696

97+
$tests['direct']['activitypub_test_threaded_comments'] = array(
98+
'label' => \__( 'Threaded Comments Test', 'activitypub' ),
99+
'test' => array( self::class, 'test_threaded_comments' ),
100+
);
101+
102+
$tests['direct']['activitypub_test_pretty_permalinks'] = array(
103+
'label' => \__( 'Pretty Permalinks Test', 'activitypub' ),
104+
'test' => array( self::class, 'test_pretty_permalinks' ),
105+
);
106+
97107
return $tests;
98108
}
99109

@@ -135,49 +145,6 @@ public static function test_author_url() {
135145
return $result;
136146
}
137147

138-
/**
139-
* System Cron tests.
140-
*
141-
* @return array The test result.
142-
*/
143-
public static function test_system_cron() {
144-
$result = array(
145-
'label' => \__( 'System Task Scheduler configured', 'activitypub' ),
146-
'status' => 'good',
147-
'badge' => array(
148-
'label' => \__( 'ActivityPub', 'activitypub' ),
149-
'color' => 'green',
150-
),
151-
'description' => \sprintf(
152-
'<p>%s</p>',
153-
\esc_html__( 'You seem to use the System Task Scheduler to process WP_Cron tasks.', 'activitypub' )
154-
),
155-
'actions' => '',
156-
'test' => 'test_system_cron',
157-
);
158-
159-
if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
160-
return $result;
161-
}
162-
163-
$result['status'] = 'recommended';
164-
$result['label'] = \__( 'System Task Scheduler not configured', 'activitypub' );
165-
$result['badge']['color'] = 'orange';
166-
$result['description'] = \sprintf(
167-
'<p>%s</p>',
168-
\__( 'Enhance your WordPress site’s performance and mitigate potential heavy loads caused by plugins like ActivityPub by setting up a system cron job to run WP Cron. This ensures scheduled tasks are executed consistently and reduces the reliance on website traffic for trigger events.', 'activitypub' )
169-
);
170-
$result['actions'] .= sprintf(
171-
'<p><a href="%s" target="_blank" rel="noopener">%s<span class="screen-reader-text"> %s</span><span aria-hidden="true" class="dashicons dashicons-external"></span></a></p>',
172-
esc_url( __( 'https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/', 'activitypub' ) ),
173-
__( 'Learn how to hook the WP-Cron into the System Task Scheduler.', 'activitypub' ),
174-
/* translators: Hidden accessibility text. */
175-
__( '(opens in a new tab)', 'activitypub' )
176-
);
177-
178-
return $result;
179-
}
180-
181148
/**
182149
* WebFinger tests.
183150
*
@@ -379,4 +346,82 @@ public static function debug_information( $info ) {
379346

380347
return $info;
381348
}
349+
350+
/**
351+
* Threaded Comments tests.
352+
*
353+
* @return array The test result.
354+
*/
355+
public static function test_threaded_comments() {
356+
$result = array(
357+
'label' => \__( 'Threaded (nested) comments enabled', 'activitypub' ),
358+
'status' => 'good',
359+
'badge' => array(
360+
'label' => \__( 'ActivityPub', 'activitypub' ),
361+
'color' => 'green',
362+
),
363+
'description' => \sprintf(
364+
'<p>%s</p>',
365+
\__( 'Threaded (nested) comments are enabled.', 'activitypub' )
366+
),
367+
'actions' => '',
368+
'test' => 'test_threaded_comments',
369+
);
370+
371+
if ( '1' !== get_option( 'thread_comments', '0' ) ) {
372+
$result['status'] = 'recommended';
373+
$result['label'] = \__( 'Threaded (nested) comments are not enabled', 'activitypub' );
374+
$result['badge']['color'] = 'orange';
375+
$result['description'] = \sprintf(
376+
'<p>%s</p><p>%s</p>',
377+
\__( 'This is particularly important for fediverse users, as they rely on the visual hierarchy to understand conversation threads across different platforms. Without threaded comments, it becomes much more difficult to follow discussions that span multiple platforms in the fediverse.', 'activitypub' ),
378+
\sprintf(
379+
// translators: %s: Discussion settings URL.
380+
\__( 'You can enable them in the <a href="%s">Discussion Settings</a>.', 'activitypub' ),
381+
esc_url( admin_url( 'options-discussion.php' ) )
382+
)
383+
);
384+
}
385+
386+
return $result;
387+
}
388+
389+
/**
390+
* Pretty Permalinks tests.
391+
*
392+
* @return array The test result.
393+
*/
394+
public static function test_pretty_permalinks() {
395+
$result = array(
396+
'label' => \__( 'Pretty Permalinks enabled', 'activitypub' ),
397+
'status' => 'good',
398+
'badge' => array(
399+
'label' => \__( 'ActivityPub', 'activitypub' ),
400+
'color' => 'green',
401+
),
402+
'description' => \sprintf(
403+
'<p>%s</p>',
404+
\__( 'Your pretty permalinks are enabled and working correctly.', 'activitypub' )
405+
),
406+
'actions' => '',
407+
'test' => 'test_pretty_permalinks',
408+
);
409+
410+
$permalink_structure = \get_option( 'permalink_structure' );
411+
if ( empty( $permalink_structure ) ) {
412+
$result['status'] = 'critical';
413+
$result['label'] = \__( 'Pretty Permalinks are not enabled.', 'activitypub' );
414+
$result['badge']['color'] = 'red';
415+
$result['description'] = \sprintf(
416+
'<p>%s</p>',
417+
sprintf(
418+
/* translators: %s: Permalink settings URL. */
419+
\__( 'ActivityPub needs SEO-friendly URLs to work properly. Please <a href="%s">update your permalink structure</a> to an option other than Plain.', 'activitypub' ),
420+
esc_url( admin_url( 'options-permalink.php' ) )
421+
)
422+
);
423+
}
424+
425+
return $result;
426+
}
382427
}

0 commit comments

Comments
 (0)