Advertisement
Guest User

Untitled

a guest
Mar 28th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. * PLugin Name: Factorian Toolkit
  5. */
  6.  
  7. //function factorian_alert_shortcode($atts,$content=null){
  8. // return '<div class="alert alert-danger" role="alert">this is simple alert</div>
  9. // <div class="alert alert-success" role="alert">this is success alert</div>
  10. // <div class="alert alert-info" role="alert">this is info alert</div>
  11. // <div class="alert alert-warning" role="alert">this is warning alert</div>';
  12.  
  13. // extract(shortcode_atts(
  14. // array(
  15. // 'city'=>''
  16. // ),
  17. // $stts
  18. // ));
  19. // if($city='Dhaka'){
  20. // $message=''.esc_html($city).' is the land of Dreams';
  21. // } elseif ($city='Sylhet') {
  22. // $message=''.esc_html($city).' is the land of green tea';
  23. // }elseif ($city='Borisal') {
  24. // $message=''.esc_html($city).' is the land of river';
  25. // }else{
  26. // $message='You are not define yet';
  27. // }
  28.  
  29. // return $message;
  30.  
  31. // extract(shortcode_atts(
  32. // array(
  33. // 'id'=>'',
  34. // 'size'=>''
  35. // ),
  36. // $atts
  37. // ));
  38. // $image_array=wp_get_attachment_image_src($id,$size);
  39. // return '<img src="'.$image_array[0].'"/>';
  40. // }
  41.  
  42. // add_shortcode('image','factorian_alert_shortcode');
  43.  
  44.  
  45. // function post_list_shortcode($atts){
  46. // extract(shortcode_atts(
  47. // array(
  48. // 'count'=>-1,
  49. // 'type'=>'post'
  50. // ),
  51. // $atts
  52. // ));
  53. // $q=new WP_Query(
  54. // array(
  55. // 'posts_per_page'=>$count,
  56. // 'post_type'=>$type
  57. // ));
  58. // $list='<ul>';
  59. // while($q->have_posts()):$q->the_post();
  60. // $idd=get_the_ID();
  61. // $post_content=get_the_content();
  62. // $list .='<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
  63. // endwhile;
  64. // $list.='</ul>';
  65.  
  66. // wp_reset_query();
  67. // return $list;
  68. // }
  69.  
  70. // add_shortcode('post_list','post_list_shortcode');
  71.  
  72.  
  73. add_action('init','factorian_theme_custom_post');
  74.  
  75. function factorian_theme_custom_post(){
  76. register_post_type('testimonial',
  77. array(
  78. 'labels'=>array(
  79. 'name'=>__('Testimonials'),
  80. 'singular_name'=>__('Testimonial')
  81. ),
  82. 'support'=>array('title','editor','thumbnail','page-attributes'),
  83. 'public'=>false,
  84. 'show_ui'=>true,
  85. )
  86. );
  87. }
  88.  
  89.  
  90. function post_list_shortcode($atts){
  91. extract(shortcode_atts(array(
  92. 'count'=>-1,
  93. 'type'=>'post'
  94. ),
  95. $atts
  96. ));
  97. $q=new WP_Query(
  98. array(
  99. 'posts_per_page'=>$count,
  100. 'post_type'=>$type,
  101. 'color'=>'#dd4d4',
  102. 'icon'=>''
  103. )
  104. );
  105. $list='<ul>';
  106. while($q->have_posts()):$q->the_post();
  107. $idd=get_the_ID();
  108. $post_content=get_the_content();
  109. $list='<li><a style="color:'.$color.'"href="'.get_permalink().'">';
  110. if (!empty($icon)) {
  111. $list.='<i class="'.$icon.'"></i>';
  112. }
  113. $list.=''.get_the_title().'</a></li>';
  114. endwhile;
  115. $list.='</ul>';
  116. wp_reset_query();
  117. return $list;
  118. }
  119.  
  120. add_shortcode('post_list','post_list_shortcode');
  121.  
  122. function factorian_vc_postlist_addon(){
  123. vc_map(array(
  124. "name"=>__("Post list","my-text-domain"),
  125. "base"=>"post_list",
  126. "category"=>__("Factorian","my-text-domain"),
  127. "params"=>array(
  128. array(
  129. "type"=>"textfield",
  130. "heading"=>__("Post type","my-text-domain"),
  131. "param_name"=>"type",
  132. "value"=>__("post","my-text-domain"),
  133. "description"=>__("Type post type here.","my-text-domain")
  134. ),
  135. array(
  136. "type"=>"textfield",
  137. "heading"=>__("Post type","my-text-domain"),
  138. "param_name"=>"count",
  139. "value"=>__("-1","my-text-domain"),
  140. "description"=>__("Type how many item you want to show. type -1 for unlimited item","my-text-domain")
  141. ),
  142. array(
  143. "type"=>"colorpicker",
  144. "heading"=>__("Link color","my-text-domain"),
  145. "param_name"=>"color",
  146. "value"=>__("#dd4d4","my-text-domain"),
  147. "description"=>__("Select link color.","my-text-domain")
  148. ),
  149. array(
  150. "type"=>"iconpicker",
  151. "heading"=>__("Icon","my-text-domain"),
  152. "param_name"=>"icon",
  153. "value"=>__("fa fa-link","my-text-domain"),
  154. "description"=>__("Select link icon.","my-text-domain")
  155. )
  156. )
  157. ));
  158. }
  159.  
  160. add_action('vc_before_init','factorian_vc_postlist_addon');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement