Advertisement
firoze

wordpress plugin requirements

Feb 15th, 2016
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. // wordpress plugin requirements
  2.  
  3. // add option/menu page in plugin
  4. // source link : https://codex.wordpress.org/Administration_Menus
  5. // source link : https://codex.wordpress.org/Function_Reference/add_menu_page
  6. // step 1
  7. if(! function_exists('news_ticker_option_page')):
  8. function news_ticker_option_page(){
  9. // add_menu_page or add_options_page
  10. add_menu_page(
  11. 'News ticker options', // page_title
  12. 'News Ticker Plugin', // menu_title
  13. 'manage_options', //capability will go step 3
  14. 'ticker.php', // menu_slug this show in url
  15. 'news_ticker_plugin_page', // function wiil go step 3
  16.  
  17. /* The below option only for add_menu_page */
  18. //plugins_url('/news-ticker/images/icon.png'),25 // only for add_menu_page and icon (20X20 size) insert 25 this will indicate position
  19. 'dashicons-welcome-write-blog',25 // 25 this will indicate position +++ wordpress font icon usage source link: https://developer.wordpress.org/resource/dashicons/
  20. );
  21. }
  22. add_action('admin_menu','news_ticker_option_page');
  23.  
  24. endif;
  25.  
  26.  
  27.  
  28.  
  29. // step 2 for API Settings
  30. if(! function_exists('news_ticker_plugin_page')):
  31. function news_ticker_plugin_page() {
  32. if ( !current_user_can( 'manage_options' ) ) {
  33. wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
  34. }
  35. echo '<div class="wrap"><h2>This is news ticker options</h2><div>'; // this will show the mail title on the top of page
  36. ?>
  37. <div class="wrap">
  38. <h1>Owl Carousel Settings</h1>
  39.  
  40. <table class="form-table">
  41. <tbody>
  42. <tr>
  43. <th scope="row">
  44. <label for="blogname">Site Title</label>
  45. </th>
  46. <td>
  47. <input id="blogname" class="regular-text" type="text" placeholder="<?php echo get_option('blogname');?>" name="blogname">
  48. </td>
  49. </tr>
  50. </tbody>
  51. </table>
  52. <input name="submit" id="submit" class="button button-primary" value="Save Changes" type="submit">
  53. </div>
  54. <?php
  55. }
  56.  
  57. endif;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement