diff --git a/activitypub.php b/activitypub.php index dbca209..e0f7880 100644 --- a/activitypub.php +++ b/activitypub.php @@ -21,50 +21,50 @@ namespace Activitypub; function init() { \defined( 'ACTIVITYPUB_HASHTAGS_REGEXP' ) || \define( 'ACTIVITYPUB_HASHTAGS_REGEXP', '(?:(?<=\s)|^)#(\w*[A-Za-z_]+\w*)' ); - require_once dirname( __FILE__ ) . '/includes/table/followers-list.php'; - require_once dirname( __FILE__ ) . '/includes/class-signature.php'; - require_once dirname( __FILE__ ) . '/includes/peer/class-followers.php'; - require_once dirname( __FILE__ ) . '/includes/functions.php'; + require_once \dirname( __FILE__ ) . '/includes/table/followers-list.php'; + require_once \dirname( __FILE__ ) . '/includes/class-signature.php'; + require_once \dirname( __FILE__ ) . '/includes/peer/class-followers.php'; + require_once \dirname( __FILE__ ) . '/includes/functions.php'; - require_once dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php'; + require_once \dirname( __FILE__ ) . '/includes/class-activity-dispatcher.php'; \Activitypub\Activity_Dispatcher::init(); - require_once dirname( __FILE__ ) . '/includes/model/class-activity.php'; - require_once dirname( __FILE__ ) . '/includes/model/class-post.php'; + require_once \dirname( __FILE__ ) . '/includes/model/class-activity.php'; + require_once \dirname( __FILE__ ) . '/includes/model/class-post.php'; \Activitypub\Model\Post::init(); - require_once dirname( __FILE__ ) . '/includes/class-activitypub.php'; + require_once \dirname( __FILE__ ) . '/includes/class-activitypub.php'; \Activitypub\Activitypub::init(); // Configure the REST API route - require_once dirname( __FILE__ ) . '/includes/rest/class-outbox.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-outbox.php'; \Activitypub\Rest\Outbox::init(); - require_once dirname( __FILE__ ) . '/includes/rest/class-inbox.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-inbox.php'; \Activitypub\Rest\Inbox::init(); - require_once dirname( __FILE__ ) . '/includes/rest/class-followers.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-followers.php'; \Activitypub\Rest\Followers::init(); - require_once dirname( __FILE__ ) . '/includes/rest/class-following.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-following.php'; \Activitypub\Rest\Following::init(); - require_once dirname( __FILE__ ) . '/includes/rest/class-webfinger.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-webfinger.php'; \Activitypub\Rest\Webfinger::init(); - require_once dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php'; + require_once \dirname( __FILE__ ) . '/includes/rest/class-nodeinfo.php'; \Activitypub\Rest\NodeInfo::init(); - require_once dirname( __FILE__ ) . '/includes/class-admin.php'; + require_once \dirname( __FILE__ ) . '/includes/class-admin.php'; \Activitypub\Admin::init(); - require_once dirname( __FILE__ ) . '/includes/class-hashtag.php'; + require_once \dirname( __FILE__ ) . '/includes/class-hashtag.php'; \Activitypub\Hashtag::init(); - require_once dirname( __FILE__ ) . '/includes/class-debug.php'; + require_once \dirname( __FILE__ ) . '/includes/class-debug.php'; \Activitypub\Debug::init(); - require_once dirname( __FILE__ ) . '/includes/class-health-check.php'; + require_once \dirname( __FILE__ ) . '/includes/class-health-check.php'; \Activitypub\Health_Check::init(); } add_action( 'plugins_loaded', '\Activitypub\init' ); diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 07d9223..49e022a 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -57,14 +57,14 @@ class Activitypub { $accept_header = $_SERVER['HTTP_ACCEPT']; if ( - stristr( $accept_header, 'application/activity+json' ) || - stristr( $accept_header, 'application/ld+json' ) + \stristr( $accept_header, 'application/activity+json' ) || + \stristr( $accept_header, 'application/ld+json' ) ) { return $json_template; } // accept header as an array - $accept = \explode( ',', trim( $accept_header ) ); + $accept = \explode( ',', \trim( $accept_header ) ); if ( \in_array( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"', $accept, true ) || @@ -113,11 +113,11 @@ class Activitypub { } if ( 'publish' === $new_status && 'publish' !== $old_status ) { - \wp_schedule_single_event( time(), 'activitypub_send_post_activity', array( $post->ID ) ); + \wp_schedule_single_event( \time(), 'activitypub_send_post_activity', array( $post->ID ) ); } elseif ( 'publish' === $new_status ) { - \wp_schedule_single_event( time(), 'activitypub_send_update_activity', array( $post->ID ) ); + \wp_schedule_single_event( \time(), 'activitypub_send_update_activity', array( $post->ID ) ); } elseif ( 'trash' === $new_status ) { - \wp_schedule_single_event( time(), 'activitypub_send_delete_activity', array( get_permalink( $post ) ) ); + \wp_schedule_single_event( \time(), 'activitypub_send_delete_activity', array( get_permalink( $post ) ) ); } } diff --git a/includes/class-admin.php b/includes/class-admin.php index 51513cb..fbdf85d 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -39,14 +39,14 @@ class Admin { * Load settings page */ public static function settings_page() { - \load_template( dirname( __FILE__ ) . '/../templates/settings.php' ); + \load_template( \dirname( __FILE__ ) . '/../templates/settings.php' ); } /** * Load user settings page */ public static function followers_list_page() { - \load_template( dirname( __FILE__ ) . '/../templates/followers-list.php' ); + \load_template( \dirname( __FILE__ ) . '/../templates/followers-list.php' ); } /** diff --git a/includes/class-debug.php b/includes/class-debug.php index 5539cf6..ac8b8bf 100644 --- a/includes/class-debug.php +++ b/includes/class-debug.php @@ -21,7 +21,7 @@ class Debug { } public static function write_log( $log ) { - if ( is_array( $log ) || is_object( $log ) ) { + if ( \is_array( $log ) || \is_object( $log ) ) { \error_log( \print_r( $log, true ) ); } else { \error_log( $log ); diff --git a/includes/functions.php b/includes/functions.php index 4eeeb33..a2587ee 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -194,7 +194,7 @@ function get_identifier_settings( $user_id ) {

or

-

+

@@ -236,7 +236,7 @@ function url_to_authorid( $url ) { } // first, check to see if there is a 'author=N' to match against - if ( preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) { + if ( \preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) { $id = absint( $values[1] ); if ( $id ) { return $id; @@ -253,10 +253,10 @@ function url_to_authorid( $url ) { // generate rewrite rule for the author url $author_rewrite = $wp_rewrite->get_author_permastruct(); - $author_regexp = str_replace( '%author%', '', $author_rewrite ); + $author_regexp = \str_replace( '%author%', '', $author_rewrite ); // match the rewrite rule with the passed url - if ( preg_match( '/https?:\/\/(.+)' . preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) { + if ( \preg_match( '/https?:\/\/(.+)' . \preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) { $user = get_user_by( 'slug', $match[2] ); if ( $user ) { return $user->ID; diff --git a/includes/model/class-activity.php b/includes/model/class-activity.php index 0cfc1c6..470b192 100644 --- a/includes/model/class-activity.php +++ b/includes/model/class-activity.php @@ -30,7 +30,7 @@ class Activity { } $this->type = \ucfirst( $type ); - $this->published = \date( 'Y-m-d\TH:i:s\Z', strtotime( 'now' ) ); + $this->published = \date( 'Y-m-d\TH:i:s\Z', \strtotime( 'now' ) ); } public function __call( $method, $params ) { diff --git a/includes/rest/class-inbox.php b/includes/rest/class-inbox.php index 85d4ba1..e2772ae 100644 --- a/includes/rest/class-inbox.php +++ b/includes/rest/class-inbox.php @@ -252,7 +252,7 @@ class Inbox { 'comment_author_email' => '', 'comment_author_url' => \esc_url_raw( $object['actor'] ), 'comment_content' => \esc_url_raw( $object['actor'] ), - 'comment_type' => \esc_attr( strtolower( $object['type'] ) ), + 'comment_type' => \esc_attr( \strtolower( $object['type'] ) ), 'comment_parent' => 0, 'comment_meta' => array( 'source_url' => \esc_url_raw( $object['id'] ), diff --git a/includes/rest/class-outbox.php b/includes/rest/class-outbox.php index c7ddbcb..a43b74e 100644 --- a/includes/rest/class-outbox.php +++ b/includes/rest/class-outbox.php @@ -78,7 +78,7 @@ class Outbox { $json->first = \add_query_arg( 'page', 0, $json->partOf ); // phpcs:ignore $json->last = \add_query_arg( 'page', ( \ceil ( $json->totalItems / 10 ) ) - 1, $json->partOf ); // phpcs:ignore - if ( ( ceil ( $json->totalItems / 10 ) ) - 1 > $page ) { // phpcs:ignore + if ( ( \ceil ( $json->totalItems / 10 ) ) - 1 > $page ) { // phpcs:ignore $json->next = \add_query_arg( 'page', ++$page, $json->partOf ); // phpcs:ignore } diff --git a/includes/table/followers-list.php b/includes/table/followers-list.php index 965cb90..81444ee 100644 --- a/includes/table/followers-list.php +++ b/includes/table/followers-list.php @@ -1,7 +1,7 @@
  • - name, $support_post_types, true ) ); ?> /> + name, $support_post_types, true ) ); ?> />
  • diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b37004a..e75f0bb 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,10 +1,10 @@ assertEquals( 3, count( $db_followers ) ); + $this->assertEquals( 3, \count( $db_followers ) ); $this->assertSame( array( 'https://example.com/author/jon', 'https://example.org/author/doe', 'http://sally.example.org' ), $db_followers ); } public function test_add_follower() { - $follower = 'https://example.com/author/' . time(); + $follower = 'https://example.com/author/' . \time(); \Activitypub\Peer\Followers::add_follower( $follower, 1 ); $db_followers = \Activitypub\Peer\Followers::get_followers( 1 );