register_control_type( 'Epsilon_Control_Layouts' ); } /** * Add custom parameters to pass to the JS via JSON. * * @since 1.2.0 * @access public */ public function json() { $json = parent::json(); $json['layouts'] = $this->get_layouts(); $json['id'] = $this->id; $json['link'] = $this->get_link(); $json['value'] = $this->value(); $json['default'] = $this->default; $json['columns'] = $this->get_columns(); $json['minSpan'] = null === $this->min_span ? 2 : (int) $this->min_span; $json['intString'] = $this->match_int_to_string( count( $json['layouts'] ) ); $json['fixed'] = $this->fixed; $this->json['inputAttrs'] = ''; foreach ( $this->input_attrs as $attr => $value ) { $this->json['inputAttrs'] .= $attr . '="' . esc_attr( $value ) . '" '; } return $json; } /** * Create a custom array so it's easier to setup columns * * @since 1.2.0 * @access private */ private function get_columns() { $arr = array(); $val = $this->value(); if ( '' === $val ) { return $this->default; } if ( is_string( $val ) ) { $val = json_decode( $val ); } return $val; } /** * Create a custom array to hold options * * @since 1.0.0 * @acces private */ private function get_layouts() { $arr = array(); foreach ( $this->layouts as $k => $v ) { $arr[] = array( 'value' => $k, 'label' => $v, ); } return $arr; } /** * Matches an int to a string * * @since 1.3.4 */ public function match_int_to_string( $int = 1 ) { $arr = array( 1 => 'one', 2 => 'two', 3 => 'three', 4 => 'four', 5 => 'five', 6 => 'six', ); return $arr[ $int ]; } /** * As it should be * * @since 1.0.0 */ public function render_content() { } /** * Displays the control content. * * @since 1.0.0 */ public function content_template() { //@formatter:off ?>