2024-07-05 13:29:13 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2024-07-05 15:09:53 +02:00
|
|
|
* Class responsible for general admin notices.
|
2024-07-05 13:29:13 +02:00
|
|
|
*
|
2024-07-05 15:09:53 +02:00
|
|
|
* Notices for guiding to proper configuration of this plugin.
|
2024-07-05 13:29:13 +02:00
|
|
|
*
|
2024-10-02 21:54:03 +02:00
|
|
|
* @package ActivityPub_Event_Bridge
|
2024-07-05 13:29:13 +02:00
|
|
|
* @since 1.0.0
|
2024-08-01 20:08:35 +02:00
|
|
|
* @license AGPL-3.0-or-later
|
2024-07-05 13:29:13 +02:00
|
|
|
*/
|
|
|
|
|
2024-10-02 21:54:03 +02:00
|
|
|
namespace ActivityPub_Event_Bridge\Admin;
|
2024-07-05 13:29:13 +02:00
|
|
|
|
2024-09-28 13:14:10 +02:00
|
|
|
// Exit if accessed directly.
|
|
|
|
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
|
|
|
|
2024-07-05 13:29:13 +02:00
|
|
|
/**
|
2024-07-05 15:09:53 +02:00
|
|
|
* Class responsible for general admin notices.
|
2024-07-05 13:29:13 +02:00
|
|
|
*
|
2024-07-05 15:09:53 +02:00
|
|
|
* Notices for guiding to proper configuration of this plugin.
|
|
|
|
* - ActivityPub plugin not installed and activated
|
|
|
|
* - No supported Event Plugin installed and activated
|
2024-07-05 13:29:13 +02:00
|
|
|
*
|
|
|
|
* @since 1.0.0
|
|
|
|
*/
|
|
|
|
class General_Admin_Notices {
|
|
|
|
/**
|
2024-07-05 15:09:53 +02:00
|
|
|
* URL of the ActivityPub plugin. Needed when the ActivityPub plugin is not installed.
|
|
|
|
*/
|
|
|
|
const ACTIVITYPUB_PLUGIN_URL = 'https://wordpress.org/plugins/activitypub';
|
|
|
|
|
2024-10-02 21:54:03 +02:00
|
|
|
const ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL = 'https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-bridge#events-plugin-that-will-be-supported-at-first';
|
2024-07-05 15:09:53 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allowed HTML for admin notices.
|
|
|
|
*
|
|
|
|
* @var array
|
2024-07-05 13:29:13 +02:00
|
|
|
*/
|
2024-07-05 15:09:53 +02:00
|
|
|
const ALLOWED_HTML = array(
|
|
|
|
'a' => array(
|
|
|
|
'href' => true,
|
|
|
|
'title' => true,
|
|
|
|
),
|
|
|
|
'br',
|
|
|
|
'i',
|
|
|
|
);
|
2024-07-05 13:29:13 +02:00
|
|
|
|
2024-07-05 15:09:53 +02:00
|
|
|
/**
|
|
|
|
* Admin notice when the ActivityPub plugin is not enabled.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function get_admin_notice_activitypub_plugin_not_enabled(): string {
|
|
|
|
return sprintf(
|
2024-09-11 13:55:37 +02:00
|
|
|
/* translators: 1: An URL that points to the ActivityPub plugin. */
|
2024-07-05 13:29:13 +02:00
|
|
|
_x(
|
2024-10-02 21:54:03 +02:00
|
|
|
'For the ActivityPub Event Bridge to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.',
|
2024-07-05 13:29:13 +02:00
|
|
|
'admin notice',
|
2024-10-02 21:54:03 +02:00
|
|
|
'activitypub-event-bridge'
|
2024-07-05 13:29:13 +02:00
|
|
|
),
|
2024-09-11 13:55:37 +02:00
|
|
|
esc_html( self::ACTIVITYPUB_PLUGIN_URL )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Admin notice when the ActivityPub plugin version is too old.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function get_admin_notice_activitypub_plugin_version_too_old(): string {
|
|
|
|
return sprintf(
|
|
|
|
/* translators: 1: The name of the ActivityPub plugin. 2: The minimum required version number of the ActivityPub plugin. */
|
|
|
|
_x(
|
2024-10-02 21:54:03 +02:00
|
|
|
'Please upgrade your <a href="%1$s">ActivityPub</a> plugin. At least version %2$s is required for the ActivityPub Event Bridge to work.',
|
2024-09-11 13:55:37 +02:00
|
|
|
'admin notice',
|
2024-10-02 21:54:03 +02:00
|
|
|
'activitypub-event-bridge'
|
2024-09-11 13:55:37 +02:00
|
|
|
),
|
2024-07-05 15:09:53 +02:00
|
|
|
esc_html( self::ACTIVITYPUB_PLUGIN_URL ),
|
2024-10-02 21:54:03 +02:00
|
|
|
esc_html( ACTIVITYPUB_EVENT_BRIDGE_ACTIVITYPUB_PLUGIN_MIN_VERSION )
|
2024-07-05 13:29:13 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Warning that no supported event plugin can be found.
|
2024-07-05 15:09:53 +02:00
|
|
|
*
|
|
|
|
* @return string
|
2024-07-05 13:29:13 +02:00
|
|
|
*/
|
2024-07-05 15:09:53 +02:00
|
|
|
public static function get_admin_notice_no_supported_event_plugin_active(): string {
|
|
|
|
return sprintf(
|
2024-09-11 13:55:37 +02:00
|
|
|
/* translators: 1: An URL to the list of supported event plugins. */
|
2024-07-05 13:29:13 +02:00
|
|
|
_x(
|
2024-10-02 21:54:03 +02:00
|
|
|
'The Plugin <i>ActivityPub Event Bridge</i> is of no use, because you do not have installed and activated a supported Event Plugin.
|
2024-07-05 13:29:13 +02:00
|
|
|
<br> For a list of supported Event Plugins see <a href="%1$s">here</a>.',
|
|
|
|
'admin notice',
|
2024-10-02 21:54:03 +02:00
|
|
|
'activitypub-event-bridge'
|
2024-07-05 13:29:13 +02:00
|
|
|
),
|
2024-10-02 21:54:03 +02:00
|
|
|
esc_html( self::ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL )
|
2024-07-05 13:29:13 +02:00
|
|
|
);
|
2024-07-05 15:09:53 +02:00
|
|
|
}
|
|
|
|
|
2024-10-22 16:18:29 +02:00
|
|
|
/**
|
|
|
|
* Warning to fix status issues first.
|
|
|
|
*
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public static function get_admin_notice_status_not_ok(): string {
|
|
|
|
return sprintf(
|
|
|
|
/* translators: 1: An URL to the list of supported event plugins. */
|
|
|
|
_x(
|
|
|
|
'The Plugin <i>ActivityPub Event Bridge</i> is of no use, because you do not have installed and activated a supported Event Plugin.
|
|
|
|
<br> For a list of supported Event Plugins see <a href="%1$s">here</a>.',
|
|
|
|
'admin notice',
|
|
|
|
'activitypub-event-bridge'
|
|
|
|
),
|
|
|
|
esc_html( self::ACTIVITYPUB_EVENT_BRIDGE_SUPPORTED_EVENT_PLUGINS_URL )
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-07-05 15:09:53 +02:00
|
|
|
/**
|
|
|
|
* Warning if the plugin is Active and the ActivityPub plugin is not.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2024-09-11 00:38:21 +02:00
|
|
|
public static function activitypub_plugin_not_enabled(): void {
|
2024-07-05 15:09:53 +02:00
|
|
|
$notice = self::get_admin_notice_activitypub_plugin_not_enabled();
|
|
|
|
echo '<div class="notice notice-warning"><p>' . \wp_kses( $notice, self::ALLOWED_HTML ) . '</p></div>';
|
|
|
|
}
|
|
|
|
|
2024-09-11 13:55:37 +02:00
|
|
|
/**
|
|
|
|
* Warning if the plugin is Active and the ActivityPub plugins version is too old.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public static function activitypub_plugin_version_too_old(): void {
|
|
|
|
$notice = self::get_admin_notice_activitypub_plugin_version_too_old();
|
|
|
|
echo '<div class="notice notice-warning"><p>' . \wp_kses( $notice, self::ALLOWED_HTML ) . '</p></div>';
|
|
|
|
}
|
|
|
|
|
2024-07-05 15:09:53 +02:00
|
|
|
/**
|
|
|
|
* Warning when no supported Even Plugin is installed and active.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2024-09-11 00:38:21 +02:00
|
|
|
public static function no_supported_event_plugin_active(): void {
|
2024-07-05 15:09:53 +02:00
|
|
|
$notice = self::get_admin_notice_no_supported_event_plugin_active();
|
|
|
|
echo '<div class="notice notice-warning"><p>' . \wp_kses( $notice, self::ALLOWED_HTML ) . '</p></div>';
|
2024-07-05 13:29:13 +02:00
|
|
|
}
|
|
|
|
}
|