Making WordPress.org


Ignore:
Timestamp:
12/09/2020 11:41:55 PM (6 years ago)
Author:
dd32
Message:

Plugin Directory: Allow Plugin_Directory::get_plugin_post() to accept a (int) post id for consistency and ease of use.

See [10506].

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-plugin-directory.php

    r10408 r10507  
    16681668         * @global \WP_Post $post WordPress post object.
    16691669         *
    1670          * @param string|\WP_Post $plugin_slug The slug of the plugin to retrieve.
     1670         * @param int|string|\WP_Post $plugin_slug The slug of the plugin to retrieve.
    16711671         * @return \WP_Post|bool
    16721672         */
    … …  
    16761676                if ( $plugin_slug instanceof \WP_Post ) {
    16771677                        return $plugin_slug;
     1678                }
     1679
     1680                // Handle int $plugin_slug being passed. NOT numeric slugs
     1681                if (
     1682                        is_int( $plugin_slug ) &&
     1683                        ( $post_obj = get_post( $plugin_slug ) ) &&
     1684                        ( $post_obj->ID === $plugin_slug )
     1685                ) {
     1686                        $post = $post_obj;
     1687                        return $post_obj;
    16781688                }
    16791689
Note: See TracChangeset for help on using the changeset viewer.