/**
     * Render control wrapper, label, description, and control input
     *
     * @param WP_Fields_API_Control $control Control object
     */
    protected function render_control($control)
    {
        $input_id = 'field-' . $control->id;
        if (isset($control->input_attrs['id'])) {
            $input_id = $control->input_attrs['id'];
        }
        ?>
			<tr <?php 
        $control->wrap_attrs();
        ?>
>
				<th>
					<?php 
        if ($control->label && $control->display_label) {
            ?>
						<label for="<?php 
            echo esc_attr($input_id);
            ?>
">
							<?php 
            $control->render_label();
            ?>
						</label>
					<?php 
        }
        ?>
				</th>
				<td>
					<?php 
        $control->maybe_render();
        ?>

					<?php 
        if ($control->description) {
            ?>
						<p class="description">
							<?php 
            $control->render_description();
            ?>
						</p>
					<?php 
        }
        ?>
				</td>
			</tr>
		<?php 
    }
コード例 #2
0
    /**
     * Render control wrapper, label, description, and control input
     *
     * @param WP_Fields_API_Control $control     Control object
     * @param null|int              $item_id     Item ID
     * @param null|string           $object_name Object name
     */
    public function render_control($control, $item_id = null, $object_name = null)
    {
        // Pass $object_name and $item_id to Control
        $control->object_name = $object_name;
        $control->item_id = $item_id;
        $label = trim($control->label);
        $description = trim($control->description);
        // Avoid outputting them in render_content()
        $control->label = '';
        $control->description = '';
        $input_id = 'field-' . $control->id;
        if (isset($control->input_attrs['id'])) {
            $input_id = $control->input_attrs['id'];
        }
        ?>
			<div <?php 
        $control->wrap_attrs();
        ?>
>
				<?php 
        if (0 < strlen($label)) {
            ?>
					<label for="<?php 
            echo esc_attr($input_id);
            ?>
"><?php 
            echo esc_html($label);
            ?>
</label>
				<?php 
        }
        ?>

				<?php 
        $control->render_content();
        ?>

				<?php 
        if (0 < strlen($description)) {
            ?>
					<p class="description"><?php 
            echo wp_kses_post($description);
            ?>
</p>
				<?php 
        }
        ?>
			</div>
		<?php 
    }