PluginProbe
ActivityPub / 7.8.4
ActivityPub v7.8.4
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 +14 -164 9.0.2 → 7.8.4 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' );
@@ -654,9 +514,8 @@
654 514 array(
655 515 'type' => 'string',
656 516 'single' => true,
657 517 'show_in_rest' => true,
658 - 'default' => \get_option( 'activitypub_default_quote_policy', ACTIVITYPUB_INTERACTION_POLICY_ANYONE ),
659 518 'sanitize_callback' => static function ( $value ) {
660 519 $schema = array(
661 520 'type' => 'string',
662 521 'enum' => array( ACTIVITYPUB_INTERACTION_POLICY_ANYONE, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS, ACTIVITYPUB_INTERACTION_POLICY_ME ),
@@ -679,22 +538,12 @@
679 538 'type' => 'string',
680 539 'single' => true,
681 540 'show_in_rest' => true,
682 541 'sanitize_callback' => static function ( $value ) {
683 - // Allow empty values to pass through without setting a default.
684 - if ( empty( $value ) ) {
685 - return '';
686 - }
687 -
688 542 $schema = array(
689 543 'type' => 'string',
690 - 'enum' => array(
691 - ACTIVITYPUB_OBJECT_STATE_PENDING,
692 - ACTIVITYPUB_OBJECT_STATE_FEDERATED,
693 - ACTIVITYPUB_OBJECT_STATE_FAILED,
694 - ACTIVITYPUB_OBJECT_STATE_DELETED,
695 - ),
696 - 'default' => '',
544 + 'enum' => array( 'pending', 'federated', 'failed' ),
545 + 'default' => 'pending',
697 546 );
698 547
699 548 if ( \is_wp_error( \rest_validate_enum( $value, $schema, '' ) ) ) {
700 549 return $schema['default'];
@@ -812,9 +661,9 @@
812 661 * Register a REST field for the ap_post post type to embed remote actor data.
813 662 */
814 663 public static function register_ap_post_actor_rest_field() {
815 664 \register_rest_field(
816 - Remote_Posts::POST_TYPE,
665 + Posts::POST_TYPE,
817 666 'actor_info',
818 667 array(
819 668 /**
820 669 * Get the remote actor data for an ap_post.
@@ -852,9 +701,9 @@
852 701 * Register custom REST API parameters for ap_post endpoint.
853 702 */
854 703 public static function register_ap_post_rest_params() {
855 704 \add_filter(
856 - 'rest_' . Remote_Posts::POST_TYPE . '_collection_params',
705 + 'rest_' . Posts::POST_TYPE . '_collection_params',
857 706 function ( $params ) {
858 707 $params['user_id'] = array(
859 708 'description' => __( 'Filter posts by user ID (0 for site/blog actor).', 'activitypub' ),
860 709 'type' => 'integer',
@@ -1007,11 +856,12 @@
1007 856 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
1008 857 */
1009 858 public static function prevent_empty_post_meta( $check, $object_id, $meta_key, $meta_value ) {
1010 859 $post_metas = array(
1011 - 'activitypub_content_visibility' => '',
1012 - 'activitypub_content_warning' => '',
1013 - 'activitypub_max_image_attachments' => (string) \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ),
860 + 'activitypub_content_visibility' => '',
861 + 'activitypub_content_warning' => '',
862 + 'activitypub_interaction_policy_quote' => ACTIVITYPUB_INTERACTION_POLICY_ANYONE,
863 + 'activitypub_max_image_attachments' => (string) \get_option( 'activitypub_max_image_attachments', ACTIVITYPUB_MAX_IMAGE_ATTACHMENTS ),
1014 864 );
1015 865
1016 866 if ( isset( $post_metas[ $meta_key ] ) && $post_metas[ $meta_key ] === (string) $meta_value ) {
1017 867 if ( 'update_post_metadata' === current_action() ) {