18.2 Custom Ordering of Category (ok)
Previous18.1 Làm form filter Category (ok)Next18.3 Include Categories, Exclude Categories, Show "All" option (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; ?>
<div class="wpf_ct_back_active_module_row">
<div class="wpf_ct_back_active_module_label">
<label><?php _e('Display as', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input wpf_ct_display_as wpf_changed">
<?php foreach ($display as $k => $v): ?>
<label>
<input type="radio" name="[<?php echo $type ?>][show_as]" value="<?php echo $k ?>" <?php if ((isset($module['show_as']) && $module['show_as'] === $k) || (!isset($module['show_as']) && $k === 'checkbox')): ?>checked="checked"<?php endif; ?> />
<?php echo $v ?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="wpf_ct_back_active_module_row">
<div class="wpf_ct_back_active_module_label">
<label><?php _e('Logic', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input wpf_ct_logic">
<?php foreach ($logic as $k => $v): ?>
<label>
<input type="radio" name="[<?php echo $type ?>][logic]" value="<?php echo $k ?>" <?php if ((isset($module['logic']) && $module['logic'] === $k) || (!isset($module['logic']) && $k === 'or')): ?>checked="checked"<?php endif; ?> />
<?php echo $v ?>
</label>
<?php endforeach; ?>
</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 ?>[order]"><?php _e('Order', 'wpf') ?></label>
</div>
<div class="wpf_ct_back_active_module_input">
<div class="wpf_ct_custom_select wpf_ct_order wpf_ct_changed">
<select name="[<?php echo $type ?>][order]">
<?php foreach ($order as $k => $v): if('term_order'===$k && !in_array($type,array('wpf_ct_cat','wpf_ct_tag'))) continue; ?>
<option <?php if (!empty($module['order']) && $module['order'] === $k): ?>selected="selected"<?php endif; ?> value="<?php echo $k ?>"><?php echo $v ?></option>
<?php endforeach; ?>
</select>
</div>
<div class="wpf_ct_custom_select wpf_ct_orderby">
<select name="[<?php echo $type ?>][orderby]">
<?php foreach ($orderby as $k => $v): ?>
<option <?php if (!empty($module['orderby']) && $module['orderby'] === $k): ?>selected="selected"<?php endif; ?> value="<?php echo $k ?>"><?php echo $v ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
</div>
<?php break; ?>
<?php endswitch; ?>
<?php
}
C:\xampp\htdocs\test\wp-content\plugins\plugin-name\admin\js\wpf-themplate_ct.js
ShowHide: function () {
$( '#' + WPF.prefix + 'lightbox_container' ).on( 'change', '.' + WPF.prefix + 'changed input,.' + WPF.prefix + 'changed select', function () {
var $container, slide = true;
if($(this).closest('.'+WPF.prefix +'order').length>0){
$container = $(this).closest('.'+WPF.prefix+'order').next('.'+WPF.prefix +'orderby');
slide = $(this).val()!=='term_order';
}
else if ( $( this ).prop( 'name' ) === 'pagination_type' ) {
if ( $( this ).val() === 'infinity_auto' ) {
$( '.wpf_lightbox_row.wpf_infinity_buffer' ).show();
} else {
$( '.wpf_lightbox_row.wpf_infinity_buffer' ).hide();
}
}
if ( typeof $container !== 'undefined' ) {
if( slide ) $container.slideDown();
else $container.slideUp();
}
});
$('.'+WPF.prefix +'changed input:checked,.'+WPF.prefix +'changed option:selected').trigger('change');
}