17.2 Hiển thị đầy đủ các trường form edit (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
private function add_fields($data = array()) {
$layouts = array(
'vertical' => __('Vertical Layout', 'wpf'),
'horizontal' => __('Horizontal Layout', 'wpf')
);
$pagination = array(
'pagination' => __('Standard Pagination', 'wpf'),
'infinity_auto' => __('Infinite Scroll', 'wpf'),
'infinity' => __('Load More', 'wpf')
);
?>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_name"><?php _e('Form Title', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input id="wpf_name" class="wpf_towidth" type="text" value="<?php echo !empty($data['name']) ? $data['name'] : '' ?>" name="name" />
</div>
</div>
<div class="wpf_lightbox_row ">
<div class="wpf_lightbox_label"><?php _e('Layout', 'wpf'); ?></div>
<div class="wpf_lightbox_input wpf_grid wpf_ct_changed">
<?php foreach ($layouts as $id => $ch): ?>
<input id="wpf_<?php echo $id ?>" type="radio" value="<?php echo $id; ?>" name="type" <?php if ((!$data && $id === 'vertical' ) || ( isset($data['type']) && $data['type'] == $id )): ?>checked="checked"<?php endif; ?>/>
<label title="<?php echo $ch ?>" for="wpf_<?php echo $id ?>" class="wpf_grid_<?php echo $id; ?>"></label>
<?php endforeach; ?>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_empty_fields"><?php _e('Empty Fields', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if ((!isset($data['empty']) && empty($data)) || !empty($data['empty'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="empty" value="1" id="wpf_empty_fields"/>
<label for="wpf_empty_fields"><?php _e('Do not show field if empty', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_sort_fields"><?php _e('Product Sorting', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['sort'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="sort" value="1" id="wpf_sort_fields"/>
<label for="wpf_sort_fields"><?php _e('Hide product sorting', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_result_fields"><?php _e('Product Count', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['result'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="result" value="1" id="wpf_result_fields"/>
<label for="wpf_result_fields"><?php _e('Hide result product count', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_out_of_stock_fields"><?php _e('Out of Stock', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['out_of_stock'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="out_of_stock" value="1" id="wpf_out_of_stock_fields"/>
<label for="wpf_out_of_stock_fields"><?php _e('Do not show out of stock products', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row wpf_ct_changed">
<div class="wpf_lightbox_label"><label for="wpf_pagination_fields"><?php _e('Pagination', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['pagination'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="pagination" value="1" id="wpf_pagination_fields"/>
<label for="wpf_pagination_fields"><?php _e('Hide Pagination', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row wpf_infinity wpf_ct_changed">
<div class="wpf_lightbox_label"><label for="wpf_pagination_type_fields"><?php _e('Pagination Option', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<?php foreach ($pagination as $k => $v): ?>
<label for="wpf_<?php echo $k ?>_type_fields">
<input <?php if ((isset($data['pagination_type']) && $data['pagination_type'] === $k) || (empty($data['pagination_type']) && $k === 'pagination')): ?>checked="checked"<?php endif; ?> type="radio" name="pagination_type" value="<?php echo $k ?>" id="wpf_<?php echo $k ?>_type_fields"/><?php echo $v ?>
</label>
<?php endforeach; ?>
</div>
</div>
<div class="wpf_lightbox_row wpf_infinity_buffer">
<div class="wpf_lightbox_label"><label for="wpf_pagination_type_fields"> </label></div>
<div class="wpf_lightbox_input">
<input type="text" name="infinitybuffer" value="<?php echo! empty( $data['infinitybuffer'] ) ? esc_attr( $data['infinitybuffer'] ) : '' ?>" id="wpf_infinity_buffer_fields" /> <?php _e( 'Infinite scroll trigger point (px)' ) ?><br><small><?php _e( 'Default is 300, higher number means infinite scroll will trigger earlier.' ) ?></small>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_posts_per_page_fields"><?php _e('Products Per Page', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input type="text" name="posts_per_page" value="<?php echo!empty($data['posts_per_page']) ? intval($data['posts_per_page']) : '' ?>" id="wpf_posts_per_page_fields"/>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_group_fields"><?php _e('Toggle Field Groups', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['group'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="group" value="1" id="wpf_group_fields"/>
<label for="wpf_group_fields"><?php _e('Allow field groups toggle-able', 'wpf') ?></label>
</div>
</div>
<div class="wpf_lightbox_row wpf_result_page_wrapper">
<div class="wpf_lightbox_label"><label><?php _e('Reset Button', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<ul>
<li>
<input id="wpf_bottom_reset_button" type="radio" value="bottom" name="reset_button" <?php if ( !empty( $data['reset_button'] ) && 'bottom' === $data['reset_button'] ): ?>checked="checked"<?php endif; ?>>
<label for="wpf_bottom_reset_button"><?php _e( 'Add reset button at bottom', 'wpf' ); ?></label>
</li>
<li>
<input id="wpf_group_reset_button" type="radio" value="group" name="reset_button" <?php if ( !empty( $data['reset_button'] ) && 'group' === $data['reset_button'] ): ?>checked="checked"<?php endif; ?>>
<label for="wpf_group_reset_button"><?php _e( 'Add reset button at every field group', 'wpf' ); ?></label>
</li>
<li>
<input id="wpf_no_reset_button" type="radio" value="no" name="reset_button" <?php if ( empty( $data['reset_button'] ) || (!empty( $data['reset_button'] ) && 'no' === $data['reset_button']) ): ?>checked="checked"<?php endif; ?>>
<label for="wpf_no_reset_button"><?php _e( 'No reset button', 'wpf' ); ?></label>
</li>
</ul>
</div>
</div>
<div class="wpf_lightbox_row ">
<div class="wpf_lightbox_label"><label for="wpf_clear_label"><?php _e('Reset Label', 'wpf'); ?></label></div>
<?php
$get_all_languages = [
'en' => [
'name' => '',
'selected' => true,
],
];
?>
<div class="wpf_lightbox_input"><?php WPF_Utils_CT::module_language_tabs( 'clear_label', $data, $get_all_languages, null, 'text', __('Reset', 'wpf'), true ); ?>
</div>
</div>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_scroll_fields"><?php _e('Scroll To Result', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<input <?php if (!empty($data['scroll'])): ?>checked="checked"<?php endif; ?> type="checkbox" name="scroll" value="1" id="wpf_scroll_fields"/>
<label for="wpf_scroll_fields"><?php _e('Yes', 'wpf') ?></label>
</div>
</div>
<?php
$relations = array(
'and' => __('AND', 'wpf'),
'or' => __('OR', 'wpf')
);
?>
<div class="wpf_lightbox_row">
<div class="wpf_lightbox_label"><label for="wpf_tax_relation_or"><?php _e('Logical Relationship Between Taxonomies', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<?php foreach ($relations as $k => $v): ?>
<label for="wpf_tax_relation_<?php echo $k ?>">
<input <?php if (isset($data['tax_relation']) && $data['tax_relation'] === $k || (!isset($data['tax_relation']) && $k === 'or')): ?>checked="checked"<?php endif; ?> type="radio" name="tax_relation" value="<?php echo $k ?>" id="wpf_tax_relation_<?php echo $k ?>"/>
<?php echo $v ?>
</label>
<?php endforeach; ?>
</div>
</div>
<?php
$pages = get_posts(array(
'post_type' => 'page',
'post_status' => 'publish',
'numberposts' => -1,
'orderby' => 'post_title',
'order' => 'ASC'
));
$result_types = array(
'same_page' => __('Show results on the same page', 'wpf'),
'diff_page' => __('Show results on a different page', 'wpf')
)
?>
<div class="wpf_lightbox_row wpf_result_page_wrapper wpf_changed">
<div class="wpf_lightbox_label"><label for="wpf_result_page"><?php _e('Result Page Template', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<ul>
<?php foreach ($result_types as $id => $ch): ?>
<li>
<input id="wpf_<?php echo $id ?>" type="radio" value="<?php echo $id; ?>" name="result_type" <?php if ((!$data && $id === 'same_page' ) || ( isset($data['result_type']) && $data['result_type'] == $id )): ?>checked="checked"<?php endif; ?>/>
<label for="wpf_<?php echo $id ?>"><?php echo $ch ?></label>
</li>
<?php endforeach; ?>
<li class ="wpf_result_page_select">
<input id="wpf_show_form_in_results" type="checkbox" value="show_form_in_results" name="show_form_in_results" <?php if (isset($data['show_form_in_results'])): ?> checked="checked"<?php endif; ?>/>
<label for="wpf_show_form_in_results"><?php _e('Show product filter form on search result page.', 'wpf') ?></label>
</li>
</ul>
<div class="wpf_result_page_select">
<div class="wpf_custom_select">
<select name="page" id="wpf_result_page">
<?php if (!empty($pages)): ?>
<?php foreach ($pages as $p): ?>
<option <?php if (!empty($data['page']) && $data['page'] == $p->ID): ?>selected="selected"<?php endif; ?> value="<?php echo $p->ID ?>"><?php echo $p->post_title ?></option>
<?php endforeach; ?>
<?php endif; ?>
</select>
</div><br>
<label for="wpf_result_page"><?php _e('The result page must have archive products displaying (it will swap the existing products with the result products).', 'wpf') ?></label>
</div>
</div>
</div>
<div class="wpf_lightbox_row ">
<div class="wpf_lightbox_label"><label for="wpf_no_found_message"><?php _e('No Products Found Message', 'wpf'); ?></label></div>
<div class="wpf_lightbox_input">
<?php WPF_Utils_CT::module_language_tabs( 'no_found_message', $data, $get_all_languages, null, 'text', __('No products were found matching your selection.', 'wpf'), true ); ?>
</div>
</div>
<?php
}