Skip to content

Commit cc8042a

Browse files
authored
Fix minor code changes (#1635)
1 parent 0b30656 commit cc8042a

37 files changed

+258
-285
lines changed

includes/activity/class-generic-object.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ public function to_string() {
106106
*
107107
* @param string $method The method name.
108108
* @param string $params The method params.
109+
*
110+
* @return mixed
109111
*/
110112
public function __call( $method, $params ) {
111113
$var = \strtolower( \substr( $method, 4 ) );
@@ -125,6 +127,8 @@ public function __call( $method, $params ) {
125127
if ( \strncasecmp( $method, 'add', 3 ) === 0 ) {
126128
return $this->add( $var, $params[0] );
127129
}
130+
131+
return null;
128132
}
129133

130134
/**
@@ -158,7 +162,7 @@ public function set( $key, $value ) {
158162
* @param string $key The key to set.
159163
* @param mixed $value The value to add.
160164
*
161-
* @return mixed The value.
165+
* @return mixed|void The value.
162166
*/
163167
public function add( $key, $value ) {
164168
if ( empty( $value ) ) {

includes/class-blocks.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public static function inject_activitypub_options() {
136136
);
137137

138138
printf(
139-
"\n<script>var _activityPubOptions = %s;</script>",
139+
"\n<script>let _activityPubOptions = %s;</script>",
140140
wp_json_encode( $data )
141141
);
142142
}
@@ -406,7 +406,7 @@ public static function render_follower( $follower ) {
406406
$external_svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" class="components-external-link__icon css-rvs7bx esh4a730" aria-hidden="true" focusable="false"><path d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"></path></svg>';
407407
$template =
408408
'<a href="%s" title="%s" class="components-external-link activitypub-link" target="_blank" rel="external noreferrer noopener">
409-
<img width="40" height="40" src="%s" class="avatar activitypub-avatar" />
409+
<img width="40" height="40" src="%s" class="avatar activitypub-avatar" alt="" />
410410
<span class="activitypub-actor">
411411
<strong class="activitypub-name">%s</strong>
412412
<span class="sep">/</span>

includes/class-comment.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,12 +732,12 @@ public static function comment_query( $query ) {
732732
/**
733733
* Filter the comment status before it is set.
734734
*
735-
* @param string $approved The approved comment status.
736-
* @param array $commentdata The comment data.
735+
* @param int|string|\WP_Error $approved The approved comment status.
736+
* @param array $comment_data The comment data.
737737
*
738-
* @return boolean `true` if the comment is approved, `false` otherwise.
738+
* @return int|string|\WP_Error The approval status. 1, 0, 'spam', 'trash', or WP_Error.
739739
*/
740-
public static function pre_comment_approved( $approved, $commentdata ) {
740+
public static function pre_comment_approved( $approved, $comment_data ) {
741741
if ( $approved || \is_wp_error( $approved ) ) {
742742
return $approved;
743743
}
@@ -747,16 +747,16 @@ public static function pre_comment_approved( $approved, $commentdata ) {
747747
}
748748

749749
if (
750-
empty( $commentdata['comment_meta']['protocol'] ) ||
751-
'activitypub' !== $commentdata['comment_meta']['protocol']
750+
empty( $comment_data['comment_meta']['protocol'] ) ||
751+
'activitypub' !== $comment_data['comment_meta']['protocol']
752752
) {
753753
return $approved;
754754
}
755755

756756
global $wpdb;
757757

758-
$author = $commentdata['comment_author'];
759-
$author_url = $commentdata['comment_author_url'];
758+
$author = $comment_data['comment_author'];
759+
$author_url = $comment_data['comment_author_url'];
760760
// phpcs:ignore
761761
$ok_to_comment = $wpdb->get_var( $wpdb->prepare( "SELECT comment_approved FROM $wpdb->comments WHERE comment_author = %s AND comment_author_url = %s and comment_approved = '1' LIMIT 1", $author, $author_url ) );
762762

includes/class-debug.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function log_inbox( $data, $user_id, $type ) {
5656
}
5757

5858
/**
59-
* Log the sent to follower action.
59+
* Logs Follower notifications.
6060
*
6161
* @param array $result The result of the remote post request.
6262
* @param string $inbox The inbox URL.

includes/class-embed.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static function get_html_for_object( $activity_object, $inline_css = true
151151
*/
152152
public static function has_real_oembed( $url, $args = array() ) {
153153
// Temporarily remove our filter to avoid infinite loops.
154-
\remove_filter( 'pre_oembed_result', array( self::class, 'maybe_use_activitypub_embed' ), 10, 3 );
154+
\remove_filter( 'pre_oembed_result', array( self::class, 'maybe_use_activitypub_embed' ) );
155155

156156
// Try to get a "real" oEmbed result. If found, it'll be cached to avoid unnecessary HTTP requests in `wp_oembed_get`.
157157
$oembed_result = \wp_oembed_get( $url, $args );

includes/class-mention.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ class Mention {
1919
* Initialize the class, registering WordPress hooks.
2020
*/
2121
public static function init() {
22-
\add_filter( 'the_content', array( self::class, 'the_content' ), 99, 1 );
23-
\add_filter( 'comment_text', array( self::class, 'the_content' ), 10, 1 );
24-
\add_filter( 'activitypub_extra_field_content', array( self::class, 'the_content' ), 10, 1 );
22+
\add_filter( 'the_content', array( self::class, 'the_content' ), 99 );
23+
\add_filter( 'comment_text', array( self::class, 'the_content' ) );
24+
\add_filter( 'activitypub_extra_field_content', array( self::class, 'the_content' ) );
2525
\add_filter( 'activitypub_extract_mentions', array( self::class, 'extract_mentions' ), 99, 2 );
2626
\add_filter( 'activitypub_activity_object_array', array( self::class, 'filter_activity_object' ), 99 );
2727
}

includes/class-migration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ private static function migrate_to_4_0_0() {
421421
}
422422

423423
/**
424-
* Upate to 4.1.0
424+
* Update to 4.1.0
425425
*
426426
* * Migrate the `activitypub_post_content_type` to only use `activitypub_custom_post_content`.
427427
*/

includes/class-move.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public static function account( $from, $to ) {
6565
/**
6666
* Move an ActivityPub Actor from one location (internal) to another (external).
6767
*
68-
* This helps migrating local profiles to a new external profile:
68+
* This helps with migrating local profiles to a new external profile:
6969
*
7070
* `Move::externally( 'https://example.com/?author=123', 'https://mastodon.example/users/foo' );`
7171
*
@@ -119,7 +119,7 @@ public static function externally( $from, $to ) {
119119
*
120120
* Move an ActivityPub Actor from one location (internal) to another (internal).
121121
*
122-
* This helps migrating abandoned profiles to `Move` to other profiles:
122+
* This helps with migrating abandoned profiles to `Move` to other profiles:
123123
*
124124
* `Move::internally( 'https://example.com/?author=123', 'https://example.com/?author=321' );`
125125
*
@@ -236,7 +236,7 @@ public static function change_domain( $from, $to ) {
236236
if ( $actor instanceof Blog ) {
237237
\update_option( 'activitypub_blog_user_old_host_data', $json, false );
238238
} else {
239-
\update_user_option( $actor->get__id(), 'activitypub_old_host_data', $json, false );
239+
\update_user_option( $actor->get__id(), 'activitypub_old_host_data', $json );
240240
}
241241

242242
$results[] = array(

0 commit comments

Comments
 (0)