id = $id;
}
public function value() {
// get_post_meta($post_id, $key, $single);
}
public function link() {
echo 'name="meta-box-' . $this->id . '"';
}
}
}
class KobAdminControl {
private $name;
public function getName(){
return $this->name;
}
public function getData($data) {
if (isset($data) && isset($data->{$this->getName()}))
return $data->{$this->getName()};
else
return NULL;
}
private function setName($name){
$this->name = $name;
return $this;
}
public function __construct($name){
$this->setName($name);
}
public function styles(){return array();}
public function scripts(){return array();}
public function className(){echo 'kob-admin-control';}
public function update(){echo '';}
public function initialize(){echo '';}
public function serialization(){echo '';}
public function bindListeners(){echo '';}
public function render($id, $data){echo 'Kob Admin v1.0 : This KobAdminControl isnt filled. $id = ' . $id;}
public function kobRender($id, $data){
?>
render($id, $data) ?>
inputs = $inputs;
}
public function scripts() {
$result = array();
foreach($this->inputs as $input) {
$result = array_merge($result, $input->scripts());
}
return $result;
}
public function styles() {
$result = array();
foreach($this->inputs as $input) {
$result = array_merge($result, $input->styles());
}
return $result;
}
public function className() {echo 'kob-many-control';}
public function update() {
?>
$(element).children().each(function(){
updateElement(this, main, data.getName() ?>);
});
var serialized = {};
$(element).children().each(function(){
serialized[getElementName(this)] = serializeElement(this);
});
return serialized;
$(element).children().each(function(){
bindListenersToElement(this, id);
});
$(element).children().each(function(){
initializeElement(this);
});
inputs as $input)
$input->kobRender($id, $this->getData($data));
}
}
class KobAdminControlManager extends WP_Customize_Control {
public $type = 'text';
private $input;
private function setInput($input) {
$this->input = $input;
return $this;
}
public function getInput() {
return $this->input;
}
public function __construct($manager, $id, $args = array(), $input = NULL) {
parent::__construct($manager, $id, $args);
//$manager->add_control()
$this->setInput($input);
add_action( 'admin_print_footer_scripts', array($this, 'print_includes') );
}
public function kobRender($json_value) {
if($this->getInput()) {
$data = json_decode($json_value);
$this->getInput()->kobRender($this->id, $data);
}
}
public function styles() {
if ($this->getInput()) {
return $this->getInput()->styles();
}
}
public function scripts() {
if ($this->getInput()) {
return $this->getInput()->scripts();
}
}
function print_includes() {
foreach(array_merge($this->scripts(), $this->styles()) as $key => $script) {
if(!(defined($key))){
echo $script;
define($key, 'test');
}
}
}
public function sub_content($id, $value) {
?>