Changeset 10801
- Timestamp:
- 03/10/2021 05:21:46 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php
r10564 r10801 1682 1682 * @return \WP_Post|bool 1683 1683 */ 1684 public static function get_plugin_post( $plugin_slug ) {1684 public static function get_plugin_post( $plugin_slug = null ) { 1685 1685 global $post; 1686 1686 … … 1699 1699 } 1700 1700 1701 // Use the global $post object when it matches to avoid hitting the database. 1702 if ( ! empty( $post ) && 'plugin' == $post->post_type && $plugin_slug == $post->post_name ) { 1703 return $post; 1701 // Use the global $post object when appropriate 1702 if ( ! empty( $post ) && 'plugin' == $post->post_type ) { 1703 // Default to the global object. 1704 if ( is_null( $plugin_slug ) || 0 === $plugin_slug ) { 1705 return get_post( $post->ID ); 1706 } 1707 1708 // Avoid hitting the database if it matches. 1709 if ( $plugin_slug == $post->post_name ) { 1710 return get_post( $post->ID ); 1711 } 1704 1712 } 1705 1713 1706 1714 $plugin_slug = sanitize_title_for_query( $plugin_slug ); 1707 1708 if ( false !== ( $post_id = wp_cache_get( $plugin_slug, 'plugin-slugs' ) ) && ( $post = get_post( $post_id ) ) ) { 1709 // We have a $post. 1710 } else { 1711 1715 if ( ! $plugin_slug ) { 1716 return false; 1717 } 1718 1719 $post = false; 1720 $post_id = wp_cache_get( $plugin_slug, 'plugin-slugs' ); 1721 if ( 0 === $post_id ) { 1722 // Unknown plugin slug. 1723 return false; 1724 } else if ( $post_id ) { 1725 $post = get_post( $post_id ); 1726 } 1727 1728 if ( ! $post ) { 1712 1729 // get_post_by_slug(); 1713 1730 $posts = get_posts( array(
Note: See TracChangeset
for help on using the changeset viewer.