wordpress插件

wordpress后台框架options-framework的介绍,locate_template

日期:2015-04-24 阅读:2204

dmandwp系统 - wordpress系统和DM系统区块建站>>

options-framework插件下载 https://wordpress.org/plugins/options-framework/ 

一般放在当前主题下面。比如yourtheme/includes/framework

然后在function.php调用它。

if ( !function_exists( 'optionsframework_init' ) ) {
    define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/includes/framework/' );
    require_once dirname(__FILE__).'/includes/framework/options-framework.php';
}

OPTIONS_FRAMEWORK_DIRECTORY很重要,这个框架要用到的一个常量。

------------------

关于options.php这个文件,可以从这里得到:

https://github.com/devinsays/options-framework-theme  

https://github.com/devinsays/options-framework-theme/archive/master.zip

在插件的includes/class-options-framework.php有以下代码:

  $location = apply_filters( 'options_framework_location', array( 'options.php' ) );

... locate_template( $location ) 这是用来加载options.php的。

后台的主题选项编辑,主要是在options.php里。

-------------

前台得到值:类似: $logo_src = of_get_option( 'website_logo_upload', '' );

------

关于加入js代码: 因为后台不能直接加入js代码,被认为不安全,那就通过下面代码的方式来添加:

add_action('optionsframework_custom_scripts', 'optionsframework_custom_scripts');
function optionsframework_custom_scripts(){ ?>
<script type="text/javascript">
    你的js代码
</script>
<?php
}

----------------

参考: 

http://www.wpdaxue.com/options-framework-for-theme.html

http://devework.com/options-framework.html/comment-page-1

 

 

 

<<点击返回