From 6f744b9e1406c2f0effb811e923eb9c1323ad04d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Sat, 28 Sep 2024 13:14:10 +0200 Subject: [PATCH] Cleanup top of PHP files (#40) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - sorting use statements - always check for `ABSPATH` after namespace Reviewed-on: https://code.event-federation.eu/Event-Federation/wordpress-activitypub-event-extensions/pulls/40 Co-authored-by: André Menrath Co-committed-by: André Menrath --- includes/activitypub/transformer/class-event.php | 3 +++ .../transformer/class-events-manager.php | 12 ++++++------ .../activitypub/transformer/class-gatherpress.php | 13 +++++-------- .../transformer/class-the-events-calendar.php | 5 ++--- .../activitypub/transformer/class-vs-event-list.php | 12 ++++-------- includes/admin/class-event-plugin-admin-notices.php | 3 +++ includes/admin/class-general-admin-notices.php | 3 +++ includes/admin/class-settings-page.php | 6 +++--- includes/class-settings.php | 4 ++-- includes/class-setup.php | 6 +++--- 10 files changed, 34 insertions(+), 33 deletions(-) diff --git a/includes/activitypub/transformer/class-event.php b/includes/activitypub/transformer/class-event.php index ea992e1..a60f585 100644 --- a/includes/activitypub/transformer/class-event.php +++ b/includes/activitypub/transformer/class-event.php @@ -8,6 +8,9 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + use Activitypub\Activity\Extended_Object\Event as Event_Object; use Activitypub\Transformer\Post; diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index 3e95fe0..0a3ce85 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -8,17 +8,17 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + +use Activitypub\Activity\Extended_Object\Event; +use Activitypub\Activity\Extended_Object\Place; use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; use DateTime; use DateTimeZone; use EM_Event; -use Activitypub\Activity\Extended_Object\Event; -use Activitypub\Activity\Extended_Object\Place; -use function Activitypub\esc_hashtag; -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} +use function Activitypub\esc_hashtag; /** * ActivityPub Transformer for events from the WordPress plugin 'Events Manager' diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index 1bd9081..7224a82 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -8,18 +8,15 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; -use Activitypub_Event_Extensions\Activitypub\Transformer\Event; -use Activitypub\Model\Blog; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + use Activitypub\Activity\Extended_Object\Event as Event_Object; use Activitypub\Activity\Extended_Object\Place; +use Activitypub\Model\Blog; +use Activitypub_Event_Extensions\Activitypub\Transformer\Event; use GatherPress\Core\Event as GatherPress_Event; -use function Activitypub\get_rest_url_by_path; - -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} - /** * ActivityPub Transformer for VS Event * diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index 4219627..795b6b7 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -8,9 +8,8 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore use WP_Post; diff --git a/includes/activitypub/transformer/class-vs-event-list.php b/includes/activitypub/transformer/class-vs-event-list.php index f6f9b61..c592003 100644 --- a/includes/activitypub/transformer/class-vs-event-list.php +++ b/includes/activitypub/transformer/class-vs-event-list.php @@ -8,16 +8,12 @@ namespace Activitypub_Event_Extensions\Activitypub\Transformer; -use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + use Activitypub\Activity\Extended_Object\Event; use Activitypub\Activity\Extended_Object\Place; - -use WP_Error; -use function Activitypub\get_rest_url_by_path; - -if ( ! defined( 'ABSPATH' ) ) { - exit; // Exit if accessed directly. -} +use Activitypub_Event_Extensions\Activitypub\Transformer\Event as Event_Transformer; /** * ActivityPub Transformer for VS Event. diff --git a/includes/admin/class-event-plugin-admin-notices.php b/includes/admin/class-event-plugin-admin-notices.php index 9340e81..2f9459c 100644 --- a/includes/admin/class-event-plugin-admin-notices.php +++ b/includes/admin/class-event-plugin-admin-notices.php @@ -11,6 +11,9 @@ namespace Activitypub_Event_Extensions\Admin; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + use Activitypub_Event_Extensions\Plugins\Event_Plugin; /** diff --git a/includes/admin/class-general-admin-notices.php b/includes/admin/class-general-admin-notices.php index 2751287..5a26fb5 100644 --- a/includes/admin/class-general-admin-notices.php +++ b/includes/admin/class-general-admin-notices.php @@ -11,6 +11,9 @@ namespace Activitypub_Event_Extensions\Admin; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + /** * Class responsible for general admin notices. * diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index d7cc288..27735b1 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -11,12 +11,12 @@ namespace Activitypub_Event_Extensions\Admin; -use Activitypub_Event_Extensions\Setup; -use Activitypub_Event_Extensions\Plugins\Event_Plugin; - // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore +use Activitypub_Event_Extensions\Plugins\Event_Plugin; +use Activitypub_Event_Extensions\Setup; + /** * Class responsible for the ActivityPub Event Extension related Settings. * diff --git a/includes/class-settings.php b/includes/class-settings.php index ceec701..9ff64e2 100644 --- a/includes/class-settings.php +++ b/includes/class-settings.php @@ -11,11 +11,11 @@ namespace Activitypub_Event_Extensions; -use Activitypub\Activity\Extended_Object\Event; - // Exit if accessed directly. defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore +use Activitypub\Activity\Extended_Object\Event; + /** * Class responsible for the ActivityPui Event Extension related Settings. * diff --git a/includes/class-setup.php b/includes/class-setup.php index 9e4a1e6..67877fb 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -12,14 +12,14 @@ namespace Activitypub_Event_Extensions; +// Exit if accessed directly. +defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore + use Activitypub_Event_Extensions\Admin\Event_Plugin_Admin_Notices; use Activitypub_Event_Extensions\Admin\General_Admin_Notices; use Activitypub_Event_Extensions\Admin\Settings_Page; use Activitypub_Event_Extensions\Plugins\Event_Plugin; -// Exit if accessed directly. -defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore - require_once ABSPATH . 'wp-admin/includes/plugin.php'; /**