json['choices'] = array(); if ( is_array( $this->choices ) ) { if ( isset( $this->choices['top'] ) && true == $this->choices['top'] ) { $this->json['choices']['top'] = true; } if ( isset( $this->choices['bottom'] ) && true == $this->choices['bottom'] ) { $this->json['choices']['bottom'] = true; } if ( isset( $this->choices['left'] ) && true == $this->choices['left'] ) { $this->json['choices']['left'] = true; } if ( isset( $this->choices['right'] ) && true == $this->choices['right'] ) { $this->json['choices']['right'] = true; } } $i18n = Kirki_Toolkit::i18n(); $this->json['l10n'] = array( 'top' => $i18n['top'], 'bottom' => $i18n['bottom'], 'left' => $i18n['left'], 'right' => $i18n['right'], ); if ( isset( $this->json['choices']['top'] ) && ! isset( $this->json['value']['top'] ) ) { $this->json['value']['top'] = $this->json['default']['top']; } if ( isset( $this->json['choices']['bottom'] ) && ! isset( $this->json['value']['bottom'] ) ) { $this->json['value']['bottom'] = $this->json['default']['bottom']; } if ( isset( $this->json['choices']['left'] ) && ! isset( $this->json['value']['left'] ) ) { $this->json['value']['left'] = $this->json['default']['left']; } if ( isset( $this->json['choices']['right'] ) && ! isset( $this->json['value']['top'] ) ) { $this->json['value']['right'] = $this->json['default']['right']; } } protected function content_template() { ?> <# if ( data.help ) { #> <# } #> <# if ( data.label ) { #> {{{ data.label }}} <# } #> <# if ( data.description ) { #> {{{ data.description }}} <# } #> <# if ( data.choices['top'] ) { #> {{ data.l10n['top'] }} <# if ( data.choices['units'] ) { #> <# for ( key in data.choices['units'] ) { #> selected <# } #>>{{ data.choices['units'][ key ] }} <# } #> <# } else { #> <# if ( data.value && data.value['top'] ) { #> <# var units = data.value['top'].replace( parseFloat( data.value['top'] ), '' ); #> <# } else { #> <# var units = 'px'; #> <# } #> selected <# } #>>px selected <# } #>>em selected <# } #>>% <# } #> <# } #> <# if ( data.choices['bottom'] ) { #> {{ data.l10n['bottom'] }} <# if ( data.choices['units'] ) { #> <# for ( key in data.choices['units'] ) { #> selected <# } #>>{{ data.choices['units'][ key ] }} <# } #> <# } else { #> <# if ( data.value && data.value['bottom'] ) { #> <# var units = data.value['bottom'].replace( parseFloat( data.value['bottom'] ), '' ); #> <# } else { #> <# var units = 'px'; #> <# } #> selected <# } #>>px selected <# } #>>em selected <# } #>>% <# } #> <# } #> <# if ( data.choices['left'] ) { #> {{ data.l10n['left'] }} <# if ( data.choices['units'] ) { #> <# for ( key in data.choices['units'] ) { #> selected <# } #>>{{ data.choices['units'][ key ] }} <# } #> <# } else { #> <# if ( data.value && data.value['left'] ) { #> <# var units = data.value['left'].replace( parseFloat( data.value['left'] ), '' ); #> <# } else { #> <# var units = 'px'; #> <# } #> selected <# } #>>px selected <# } #>>em selected <# } #>>% <# } #> <# } #> <# if ( data.choices['right'] ) { #> {{ data.l10n['right'] }} <# if ( data.choices['units'] ) { #> <# for ( key in data.choices['units'] ) { #> selected <# } #>>{{ data.choices['units'][ key ] }} <# } #> <# } else { #> <# if ( data.value && data.value['right'] ) { #> <# var units = data.value['right'].replace( parseFloat( data.value['right'] ), '' ); #> <# } else { #> <# var units = 'px'; #> <# } #> selected <# } #>>px selected <# } #>>em selected <# } #>>% <# } #> <# } #>