18.1 Làm form filter Category (ok)
Last updated
Was this helpful?
Last updated
Was this helpful?
C:\xampp\htdocs\test\wp-content\plugins\plugin-name\includes\class-wpf-form_ct.php
protected function get_main_fields($type, $name, $module = array()) {
switch ($type):
case 'sku':
break;
default:
$order = array(
'term_order' => __('Custom Ordering', 'wpf'),
'name' => __('Name', 'wpf'),
'count' => __('Count', 'wpf'),
'id' => __('ID', 'wpf'),
);
$orderby = array(
'asc' => __('Ascending', 'wpf'),
'desc' => __('Descending', 'wpf')
);
$display = array(
'checkbox' => __('Checkbox', 'wpf'),
'link' => __('Links', 'wpf'),
'radio' => __('Radio', 'wpf'),
'dropdown' => __('Dropdown', 'wpf'),
'multiselect' => __('Multi Select', 'wpf'),
);
$logic = array(
'or' => __('OR', 'wpf'),
'and' => __('AND', 'wpf')
);
$include_children = array(
'yes' => __('Yes', 'wpf'),
'no' => __('No', 'wpf')
);
?>
<div class="wpf_ct_back_active_module_row">
<div class="wpf_ct_back_active_module_label">
<label for="wpf_ct_<?php echo $type ?>[count]"><?php _e('Product Count', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input">
<label>
<input id="wpf_ct_<?php echo $type ?>[count]" type="checkbox" name="[<?php echo $type ?>][count]" value="1" <?php if (!empty($module['count']) || !$module): ?>checked="checked"<?php endif; ?> />
<?php _e('Show product counts', 'wpf') ?>
</label>
</div>
</div>
<?php if ($type === 'wpf_ct_cat' || $type === 'wpf_ct_tag'): ?>
<?php if ($type === 'wpf_ct_cat'): ?>
<div class="wpf_ct_back_active_module_row">
<div class="wpf_ct_back_active_module_label">
<label for="wpf_ct_<?php echo $type ?>[hierachy]"><?php _e('Category Hierarchy', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input">
<label>
<input id="wpf_ct_<?php echo $type ?>[hierachy]" type="checkbox" name="[<?php echo $type ?>][hierachy]" value="1" <?php if (!empty($module['hierachy'])): ?>checked="checked"<?php endif; ?> />
<?php _e('Show category hierarchy', 'wpf') ?>
</label>
</div>
</div>
<div class="wpf_ct_back_active_module_row">
<div class="wpf_ct_back_active_module_label">
<label for="wpf_ct_<?php echo $type ?>[include]"><?php _e('Include Children ', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input">
<?php foreach ($include_children as $k => $v): ?>
<label>
<input type="radio" name="[<?php echo $type ?>][include]" value="<?php echo $k ?>" <?php if ((isset($module['include']) && $module['include'] === $k) || (!isset($module['include']) && $k === 'yes')): ?>checked="checked"<?php endif; ?> />
<?php echo $v ?>
</label>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php break; ?>
<?php endswitch; ?>
<?php
}