18.3 Include Categories, Exclude Categories, Show "All" option (ok)

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).closest('.' + WPF.prefix + 'display_as').length > 0) {
          $container = $(this).closest('.' + WPF.prefix + 'back_active_module_content').find('.' + WPF.prefix + 'icons_block');
          var val = $(this).val();
          slide = val === 'checkbox' || val === 'radio';
          if (val === 'dropdown' || val === 'radio') {
            $(this).closest('.' + WPF.prefix + 'back_active_module_content').find('.' + WPF.prefix + 'show_all_block').show();
          } else {
            $(this).closest('.' + WPF.prefix + 'back_active_module_content').find('.' + WPF.prefix + 'show_all_block').hide();
          }
        } 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');
    }

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_ct_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
        $display = array(
          'horizontal' => __('Horizontal', 'wpf'),
          'vertical' => __('Vertical', 'wpf'),
          'columns' => __('Columns', 'wpf'),
        );
      ?>
      <div class="wpf_ct_back_active_module_row">
        <div class="wpf_ct_back_active_module_label">
          <label for="wpf_ct_<?php echo $type ?>[display]"><?php _e('Layout', 'wpf') ?></label>
        </div>
        <div class="wpf_ct_back_active_module_input">
          <?php foreach ($display as $k => $v): ?>
            <label>
              <input id="wpf_ct_<?php echo $type ?>[display_<?php echo $k ?>]" type="radio" value="<?php echo $k ?>" name="[<?php echo $type ?>][display]" <?php if ((!isset($module['display']) && $k === 'horizontal') || (isset($module['display']) && $module['display'] === $k)): ?>checked="checked"<?php endif; ?>  />
              <?php echo $v ?>
              <?php if ($k === 'columns'): ?>
                <div class="wpf_ct_custom_select">
                  <select name="[<?php echo $type ?>][column]">
                    <?php for ($i = 2; $i < 4; ++$i): ?>
                      <option value="<?php echo $i ?>" <?php if (isset($module['column']) && $module['column'] == $i): ?>selected="selected"<?php endif; ?>><?php echo $i ?></option>
                    <?php endfor; ?>
                  </select>
                </div>
              <?php endif; ?>
            </label>
          <?php endforeach; ?>
        </div>
      </div>
      <?php self::show_color_icons($type, $name, $module); ?>
      <?php if (in_array($type, array('wpf_ct_cat', 'wpf_ct_tag'))) : ?>
        <div class="wpf_ct_back_active_module_row">
          <div class="wpf_ct_back_active_module_label">
            <label for="wpf_ct_<?php echo $type ?>[include_cat]"><?php echo $type === 'wpf_ct_cat' ? __('Include Categories', 'wpf_ct') : __('Include Tags', 'wpf'); ?></label>
          </div>
          <div class="wpf_ct_back_active_module_input">
            <label>
              <input id="wpf_ct_<?php echo $type ?>[include_cat]" type="text" name="[<?php echo $type ?>][include_cat]" value="<?php echo!empty($module['include_cat']) ? $module['include_cat'] : ''; ?>">
              <br>
              <?php if ($type === 'wpf_ct_cat') : ?>
                  <?php _e('Enter category ID numbers to include only (eg. 2, 4, 12)', 'wpf'); ?>
              <?php else: ?>
                  <?php _e('Enter tag ID numbers to include only (eg. 2, 4, 12)', 'wpf') ?>
              <?php endif; ?>
            </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 ?>[exclude_cat]"><?php echo $type === 'wpf_cat' ? __('Exclude Categories', 'wpf') : __('Exclude Tags', 'wpf'); ?></label>
          </div>
          <div class="wpf_ct_back_active_module_input">
            <label>
              <input id="wpf_ct_<?php echo $type ?>[exclude_cat]" type="text" name="[<?php echo $type ?>][exclude_cat]" value="<?php echo!empty($module['exclude_cat']) ? $module['exclude_cat'] : ''; ?>">
              <br>
              <?php if ($type === 'wpf_ct_cat') : ?>
                <?php _e('Enter category ID numbers to exclude (eg. 2, 4, 12)', 'wpf'); ?>
              <?php else: ?>
                <?php _e('Enter tag ID numbers to exclude (eg. 2, 4, 12)', 'wpf') ?>
              <?php endif; ?>
            </label>
          </div>
        </div>
      <?php endif; ?>
        <div class="wpf_ct_back_active_module_row wpf_ct_show_all_block">
          <div class="wpf_ct_back_active_module_label">
            <label for="wpf_ct_<?php echo $type ?>[show_all]"><?php _e( 'Show "All" option', 'wpf' ); ?></label>
          </div>
          <div class="wpf_ct_back_active_module_input">
            <label>
              <input id="wpf_ct_<?php echo $type ?>[show_all]" type="checkbox" name="[<?php echo $type ?>][show_all]" value="1" <?php if ( ! empty( $module['show_all'] ) ) : ?>checked="checked"<?php endif; ?> />
              <?php _e( 'Show option to list all terms', 'wpf' ) ?>
            </label>
          </div>
        </div>
      <?php break; ?>
    <?php endswitch; ?>
    <?php
  }

Last updated