Changeset 13510 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
- Timestamp:
- 04/12/2024 05:22:33 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-tools.php
r12505 r13510 239 239 $email->send(); 240 240 } 241 242 Tools::subscribe_user_to_forum_threads( $user, $post ); 241 243 242 244 return $result; … … 407 409 } 408 410 411 Tools::subscribe_user_to_forum_threads( $user, $post ); 412 409 413 return $result; 410 414 } … … 639 643 ] ); 640 644 } 645 646 /** 647 * Subscribe a user to the forum topics for a given plugin. 648 * 649 * @param WP_User|int $user_id The user to subscribe. 650 * @param WP_Post $post The plugin to subscribe to. 651 * @return bool 652 */ 653 public static function subscribe_user_to_forum_threads( $user_id, $post = null ) { 654 $post = Plugin_Directory::get_plugin_post( $post ); 655 656 if ( ! $user_id || ! $post || ! defined( 'PLUGIN_API_INTERNAL_BEARER_TOKEN' ) ) { 657 return false; 658 } 659 660 if ( $user_id instanceof \WP_User ) { 661 $user_id = $user_id->ID; 662 } 663 664 $request = wp_remote_post( 665 'https://wordpress.org/support/wp-json/wporg-support/v1/subscribe-user-to-term', 666 [ 667 'body' => [ 668 'type' => 'plugin', 669 'slug' => $post->post_name, 670 'user_id' => $user_id, 671 ], 672 'headers' => [ 673 'Authorization' => 'Bearer ' . PLUGIN_API_INTERNAL_BEARER_TOKEN, 674 ], 675 ] 676 ); 677 678 return 200 === wp_remote_retrieve_response_code( $request ); 679 } 641 680 }
Note: See TracChangeset
for help on using the changeset viewer.