The Nine 是一名非常热爱编程以及旅游、心理学的青年,Delphi将是The Nine的主要编程语言,如果您的爱好和The Nine相近,那么请关注,如果您需要与我联系,请点击"发信给作者"我会及时和你联系!
<?php
// 不允许直接访问此文件。
if ( ! defined( 'ABSPATH' ) ) {
exit( '拒绝直接访问此脚本.' );
}
/**
* 定义框架常用的几个路径,你也可以添加自己的路径在此
*
*/
//定义框架文件夹,默认为主题目录下的redux
/** 以下为常用路径函数总结,可参考添加自己用到的变量。*/
//主题常用路径总结
$op_home_url = home_url(); //输出: https://www.xxxx.com
$op_images_url = home_url('/images/'); //输出: https://www.xxxx.com/images/
$op_site_url = site_url(); //如果WordPress安装在子目录下,返回https://www.xx.com/wordpress,相当于后台->设置->常规中的“WordPress 地址(URL)”。
$op_admin_url = admin_url(); //输出:https://www.solagirl.net/wp-admin/
$op_content_url = content_url(); //输出:https://www.solagirl.net/wp-content 如果在wp-config.php中改变了wp-content目录的位置,则该函数会返回正确地址
$op_includes_url = includes_url( '/js/'); //输出:https://www.solagirl.net/wp-includes/js/
$op_wp_upload_dir = wp_upload_dir();
/** 可用参数
* 示例:$upload_dir = wp_upload_dir();
* echo $upload_dir['baseurl']; //输出:https://www.solagirl.net/wp-content/uploads
* 'path' - 上传目录的服务器绝对路径,通常以反斜杠(/)开头
* 'url' - 上传目录的完整URL
* 'subdir' - 子目录名称,通常是以年/月形式组织的目录地址,例如/2012/07
* 'basedir' - 上传目录的服务器绝对路径,不包含子目录
* 'baseurl' - 上传目录的完整URL,不包含子目录
* 'error' - 报错信息.
*/
$op_get_theme_root_uri = get_theme_root_uri(); //获取存放主题的目录URI 输出:https://www.solagirl.net/wp-content/themes
$op_get_theme_root = get_theme_root(); //获取存放主题的目录的服务器绝对路径 输出:<tt>/home/user/public_html/wp-content/themes</tt>
$op_get_theme_roots = get_theme_roots(); //获取主题目录的目录名称,如果你的主题目录是/wp-content/themes,则输出:/themes
$op_get_stylesheet_directory = get_stylesheet_directory();
/** //获取当前启用的主题目录的服务器绝对路径,
* /home/user/public_html/wp-content/themes/twentyeleven
* 可以用来include文件,例如
* <?php include( get_stylesheet_directory() . '/includes/myfile.php'); ?>
*/
$op_get_stylesheet_directory_uri = get_stylesheet_directory_uri();
/** //获取当前启用的主题目录的URI
* 输出:https://www.solagirl.net/wp-content/themes/twentyeleven
* 可以使用在需要主题目录URI的场合,例如图片
* <img src="<?php echo get_stylesheet_directory_uri() ?>/images/aternus.png" alt="WordPress常用路径函数" alt="" title="" width="" height="" />
*/
$op_GET_TEMPLATE_DIRECTORY_URI = GET_TEMPLATE_DIRECTORY_URI(); //如果当前启用的主题是一个child theme,该函数返回parent theme的主题目录URI,用法与get_stylesheet_directory_uri()类似。
$op_GET_TEMPLATE_DIRECTORY = GET_TEMPLATE_DIRECTORY(); //如果当前启用的主题是一个child theme,该函数返回parent theme的主题目录的服务器绝对路径,用法与get_stylesheet_directory()类似。
$op_get_stylesheet = get_stylesheet();//获取当前启用主题的主题目录名称,与get_template()的区别是,如果用了child theme,则返回child theme的目录名称。
$op_get_template = get_template();//获取当前启用主题的主题目录名称,例如现在启用的主题为twentyeleven,则输出:twentyeleven
//插件常用路径总结
$op_plugins_url() = plugins_url(); //输出:https://www.solagirl.net/wp-content/plugins
$op_plugins_url('',__FILE__) = plugins_url(); //输出:https://www.solagirl.net/wp-content/plugins/myplugin
$op_plugins_url('js/myscript.js',__FILE__); = plugins_url(); //输出:https://www.solagirl.net/wp-content/plugins/myplugin/js/myscript.js
$op_plugin_dir_url( __FILE__ ) = plugin_dir_url( __FILE__ ); //输出:(注意结尾有反斜杠):https://www.solagirl.net/wp-content/plugins/myplugin/
$op_plugin_dir_path( __FILE__ ) = plugin_dir_path( __FILE__ );
/**
* 输出:/home/user/public_html/wp-content/plugins/myplugin/
* 可以用来include文件,例如
* <?php
define( 'MYPLUGINNAME_PATH', plugin_dir_path(__FILE__) );
require MYPLUGINNAME_PATH . 'includes/class-metabox.php';
require MYPLUGINNAME_PATH . 'includes/class-widget.php';
?>
*/
$op_plugin_basename(__FILE__) = plugin_basename(__FILE__);
/**
* 返回调用该函数的插件文件名称(包含插件路径)
例如在插件myplugin下的myplugin.php文件中调用该函数,结果如下
echo plugin_basename(__FILE__);
//输出:myplugin/myplugin.php
如果在myplugin/include/test.php文件中调用(test.php通过include引用到myplugin.php中),结果如下
echo plugin_basename(__FILE__);
//输出:myplugin/include/test.php
*/
$op_redux_path = get_template_directory() . '/redux';
$op_redux_path = get_template_directory() . '/redux';
$op_redux_path = get_template_directory() . '/redux';
//定义框架文件夹,默认为主题目录下的redux
$op_plugins_path = get_template_directory() . '/redux/plugins';
//定义框架文件夹,默认为主题目录下的redux
$op_themes_path = get_template_directory() . '/redux/themes';
//定义框架文件夹,默认为主题目录下的redux
$op_uploads_path = get_template_directory() . '/redux/uploads';
//定义框架文件夹,默认为主题目录下的redux
$op_languages_path = get_template_directory() . '/redux/languages';
//定义框架文件夹,默认为主题目录下的redux
$op_wp_content_path = get_template_directory() . '/redux';
//定义框架文件夹,默认为主题目录下的redux
$op_wp_includes = get_template_directory() . '/redux';