我正在尝试保存wordpress插件的metabox值。它是可重复的,并通过javascript克隆。如何将克隆的metabox值保存在数据库中。还有一个WordPress编辑器。我已经将其与wp_editor集成在一起。每个编辑器还应带有唯一的ID。任何人都可以帮助我。...
克隆部分:
<div id="menu1" class="tab-pane fade">
<div class="panel-group" id="accordion">
<div class="panel panel-default template">
<div class="panel-heading"> <span class="glyphicon glyphicon-remove-circle pull-right ">Remove</span>
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseThree">
Collapsible Group Item #1 (template panel)
</a>
</h4>
</div>
<div id="collapseThree" class="panel-collapse collapse">
<div class="panel-body">
<div class="accordion_title">
<input type="text" name="my_test_name" value="<?php echo $your_name; ?>">
</div>
<div class="accordion_editor">
<?php
$content = '';
$editor_id = 'mycustomeditor';
wp_editor( $content, $editor_id );
?>
</div>
</div>
</div>
</div>
</div>
<br />
<a class="btn btn-lg btn-primary btn-add-panel"> <i class="glyphicon glyphicon-plus"></i> Add new panel </a>
</div>
Javascript部分
// Clone Item
$(document).ready(function(){
var $template = $(".template");
var hash = 0;
$(".btn-add-panel").on("click", function () {
var $newPanel = $template.clone();
$newPanel.find(".collapse").addClass('in');
$newPanel.find(".accordion-toggle").attr("href", "#" + (++hash))
.text("Dynamic panel #" + hash);
$newPanel.find(".panel-collapse").attr("id", hash);
$("#accordion").append($newPanel.fadeIn());
});
$(document).on('click', '.glyphicon-remove-circle', function () {
$(this).parents('.panel').get(0).remove();
});
});