Created
August 20, 2019 13:05
-
-
Save gilzow/d03bdbfcc32875d7c52a1e0e3a4843b3 to your computer and use it in GitHub Desktop.
referenced post_grid_filters code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Element Description: VC Post Grid Filters | |
*/ | |
// Element Class | |
class vcpostgridfilters extends WPBakeryShortCode | |
{ | |
// Element Init | |
function __construct() | |
{ | |
add_action('init', array($this, 'vc_post_grid_filters_mapping')); | |
add_shortcode('vc_post_grid_filters', array($this, 'vc_post_grid_filters_html')); | |
} | |
// Element Mapping | |
public function vc_post_grid_filters_mapping() | |
{ | |
// Stop all if VC is not enabled | |
if (!defined('WPB_VC_VERSION')) { | |
return; | |
} | |
// Map the block with vc_map() | |
vc_map( | |
array( | |
'name' => __('VC Post Grid Filters', 'text-domain'), | |
'base' => 'vc_post_grid_filters', | |
'description' => __('VC Post Grid Filters', 'text-domain'), | |
'category' => __('My Custom Elements', 'text-domain'), | |
/* 'icon' => get_template_directory_uri().'/assets/img/vc-icon.png', */ | |
'params' => array( | |
gf_vc_map_add_narrow_category(), | |
array( | |
"type" => "textfield", | |
"admin_label" => true, | |
"heading" => "Title", | |
"param_name" => "filterTitle", | |
"value" => "Categories", | |
"description" => "Title for Post Grid Filters" | |
), | |
array( | |
"type" => "checkbox", | |
"admin_label" => true, | |
"heading" => "Show Search", | |
"param_name" => "showSearch", | |
"value" => true, | |
"description" => "If checked a search area will show about Post Grid Filters" | |
), | |
array( | |
"type" => "dropdown", | |
"admin_label" => true, | |
"heading" => "Post Type", | |
"param_name" => "posttype", | |
"value" => array( | |
'our-team' => 'our-team', | |
'post' => 'post' | |
), | |
"description" => "Search Post Type" | |
), | |
) | |
) | |
); | |
} | |
// Element HTML | |
public function vc_post_grid_filters_html($atts) | |
{ | |
extract(shortcode_atts(array( | |
'category' => '', | |
'filterTitle' => 'Categories', | |
'showSearch' => true, | |
'posttype' => 'our-team' | |
), $atts)); | |
?> | |
<div class="widget post_grid_filter_theif"> | |
<div class="post_grid_filters vc_subpages clearfix bg-gray"> | |
<?php if ($showSearch) { ?> | |
<div class="g5plus-heading hd-minimal hd-light"><h2>Search</h2></div> | |
<form role="search" method="get" class="search-form" action="<?php echo esc_url(home_url('/')); ?>"> | |
<input type="search" class="search-field" placeholder="<?php echo esc_attr_x('Search', 'placeholder', 'g5plus-orion'); ?>" value="<?php echo get_query_var('s'); ?>" name="s" title="<?php echo esc_attr_x('Search for:', 'label', 'g5plus-orion'); ?>"/> | |
<input type="hidden" name="post_type" value="<?php echo $posttype ?>"/> | |
<?php if (!empty($category)): ?> | |
<?php if ($posttype == 'our-team'): ?> | |
<input type="hidden" name="department" value="<?php echo $category ?>"/> | |
<?php else: ?> | |
<input type="hidden" name="category_name" value="<?php echo $category ?>"/> | |
<?php endif; ?> | |
<?php endif; ?> | |
<button type="submit" class="search-submit"> | |
<i class="pe-7s-search"></i><span class="sr-only">Search</span></button> | |
</form> | |
<br/> | |
<?php } ?> | |
<div class="g5plus-heading hd-minimal hd-light"><h2><?php echo $filterTitle; ?></h2></div> | |
</div> | |
<script> | |
jQuery(document).ajaxComplete(function () { | |
var gridFilter = jQuery('.vc_grid-filter'); | |
var gridSelect = jQuery('.vc_grid-filter-select'); | |
if (gridFilter || gridSelect) { | |
gridFilter.detach().appendTo('div.post_grid_filters'); | |
gridSelect.detach().appendTo('div.post_grid_filters'); | |
} | |
}); | |
</script> | |
</div> | |
<?php | |
} | |
} // End Element Class | |
// Element Class Init | |
new vcpostgridfilters(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment