diff --git a/.php_cs b/.php_cs index f7a56ff..7f81780 100644 --- a/.php_cs +++ b/.php_cs @@ -8,7 +8,7 @@ $finder = PhpCsFixer\Finder::create() return PhpCsFixer\Config::create() ->setRules([ - 'native_function_invocation' => true, + 'native_function_invocation' => ['include' => ['@all']], 'native_constant_invocation' => true, ]) ->setFinder($finder) diff --git a/activitypub.php b/activitypub.php index e6a5539..fe834cd 100644 --- a/activitypub.php +++ b/activitypub.php @@ -72,7 +72,7 @@ function init() { return '\Activitypub\Rest\Server'; } ); } -add_action( 'plugins_loaded', '\Activitypub\init' ); +\add_action( 'plugins_loaded', '\Activitypub\init' ); /** * Add rewrite rules diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 49e022a..e3b63ee 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -117,7 +117,7 @@ class Activitypub { } elseif ( 'publish' === $new_status ) { \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 0dca896..b9b7d59 100644 --- a/includes/class-admin.php +++ b/includes/class-admin.php @@ -30,7 +30,7 @@ class Admin { \add_action( 'load-' . $settings_page, array( '\Activitypub\Admin', 'add_settings_help_tab' ) ); - $followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), __( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) ); + $followers_list_page = \add_users_page( \__( 'Followers', 'activitypub' ), \__( 'Followers (Fediverse)', 'activitypub' ), 'read', 'activitypub-followers-list', array( '\Activitypub\Admin', 'followers_list_page' ) ); \add_action( 'load-' . $followers_list_page, array( '\Activitypub\Admin', 'add_followers_list_help_tab' ) ); } diff --git a/includes/functions.php b/includes/functions.php index 982d740..b80ad99 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -157,7 +157,7 @@ function get_inbox_by_actor( $actor ) { return $metadata['inbox']; } - return new \WP_Error( 'activitypub_no_inbox', __( 'No "Inbox" found', 'activitypub' ), $metadata ); + return new \WP_Error( 'activitypub_no_inbox', \__( 'No "Inbox" found', 'activitypub' ), $metadata ); } /** @@ -253,13 +253,13 @@ function url_to_authorid( $url ) { global $wp_rewrite; // check if url hase the same host - if ( wp_parse_url( site_url(), \PHP_URL_HOST ) !== wp_parse_url( $url, \PHP_URL_HOST ) ) { + if ( \wp_parse_url( \site_url(), \PHP_URL_HOST ) !== \wp_parse_url( $url, \PHP_URL_HOST ) ) { return 0; } // first, check to see if there is a 'author=N' to match against if ( \preg_match( '/[?&]author=(\d+)/i', $url, $values ) ) { - $id = absint( $values[1] ); + $id = \absint( $values[1] ); if ( $id ) { return $id; } @@ -279,7 +279,7 @@ function url_to_authorid( $url ) { // match the rewrite rule with the passed url if ( \preg_match( '/https?:\/\/(.+)' . \preg_quote( $author_regexp, '/' ) . '([^\/]+)/i', $url, $match ) ) { - $user = get_user_by( 'slug', $match[2] ); + $user = \get_user_by( 'slug', $match[2] ); if ( $user ) { return $user->ID; } diff --git a/includes/rest/class-nodeinfo.php b/includes/rest/class-nodeinfo.php index 9d5101b..5464e08 100644 --- a/includes/rest/class-nodeinfo.php +++ b/includes/rest/class-nodeinfo.php @@ -105,7 +105,7 @@ class Nodeinfo { $nodeinfo['version'] = '1.0'; $nodeinfo['server'] = array( - 'baseUrl' => home_url( '/' ), + 'baseUrl' => \home_url( '/' ), 'name' => \get_bloginfo( 'name' ), 'software' => 'wordpress', 'version' => \get_bloginfo( 'version' ), diff --git a/includes/rest/class-outbox.php b/includes/rest/class-outbox.php index a43b74e..65cc3ba 100644 --- a/includes/rest/class-outbox.php +++ b/includes/rest/class-outbox.php @@ -42,7 +42,7 @@ class Outbox { $author = \get_user_by( 'ID', $user_id ); if ( ! $author ) { - return new \WP_Error( 'rest_invalid_param', __( 'User not found', 'activitypub' ), array( + return new \WP_Error( 'rest_invalid_param', \__( 'User not found', 'activitypub' ), array( 'status' => 404, 'params' => array( 'user_id' => \__( 'User not found', 'activitypub' ), diff --git a/includes/rest/class-server.php b/includes/rest/class-server.php index 841c6ba..6c68621 100644 --- a/includes/rest/class-server.php +++ b/includes/rest/class-server.php @@ -24,7 +24,7 @@ class Server extends \WP_REST_Server { } // make request filterable - $request = apply_filters( 'activitypub_pre_dispatch_request', $request ); + $request = \apply_filters( 'activitypub_pre_dispatch_request', $request ); return parent::dispatch( $request ); } diff --git a/templates/json-author.php b/templates/json-author.php index bfe4e97..a16de2f 100644 --- a/templates/json-author.php +++ b/templates/json-author.php @@ -31,7 +31,7 @@ $json->outbox = \get_rest_url( null, "/activitypub/1.0/users/$author_id/outbox" $json->followers = \get_rest_url( null, "/activitypub/1.0/users/$author_id/followers" ); $json->following = \get_rest_url( null, "/activitypub/1.0/users/$author_id/following" ); -$json->manuallyApprovesFollowers = \apply_filters( 'activitypub_json_manually_approves_followers', __return_false() ); // phpcs:ignore +$json->manuallyApprovesFollowers = \apply_filters( 'activitypub_json_manually_approves_followers', \__return_false() ); // phpcs:ignore // phpcs:ignore $json->publicKey = array( @@ -45,7 +45,7 @@ $json->attachment = array(); $json->attachment[] = array( 'type' => 'PropertyValue', - 'name' => __( 'Blog', 'activitypub' ), + 'name' => \__( 'Blog', 'activitypub' ), 'value' => \html_entity_decode( '' . \wp_parse_url( \home_url( '/' ), \PHP_URL_HOST ) . '', \ENT_QUOTES, @@ -55,7 +55,7 @@ $json->attachment[] = array( $json->attachment[] = array( 'type' => 'PropertyValue', - 'name' => __( 'Profile', 'activitypub' ), + 'name' => \__( 'Profile', 'activitypub' ), 'value' => \html_entity_decode( '' . \wp_parse_url( \get_author_posts_url( $author_id ), \PHP_URL_HOST ) . '', \ENT_QUOTES, @@ -66,7 +66,7 @@ $json->attachment[] = array( if ( \get_the_author_meta( 'user_url', $author_id ) ) { $json->attachment[] = array( 'type' => 'PropertyValue', - 'name' => __( 'Website', 'activitypub' ), + 'name' => \__( 'Website', 'activitypub' ), 'value' => \html_entity_decode( '' . \wp_parse_url( \get_the_author_meta( 'user_url', $author_id ), \PHP_URL_HOST ) . '', \ENT_QUOTES, diff --git a/templates/settings.php b/templates/settings.php index 11c1eb4..099ab54 100644 --- a/templates/settings.php +++ b/templates/settings.php @@ -14,7 +14,7 @@ - +

@@ -34,7 +34,7 @@

-

', '' ); ?>

+

', '' ); ?>

@@ -121,6 +121,6 @@

- donation?', 'activitypub' ); ?> + donation?', 'activitypub' ); ?>

diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 9c550d9..cfc6d00 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -14,7 +14,7 @@ require_once $_tests_dir . '/includes/functions.php'; function _manually_load_plugin() { require \dirname( \dirname( __FILE__ ) ) . '/activitypub.php'; } -tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); +\tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); require $_tests_dir . '/includes/bootstrap.php'; diff --git a/tests/test-class-activitypub-hashtag.php b/tests/test-class-activitypub-hashtag.php index 54d622e..e7699d2 100644 --- a/tests/test-class-activitypub-hashtag.php +++ b/tests/test-class-activitypub-hashtag.php @@ -10,9 +10,9 @@ class Test_Activitypub_Hashtag extends WP_UnitTestCase { } public function the_content_provider() { - wp_create_term( 'object', 'post_tag' ); - $object = get_term_by( 'name', 'object', 'post_tag' ); - $link = get_term_link( $object, 'post_tag' ); + \wp_create_term( 'object', 'post_tag' ); + $object = \get_term_by( 'name', 'object', 'post_tag' ); + $link = \get_term_link( $object, 'post_tag' ); return array( array( 'test', 'test' ), diff --git a/tests/test-class-activitypub.php b/tests/test-class-activitypub.php index 090389b..26efbf6 100644 --- a/tests/test-class-activitypub.php +++ b/tests/test-class-activitypub.php @@ -1,10 +1,10 @@ assertContains( 'post', get_post_types_by_support( 'activitypub' ) ); - $this->assertContains( 'page', get_post_types_by_support( 'activitypub' ) ); + $this->assertContains( 'post', \get_post_types_by_support( 'activitypub' ) ); + $this->assertContains( 'page', \get_post_types_by_support( 'activitypub' ) ); } } diff --git a/tests/test-class-db-activitypub-followers.php b/tests/test-class-db-activitypub-followers.php index 295bf24..c502bf2 100644 --- a/tests/test-class-db-activitypub-followers.php +++ b/tests/test-class-db-activitypub-followers.php @@ -7,7 +7,7 @@ class Test_Db_Activitypub_Followers extends WP_UnitTestCase { 'id' => 'http://sally.example.org', 'name' => 'Sally Smith', ); - update_user_meta( 1, 'activitypub_followers', $followers ); + \update_user_meta( 1, 'activitypub_followers', $followers ); $db_followers = \Activitypub\Peer\Followers::get_followers( 1 );