PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
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/class-post-types.php +15 -155 9.2.08.0.2 View file →
@@ -12,13 +12,10 @@
12 12 use Activitypub\Collection\Followers;
13 13 use Activitypub\Collection\Following;
14 14 use Activitypub\Collection\Inbox;
15 15 use Activitypub\Collection\Outbox;
16 +use Activitypub\Collection\Posts;
16 17 use Activitypub\Collection\Remote_Actors;
17 -use Activitypub\Collection\Remote_Posts;
18 -use Activitypub\OAuth\Client;
19 -use Activitypub\OAuth\Scope;
20 -use Activitypub\OAuth\Token;
21 18
22 19 /**
23 20 * Post Types class.
24 21 */
@@ -32,10 +29,8 @@
32 29 \add_action( 'init', array( self::class, 'register_outbox_post_type' ), 11 );
33 30 \add_action( 'init', array( self::class, 'register_post_post_type' ), 11 );
34 31 \add_action( 'init', array( self::class, 'register_extra_fields_post_types' ), 11 );
35 32 \add_action( 'init', array( self::class, 'register_activitypub_post_meta' ), 11 );
36 - \add_action( 'init', array( self::class, 'register_oauth_post_types' ), 11 );
37 - \add_action( 'init', array( self::class, 'register_tombstone_post_type' ), 11 );
38 33
39 34 \add_action( 'rest_api_init', array( self::class, 'register_ap_actor_rest_field' ) );
40 35 \add_action( 'rest_api_init', array( self::class, 'register_ap_post_actor_rest_field' ) );
41 36 \add_action( 'rest_api_init', array( self::class, 'register_ap_post_rest_params' ) );
@@ -349,9 +344,9 @@
349 344 * Register the Post post type.
350 345 */
351 346 public static function register_post_post_type() {
352 347 \register_post_type(
353 - Remote_Posts::POST_TYPE,
348 + Posts::POST_TYPE,
354 349 array(
355 350 'labels' => array(
356 351 'name' => \_x( 'Posts', 'post_type plural name', 'activitypub' ),
357 352 'singular_name' => \_x( 'Post', 'post_type single name', 'activitypub' ),
@@ -373,9 +368,9 @@
373 368 );
374 369
375 370 \register_taxonomy(
376 371 'ap_tag',
377 - array( Remote_Posts::POST_TYPE ),
372 + array( Posts::POST_TYPE ),
378 373 array(
379 374 'public' => false,
380 375 'query_var' => true,
381 376 'show_in_rest' => true,
@@ -383,9 +378,9 @@
383 378 );
384 379
385 380 \register_taxonomy(
386 381 'ap_object_type',
387 - array( Remote_Posts::POST_TYPE ),
382 + array( Posts::POST_TYPE ),
388 383 array(
389 384 'public' => false,
390 385 'query_var' => true,
391 386 'show_in_rest' => true,
@@ -392,9 +387,9 @@
392 387 )
393 388 );
394 389
395 390 \register_post_meta(
396 - Remote_Posts::POST_TYPE,
391 + Posts::POST_TYPE,
397 392 '_activitypub_remote_actor_id',
398 393 array(
399 394 'type' => 'integer',
400 395 'single' => true,
@@ -403,9 +398,9 @@
403 398 )
404 399 );
405 400
406 401 \register_post_meta(
407 - Remote_Posts::POST_TYPE,
402 + Posts::POST_TYPE,
408 403 '_activitypub_user_id',
409 404 array(
410 405 'type' => 'integer',
411 406 'single' => true,
@@ -461,143 +456,8 @@
461 456 \do_action( 'activitypub_after_register_post_type' );
462 457 }
463 458
464 459 /**
465 - * Register OAuth 2.0 post types for C2S support.
466 - *
467 - * Registers post type for OAuth clients.
468 - * Note: Tokens are stored in user meta and authorization codes in transients.
469 - */
470 - public static function register_oauth_post_types() {
471 - // OAuth Clients post type.
472 - \register_post_type(
473 - Client::POST_TYPE,
474 - array(
475 - 'labels' => array(
476 - 'name' => \_x( 'OAuth Clients', 'post_type plural name', 'activitypub' ),
477 - 'singular_name' => \_x( 'OAuth Client', 'post_type single name', 'activitypub' ),
478 - ),
479 - 'public' => false,
480 - 'show_in_rest' => false,
481 - 'hierarchical' => false,
482 - 'rewrite' => false,
483 - 'query_var' => false,
484 - 'delete_with_user' => false,
485 - 'can_export' => true,
486 - 'supports' => array( 'title', 'editor', 'custom-fields' ),
487 - 'exclude_from_search' => true,
488 - )
489 - );
490 -
491 - // OAuth Client meta.
492 - \register_post_meta(
493 - Client::POST_TYPE,
494 - '_activitypub_client_id',
495 - array(
496 - 'type' => 'string',
497 - 'single' => true,
498 - 'description' => 'Unique OAuth client identifier (UUID).',
499 - 'sanitize_callback' => 'sanitize_text_field',
500 - )
501 - );
502 -
503 - \register_post_meta(
504 - Client::POST_TYPE,
505 - '_activitypub_client_secret_hash',
506 - array(
507 - 'type' => 'string',
508 - 'single' => true,
509 - 'description' => 'SHA-256 hash of the client secret (null for public clients).',
510 - 'sanitize_callback' => 'sanitize_text_field',
511 - )
512 - );
513 -
514 - \register_post_meta(
515 - Client::POST_TYPE,
516 - '_activitypub_redirect_uris',
517 - array(
518 - 'type' => 'array',
519 - 'single' => true,
520 - 'description' => 'Allowed redirect URIs for this client.',
521 - 'sanitize_callback' => static function ( $value ) {
522 - if ( ! \is_array( $value ) ) {
523 - return array();
524 - }
525 - return \array_map( array( Sanitize::class, 'redirect_uri' ), $value );
526 - },
527 - )
528 - );
529 -
530 - \register_post_meta(
531 - Client::POST_TYPE,
532 - '_activitypub_allowed_scopes',
533 - array(
534 - 'type' => 'array',
535 - 'single' => true,
536 - 'description' => 'Allowed OAuth scopes for this client.',
537 - 'sanitize_callback' => array( Scope::class, 'sanitize' ),
538 - )
539 - );
540 -
541 - \register_post_meta(
542 - Client::POST_TYPE,
543 - '_activitypub_is_public',
544 - array(
545 - 'type' => 'boolean',
546 - 'single' => true,
547 - 'description' => 'Whether this is a public client (PKCE-only, no secret).',
548 - 'sanitize_callback' => 'rest_sanitize_boolean',
549 - 'default' => true,
550 - )
551 - );
552 -
553 - \register_post_meta(
554 - Client::POST_TYPE,
555 - Token::USER_META_KEY,
556 - array(
557 - 'type' => 'integer',
558 - 'single' => false,
559 - 'description' => 'User IDs that have active tokens for this client.',
560 - 'sanitize_callback' => 'absint',
561 - )
562 - );
563 - }
564 -
565 - /**
566 - * Register the ap_tombstone post type.
567 - *
568 - * Stores local tombstone URLs out of the autoloaded options row.
569 - * The post type is fully internal — never queried publicly, never shown in UI.
570 - *
571 - * @since 8.3.0
572 - */
573 - public static function register_tombstone_post_type() {
574 - \register_post_type(
575 - Tombstone::POST_TYPE,
576 - array(
577 - 'labels' => array(
578 - 'name' => \_x( 'Tombstones', 'post_type plural name', 'activitypub' ),
579 - 'singular_name' => \_x( 'Tombstone', 'post_type single name', 'activitypub' ),
580 - ),
581 - 'public' => false,
582 - 'publicly_queryable' => false,
583 - 'show_ui' => false,
584 - 'show_in_menu' => false,
585 - 'show_in_nav_menus' => false,
586 - 'show_in_admin_bar' => false,
587 - 'show_in_rest' => false,
588 - 'exclude_from_search' => true,
589 - 'has_archive' => false,
590 - 'rewrite' => false,
591 - 'query_var' => false,
592 - 'can_export' => false,
593 - 'delete_with_user' => false,
594 - 'supports' => array(),
595 - )
596 - );
597 - }
598 -
599 - /**
600 460 * Register post meta for ActivityPub supported post types.
601 461 */
602 462 public static function register_activitypub_post_meta() {
603 463 $ap_post_types = \get_post_types_by_support( 'activitypub' );
@@ -744,10 +604,10 @@
744 604 }
745 605 return array(
746 606 'username' => $actor->get_preferred_username(),
747 607 'name' => $actor->get_name() ?? $actor->get_preferred_username(),
748 - 'icon' => \sanitize_url( object_to_uri( $actor->get_icon() ) ?? '' ),
749 - 'url' => \sanitize_url( object_to_uri( $actor->get_url() ?? $actor->get_id() ) ?? '' ),
608 + 'icon' => object_to_uri( $actor->get_icon() ),
609 + 'url' => object_to_uri( $actor->get_url() ?? $actor->get_id() ),
750 610 'webfinger' => Remote_Actors::get_acct( $response['id'] ),
751 611 'identifier' => $actor->get_id(),
752 612 );
753 613 },
@@ -812,9 +672,9 @@
812 672 * Register a REST field for the ap_post post type to embed remote actor data.
813 673 */
814 674 public static function register_ap_post_actor_rest_field() {
815 675 \register_rest_field(
816 - Remote_Posts::POST_TYPE,
676 + Posts::POST_TYPE,
817 677 'actor_info',
818 678 array(
819 679 /**
820 680 * Get the remote actor data for an ap_post.
@@ -832,10 +692,10 @@
832 692
833 693 return array(
834 694 'username' => $actor->get_preferred_username(),
835 695 'name' => $actor->get_name() ?? $actor->get_preferred_username(),
836 - 'icon' => \sanitize_url( object_to_uri( $actor->get_icon() ) ?? '' ),
837 - 'url' => \sanitize_url( object_to_uri( $actor->get_url() ?? $actor->get_id() ) ?? '' ),
696 + 'icon' => object_to_uri( $actor->get_icon() ),
697 + 'url' => object_to_uri( $actor->get_url() ?? $actor->get_id() ),
838 698 'webfinger' => Remote_Actors::get_acct( $id ),
839 699 'identifier' => $actor->get_id(),
840 700 );
841 701 },
@@ -852,12 +712,12 @@
852 712 * Register custom REST API parameters for ap_post endpoint.
853 713 */
854 714 public static function register_ap_post_rest_params() {
855 715 \add_filter(
856 - 'rest_' . Remote_Posts::POST_TYPE . '_collection_params',
716 + 'rest_' . Posts::POST_TYPE . '_collection_params',
857 717 function ( $params ) {
858 718 $params['user_id'] = array(
859 - 'description' => \__( 'Filter posts by user ID (0 for site/blog actor).', 'activitypub' ),
719 + 'description' => __( 'Filter posts by user ID (0 for site/blog actor).', 'activitypub' ),
860 720 'type' => 'integer',
861 721 'sanitize_callback' => 'absint',
862 722 );
863 723
@@ -945,9 +805,9 @@
945 805 * @return array Modified collection parameters.
946 806 */
947 807 public static function register_object_type_user_param( $params ) {
948 808 $params['user_id'] = array(
949 - 'description' => \__( 'Filter terms to those with posts from this user ID.', 'activitypub' ),
809 + 'description' => __( 'Filter terms to those with posts from this user ID.', 'activitypub' ),
950 810 'type' => 'integer',
951 811 'sanitize_callback' => 'absint',
952 812 );
953 813
@@ -1013,9 +873,9 @@
1013 873 'activitypub_max_image_attachments' => (string) \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ),
1014 874 );
1015 875
1016 876 if ( isset( $post_metas[ $meta_key ] ) && $post_metas[ $meta_key ] === (string) $meta_value ) {
1017 - if ( 'update_post_metadata' === \current_action() ) {
877 + if ( 'update_post_metadata' === current_action() ) {
1018 878 \delete_post_meta( $object_id, $meta_key );
1019 879 }
1020 880
1021 881 $check = true;