modified file bootstrap-buttons.css
This commit is contained in:
@ -1,6 +1,14 @@
|
||||
<?php
|
||||
namespace Activitypub;
|
||||
|
||||
use WP_Error;
|
||||
use Activitypub\Webfinger;
|
||||
use Activitypub\Collection\Users;
|
||||
|
||||
use function Activitypub\get_plugin_version;
|
||||
use function Activitypub\is_user_type_disabled;
|
||||
use function Activitypub\get_webfinger_resource;
|
||||
|
||||
/**
|
||||
* ActivityPub Health_Check Class
|
||||
*
|
||||
@ -14,19 +22,26 @@ class Health_Check {
|
||||
* @return void
|
||||
*/
|
||||
public static function init() {
|
||||
\add_filter( 'site_status_tests', array( '\Activitypub\Health_Check', 'add_tests' ) );
|
||||
\add_filter( 'debug_information', array( '\Activitypub\Health_Check', 'debug_information' ) );
|
||||
\add_filter( 'site_status_tests', array( self::class, 'add_tests' ) );
|
||||
\add_filter( 'debug_information', array( self::class, 'debug_information' ) );
|
||||
}
|
||||
|
||||
public static function add_tests( $tests ) {
|
||||
$tests['direct']['activitypub_test_author_url'] = array(
|
||||
'label' => \__( 'Author URL test', 'activitypub' ),
|
||||
'test' => array( '\Activitypub\Health_Check', 'test_author_url' ),
|
||||
);
|
||||
if ( ! is_user_type_disabled( 'user' ) ) {
|
||||
$tests['direct']['activitypub_test_author_url'] = array(
|
||||
'label' => \__( 'Author URL test', 'activitypub' ),
|
||||
'test' => array( self::class, 'test_author_url' ),
|
||||
);
|
||||
}
|
||||
|
||||
$tests['direct']['activitypub_test_webfinger'] = array(
|
||||
'label' => __( 'WebFinger Test', 'activitypub' ),
|
||||
'test' => array( '\Activitypub\Health_Check', 'test_webfinger' ),
|
||||
'test' => array( self::class, 'test_webfinger' ),
|
||||
);
|
||||
|
||||
$tests['direct']['activitypub_test_system_cron'] = array(
|
||||
'label' => __( 'System Cron Test', 'activitypub' ),
|
||||
'test' => array( self::class, 'test_system_cron' ),
|
||||
);
|
||||
|
||||
return $tests;
|
||||
@ -35,7 +50,7 @@ class Health_Check {
|
||||
/**
|
||||
* Author URL tests
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public static function test_author_url() {
|
||||
$result = array(
|
||||
@ -70,10 +85,53 @@ class Health_Check {
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* System Cron tests
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function test_system_cron() {
|
||||
$result = array(
|
||||
'label' => \__( 'System Task Scheduler configured', 'activitypub' ),
|
||||
'status' => 'good',
|
||||
'badge' => array(
|
||||
'label' => \__( 'ActivityPub', 'activitypub' ),
|
||||
'color' => 'green',
|
||||
),
|
||||
'description' => \sprintf(
|
||||
'<p>%s</p>',
|
||||
\esc_html__( 'You seem to use the System Task Scheduler to process WP_Cron tasks.', 'activitypub' )
|
||||
),
|
||||
'actions' => '',
|
||||
'test' => 'test_system_cron',
|
||||
);
|
||||
|
||||
if ( defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result['status'] = 'recommended';
|
||||
$result['label'] = \__( 'System Task Scheduler not configured', 'activitypub' );
|
||||
$result['badge']['color'] = 'orange';
|
||||
$result['description'] = \sprintf(
|
||||
'<p>%s</p>',
|
||||
\__( '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' )
|
||||
);
|
||||
$result['actions'] .= sprintf(
|
||||
'<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>',
|
||||
__( 'https://developer.wordpress.org/plugins/cron/hooking-wp-cron-into-the-system-task-scheduler/', 'activitypub' ),
|
||||
__( 'Learn how to hook the WP-Cron into the System Task Scheduler.', 'activitypub' ),
|
||||
/* translators: Hidden accessibility text. */
|
||||
__( '(opens in a new tab)', 'activitypub' )
|
||||
);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* WebFinger tests
|
||||
*
|
||||
* @return void
|
||||
* @return array
|
||||
*/
|
||||
public static function test_webfinger() {
|
||||
$result = array(
|
||||
@ -85,7 +143,7 @@ class Health_Check {
|
||||
),
|
||||
'description' => \sprintf(
|
||||
'<p>%s</p>',
|
||||
\__( 'Your WebFinger endpoint is accessible and returns the correct informations.', 'activitypub' )
|
||||
\__( 'Your WebFinger endpoint is accessible and returns the correct information.', 'activitypub' )
|
||||
),
|
||||
'actions' => '',
|
||||
'test' => 'test_webfinger',
|
||||
@ -109,7 +167,7 @@ class Health_Check {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if `author_posts_url` is accessible and that requerst returns correct JSON
|
||||
* Check if `author_posts_url` is accessible and that request returns correct JSON
|
||||
*
|
||||
* @return boolean|WP_Error
|
||||
*/
|
||||
@ -120,12 +178,12 @@ class Health_Check {
|
||||
|
||||
// check for "author" in URL
|
||||
if ( $author_url !== $reference_author_url ) {
|
||||
return new \WP_Error(
|
||||
return new WP_Error(
|
||||
'author_url_not_accessible',
|
||||
\sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your author URL <code>%s</code> was replaced, this is often done by plugins.</p>',
|
||||
'Your author URL <code>%s</code> was replaced, this is often done by plugins.',
|
||||
'activitypub'
|
||||
),
|
||||
$author_url
|
||||
@ -143,12 +201,12 @@ class Health_Check {
|
||||
);
|
||||
|
||||
if ( \is_wp_error( $response ) ) {
|
||||
return new \WP_Error(
|
||||
return new WP_Error(
|
||||
'author_url_not_accessible',
|
||||
\sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your author URL <code>%s</code> is not accessible. Please check your WordPress setup or permalink structure. If the setup seems fine, maybe check if a plugin might restrict the access.</p>',
|
||||
'Your author URL <code>%s</code> is not accessible. Please check your WordPress setup or permalink structure. If the setup seems fine, maybe check if a plugin might restrict the access.',
|
||||
'activitypub'
|
||||
),
|
||||
$author_url
|
||||
@ -160,12 +218,12 @@ class Health_Check {
|
||||
|
||||
// check for redirects
|
||||
if ( \in_array( $response_code, array( 301, 302, 307, 308 ), true ) ) {
|
||||
return new \WP_Error(
|
||||
return new WP_Error(
|
||||
'author_url_not_accessible',
|
||||
\sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your author URL <code>%s</code> is redirecting to another page, this is often done by SEO plugins like "Yoast SEO".</p>',
|
||||
'Your author URL <code>%s</code> is redirecting to another page, this is often done by SEO plugins like "Yoast SEO".',
|
||||
'activitypub'
|
||||
),
|
||||
$author_url
|
||||
@ -177,12 +235,12 @@ class Health_Check {
|
||||
$body = \wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( ! \is_string( $body ) || ! \is_array( \json_decode( $body, true ) ) ) {
|
||||
return new \WP_Error(
|
||||
return new WP_Error(
|
||||
'author_url_not_accessible',
|
||||
\sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your author URL <code>%s</code> does not return valid JSON for <code>application/activity+json</code>. Please check if your hosting supports alternate <code>Accept</code> headers.</p>',
|
||||
'Your author URL <code>%s</code> does not return valid JSON for <code>application/activity+json</code>. Please check if your hosting supports alternate <code>Accept</code> headers.',
|
||||
'activitypub'
|
||||
),
|
||||
$author_url
|
||||
@ -194,31 +252,49 @@ class Health_Check {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if WebFinger endoint is accessible and profile requerst returns correct JSON
|
||||
* Check if WebFinger endpoint is accessible and profile request returns correct JSON
|
||||
*
|
||||
* @return boolean|WP_Error
|
||||
*/
|
||||
public static function is_webfinger_endpoint_accessible() {
|
||||
$user = \wp_get_current_user();
|
||||
$account = \Activitypub\get_webfinger_resource( $user->ID );
|
||||
$user = \wp_get_current_user();
|
||||
|
||||
$url = \Activitypub\Webfinger::resolve( $account );
|
||||
if ( ! is_user_type_disabled( 'blog' ) ) {
|
||||
$account = get_webfinger_resource( $user->ID );
|
||||
} elseif ( ! is_user_type_disabled( 'user' ) ) {
|
||||
$account = get_webfinger_resource( Users::BLOG_USER_ID );
|
||||
} else {
|
||||
$account = '';
|
||||
}
|
||||
|
||||
$url = Webfinger::resolve( $account );
|
||||
if ( \is_wp_error( $url ) ) {
|
||||
$allowed = array( 'code' => array() );
|
||||
$not_accessible = wp_kses(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'Your WebFinger endpoint <code>%s</code> is not accessible. Please check your WordPress setup or permalink structure.',
|
||||
'activitypub'
|
||||
),
|
||||
$allowed
|
||||
);
|
||||
$invalid_response = wp_kses(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'Your WebFinger endpoint <code>%s</code> does not return valid JSON for <code>application/jrd+json</code>.',
|
||||
'activitypub'
|
||||
),
|
||||
$allowed
|
||||
);
|
||||
|
||||
$health_messages = array(
|
||||
'webfinger_url_not_accessible' => \sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your WebFinger endpoint <code>%s</code> is not accessible. Please check your WordPress setup or permalink structure.</p>',
|
||||
'activitypub'
|
||||
),
|
||||
$not_accessible,
|
||||
$url->get_error_data()
|
||||
),
|
||||
'webfinger_url_invalid_response' => \sprintf(
|
||||
// translators: %s: Author URL
|
||||
\__(
|
||||
'<p>Your WebFinger endpoint <code>%s</code> does not return valid JSON for <code>application/jrd+json</code>.</p>',
|
||||
'activitypub'
|
||||
),
|
||||
$invalid_response,
|
||||
$url->get_error_data()
|
||||
),
|
||||
);
|
||||
@ -226,7 +302,7 @@ class Health_Check {
|
||||
if ( isset( $health_messages[ $url->get_error_code() ] ) ) {
|
||||
$message = $health_messages[ $url->get_error_code() ];
|
||||
}
|
||||
return new \WP_Error(
|
||||
return new WP_Error(
|
||||
$url->get_error_code(),
|
||||
$message,
|
||||
$url->get_error_data()
|
||||
@ -272,7 +348,7 @@ class Health_Check {
|
||||
* Static function for generating site debug data when required.
|
||||
*
|
||||
* @param array $info The debug information to be added to the core information page.
|
||||
* @return array The filtered informations
|
||||
* @return array The filtered information
|
||||
*/
|
||||
public static function debug_information( $info ) {
|
||||
$info['activitypub'] = array(
|
||||
@ -280,7 +356,7 @@ class Health_Check {
|
||||
'fields' => array(
|
||||
'webfinger' => array(
|
||||
'label' => __( 'WebFinger Resource', 'activitypub' ),
|
||||
'value' => \Activitypub\Webfinger::get_user_resource( wp_get_current_user()->ID ),
|
||||
'value' => Webfinger::get_user_resource( wp_get_current_user()->ID ),
|
||||
'private' => true,
|
||||
),
|
||||
'author_url' => array(
|
||||
@ -288,6 +364,11 @@ class Health_Check {
|
||||
'value' => get_author_posts_url( wp_get_current_user()->ID ),
|
||||
'private' => true,
|
||||
),
|
||||
'plugin_version' => array(
|
||||
'label' => __( 'Plugin Version', 'activitypub' ),
|
||||
'value' => get_plugin_version(),
|
||||
'private' => true,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user