visibility_settings = $args['visibility_settings'] ? $args['visibility_settings'] : false;
parent::__construct( $manager, $id, $args );
}
private function calculate_available() {
$output = '';
$components = $this->choices;
$saved = $this->value();
if(!empty($saved))
$components = $this->map_saved_components($saved);
foreach($components as $name=>$label){
$output .= $this->get_sortable_markup( $name, $label);
}
return $output;
}
// the actual list items in teh sortable areas
private function get_sortable_markup( $name, $label) {
$output = '';
$output .= '
';
$output .= '';
$output .= $label;
$output .= '
';
$output .= '';
return $output;
}
private function map_saved_components($saved = array()){
$ret = array();
$saved = json_decode($saved);
if(empty($saved))
return $this->choices;
foreach($saved as $comp){
$name = $comp->name;
$label = $comp->label;
if(array_key_exists($name, $this->choices) ){
$ret[$name] = $label;
}
}
// should add the missing component
$ret = array_merge($ret, $this->choices);
// $missing = array_diff($this->choices, $ret);
// foreach($missing as $n=>$l)
// $ret[$name] = $l;
return $ret;
}
private function get_available(){
$output = '';
$output .= $this->calculate_available();
return $output;
}
/**
* Render the content on the theme customizer page
*/
public function render_content()
{
?>
link(); ?>
data-customize-setting-link="id; ?>"
value='value();?>'
/>