Changeset 3084
- Timestamp:
- 05/05/2016 08:18:29 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r3040 r3084 516 516 } 517 517 518 // TODO: Add caching here. 519 520 // get_post_by_slug(); 521 $posts = get_posts( array( 522 'post_type' => 'plugin', 523 'name' => $plugin_slug, 524 'post_status' => array( 'publish', 'pending', 'disabled', 'closed', 'draft', 'approved' ), 525 ) ); 526 if ( ! $posts ) { 527 return false; 528 } 529 530 return reset( $posts ); 518 $plugin_slug = sanitize_title_for_query( $plugin_slug ); 519 520 if ( false !== ( $post_id = wp_cache_get( $plugin_slug, 'plugin-slugs' ) ) && ( $post = get_post( $post_id ) ) ) { 521 // We have a $post. 522 } else { 523 // get_post_by_slug(); 524 $posts = get_posts( array( 525 'post_type' => 'plugin', 526 'name' => $plugin_slug, 527 'post_status' => array( 'publish', 'pending', 'disabled', 'closed', 'draft', 'approved' ), 528 ) ); 529 if ( ! $posts ) { 530 $post = false; 531 wp_cache_add( 0, $plugin_slug, 'plugin-slugs' ); 532 } else { 533 $post = reset( $posts ); 534 wp_cache_add( $post->ID, $plugin_slug, 'plugin-slugs' ); 535 } 536 } 537 538 return $post; 531 539 } 532 540 … … 574 582 } 575 583 584 wp_cache_set( $id, $slug, 'plugin-slugs' ); 585 576 586 return get_post( $id ); 577 587 }
Note: See TracChangeset
for help on using the changeset viewer.