get_blog_prefix(); // The user meta fields that affect a profile. $fields = array( $blog_prefix . 'activitypub_description', $blog_prefix . 'activitypub_header_image', $blog_prefix . 'activitypub_icon', 'description', 'display_name', 'user_url', ); if ( in_array( $meta_key, $fields, true ) ) { self::schedule_profile_update( $user_id ); } } /** * Send a profile update when a user is updated. * * @param int $user_id User ID being updated. */ public static function user_update( $user_id ) { // Don't bother if the user can't publish. if ( ! \user_can( $user_id, 'activitypub' ) ) { return; } self::schedule_profile_update( $user_id ); } /** * Theme mods only have a dynamic filter so we fudge it like this. * * @param mixed $value Optional. The value to be updated. Default null. * * @return mixed */ public static function blog_user_update( $value = null ) { self::schedule_profile_update( Actors::BLOG_USER_ID ); return $value; } /** * Schedule Activities. * * @param string $new_status New post status. * @param string $old_status Old post status. * @param \WP_Post $post Post object. */ public static function schedule_post_activity( $new_status, $old_status, $post ) { if ( $post instanceof \WP_Post ) { if ( Extra_Fields::USER_POST_TYPE === $post->post_type ) { self::schedule_profile_update( $post->post_author ); } elseif ( Extra_Fields::BLOG_POST_TYPE === $post->post_type ) { self::schedule_profile_update( Actors::BLOG_USER_ID ); } } } /** * Send a profile update to all followers. Gets hooked into all relevant options/meta etc. * * @param int $user_id The user ID to update (Could be 0 for Blog-User). */ public static function schedule_profile_update( $user_id ) { if ( defined( 'WP_IMPORTING' ) && WP_IMPORTING ) { return; } $actor = Actors::get_by_id( $user_id ); if ( ! $actor || \is_wp_error( $actor ) ) { return; } $actor->set_updated( gmdate( ACTIVITYPUB_DATE_TIME_RFC3339, time() ) ); add_to_outbox( $actor, 'Update', $user_id ); } }