Changeset 13510 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
- Timestamp:
- 04/12/2024 05:22:33 AM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note: See TracChangeset
for help on using the changeset viewer.