PluginProbe
ActivityPub / 7.8.2
ActivityPub v7.8.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 +14 -129 8.2.07.8.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,9 +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 33
38 34 \add_action( 'rest_api_init', array( self::class, 'register_ap_actor_rest_field' ) );
39 35 \add_action( 'rest_api_init', array( self::class, 'register_ap_post_actor_rest_field' ) );
40 36 \add_action( 'rest_api_init', array( self::class, 'register_ap_post_rest_params' ) );
@@ -348,9 +344,9 @@
348 344 * Register the Post post type.
349 345 */
350 346 public static function register_post_post_type() {
351 347 \register_post_type(
352 - Remote_Posts::POST_TYPE,
348 + Posts::POST_TYPE,
353 349 array(
354 350 'labels' => array(
355 351 'name' => \_x( 'Posts', 'post_type plural name', 'activitypub' ),
356 352 'singular_name' => \_x( 'Post', 'post_type single name', 'activitypub' ),
@@ -372,9 +368,9 @@
372 368 );
373 369
374 370 \register_taxonomy(
375 371 'ap_tag',
376 - array( Remote_Posts::POST_TYPE ),
372 + array( Posts::POST_TYPE ),
377 373 array(
378 374 'public' => false,
379 375 'query_var' => true,
380 376 'show_in_rest' => true,
@@ -382,9 +378,9 @@
382 378 );
383 379
384 380 \register_taxonomy(
385 381 'ap_object_type',
386 - array( Remote_Posts::POST_TYPE ),
382 + array( Posts::POST_TYPE ),
387 383 array(
388 384 'public' => false,
389 385 'query_var' => true,
390 386 'show_in_rest' => true,
@@ -391,9 +387,9 @@
391 387 )
392 388 );
393 389
394 390 \register_post_meta(
395 - Remote_Posts::POST_TYPE,
391 + Posts::POST_TYPE,
396 392 '_activitypub_remote_actor_id',
397 393 array(
398 394 'type' => 'integer',
399 395 'single' => true,
@@ -402,9 +398,9 @@
402 398 )
403 399 );
404 400
405 401 \register_post_meta(
406 - Remote_Posts::POST_TYPE,
402 + Posts::POST_TYPE,
407 403 '_activitypub_user_id',
408 404 array(
409 405 'type' => 'integer',
410 406 'single' => true,
@@ -460,109 +456,8 @@
460 456 \do_action( 'activitypub_after_register_post_type' );
461 457 }
462 458
463 459 /**
464 - * Register OAuth 2.0 post types for C2S support.
465 - *
466 - * Registers post type for OAuth clients.
467 - * Note: Tokens are stored in user meta and authorization codes in transients.
468 - */
469 - public static function register_oauth_post_types() {
470 - // OAuth Clients post type.
471 - \register_post_type(
472 - Client::POST_TYPE,
473 - array(
474 - 'labels' => array(
475 - 'name' => \_x( 'OAuth Clients', 'post_type plural name', 'activitypub' ),
476 - 'singular_name' => \_x( 'OAuth Client', 'post_type single name', 'activitypub' ),
477 - ),
478 - 'public' => false,
479 - 'show_in_rest' => false,
480 - 'hierarchical' => false,
481 - 'rewrite' => false,
482 - 'query_var' => false,
483 - 'delete_with_user' => false,
484 - 'can_export' => true,
485 - 'supports' => array( 'title', 'editor', 'custom-fields' ),
486 - 'exclude_from_search' => true,
487 - )
488 - );
489 -
490 - // OAuth Client meta.
491 - \register_post_meta(
492 - Client::POST_TYPE,
493 - '_activitypub_client_id',
494 - array(
495 - 'type' => 'string',
496 - 'single' => true,
497 - 'description' => 'Unique OAuth client identifier (UUID).',
498 - 'sanitize_callback' => 'sanitize_text_field',
499 - )
500 - );
501 -
502 - \register_post_meta(
503 - Client::POST_TYPE,
504 - '_activitypub_client_secret_hash',
505 - array(
506 - 'type' => 'string',
507 - 'single' => true,
508 - 'description' => 'SHA-256 hash of the client secret (null for public clients).',
509 - 'sanitize_callback' => 'sanitize_text_field',
510 - )
511 - );
512 -
513 - \register_post_meta(
514 - Client::POST_TYPE,
515 - '_activitypub_redirect_uris',
516 - array(
517 - 'type' => 'array',
518 - 'single' => true,
519 - 'description' => 'Allowed redirect URIs for this client.',
520 - 'sanitize_callback' => static function ( $value ) {
521 - if ( ! is_array( $value ) ) {
522 - return array();
523 - }
524 - return array_map( array( Sanitize::class, 'redirect_uri' ), $value );
525 - },
526 - )
527 - );
528 -
529 - \register_post_meta(
530 - Client::POST_TYPE,
531 - '_activitypub_allowed_scopes',
532 - array(
533 - 'type' => 'array',
534 - 'single' => true,
535 - 'description' => 'Allowed OAuth scopes for this client.',
536 - 'sanitize_callback' => array( Scope::class, 'sanitize' ),
537 - )
538 - );
539 -
540 - \register_post_meta(
541 - Client::POST_TYPE,
542 - '_activitypub_is_public',
543 - array(
544 - 'type' => 'boolean',
545 - 'single' => true,
546 - 'description' => 'Whether this is a public client (PKCE-only, no secret).',
547 - 'sanitize_callback' => 'rest_sanitize_boolean',
548 - 'default' => true,
549 - )
550 - );
551 -
552 - \register_post_meta(
553 - Client::POST_TYPE,
554 - Token::USER_META_KEY,
555 - array(
556 - 'type' => 'integer',
557 - 'single' => false,
558 - 'description' => 'User IDs that have active tokens for this client.',
559 - 'sanitize_callback' => 'absint',
560 - )
561 - );
562 - }
563 -
564 - /**
565 460 * Register post meta for ActivityPub supported post types.
566 461 */
567 462 public static function register_activitypub_post_meta() {
568 463 $ap_post_types = \get_post_types_by_support( 'activitypub' );
@@ -619,9 +514,8 @@
619 514 array(
620 515 'type' => 'string',
621 516 'single' => true,
622 517 'show_in_rest' => true,
623 - 'default' => \get_option( 'activitypub_default_quote_policy', ACTIVITYPUB_INTERACTION_POLICY_ANYONE ),
624 518 'sanitize_callback' => static function ( $value ) {
625 519 $schema = array(
626 520 'type' => 'string',
627 521 'enum' => array( ACTIVITYPUB_INTERACTION_POLICY_ANYONE, ACTIVITYPUB_INTERACTION_POLICY_FOLLOWERS, ACTIVITYPUB_INTERACTION_POLICY_ME ),
@@ -644,22 +538,12 @@
644 538 'type' => 'string',
645 539 'single' => true,
646 540 'show_in_rest' => true,
647 541 'sanitize_callback' => static function ( $value ) {
648 - // Allow empty values to pass through without setting a default.
649 - if ( empty( $value ) ) {
650 - return '';
651 - }
652 -
653 542 $schema = array(
654 543 'type' => 'string',
655 - 'enum' => array(
656 - ACTIVITYPUB_OBJECT_STATE_PENDING,
657 - ACTIVITYPUB_OBJECT_STATE_FEDERATED,
658 - ACTIVITYPUB_OBJECT_STATE_FAILED,
659 - ACTIVITYPUB_OBJECT_STATE_DELETED,
660 - ),
661 - 'default' => '',
544 + 'enum' => array( 'pending', 'federated', 'failed' ),
545 + 'default' => 'pending',
662 546 );
663 547
664 548 if ( \is_wp_error( \rest_validate_enum( $value, $schema, '' ) ) ) {
665 549 return $schema['default'];
@@ -777,9 +661,9 @@
777 661 * Register a REST field for the ap_post post type to embed remote actor data.
778 662 */
779 663 public static function register_ap_post_actor_rest_field() {
780 664 \register_rest_field(
781 - Remote_Posts::POST_TYPE,
665 + Posts::POST_TYPE,
782 666 'actor_info',
783 667 array(
784 668 /**
785 669 * Get the remote actor data for an ap_post.
@@ -817,9 +701,9 @@
817 701 * Register custom REST API parameters for ap_post endpoint.
818 702 */
819 703 public static function register_ap_post_rest_params() {
820 704 \add_filter(
821 - 'rest_' . Remote_Posts::POST_TYPE . '_collection_params',
705 + 'rest_' . Posts::POST_TYPE . '_collection_params',
822 706 function ( $params ) {
823 707 $params['user_id'] = array(
824 708 'description' => __( 'Filter posts by user ID (0 for site/blog actor).', 'activitypub' ),
825 709 'type' => 'integer',
@@ -972,11 +856,12 @@
972 856 * @param mixed $meta_value Metadata value. Must be serializable if non-scalar.
973 857 */
974 858 public static function prevent_empty_post_meta( $check, $object_id, $meta_key, $meta_value ) {
975 859 $post_metas = array(
976 - 'activitypub_content_visibility' => '',
977 - 'activitypub_content_warning' => '',
978 - '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 ),
979 864 );
980 865
981 866 if ( isset( $post_metas[ $meta_key ] ) && $post_metas[ $meta_key ] === (string) $meta_value ) {
982 867 if ( 'update_post_metadata' === current_action() ) {