Rom*_*man 3 wordpress carbon-fields
我为主题选项创建容器并向其中添加字段数组。然后打开此选项页面,查看标题和应添加字段的空块。如何显示字段?
碳田2.1.0
use Carbon_Fields\Container;
use Carbon_Fields\Field;
Container::make( 'theme_options', __( 'Theme Options', 'crb' ) )
->add_fields( array(
Field::make( 'text', 'crb_text', 'Text Field' ),
) );
Run Code Online (Sandbox Code Playgroud)
小智 5
为了让 Carbon Fields 在插件中工作,我必须定义 的值Carbon_Fields\URL来修复它。
我的插件根文件中的引导代码如下所示:
// Define the url where Carbon Fields assets will be enqueued from
define( 'Carbon_Fields\URL', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'vendor/htmlburger/carbon-fields/' );
// Boot Carbon Fields
\Carbon_Fields\Carbon_Fields::boot();
// Return the class that sets up the settings pages
return new \MyPlugin\Settings();
Run Code Online (Sandbox Code Playgroud)
您可以在此处查看引导之前可以覆盖的所有 Carbon Field 常量: https: //github.com/htmlburger/carbon-fields/blob/development/config.php
| 归档时间: |
|
| 查看次数: |
1450 次 |
| 最近记录: |