我正在尝试构建一个新的自定义“媒体”样式的自定义字段(它允许用户从媒体库中选择视频或粘贴到url中),除保存新值外,其他一切都正常。
我的自定义设置为:
$wp_customize->register_control_type( \'WP3432_Video_Control\' );
$wp_customize->add_setting(\'feed_video_setting\', array(
\'default\' => \'\',
\'sanitize_callback\' => \'absint\'
));
$wp_customize->add_control(new WP3432_Video_Control( $wp_customize,
\'feed_video_control\', array(
\'label\' => \'Hero Video\',
\'section\' => \'feed_settings_section\',
\'settings\' => \'feed_video_setting\',
)));
我正在手动将setting customizer链接设置为\\u json方法:
public function to_json() {
parent::to_json();
...
$this->json[\'control_name\'] = $this->id;
$this->json[\'setting_name\'] = $this->setting->id;
...
}
并在content\\u template方法中手动设置该属性:
public function content_template() {
?>
...
<span class="use-url"> - or use URL -</span>
<input class="js--video-url"
id="{{ data.control_name }}"
name="{{ data.control_name }}"
data-customize-setting-link = "{{ data.setting_name }}"
type="url"
value="{{ data.value }}"
>
...
<?php
}
这将在customizer表单中生成以下标记:
<input class="js--video-url" id="archive_video_control" name="archive_video_control" data-customize-setting-link="archive_video_setting" type="url" value="">
但当我检查get\\u theme\\u mods()的内容时,我看到:
[archive_video_setting] => 0