PluginProbe
ActivityPub / 9.2.1
ActivityPub v9.2.1
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/wp-admin/class-admin.php +66 -66 8.2.19.2.1 View file →
@@ -91,9 +91,9 @@
91 91 /**
92 92 * Display admin menu notices about configuration problems or conflicts.
93 93 */
94 94 public static function admin_notices() {
95 - $current_screen = get_current_screen();
95 + $current_screen = \get_current_screen();
96 96
97 97 if ( ! $current_screen ) {
98 98 return;
99 99 }
@@ -105,12 +105,12 @@
105 105 \delete_option( 'activitypub_self_destruct_complete' );
106 106 ?>
107 107 <div class="notice notice-success is-dismissible">
108 108 <p>
109 - <strong><?php esc_html_e( 'ActivityPub Self-Destruct Complete!', 'activitypub' ); ?></strong>
109 + <strong><?php \esc_html_e( 'ActivityPub Self-Destruct Complete!', 'activitypub' ); ?></strong>
110 110 </p>
111 111 <p>
112 - <?php esc_html_e( 'All Delete activities have been successfully sent to the Fediverse. Your blog is no longer discoverable via ActivityPub and all followers have been notified of the deletion.', 'activitypub' ); ?>
112 + <?php \esc_html_e( 'All Delete activities have been successfully sent to the Fediverse. Your blog is no longer discoverable via ActivityPub and all followers have been notified of the deletion.', 'activitypub' ); ?>
113 113 </p>
114 114 </div>
115 115 <?php
116 116 }
@@ -118,9 +118,9 @@
118 118 if ( 'edit' === $current_screen->base && Extra_Fields::is_extra_fields_post_type( $current_screen->post_type ) ) {
119 119 ?>
120 120 <div class="notice" style="margin: 0; background: none; border: none; box-shadow: none; padding: 15px 0 0 0; font-size: 14px;">
121 121 <?php
122 - esc_html_e( 'These are extra fields that are used for your ActivityPub profile. You can use your homepage, social profiles, pronouns, age, anything you want.', 'activitypub' );
122 + \esc_html_e( 'These are extra fields that are used for your ActivityPub profile. You can use your homepage, social profiles, pronouns, age, anything you want.', 'activitypub' );
123 123 ?>
124 124 </div>
125 125 <?php
126 126 }
@@ -199,13 +199,13 @@
199 199 /**
200 200 * Render user settings.
201 201 */
202 202 public static function add_profile() {
203 - wp_enqueue_media();
204 - wp_enqueue_script( 'activitypub-header-image' );
203 + \wp_enqueue_media();
204 + \wp_enqueue_script( 'activitypub-header-image' );
205 205
206 - wp_nonce_field( 'activitypub-user-settings', '_apnonce' );
207 - do_settings_sections( 'activitypub_user_settings' );
206 + \wp_nonce_field( 'activitypub-user-settings', '_apnonce' );
207 + \do_settings_sections( 'activitypub_user_settings' );
208 208 }
209 209
210 210 /**
211 211 * Save the user settings.
@@ -218,12 +218,12 @@
218 218 if ( ! isset( $_REQUEST['_apnonce'] ) ) {
219 219 return;
220 220 }
221 221
222 - $nonce = sanitize_text_field( wp_unslash( $_REQUEST['_apnonce'] ) );
222 + $nonce = \sanitize_text_field( \wp_unslash( $_REQUEST['_apnonce'] ) );
223 223 if (
224 - ! wp_verify_nonce( $nonce, 'activitypub-user-settings' ) ||
225 - ! current_user_can( 'edit_user', $user_id )
224 + ! \wp_verify_nonce( $nonce, 'activitypub-user-settings' ) ||
225 + ! \current_user_can( 'edit_user', $user_id )
226 226 ) {
227 227 return;
228 228 }
229 229
@@ -234,9 +234,9 @@
234 234 );
235 235
236 236 foreach ( $textarea_field_user_options as $option ) {
237 237 if ( ! empty( $_POST[ $option ] ) ) {
238 - \update_user_option( $user_id, $option, sanitize_textarea_field( wp_unslash( $_POST[ $option ] ) ) );
238 + \update_user_option( $user_id, $option, \sanitize_textarea_field( \wp_unslash( $_POST[ $option ] ) ) );
239 239 } else {
240 240 \delete_user_option( $user_id, $option );
241 241 }
242 242 }
@@ -247,9 +247,9 @@
247 247 );
248 248
249 249 foreach ( $text_field_user_options as $option ) {
250 250 if ( ! empty( $_POST[ $option ] ) ) {
251 - \update_user_option( $user_id, $option, sanitize_text_field( wp_unslash( $_POST[ $option ] ) ) );
251 + \update_user_option( $user_id, $option, \sanitize_text_field( \wp_unslash( $_POST[ $option ] ) ) );
252 252 } else {
253 253 \delete_user_option( $user_id, $option );
254 254 }
255 255 }
@@ -264,9 +264,9 @@
264 264 'activitypub_mailer_monthly_report',
265 265 );
266 266
267 267 foreach ( $required_user_options as $option ) {
268 - \update_user_option( $user_id, $option, sanitize_text_field( wp_unslash( $_POST[ $option ] ?? 0 ) ) );
268 + \update_user_option( $user_id, $option, \sanitize_text_field( \wp_unslash( $_POST[ $option ] ?? 0 ) ) );
269 269 }
270 270 }
271 271
272 272 /**
@@ -274,11 +274,11 @@
274 274 *
275 275 * @param string $hook_suffix The current page.
276 276 */
277 277 public static function enqueue_scripts( $hook_suffix ) {
278 - wp_register_script(
278 + \wp_register_script(
279 279 'activitypub-header-image',
280 - plugins_url(
280 + \plugins_url(
281 281 'assets/js/activitypub-header-image.js',
282 282 ACTIVITYPUB_PLUGIN_FILE
283 283 ),
284 284 array( 'jquery' ),
@@ -288,17 +288,17 @@
288 288
289 289 // Register and enqueue command palette integration.
290 290 if ( user_can_activitypub( \get_current_user_id() ) || \current_user_can( 'manage_options' ) ) {
291 291 $asset_data = include ACTIVITYPUB_PLUGIN_DIR . 'build/command-palette/plugin.asset.php';
292 - wp_enqueue_script(
292 + \wp_enqueue_script(
293 293 'activitypub-command-palette',
294 - plugins_url( 'build/command-palette/plugin.js', ACTIVITYPUB_PLUGIN_FILE ),
294 + \plugins_url( 'build/command-palette/plugin.js', ACTIVITYPUB_PLUGIN_FILE ),
295 295 $asset_data['dependencies'],
296 296 $asset_data['version'],
297 297 true
298 298 );
299 299
300 - wp_localize_script(
300 + \wp_localize_script(
301 301 'activitypub-command-palette',
302 302 'activitypubCommandPalette',
303 303 array(
304 304 'followingEnabled' => '1' === \get_option( 'activitypub_following_ui', '0' ),
@@ -307,12 +307,12 @@
307 307 )
308 308 );
309 309 }
310 310
311 - if ( false !== strpos( $hook_suffix, 'activitypub' ) && 'dashboard_page_activitypub-social-web' !== $hook_suffix ) {
312 - wp_enqueue_style(
311 + if ( false !== \strpos( $hook_suffix, 'activitypub' ) && 'dashboard_page_activitypub-social-web' !== $hook_suffix ) {
312 + \wp_enqueue_style(
313 313 'activitypub-admin-styles',
314 - plugins_url(
314 + \plugins_url(
315 315 'assets/css/activitypub-admin.css',
316 316 ACTIVITYPUB_PLUGIN_FILE
317 317 ),
318 318 array(),
@@ -317,11 +317,11 @@
317 317 ),
318 318 array(),
319 319 ACTIVITYPUB_PLUGIN_VERSION
320 320 );
321 - wp_enqueue_script(
321 + \wp_enqueue_script(
322 322 'activitypub-admin-script',
323 - plugins_url(
323 + \plugins_url(
324 324 'assets/js/activitypub-admin.js',
325 325 ACTIVITYPUB_PLUGIN_FILE
326 326 ),
327 327 array( 'jquery', 'wp-util' ),
@@ -335,11 +335,11 @@
335 335 \wp_enqueue_script( 'updates' );
336 336 }
337 337
338 338 if ( 'index.php' === $hook_suffix ) {
339 - wp_enqueue_style(
339 + \wp_enqueue_style(
340 340 'activitypub-admin-styles',
341 - plugins_url(
341 + \plugins_url(
342 342 'assets/css/activitypub-admin.css',
343 343 ACTIVITYPUB_PLUGIN_FILE
344 344 ),
345 345 array(),
@@ -467,15 +467,15 @@
467 467 if ( 'edit_post' !== $arg[0] ) {
468 468 return $all_caps;
469 469 }
470 470
471 - $post = get_post( $arg[2] );
471 + $post = \get_post( $arg[2] );
472 472
473 473 if ( ! Extra_Fields::is_extra_field_post_type( $post->post_type ) ) {
474 474 return $all_caps;
475 475 }
476 476
477 - if ( get_current_user_id() !== (int) $post->post_author ) {
477 + if ( \get_current_user_id() !== (int) $post->post_author ) {
478 478 return false;
479 479 }
480 480
481 481 return $all_caps;
@@ -489,14 +489,14 @@
489 489 * Add ActivityPub specific actions/filters to the post list view.
490 490 */
491 491 public static function list_posts() {
492 492 // Remove all views for the extra fields.
493 - $screen_id = get_current_screen()->id;
493 + $screen_id = \get_current_screen()->id;
494 494
495 - add_filter(
495 + \add_filter(
496 496 "views_{$screen_id}",
497 497 static function ( $views ) {
498 - if ( Extra_Fields::is_extra_fields_post_type( get_current_screen()->post_type ) ) {
498 + if ( Extra_Fields::is_extra_fields_post_type( \get_current_screen()->post_type ) ) {
499 499 return array();
500 500 }
501 501
502 502 return $views;
@@ -516,9 +516,9 @@
516 516 if ( was_comment_received( $comment ) ) {
517 517 unset( $actions['edit'], $actions['quickedit'] );
518 518 }
519 519
520 - if ( in_array( get_comment_type( $comment ), Comment::get_comment_type_slugs(), true ) ) {
520 + if ( \in_array( \get_comment_type( $comment ), Comment::get_comment_type_slugs(), true ) ) {
521 521 unset( $actions['reply'] );
522 522 }
523 523
524 524 return $actions;
@@ -533,9 +533,9 @@
533 533 *
534 534 * @return array The columns extended by the activitypub.
535 535 */
536 536 public static function manage_users_columns( $columns ) {
537 - $columns['activitypub'] = __( 'ActivityPub', 'activitypub' );
537 + $columns['activitypub'] = \__( 'ActivityPub', 'activitypub' );
538 538 return $columns;
539 539 }
540 540
541 541 /**
@@ -545,10 +545,10 @@
545 545 *
546 546 * @return array The extended list of column names.
547 547 */
548 548 public static function manage_comment_columns( $columns ) {
549 - $columns['comment_type'] = esc_attr__( 'Comment-Type', 'activitypub' );
550 - $columns['comment_protocol'] = esc_attr__( 'Protocol', 'activitypub' );
549 + $columns['comment_type'] = \esc_attr__( 'Comment-Type', 'activitypub' );
550 + $columns['comment_protocol'] = \esc_attr__( 'Protocol', 'activitypub' );
551 551
552 552 return $columns;
553 553 }
554 554
@@ -562,10 +562,10 @@
562 562 */
563 563 public static function manage_post_columns( $columns, $post_type ) {
564 564 if ( Extra_Fields::is_extra_fields_post_type( $post_type ) ) {
565 565 $after_key = 'title';
566 - $index = array_search( $after_key, array_keys( $columns ), true );
567 - $columns = array_slice( $columns, 0, $index + 1 ) + array( 'extra_field_content' => esc_attr__( 'Content', 'activitypub' ) ) + $columns;
566 + $index = \array_search( $after_key, \array_keys( $columns ), true );
567 + $columns = \array_slice( $columns, 0, $index + 1 ) + array( 'extra_field_content' => \esc_attr__( 'Content', 'activitypub' ) ) + $columns;
568 568 }
569 569
570 570 return $columns;
571 571 }
@@ -576,17 +576,17 @@
576 576 * @param array $column The column to implement.
577 577 * @param int $comment_id The comment id.
578 578 */
579 579 public static function manage_comments_custom_column( $column, $comment_id ) {
580 - if ( 'comment_type' === $column && ! defined( 'WEBMENTION_PLUGIN_DIR' ) ) {
581 - echo esc_attr( ucfirst( get_comment_type( $comment_id ) ) );
580 + if ( 'comment_type' === $column && ! \defined( 'WEBMENTION_PLUGIN_DIR' ) ) {
581 + echo \esc_attr( \ucfirst( \get_comment_type( $comment_id ) ) );
582 582 } elseif ( 'comment_protocol' === $column ) {
583 - $protocol = get_comment_meta( $comment_id, 'protocol', true );
583 + $protocol = \get_comment_meta( $comment_id, 'protocol', true );
584 584
585 585 if ( $protocol ) {
586 - echo esc_attr( ucfirst( str_replace( 'activitypub', 'ActivityPub', $protocol ) ) );
586 + echo \esc_attr( \ucfirst( \str_replace( 'activitypub', 'ActivityPub', $protocol ) ) );
587 587 } else {
588 - esc_attr_e( 'Local', 'activitypub' );
588 + \esc_attr_e( 'Local', 'activitypub' );
589 589 }
590 590 }
591 591 }
592 592
@@ -598,9 +598,9 @@
598 598 * @return array The extended comment types.
599 599 */
600 600 public static function comment_types_dropdown( $types ) {
601 601 foreach ( Comment::get_comment_types() as $comment_type ) {
602 - $types[ $comment_type['type'] ] = esc_html( $comment_type['label'] );
602 + $types[ $comment_type['type'] ] = \esc_html( $comment_type['label'] );
603 603 }
604 604
605 605 return $types;
606 606 }
@@ -619,11 +619,11 @@
619 619 return $output;
620 620 }
621 621
622 622 if ( \user_can( $user_id, 'activitypub' ) ) {
623 - return '<span aria-hidden="true">&#x2713;</span><span class="screen-reader-text">' . esc_html__( 'ActivityPub enabled for this author', 'activitypub' ) . '</span>';
623 + return '<span aria-hidden="true">&#x2713;</span><span class="screen-reader-text">' . \esc_html__( 'ActivityPub enabled for this author', 'activitypub' ) . '</span>';
624 624 } else {
625 - return '<span aria-hidden="true">&#x2717;</span><span class="screen-reader-text">' . esc_html__( 'ActivityPub disabled for this author', 'activitypub' ) . '</span>';
625 + return '<span aria-hidden="true">&#x2717;</span><span class="screen-reader-text">' . \esc_html__( 'ActivityPub disabled for this author', 'activitypub' ) . '</span>';
626 626 }
627 627 }
628 628
629 629 /**
@@ -635,11 +635,11 @@
635 635 * @return void
636 636 */
637 637 public static function manage_posts_custom_column( $column_name, $post_id ) {
638 638 if ( 'extra_field_content' === $column_name ) {
639 - $post = get_post( $post_id );
639 + $post = \get_post( $post_id );
640 640 if ( Extra_Fields::is_extra_fields_post_type( $post->post_type ) ) {
641 - echo esc_attr( wp_strip_all_tags( $post->post_content ) );
641 + echo \esc_attr( \wp_strip_all_tags( $post->post_content ) );
642 642 }
643 643 }
644 644 }
645 645
@@ -650,10 +650,10 @@
650 650 *
651 651 * @return array The extended bulk options.
652 652 */
653 653 public static function user_bulk_options( $actions ) {
654 - $actions['add_activitypub_cap'] = __( 'Enable for ActivityPub', 'activitypub' );
655 - $actions['remove_activitypub_cap'] = __( 'Disable for ActivityPub', 'activitypub' );
654 + $actions['add_activitypub_cap'] = \__( 'Enable for ActivityPub', 'activitypub' );
655 + $actions['remove_activitypub_cap'] = \__( 'Disable for ActivityPub', 'activitypub' );
656 656
657 657 return $actions;
658 658 }
659 659
@@ -714,9 +714,9 @@
714 714 );
715 715
716 716 // Add user IDs as separate parameters.
717 717 foreach ( $users as $index => $user_id ) {
718 - $query_args[ sprintf( 'users[%d]', $index ) ] = absint( $user_id );
718 + $query_args[ \sprintf( 'users[%d]', $index ) ] = \absint( $user_id );
719 719 }
720 720
721 721 $confirmation_url = \add_query_arg( $query_args, \admin_url( 'users.php' ) );
722 722
@@ -818,9 +818,9 @@
818 818 * @return string The URL to redirect to.
819 819 */
820 820 public static function process_capability_removal( $users, $remove_from_fediverse, $send_back ) {
821 821 // Normalize fediverse removal parameter.
822 - if ( is_string( $remove_from_fediverse ) ) {
822 + if ( \is_string( $remove_from_fediverse ) ) {
823 823 // Legacy format: 'delete' or 'keep' for all users.
824 824 $delete_all = ( 'delete' === $remove_from_fediverse );
825 825 $users_to_delete = $delete_all ? $users : array();
826 826 } else {
@@ -858,11 +858,11 @@
858 858 public static function dashboard_glance_items( $items ) {
859 859 \add_filter( 'number_format_i18n', '\Activitypub\custom_large_numbers', 10, 2 );
860 860
861 861 if ( user_can_activitypub( \get_current_user_id() ) ) {
862 - $follower_count = sprintf(
862 + $follower_count = \sprintf(
863 863 // translators: %s: number of followers.
864 - _n(
864 + \_n(
865 865 '%s Follower',
866 866 '%s Followers',
867 867 count_followers( \get_current_user_id() ),
868 868 'activitypub'
@@ -868,9 +868,9 @@
868 868 'activitypub'
869 869 ),
870 870 \number_format_i18n( count_followers( \get_current_user_id() ) )
871 871 );
872 - $items['activitypub-followers-user'] = sprintf(
872 + $items['activitypub-followers-user'] = \sprintf(
873 873 '<a class="activitypub-followers" href="%1$s" title="%2$s">%3$s</a>',
874 874 \esc_url( \admin_url( 'users.php?page=activitypub-followers-list' ) ),
875 875 \esc_attr__( 'Your followers', 'activitypub' ),
876 876 \esc_html( $follower_count )
@@ -876,12 +876,12 @@
876 876 \esc_html( $follower_count )
877 877 );
878 878 }
879 879
880 - if ( ! is_user_type_disabled( 'blog' ) && current_user_can( 'manage_options' ) ) {
881 - $follower_count = sprintf(
880 + if ( ! is_user_type_disabled( 'blog' ) && \current_user_can( 'manage_options' ) ) {
881 + $follower_count = \sprintf(
882 882 // translators: %s: number of followers.
883 - _n(
883 + \_n(
884 884 '%s Follower (Blog)',
885 885 '%s Followers (Blog)',
886 886 count_followers( Actors::BLOG_USER_ID ),
887 887 'activitypub'
@@ -887,9 +887,9 @@
887 887 'activitypub'
888 888 ),
889 889 \number_format_i18n( count_followers( Actors::BLOG_USER_ID ) )
890 890 );
891 - $items['activitypub-followers-blog'] = sprintf(
891 + $items['activitypub-followers-blog'] = \sprintf(
892 892 '<a class="activitypub-followers" href="%1$s" title="%2$s">%3$s</a>',
893 893 \esc_url( \admin_url( 'options-general.php?page=activitypub&tab=followers' ) ),
894 894 \esc_attr__( 'The Blog\'s followers', 'activitypub' ),
895 895 \esc_html( $follower_count )
@@ -912,9 +912,9 @@
912 912 public static function row_actions( $actions, $post ) {
913 913 // check if the post is enabled for ActivityPub.
914 914 if (
915 915 ! \post_type_supports( \get_post_type( $post ), 'activitypub' ) ||
916 - ! in_array( $post->post_status, array( 'pending', 'draft', 'future', 'publish' ), true ) ||
916 + ! \in_array( $post->post_status, array( 'pending', 'draft', 'future', 'publish' ), true ) ||
917 917 ! \current_user_can( 'edit_post', $post->ID ) ||
918 918 ACTIVITYPUB_CONTENT_VISIBILITY_LOCAL === get_content_visibility( $post->ID ) ||
919 919 ( site_supports_blocks() && \use_block_editor_for_post_type( $post->post_type ) )
920 920 ) {
@@ -920,11 +920,11 @@
920 920 ) {
921 921 return $actions;
922 922 }
923 923
924 - $preview_url = add_query_arg( 'activitypub', 'true', \get_preview_post_link( $post ) );
924 + $preview_url = \add_query_arg( 'activitypub', 'true', \get_preview_post_link( $post ) );
925 925
926 - $actions['activitypub'] = sprintf(
926 + $actions['activitypub'] = \sprintf(
927 927 '<a href="%s" target="_blank">%s</a>',
928 928 \esc_url( $preview_url ),
929 929 \esc_html__( 'Fediverse Preview ⁂', 'activitypub' )
930 930 );
@@ -957,9 +957,9 @@
957 957 if ( ! isset( $update->upgrade_notice ) ) {
958 958 return;
959 959 }
960 960
961 - echo '<br>' . wp_strip_all_tags( $update->upgrade_notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
961 + echo '<br>' . \wp_strip_all_tags( $update->upgrade_notice ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
962 962 }
963 963
964 964 /**
965 965 * Adds meta box on wp-admin/tools.php.
@@ -1013,13 +1013,13 @@
1013 1013 $type = \sanitize_text_field( \wp_unslash( $_POST['type'] ?? '' ) );
1014 1014 $value = \sanitize_text_field( \wp_unslash( $_POST['value'] ?? '' ) );
1015 1015
1016 1016 // Validate required parameters.
1017 - if ( ! in_array( $context, array( 'user', 'site' ), true ) || ! in_array( $operation, array( 'add', 'remove' ), true ) ) {
1017 + if ( ! \in_array( $context, array( 'user', 'site' ), true ) || ! \in_array( $operation, array( 'add', 'remove' ), true ) ) {
1018 1018 \wp_send_json_error( array( 'message' => \__( 'Invalid context or action.', 'activitypub' ) ) );
1019 1019 }
1020 1020
1021 - if ( empty( $type ) || empty( $value ) || ! in_array( $type, array( 'domain', 'keyword' ), true ) ) {
1021 + if ( empty( $type ) || empty( $value ) || ! \in_array( $type, array( 'domain', 'keyword' ), true ) ) {
1022 1022 \wp_send_json_error( array( 'message' => \__( 'Invalid parameters.', 'activitypub' ) ) );
1023 1023 }
1024 1024
1025 1025 // Verify nonce for all operations.
@@ -1235,9 +1235,9 @@
1235 1235
1236 1236 $meta_key = \sanitize_text_field( \wp_unslash( $_POST['meta_key'] ?? '' ) ); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Not a DB query parameter.
1237 1237
1238 1238 // Verify the meta key belongs to our token prefix.
1239 - if ( 0 !== strpos( $meta_key, Token::META_PREFIX ) ) {
1239 + if ( 0 !== \strpos( $meta_key, Token::META_PREFIX ) ) {
1240 1240 \wp_send_json_error( array( 'message' => \__( 'Invalid token.', 'activitypub' ) ) );
1241 1241 }
1242 1242
1243 1243 $user_id = \get_current_user_id();
@@ -1243,9 +1243,9 @@
1243 1243 $user_id = \get_current_user_id();
1244 1244 $token_data = \get_user_meta( $user_id, $meta_key, true );
1245 1245
1246 1246 // Verify the token belongs to the current user.
1247 - if ( empty( $token_data ) || ! is_array( $token_data ) ) {
1247 + if ( empty( $token_data ) || ! \is_array( $token_data ) ) {
1248 1248 \wp_send_json_error( array( 'message' => \__( 'Token not found.', 'activitypub' ) ) );
1249 1249 }
1250 1250
1251 1251 // Delete the token.