render_content() protected method

Allows the content to be overridden without having to rewrite the wrapper in $this::render(). Supports basic input types text, checkbox, textarea, radio, select and dropdown-pages. Additional input types such as email, url, number, hidden and date are supported implicitly. Control content can alternately be rendered in JS. See WP_Customize_Control::print_template().
Since: 3.4.0
protected render_content ( )
 public function render_content()
 {
     parent::render_content();
     // echo "<p class='description'>{$this->description}</p>";
 }
Example #2
0
        protected function render_content()
        {
            switch ($this->type) {
                default:
                    return parent::render_content();
                case 'text':
                    ?>
				<label>
					<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
					<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
					<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
					<?php 
                    }
                    ?>
					<input type="text" value="<?php 
                    echo esc_attr($this->value());
                    ?>
" <?php 
                    $this->link();
                    ?>
 />
				</label>
				<?php 
                    break;
                case 'checkbox':
                    ?>
				<label>
					<input type="checkbox" value="<?php 
                    echo esc_attr($this->value());
                    ?>
" <?php 
                    $this->link();
                    checked($this->value());
                    ?>
 />
					<?php 
                    echo esc_html($this->label);
                    ?>
				</label>
				<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
				<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
				<?php 
                    }
                    ?>
				<?php 
                    break;
                case 'radio':
                    if (empty($this->choices)) {
                        return;
                    }
                    $name = '_customize-radio-' . $this->id;
                    ?>
				<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
				<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
				<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
				<?php 
                    }
                    ?>
				<?php 
                    foreach ($this->choices as $value => $label) {
                        ?>
					<label>
						<input type="radio" value="<?php 
                        echo esc_attr($value);
                        ?>
" name="<?php 
                        echo esc_attr($name);
                        ?>
" <?php 
                        $this->link();
                        checked($this->value(), $value);
                        ?>
 />
						<?php 
                        echo esc_html($label);
                        ?>
<br/>
					</label>
					<?php 
                    }
                    break;
                case 'custom-radio':
                    if (empty($this->choices)) {
                        return;
                    }
                    $name = '_customize-radio-' . $this->id;
                    ?>
				<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
				<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
				<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
				<?php 
                    }
                    ?>
				<?php 
                    foreach ($this->choices as $value => $label) {
                        $screenshot_img = substr($value, 0, -4);
                        ?>
					<label>
						<div class="theme-img">
							<img src="<?php 
                        echo get_template_directory_uri();
                        ?>
/_inc/preset-styles/images/<?php 
                        echo $screenshot_img . '.png';
                        ?>
" alt="<?php 
                        echo $screenshot_img;
                        ?>
" />
						</div>
						<input type="radio" value="<?php 
                        echo esc_attr($value);
                        ?>
" name="<?php 
                        echo esc_attr($name);
                        ?>
" <?php 
                        $this->link();
                        checked($this->value(), $value);
                        ?>
 />
						<?php 
                        echo esc_html($label);
                        ?>
<br/>
					</label>
					<?php 
                    }
                    break;
                case 'select':
                    if (empty($this->choices)) {
                        return;
                    }
                    ?>
				<label>
					<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
					<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
					<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
					<?php 
                    }
                    ?>
					<select <?php 
                    $this->link();
                    ?>
>
						<?php 
                    foreach ($this->choices as $value => $label) {
                        echo '<option value="' . esc_attr($value) . '"' . selected($this->value(), $value, false) . '>' . $label . '</option>';
                    }
                    ?>
					</select>
				</label>
				<?php 
                    break;
                    // Handle textarea
                // Handle textarea
                case 'textarea':
                    ?>
				<label>
					<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
					<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
					<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
					<?php 
                    }
                    ?>
					<textarea rows="10" cols="40" <?php 
                    $this->link();
                    ?>
><?php 
                    echo esc_attr($this->value());
                    ?>
</textarea>
				</label>
				<?php 
                    break;
            }
        }
        protected function render_content()
        {
            switch ($this->type) {
                default:
                    return parent::render_content();
                case 'text':
                    ?>
				<label>
					<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
					<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
					<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
					<?php 
                    }
                    ?>
					<input type="text" value="<?php 
                    echo esc_attr($this->value());
                    ?>
" <?php 
                    $this->link();
                    ?>
 />
				</label>
				<?php 
                    break;
                case 'radio':
                    if (empty($this->choices)) {
                        return;
                    }
                    $name = '_customize-radio-' . $this->id;
                    ?>
				<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
				<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
				<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
				<?php 
                    }
                    ?>
				<?php 
                    foreach ($this->choices as $value => $label) {
                        ?>
					<label>
						<input type="radio" value="<?php 
                        echo esc_attr($value);
                        ?>
" name="<?php 
                        echo esc_attr($name);
                        ?>
" <?php 
                        $this->link();
                        checked($this->value(), $value);
                        ?>
 />
						<?php 
                        echo esc_html($label);
                        ?>
<br/>
					</label>
					<?php 
                    }
                    break;
                case 'select':
                    if (empty($this->choices)) {
                        return;
                    }
                    ?>
				<label>
					<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
					<?php 
                    if (isset($this->description) && !empty($this->description)) {
                        ?>
					<span class="customize-control-description"><?php 
                        echo $this->description;
                        ?>
</span>
					<?php 
                    }
                    ?>
					<select <?php 
                    $this->link();
                    ?>
>
						<?php 
                    foreach ($this->choices as $value => $label) {
                        echo '<option value="' . esc_attr($value) . '"' . selected($this->value(), $value, false) . '>' . $label . '</option>';
                    }
                    ?>
					</select>
				</label>
				<?php 
                    break;
            }
        }