Created
March 5, 2021 05:06
-
-
Save asifpix/a7acef72ea07ef347f2cc2666b3992f1 to your computer and use it in GitHub Desktop.
Removed select field and added text field to increase the item count on project VC addon.
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 | |
function itl_isotope_scripts() { | |
wp_enqueue_script( 'isotope-script', plugins_url() . '/imperial-core/assets/js/isotope-scripts.js', array( 'isotope' ), false, true ); | |
} | |
add_action( 'wp_enqueue_scripts', 'itl_isotope_scripts' ); | |
add_shortcode( 'itl_project', function( $atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'item_count' => '8', | |
'column' => '4', | |
'grid_style' => '', | |
'extra_class' => '', | |
), $atts) ); | |
$item_count = isset( $item_count ) ? intval( $item_count ) : 8; | |
$column = isset( $column ) ? intval( $column ) : 4; | |
global $post; | |
// get prject type for filter start | |
$terms = get_terms( 'project_type' ); | |
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) : | |
$output = '<div class="container">'; | |
$output .= '<div class="row">'; | |
$output .= '<div class="col-xs-12">'; | |
$output .= '<div class="project-nav">'; | |
$output .= '<ul>'; | |
$output .= '<li class="active" data-filter="*">'.esc_html__( "Show All", "imperial-core" ).'</li>'; | |
foreach ($terms as $term) : | |
$output .= '<li data-filter=".'.$term->slug.'">'.$term->name.'</li>'; | |
endforeach; | |
$output .= '</ul>'; | |
$output .= '</div>'; //.project-nav | |
$output .= '</div>'; //.col | |
$output .= '</div>'; //.row | |
$output .= '</div>'; //.continer | |
endif; | |
// get prject type for filter end | |
// wp_query and its argument start | |
$meta_query = array( | |
array( | |
'key' => 'project_wip', | |
'value' => 'complete', | |
'compare' => '=', | |
), | |
); | |
$args = array( | |
'post_type' => 'project', | |
'posts_per_page' => $item_count, | |
'meta_query' => $meta_query, | |
); | |
$posts = get_posts( $args ); | |
$output .= '<div class="project-addon">'; | |
foreach ($posts as $post) : | |
setup_postdata( $post ); | |
$filters = get_the_terms( $post->ID, 'project_type' ); | |
$filters_name = ''; | |
if ($filters) { | |
foreach ( $filters as $filter ) { | |
$filters_name .= ' '.$filter->slug; | |
} | |
} | |
$output .= '<div class="project-item col-'.$column.' '.$filters_name.' '.$grid_style.'">'; | |
if(has_post_thumbnail($post->ID)) { | |
$output .= '<img src="'.esc_url( get_the_post_thumbnail_url( $post->ID, "imperial_standard_project_thumb" ) ).'" alt="'.get_the_title().'">'; | |
} | |
$output .= '<div class="project-overley">'; | |
$output .= '<div class="content">'; | |
$output .= '<h3><a href="'.get_the_permalink( $post->ID ).'">'.get_the_title( $post->ID ).'</a></h3>'; | |
$output .= '<div class="project-tags">'; | |
if (is_array($filters)) : | |
foreach ($filters as $filter) : | |
$output .= '<span>' . $filter->name . '</span>'; | |
endforeach; | |
endif; | |
$output .= '</div>'; | |
$output .= '</div>'; //.content | |
$output .= '</div>'; //.portfolio-overley | |
$output .= '</div>'; //.project-item | |
endforeach; | |
$output .= '</div>'; //.project | |
return $output; | |
} ); | |
add_action( 'vc_before_init', 'itl_project' ); | |
function itl_project() { | |
vc_map( array( | |
"name" => __( "Project", "imperial-core" ), | |
"base" => "itl_project", | |
"class" => "", | |
"category" => __( "iTL Extended Addons", "imperial-core" ), | |
"icon" => plugins_url().'/imperial-core/assets/images/itl.png', | |
"params" => array( | |
array( | |
"type" => "textfield", | |
"param_name" => "item_count", | |
"heading" => esc_html__( "Item Count", "imperial-core" ), | |
"std" => "8", | |
"group" => "General", | |
), | |
array( | |
"type" => "dropdown", | |
"param_name" => "column", | |
"value" => array( | |
'2' => '2', | |
'3' => '3', | |
'4' => '4', | |
), | |
"heading" => esc_html__( "Column", "imperial-core" ), | |
"std" => "4", | |
"group" => "General", | |
), | |
array( | |
"type" => "dropdown", | |
"param_name" => "grid_style", | |
"value" => array( | |
esc_html__( 'Grid without Space' ) => '' , | |
esc_html__( 'Grid with Space' ) => 'spaced' , | |
), | |
"heading" => esc_html__( "Column", "imperial-core" ), | |
"std" => "4", | |
"group" => "General", | |
), | |
array( | |
"type" => "textfield", | |
"heading" => __( "Extra Class Name", "imperial-core" ), | |
"param_name" => "extra_class", | |
"description" => __( "Style particular content element differently - add a class name and refer to it in custom CSS.", "imperial-core" ), | |
"group" => "General", | |
), | |
) | |
)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment