WordPress.org

Make WordPress Core

Ticket #11007: plugin.php.diff

File plugin.php.diff, 1.0 KB (added by sirzooro, 9 years ago)
  • plugin.php

    old new  
    484484 * @access private
    485485 *
    486486 * @param string $file The filename of plugin.
     487 * @param bool $strip_ext Set to true to strip file extension. Default false.
    487488 * @return string The name of a plugin.
    488489 * @uses WP_PLUGIN_DIR
    489490 */
    490 function plugin_basename($file) {
     491function plugin_basename( $file, $strip_ext = false ) {
    491492        $file = str_replace('\\','/',$file); // sanitize for Win32 installs
    492493        $file = preg_replace('|/+|','/', $file); // remove any duplicate slash
    493494        $plugin_dir = str_replace('\\','/',WP_PLUGIN_DIR); // sanitize for Win32 installs
     
    496497        $mu_plugin_dir = preg_replace('|/+|','/', $mu_plugin_dir); // remove any duplicate slash
    497498        $file = preg_replace('#^' . preg_quote($plugin_dir, '#') . '/|^' . preg_quote($mu_plugin_dir, '#') . '/#','',$file); // get relative path from plugins dir
    498499        $file = trim($file, '/');
     500        if ( $strip_ext ) {
     501                $file = substr( $file, 0, strrpos( $file, '.' ) );
     502        }
    499503        return $file;
    500504}
    501505