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
}
主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!
立刻開啟你的建站之旅