Make WordPress Core

Ticket #55522: 55522.patch

File 55522.patch, 1.6 KB (added by subrataemfluence, 3 years ago)

Suggested enhancement

  • .php

    old new  
    772772/**
    773773 * Get the filesystem directory path (with trailing slash) for the plugin __FILE__ passed in.
    774774 *
    775  * @since 2.8.0
     775 * @since 5.9.2
    776776 *
    777  * @param string $file The filename of the plugin (__FILE__).
    778  * @return string the filesystem path of the directory that contains the plugin.
     777 * @param string $file The filename of the plugin (__FILE__). Default empty
     778 * @return string the filesystem path of the directory that contains the plugin if a filename is specified. Returns the base plugin directory path otherwise.
    779779 */
    780 function plugin_dir_path( $file ) {
    781         return trailingslashit( dirname( $file ) );
     780function plugin_dir_path( $file = '' ) {
     781        return trim( $file ) !== ''
     782                ? trailingslashit( dirname( $file ) )
     783                : trailingslashit( WP_CONTENT_DIR . '/plugins' );
    782784}
    783785
    784786/**
    785787 * Get the URL directory path (with trailing slash) for the plugin __FILE__ passed in.
    786788 *
    787  * @since 2.8.0
     789 * @since 5.9.2
    788790 *
    789  * @param string $file The filename of the plugin (__FILE__).
    790  * @return string the URL path of the directory that contains the plugin.
     791 * @param string $file The filename of the plugin (__FILE__). Default empty
     792 * @return string the filesystem path of the directory that contains the plugin if a filename is specified. Returns the base plugin directory path otherwise.
    791793 */
    792 function plugin_dir_url( $file ) {
    793         return trailingslashit( plugins_url( '', $file ) );
     794function plugin_dir_url( $file = '' ) {
     795        return trim( $file ) !== ''
     796                ? trailingslashit( plugins_url( '', $file ) )
     797                : trailingslashit( plugins_url() );
    794798}
    795799
    796800/**