コード例 #1
0
ファイル: column.php プロジェクト: Clear-Space/meritq
    /**
     * @since 2.0
     */
    public function display()
    {
        $classes = implode(' ', array_filter(array("cpac-box-{$this->properties->type}", $this->properties->classes)));
        // column list
        $column_list = '';
        $groups = $this->storage_model->get_column_type_groups();
        foreach ($groups as $group => $label) {
            $column_list .= $this->get_column_list($this->storage_model->column_types[$group], $label);
        }
        // clone attribute
        $data_clone = $this->properties->is_cloneable ? " data-clone='{$this->properties->clone}'" : '';
        ?>
		<div class="cpac-column <?php 
        echo $classes;
        ?>
" data-type="<?php 
        echo $this->properties->type;
        ?>
"<?php 
        echo $data_clone;
        ?>
>
			<input type="hidden" class="column-name" name="<?php 
        echo $this->attr_name('column-name');
        ?>
" value="<?php 
        echo esc_attr($this->properties->name);
        ?>
" />
			<input type="hidden" class="type"  name="<?php 
        echo $this->attr_name('type');
        ?>
" value="<?php 
        echo $this->properties->type;
        ?>
" />
			<input type="hidden" class="clone" name="<?php 
        echo $this->attr_name('clone');
        ?>
" value="<?php 
        echo $this->properties->clone;
        ?>
" />
			<div class="column-meta">
				<table class="widefat">
					<tbody>
						<tr>
							<td class="column_sort"></td>
							<td class="column_label">
								<div class="inner">
									<div class="meta">

										<span title="<?php 
        echo esc_attr(__('width', 'cpac'));
        ?>
" class="width" data-indicator-id="">
											<?php 
        echo !empty($this->options->width) ? $this->options->width . $this->options->width_unit : '';
        ?>
										</span>

										<?php 
        /**
         * Fires in the meta-element for column options, which is displayed right after the column label
         *
         * @since 2.0
         *
         * @param CPAC_Column $column_instance Column class instance
         */
        do_action('cac/column/settings_meta', $this);
        /**
         * @deprecated 2.2 Use cac/column/settings_meta instead
         */
        do_action('cac/column/label', $this);
        ?>

									</div>
									<a class="toggle" href="javascript:;"><?php 
        echo stripslashes($this->get_label());
        ?>
</a>
									<a class="edit-button" href="javascript:;"><?php 
        _e('Edit', 'cpac');
        ?>
</a>
									<?php 
        if ($this->properties->is_cloneable) {
            ?>
										<a class="clone-button" href="#"><?php 
            _e('Clone', 'cpac');
            ?>
</a>
									<?php 
        }
        ?>
									<a class="remove-button" href="javascript:;"><?php 
        _e('Remove', 'cpac');
        ?>
</a>
								</div>
							</td>
							<td class="column_type">
								<div class="inner">
									<a href="#"><?php 
        echo stripslashes($this->properties->label);
        ?>
</a>
								</div>
							</td>
							<td class="column_edit"></td>
						</tr>
					</tbody>
				</table>
			</div><!--.column-meta-->

			<div class="column-form">
				<table class="widefat">
					<tbody>
						<tr class="column_type">
							<?php 
        $this->label_view(__('Type', 'cpac'), __('Choose a column type.', 'cpac') . '<em>' . __('Type', 'cpac') . ': ' . $this->properties->type . '</em><em>' . __('Name', 'cpac') . ': ' . $this->properties->name . '</em>', 'type');
        ?>
							<td class="input">
								<select name="<?php 
        $this->attr_name('type');
        ?>
" id="<?php 
        $this->attr_id('type');
        ?>
">
									<?php 
        echo $column_list;
        ?>
								</select>
								<div class="msg"></div>
							</td>
						</tr><!--.column_label-->

						<tr class="column_label<?php 
        echo $this->properties->hide_label ? ' hidden' : '';
        ?>
">
							<?php 
        $this->label_view(__('Label', 'cpac'), __('This is the name which will appear as the column header.', 'cpac'), 'label');
        ?>
							<td class="input">
								<input class="text" type="text" name="<?php 
        $this->attr_name('label');
        ?>
" id="<?php 
        $this->attr_id('label');
        ?>
" value="<?php 
        echo esc_attr($this->options->label);
        //echo sanitize_text_field( $this->options->label );
        ?>
" />
							</td>
						</tr><!--.column_label-->

						<tr class="column_width">
							<?php 
        $this->label_view(__('Width', 'cpac'), '', 'width');
        ?>
							<td class="input">
								<div class="description" title="<?php 
        _e('default', 'cpac');
        ?>
">
									<input class="width" type="text" placeholder="<?php 
        _e('auto', 'cpac');
        ?>
" name="<?php 
        $this->attr_name('width');
        ?>
" id="<?php 
        $this->attr_id('width');
        ?>
" value="<?php 
        echo $this->options->width;
        ?>
" />
									<span class="unit"><?php 
        echo $this->options->width_unit;
        ?>
</span>
								</div>
								<div class="width-slider"></div>

								<div class="unit-select">
									<label for="<?php 
        $this->attr_id('width_unit_px');
        ?>
">
										<input type="radio" class="unit" name="<?php 
        $this->attr_name('width_unit');
        ?>
" id="<?php 
        $this->attr_id('width_unit_px');
        ?>
" value="px"<?php 
        checked($this->options->width_unit, 'px');
        ?>
/>
										px
									</label>
									<label for="<?php 
        $this->attr_id('width_unit_perc');
        ?>
">
										<input type="radio" class="unit" name="<?php 
        $this->attr_name('width_unit');
        ?>
" id="<?php 
        $this->attr_id('width_unit_perc');
        ?>
" value="%"<?php 
        checked($this->options->width_unit, '%');
        ?>
/>
										%
									</label>
								</div>

							</td>
						</tr><!--.column_width-->

						<?php 
        /**
         * Fires directly before the custom options for a column are displayed in the column form
         *
         * @since 2.0
         * @param CPAC_Column $column_instance Column class instance
         */
        do_action('cac/column/settings_before', $this);
        ?>

						<?php 
        /**
         * Load specific column settings.
         *
         */
        $this->display_settings();
        ?>

						<?php 
        /**
         * Fires directly after the custom options for a column are displayed in the column form
         *
         * @since 2.0
         * @param CPAC_Column $column_instance Column class instance
         */
        do_action('cac/column/settings_after', $this);
        ?>

						<tr class="column_action">
							<td colspan="2">
								<p>
									<?php 
        if ($this->properties->is_cloneable) {
            ?>
										<a class="clone-button" href="#"><?php 
            _e('Clone', 'cpac');
            ?>
</a>
									<?php 
        }
        ?>
									<a href="javascript:;" class="remove-button"><?php 
        _e('Remove');
        ?>
</a>
								</p>
							</td>
						</tr>

					</tbody>
				</table>
			</div>
		</div>
		<?php 
    }