wp_normalize_path()获取一个windows系统的正常路径

目录

描述

Call the functions to normalize a filesystem path.
This function is mainly for windows based server, to replaces backslashes with forward slashes, and ensures no duplicate slashes exist.

wp_normalize_path() 描述

用法

<?php wp_normalize_path($path); ?>

wp_normalize_path() 用法

参数

$path

(string) (必填) Path to normalize.

默认值: None

wp_normalize_path() 参数

返回值

(string

Normalized path.

wp_normalize_path() 返回值

示例

A Simple example to normalize the theme include path

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

    $bS_incl_path = get_template_directory() . '/inc';

    /**
     * Define theme include path
     * 
     * Normalize the include path to be safe on windows hosts
     * @return string Normalized path
     * require min WordPress version 3.9
     * @since boot_Strap 1.0.1
     * 
     */

     if(function_exists('wp_normalize_path')){
         
        $bS_incl_path = wp_normalize_path($bS_incl_path);
     }
    
    define('THM_INC', $bS_incl_path);

    require_once (THM_INC. '/wp_bootstrap_navwalker.php');   

print_r($bS_incl_path); shows

Using this function:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */

C:/xampp/htdocs/boot_strap/wp-content/themes/boot_Strap/inc

Without this function:

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
C:xampphtdocsoot_strap/wp-content/themes/boot_Strap/inc

On a Windows server.

wp_normalize_path() 示例

历史

添加于 版本: 3.9

wp_normalize_path() 历史