Adding a custom field to Redux is quite simple. It is important the following code is included before the ReduxFramework object is created.
添加自定义字段到框架是很简单的。以下的代码是重要的,reduxframework对象创建前包含的。
Hook into the overload filter 钩的负载滤波器
Ideally, this call would be made in your own class. In this example, no class is needed. First, run the hook:
这个调用将是你自己的类。在这个例子中,没有类是必要的。第一,打钩:
1
|
add_filter(
"redux/{$YOUR_OPT_NAME}/field/class/edd_license"
,
"overload_edd_license_field_path"
);
// Adds the local field
|
The overload function在过载功能
Next, include the file path, wherever it may be. Here’s an example.
下一步,包括文件路径,无论它可能是。这是一个例子。
1
2
3
|
public
function
overload_edd_license_field_path(
$field
) {
return
dirname(
__FILE__
).
'/edd_license/field_edd_license.php'
;
}
|
This allows any field type to be overridden with your own code using your individual opt_name
.
这允许任何类型的overridden场是与您自己的个人使用您的代码
Override an existing field 重写现有的市场
With the code above you can also overload any core field within Redux with one of your own. Make sure the class names match, and you can modify an existing field without actually touching the core code.
Use the extension boilerplate
To make your life much easier, you can use the extension boilerplate. It will be a great starting point to see how to build a custom Redux field. You will also need to utilize the extension loader in order to make your custom field operable.