Created
          February 8, 2018 06:59 
        
      - 
      
- 
        Save salehahmadbabu/70277671de61fcb202ada69be1a0507c to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or 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 | |
| /* | |
| Plugin Name: Stock Toolkit | |
| */ | |
| add_action( 'init', 'stock_theme_custom_post' ); | |
| function stock_theme_custom_post() { | |
| register_post_type( 'testimonial', | |
| array( | |
| 'labels' => array( | |
| 'name' => __( 'Testimonials' ), | |
| 'singular_name' => __( 'Testimonial' ) | |
| ), | |
| 'supports' => array('title', 'editor', 'thumbnail', 'page-attributes'), | |
| 'public' => false, | |
| 'show_ui' => true, | |
| ) | |
| ); | |
| } | |
| function post_list_shortcode($atts){ | |
| extract( shortcode_atts( array( | |
| 'count' => -1, | |
| 'type' => 'post', | |
| 'color' => '#aaddff', | |
| 'icon' => '' | |
| ), $atts) ); | |
| $q = new WP_Query( | |
| array('posts_per_page' => $count, 'post_type' => $type) | |
| ); | |
| $list = '<ul>'; | |
| while($q->have_posts()) : $q->the_post(); | |
| $idd = get_the_ID(); | |
| $post_content = get_the_content(); | |
| $list .= '<li><a style="color:'.$color.'" href="'.get_permalink().'">'; | |
| if(!empty($icon)){ | |
| $list .='<i class="'.$icon.'"></i> '; | |
| } | |
| $list .= ''.get_the_title().'</a></li>'; | |
| endwhile; | |
| $list.= '</ul>'; | |
| wp_reset_query(); | |
| return $list; | |
| } | |
| add_shortcode('post_list', 'post_list_shortcode'); | |
| function stock_vc_postlist_addon() { | |
| vc_map( array( | |
| "name" => __( "Post list", "my-text-domain" ), | |
| "base" => "post_list", | |
| "category" => __( "Stock", "my-text-domain"), | |
| "params" => array( | |
| array( | |
| "type" => "textfield", | |
| "heading" => __( "Post type", "my-text-domain" ), | |
| "param_name" => "type", | |
| "value" => __( "post", "my-text-domain" ), | |
| "description" => __( "Type your post type.", "my-text-domain" ) | |
| ), | |
| array( | |
| "type" => "textfield", | |
| "heading" => __( "Post count", "my-text-domain" ), | |
| "param_name" => "count", | |
| "value" => __( "-1", "my-text-domain" ), | |
| "description" => __( "Type how many items you want to show. Number only. Select -1 to show all.", "my-text-domain" ) | |
| ), | |
| array( | |
| "type" => "colorpicker", | |
| "heading" => __( "Link color", "my-text-domain" ), | |
| "param_name" => "color", | |
| "value" => __( "#aaddff", "my-text-domain" ), | |
| "description" => __( "Pick your link color.", "my-text-domain" ) | |
| ), | |
| array( | |
| "type" => "iconpicker", | |
| "heading" => __( "Icon", "my-text-domain" ), | |
| "param_name" => "icon", | |
| "description" => __( "Pick your icon.", "my-text-domain" ) | |
| ) | |
| ) | |
| ) ); | |
| } | |
| add_action( 'vc_before_init', 'stock_vc_postlist_addon' ); | |
| ?> | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment