'repeater',
'type' => 'repeater',
'layout' => 'row',
'add_row_text' => null,
'min_rows' => 0,
'max_rows' => 999,
'sorting' => true,
'controls' => array(),
'default_value' => array(),
'value' => array()
);
public function enqueue(){
wp_enqueue_style('rst-css-repeater', RS_LIB_URL . '/customize/controls/repeater/repeater.css');
wp_enqueue_script('jquery-ui-sortable');
wp_enqueue_script('rst-js-repeater', RS_LIB_URL . '/customize/controls/repeater/repeater.js');
wp_enqueue_script('rst-js-repeater-save', RS_LIB_URL . '/customize/controls/repeater/save.js');
}
public function render_content(){
$options = array_merge( self::$default, $this->params );
if( !isset($options['controls']) || !is_array($options['controls']) || sizeof($options['controls']) == 0 ){
echo 'Repeater controls must be an array.';
return;
}
$options['add_row_text'] = $options['add_row_text'] !== null ? $options['add_row_text'] : ($options['layout'] == 'single' ? 'Add Item' : 'Add Row');
// Get Value Customize Control Repeater
if( $this->value() && !empty( $options['name'] ) ) {
parse_str($this->value(), $value );
$options['value'] = $value[$options['name']];
}
else {
$options['value'] = array();
}
foreach($options['controls'] as $key => $control){
if(is_array($control)){
if(empty($control['name']) && $control['type'] != 'group'){
$control['name'] = $control['type'];
}
if(empty($control['label'])){
$control['label'] = ucfirst($control['name']);
}
if(empty($control['description'])){
$control['description'] = '';
}
$options['controls'][$key] = $control;
}
else{
unset($options['controls'][$key]);
}
}
$options['sorting'] = $options['sorting'] ? 'sorting-true' : 'sorting-false';
?>
label ) ) : ?>
label ); ?>
description ) ) : ?>
description) ; ?>
link(); ?> class="rst-repeater-values" value="value());?>" />
renderRowLayout($options);
?>
$value) { ?>
|
$control) :
unset($control['value']);
if(isset($options['value'][$i][$control['name']])){
$control['value'] = $value[$control['name']];;
}
$control['name'] = $options['name'].'['.$i.']['.$control['name'].']';
if(isset($control['field_id'])){
$control['conditional_logic_id'] = rs::generateId($control['field_id']) . '-field';
}
else{
$control['conditional_logic_id'] = rs::generateId($control['name']) . '-field';
}
?>
|
renderControl($control);
?>
|
|
+
-
|
|
|
renderControl($control);
?>
|
|
+
-
|
|
|
renderControl($control);
?>
|
|
+
-
|
Click Done to preview and save data.
renderError($return['message']);
}
}
}