updated plugin Event Bridge for ActivityPub version 1.3.0

This commit is contained in:
2026-06-03 21:28:57 +00:00
committed by Gitium
parent 1f3438440f
commit f2d6714572
84 changed files with 1721 additions and 1361 deletions

View File

@ -14,7 +14,7 @@ namespace Event_Bridge_For_ActivityPub;
use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Event_Bridge_For_ActivityPub\Integrations\Feature_Event_Sources;
@ -26,14 +26,14 @@ use Event_Bridge_For_ActivityPub\Integrations\Feature_Event_Sources;
* @since 1.0.0
*/
class Settings {
const SETTINGS_SLUG = 'event-bridge-for-activitypub';
public const SETTINGS_SLUG = 'event-bridge-for-activitypub';
/**
* The default ActivityPub event category.
*
* @var string
*/
const DEFAULT_EVENT_CATEGORY = 'MEETING';
private const DEFAULT_EVENT_CATEGORY = 'MEETING';
/**
* Register the settings for the Event Bridge for ActivityPub plugin.
@ -168,10 +168,11 @@ class Settings {
/**
* Do not allow the event sources feature to get deactivated, when event sources are still followed.
*
* @param mixed $value The optios value.
* @param mixed $value The options value.
* @return bool
*/
public static function sanitize_event_sources_feature_active( $value ) {
$count = count( Event_Sources::get_event_sources() );
public static function sanitize_event_sources_feature_active( mixed $value ): bool {
$count = \count( Event_Sources::get_event_sources() );
$value = (bool) $value;
@ -198,7 +199,7 @@ class Settings {
* @return string
*/
public static function sanitize_event_plugin_integration_used_for_event_sources( $event_plugin_integration ): string {
if ( ! is_string( $event_plugin_integration ) ) {
if ( ! \is_string( $event_plugin_integration ) ) {
return '';
}
$setup = Setup::get_instance();
@ -207,10 +208,10 @@ class Settings {
$valid_options = array();
foreach ( $active_event_plugins as $active_event_plugin ) {
if ( $active_event_plugin instanceof Feature_Event_Sources ) {
$valid_options[] = get_class( $active_event_plugin );
$valid_options[] = \get_class( $active_event_plugin );
}
}
if ( in_array( $event_plugin_integration, $valid_options, true ) ) {
if ( \in_array( $event_plugin_integration, $valid_options, true ) ) {
return $event_plugin_integration;
}
return Setup::get_default_integration_class_name_used_for_event_sources_feature();
@ -220,8 +221,9 @@ class Settings {
* Sanitize the target ActivityPub Event category.
*
* @param string $event_category The ActivityPUb event category.
* @return string
*/
public static function sanitize_mapped_event_category( $event_category ): string {
public static function sanitize_mapped_event_category( string $event_category ): string {
return self::is_allowed_event_category( $event_category ) ? $event_category : self::DEFAULT_EVENT_CATEGORY;
}
@ -231,10 +233,9 @@ class Settings {
* Currently only the default event categories are allowed to be target of a mapping.
*
* @param array $event_category_mappings The settings value.
*
* @return array An array that contains only valid mapping pairs.
*/
public static function sanitize_event_category_mappings( $event_category_mappings ): array {
public static function sanitize_event_category_mappings( array $event_category_mappings ): array {
if ( empty( $event_category_mappings ) ) {
return array();
}
@ -253,9 +254,9 @@ class Settings {
*
* @return bool True if allowed, false otherwise.
*/
private static function is_allowed_event_category( $event_category ): bool {
private static function is_allowed_event_category( string $event_category ): bool {
require_once EVENT_BRIDGE_FOR_ACTIVITYPUB_PLUGIN_DIR . '/includes/event-categories.php';
$allowed_event_categories = array_keys( EVENT_BRIDGE_FOR_ACTIVITYPUB_EVENT_CATEGORIES );
return in_array( $event_category, $allowed_event_categories, true );
return \in_array( $event_category, $allowed_event_categories, true );
}
}