Changeset 13510
- Timestamp:
- 04/12/2024 05:22:33 AM (22 months ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins
- Files:
-
- 1 added
- 5 edited
-
plugin-directory/class-tools.php (modified) (3 diffs)
-
support-forums/inc/class-directory-compat.php (modified) (2 diffs)
-
support-forums/inc/class-plugin-directory-compat.php (modified) (1 diff)
-
support-forums/inc/class-plugin.php (modified) (2 diffs)
-
support-forums/inc/class-rest-api.php (added)
-
support-forums/support-forums.php (modified) (1 diff)
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 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
r12574 r13510 289 289 290 290 // Set the term for this view so we can reuse it. 291 $this->term = get_term_by( 'slug', $this->slug(), $this->taxonomy() ); 292 293 // New compats won't have any support topics or reviews, so will 294 // not yet exist as a compat term. 295 if ( ! $this->term && $this->get_object( $this->slug() ) ) { 296 $term_name = $this->slug(); 297 if ( ! sanitize_title( $term_name ) ) { 298 // This happens when the slug is all non-ascii such as %e5%8f%8b%e8%a8%80, which fails to insert. 299 $term_name = urldecode( $term_name ); 300 } 301 $term = wp_insert_term( $term_name, $this->taxonomy(), array( 'slug' => $this->slug() ) ); 302 303 // Term exists already? Race-condition, or get_term_by() couldn't find $slug.. 304 if ( is_wp_error( $term ) && $term->get_error_data( 'term_exists' ) ) { 305 $this->term = get_term( $term->get_error_data( 'term_exists' ) ); 306 } elseif ( ! is_wp_error( $term ) && isset( $term['term_id'] ) ) { 307 $this->term = get_term( $term['term_id'] ); 308 } 309 } 291 $this->initialize_term(); 310 292 311 293 // Add plugin- and theme-specific filters and actions. … … 345 327 346 328 $this->loaded = true; 329 } 330 } 331 332 /** 333 * Initialises the WP_Term for the compat view. 334 * 335 * If the term does not exist, it will be created. 336 */ 337 public function initialize_term() { 338 if ( ! $this->slug() ) { 339 return; 340 } 341 342 $this->term = get_term_by( 'slug', $this->slug(), $this->taxonomy() ); 343 344 if ( $this->term || ! $this->get_object( $this->slug() ) ) { 345 return; 346 } 347 348 $term_name = $this->slug(); 349 if ( ! sanitize_title( $term_name ) ) { 350 // This happens when the slug is all non-ascii such as %e5%8f%8b%e8%a8%80, which fails to insert. 351 $term_name = urldecode( $term_name ); 352 } 353 354 $term = wp_insert_term( $term_name, $this->taxonomy(), array( 'slug' => $this->slug() ) ); 355 356 // Term exists already? Race-condition, or get_term_by() couldn't find $slug.. 357 if ( is_wp_error( $term ) && $term->get_error_data( 'term_exists' ) ) { 358 $this->term = get_term( $term->get_error_data( 'term_exists' ) ); 359 } elseif ( ! is_wp_error( $term ) && isset( $term['term_id'] ) ) { 360 $this->term = get_term( $term['term_id'] ); 347 361 } 348 362 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php
r12447 r13510 113 113 $this->support_reps = $this->get_support_reps( $slug ); 114 114 115 $this->initialize_term(); 116 115 117 return true; 116 118 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin.php
r12892 r13510 40 40 public $theme_subscriptions = false; // Defined via Support_Compat 41 41 public $blocks = false; 42 public $rest_api = false; 42 43 43 44 /** … … 74 75 $this->emails = new Emails; 75 76 $this->audit_log = new Audit_Log; 77 $this->rest_api = new REST_API; 76 78 77 79 // Set a flag to indicate whether this is the global forums, or a locale forum. -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/support-forums.php
r12293 r13510 31 31 include( __DIR__ . '/inc/class-audit-log.php' ); 32 32 include( __DIR__ . '/inc/class-blocks.php' ); 33 include( __DIR__ . '/inc/class-rest-api.php' ); 33 34 34 35 // Compat-only includes.
Note: See TracChangeset
for help on using the changeset viewer.