updated plugin Event Bridge for ActivityPub version 1.3.0
This commit is contained in:
@ -12,7 +12,7 @@
|
||||
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin_Integration;
|
||||
|
||||
@ -49,7 +49,7 @@ class Event_Plugin_Admin_Notices {
|
||||
* @return bool
|
||||
*/
|
||||
private function event_post_type_is_not_activitypub_enabled(): bool {
|
||||
return ! in_array( $this->event_plugin::get_post_type(), get_option( 'activitypub_support_post_types', array() ), true );
|
||||
return ! \in_array( $this->event_plugin::get_post_type(), get_option( 'activitypub_support_post_types', array() ), true );
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +79,7 @@ class Event_Plugin_Admin_Notices {
|
||||
return;
|
||||
}
|
||||
$activitypub_plugin_data = get_plugin_data( ACTIVITYPUB_PLUGIN_FILE );
|
||||
$notice = sprintf(
|
||||
$notice = \sprintf(
|
||||
/* translators: 1: the name of the event plugin a admin notice is shown. 2: The name of the ActivityPub plugin. */
|
||||
_x(
|
||||
'You have installed the <i>%1$s</i> plugin, but the event post type of the plugin <i>%2$s</i> is <b>not enabled</b> in the <a href="%3$s">%1$s settings</a>.',
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
/**
|
||||
* Class responsible for general admin notices.
|
||||
@ -52,7 +52,7 @@ class General_Admin_Notices {
|
||||
* @return string
|
||||
*/
|
||||
public static function get_admin_notice_activitypub_plugin_not_enabled(): string {
|
||||
return sprintf(
|
||||
return \sprintf(
|
||||
/* translators: 1: An URL that points to the ActivityPub plugin. */
|
||||
_x(
|
||||
'For the Event Bridge for ActivityPub to work, you will need to install and activate the <a href="%1$s">ActivityPub</a> plugin.',
|
||||
@ -69,7 +69,7 @@ class General_Admin_Notices {
|
||||
* @return string
|
||||
*/
|
||||
public static function get_admin_notice_activitypub_plugin_version_too_old(): string {
|
||||
return sprintf(
|
||||
return \sprintf(
|
||||
/* translators: 1: The name of the ActivityPub plugin. 2: The minimum required version number of the ActivityPub plugin. */
|
||||
_x(
|
||||
'Please upgrade your <a href="%1$s">ActivityPub</a> plugin. At least version %2$s is required for the Event Bridge for ActivityPub to work.',
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
use Activitypub\Transformer\Factory as Transformer_Factory;
|
||||
use Event_Bridge_For_ActivityPub\Integrations\Event_Plugin_Integration;
|
||||
@ -90,10 +90,6 @@ class Health_Check {
|
||||
* @return bool True if the check passed.
|
||||
*/
|
||||
public static function test_if_event_transformer_is_used( $event_plugin ): bool {
|
||||
if ( ! Setup::get_instance()->is_activitypub_plugin_active() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get a (random) event post.
|
||||
$event_posts = self::get_most_recent_event_posts( $event_plugin->get_post_type(), 1 );
|
||||
|
||||
@ -121,10 +117,6 @@ class Health_Check {
|
||||
* @return \WP_Post[] Array of event posts, or false if none are found.
|
||||
*/
|
||||
public static function get_most_recent_event_posts( $event_post_type = null, $number_of_posts = 5 ): array {
|
||||
if ( ! Setup::get_instance()->is_activitypub_plugin_active() ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
if ( ! $event_post_type ) {
|
||||
$active_event_plugins = Setup::get_instance()->get_active_event_plugins();
|
||||
$active_event_plugin = reset( $active_event_plugins );
|
||||
@ -141,6 +133,7 @@ class Health_Check {
|
||||
'order' => 'DESC',
|
||||
'include' => array(),
|
||||
'exclude' => array(),
|
||||
// phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
|
||||
'meta_query' => array(
|
||||
'relation' => 'OR',
|
||||
array(
|
||||
|
||||
@ -12,7 +12,7 @@
|
||||
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
use Activitypub\Webfinger;
|
||||
use Event_Bridge_For_ActivityPub\ActivityPub\Model\Event_Source;
|
||||
@ -69,7 +69,7 @@ class Settings_Page {
|
||||
* @return void
|
||||
*/
|
||||
public static function maybe_add_event_source() {
|
||||
if ( ! isset( $_POST['event_bridge_for_activitypub_add_event_source'] ) ) {
|
||||
if ( ! \array_key_exists( '_wpnonce', $_REQUEST ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -78,11 +78,15 @@ class Settings_Page {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $_POST['event_bridge_for_activitypub_add_event_source'] ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! \current_user_can( 'manage_options' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$event_source = \sanitize_text_field( $_POST['event_bridge_for_activitypub_add_event_source'] );
|
||||
$event_source = \sanitize_text_field( \wp_unslash( $_POST['event_bridge_for_activitypub_add_event_source'] ) );
|
||||
|
||||
$actor_url = false;
|
||||
$url = \wp_parse_url( $event_source );
|
||||
@ -203,13 +207,13 @@ class Settings_Page {
|
||||
private static function get_event_terms( $event_plugin ): array {
|
||||
$taxonomy = $event_plugin::get_event_category_taxonomy();
|
||||
if ( $taxonomy ) {
|
||||
$event_terms = get_terms(
|
||||
$event_terms = \get_terms(
|
||||
array(
|
||||
'taxonomy' => $taxonomy,
|
||||
'hide_empty' => true,
|
||||
)
|
||||
);
|
||||
return ! is_wp_error( $event_terms ) ? $event_terms : array();
|
||||
return ! \is_wp_error( $event_terms ) ? $event_terms : array();
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
|
||||
@ -9,10 +9,11 @@
|
||||
|
||||
namespace Event_Bridge_For_ActivityPub\Admin;
|
||||
|
||||
// Exit if accessed directly.
|
||||
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
use WP_Post;
|
||||
|
||||
// Exit if accessed directly.
|
||||
\defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
|
||||
|
||||
use Event_Bridge_For_ActivityPub\ActivityPub\Model\Event_Source;
|
||||
use Event_Bridge_For_ActivityPub\ActivityPub\Collection\Event_Sources as Event_Sources_Collection;
|
||||
use Event_Bridge_For_ActivityPub\Event_Sources;
|
||||
|
||||
@ -39,7 +40,7 @@ class User_Interface {
|
||||
* @param array $columns The current columns.
|
||||
* @return array
|
||||
*/
|
||||
public static function add_origin_column( $columns ) {
|
||||
public static function add_origin_column( array $columns ) {
|
||||
// Add a new column after the title column.
|
||||
$columns['activitypub_origin'] = __( 'ActivityPub origin', 'event-bridge-for-activitypub' );
|
||||
return $columns;
|
||||
@ -48,12 +49,12 @@ class User_Interface {
|
||||
/**
|
||||
* Add a "⁂ Preview" link to the row actions.
|
||||
*
|
||||
* @param array $actions The existing actions.
|
||||
* @param \WP_Post $post The post object.
|
||||
* @param array $actions The existing actions.
|
||||
* @param WP_Post $post The post object.
|
||||
*
|
||||
* @return array The modified actions.
|
||||
*/
|
||||
public static function row_actions( $actions, $post ): array {
|
||||
public static function row_actions( array $actions, WP_Post $post ): array {
|
||||
// check if the post is enabled for ActivityPub.
|
||||
if ( ! Event_Sources::is_cached_external_post( $post ) ) {
|
||||
return $actions;
|
||||
@ -67,7 +68,7 @@ class User_Interface {
|
||||
$url = \get_post_meta( $parent->ID, '_activitypub_actor_id', true );
|
||||
}
|
||||
|
||||
$actions['view_origin'] = sprintf(
|
||||
$actions['view_origin'] = \sprintf(
|
||||
'<a href="%s" target="_blank">⁂ %s</a>',
|
||||
\esc_url( $url ),
|
||||
\esc_html__( 'Open original page', 'event-bridge-for-activitypub' )
|
||||
@ -79,14 +80,14 @@ class User_Interface {
|
||||
/**
|
||||
* Modify the user capabilities so that nobody can edit external events.
|
||||
*
|
||||
* @param array $caps Concerned user's capabilities.
|
||||
* @param mixed $cap Required primitive capabilities for the requested capability.
|
||||
* @param array $user_id The WordPress user ID.
|
||||
* @param array $args Additional args.
|
||||
* @param string[] $caps Concerned user's capabilities.
|
||||
* @param string $cap Required primitive capabilities for the requested capability.
|
||||
* @param int $user_id The WordPress user ID.
|
||||
* @param array $args Additional args.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function disable_editing_for_external_events( $caps, $cap, $user_id, $args ) {
|
||||
public static function disable_editing_for_external_events( array $caps, string $cap, int $user_id, array $args ) {
|
||||
if ( 'edit_post' === $cap && isset( $args[0] ) ) {
|
||||
$post_id = $args[0];
|
||||
$post = get_post( $post_id );
|
||||
|
||||
Reference in New Issue
Block a user