LSX_Customize_Layout_Control::render_content()   A
last analyzed

Complexity

Conditions 5
Paths 12

Size

Total Lines 27
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 26
nc 12
nop 0
dl 0
loc 27
rs 9.1928
c 0
b 0
f 0
1
<?php
2
/**
3
 * LSX functions and definitions - Customizer - Layout.
4
 *
5
 * @package    lsx
6
 * @subpackage customizer
7
 * @category   layout
8
 */
9
10
if ( ! defined( 'ABSPATH' ) ) {
11
	exit;
12
}
13
14
if ( ! class_exists( 'WP_Customize_Control' ) ) {
15
	return;
16
}
17
18
if ( ! class_exists( 'LSX_Customize_Layout_Control' ) ) :
19
20
	/**
21
	 * LSX_Customize_Layout_Control Class.
22
	 *
23
	 * @package    lsx
24
	 * @subpackage customizer
25
	 * @category   layout
26
	 */
27
	class LSX_Customize_Layout_Control extends WP_Customize_Control {
28
29
		public $type = 'layout';
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
30
		public $statuses;
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
31
		public $layouts = array();
0 ignored issues
show
Coding Style Documentation introduced by
Missing member variable doc comment
Loading history...
32
33
		public function __construct( $manager, $id, $args = array() ) {
0 ignored issues
show
Coding Style Documentation introduced by
Missing doc comment for function __construct()
Loading history...
34
			parent::__construct( $manager, $id, $args );
35
			if ( ! empty( $args['choices'] ) ) {
36
				$this->layouts = $args['choices'];
37
			}
38
		}
39
40
		/**
41
		 * Enqueue scripts/styles for the color picker.
42
		 */
43
		public function enqueue() {
44
			wp_enqueue_script( 'lsx-layout-control', get_template_directory_uri() . '/assets/js/admin/customizer-layout.js', array( 'jquery' ), LSX_VERSION, true );
45
		}
46
47
		/**
48
		 * Render output.
49
		 */
50
		public function render_content() {
51
			$post_id = 'customize-control-' . str_replace( '[', '-', str_replace( ']', '', $this->id ) );
52
			$class   = 'customize-control customize-control-' . $this->type;
53
			$value   = $this->value();
54
			?>
55
			<label>
56
				<?php
57
				if ( ! empty( $this->label ) ) {
58
					?>
59
					<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
60
					<?php
61
				}
62
				if ( ! empty( $this->description ) ) {
63
					?>
64
					<span class="description customize-control-description"><?php echo esc_html( $this->description ); ?></span>
65
				<?php } ?>
66
				<div class="layouts-selector">
67
					<?php
68
					foreach ( $this->layouts as $layout ) {
69
						$sel = 'border: 1px solid transparent;';
70
						if ( $value === $layout ) {
71
							$sel = 'border: 1px solid rgb(43, 166, 203);';
72
						}
73
						echo '<img class="layout-button" style="padding:2px;' . esc_attr( $sel ) . '" src="' . esc_attr( get_template_directory_uri() ) . '/assets/images/admin/' . esc_attr( $layout ) . '.png" data-option="' . esc_attr( $layout ) . '">';
74
					}
75
					?>
76
					<input <?php $this->link(); ?> class="selected-layout <?php echo esc_attr( $class ); ?>" id="<?php echo esc_attr( $post_id ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>" <?php $this->input_attrs(); ?>>
77
				</div>
78
			</label>
79
			<?php
80
		}
81
82
	}
83
84
endif;
85