Advertisement
asadsuman

Plugin Development

Jan 13th, 2015
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. <!---Plugin Development Basic to Advance ------->
  2.  
  3. 1. Latest jQuery Calling:
  4. function owl_carousel_latest_jquery(){
  5. wp_enqueue_script('jquery');
  6. }
  7. add_action('init','owl_carousel_latest_jquery');
  8.  
  9. 2. Jquery Plugin (Css and Jquery calling)
  10.  
  11. 2.1 //set-up plugin css and JS
  12. define('OWL_CAROUSEL_DEV(u can use any name )', WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/' );
  13. 2.2 js calling
  14. //Carousel Jquery calling
  15. wp_enqueue_script('owl-carousel-main-jquery(u can use any name )', OWL_CAROUSEL_DEV(this name from Define functions ).'js/owl.carousel.min.js', array('jquery'));
  16.  
  17. 2.3 css Calling
  18. //carousel css calling
  19. wp_enqueue_style('owl-carousel-css(u can use any name )', OWL_CAROUSEL_DEV(this name from Define functions ).'css/owl.carousel.css');
  20.  
  21. 2.4 Js Active Hook
  22. function function_name (){?>
  23. //active code goes here
  24. <script type="text/javascript">
  25. jQuery(document).ready(function() {
  26. jQuery("#owl-demo").owlCarousel({
  27. autoPlay: 5000,
  28. items : 6,
  29. itemsDesktop : [1199,6],
  30. itemsDesktopSmall : [979,4]
  31. });
  32.  
  33. });
  34. </script>
  35.  
  36. <?php
  37.  
  38. }
  39. add_action('where we need to load the plugins', 'you function name here'); like: add_action('wp_head', 'owl_carousel_active_hook');
  40.  
  41. 3. Add custom post type, query and category etc. step by step
  42.  
  43. 4. creating plugins admin menu page option :
  44.  
  45. 4.1: add_menu_page():
  46. function owl_carouse_options_setting(){
  47. add_menu_page( 'owl-carousel', 'owl-carousel-option', 'manage_options','owl_carousel','owl_carouse_options_setting','',30);//add_menu_page('page-title(add you page title)','menu-title(it will show in your wordpress menu)','capability(user role who can change the option)','fucnction name(which function belongs to you menu page )','icon(you can set icon of the menu)','position(after which menu below or above it will show)',);
  48. }
  49. add_action('admin_menu','owl_carouse_options_setting');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement