Advertisement
Guest User

Untitled

a guest
Apr 25th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.91 KB | None | 0 0
  1. <?php
  2.  
  3. function sync_settings_page() { ?>
  4.  
  5. <div class="wrap">
  6. <h1>Theme Settings</h1>
  7. <p>This information will be used across your website. Please ensure the correct details have been used.</p>
  8.  
  9. <?php
  10.  
  11. echo '<div><div class="postbox"><div class="inside"><form method="post" action="options.php">';
  12.  
  13. do_settings_sections("sync-options");
  14.  
  15. settings_fields("sync-settings");
  16.  
  17. submit_button();
  18.  
  19. echo '</form></div></div></div>';
  20.  
  21. ?>
  22.  
  23. </div>
  24.  
  25. <?php }
  26.  
  27. function display_environments() {
  28.  
  29. $checked = null;
  30. $environments = get_option('environments');
  31.  
  32. if ( $environments == true ) {
  33.  
  34. $checked = 'checked';
  35.  
  36. }
  37.  
  38. echo '<label for="environments"><input type="checkbox" '.$checked.' name="environments" id="environments" value="1"> <span class="description">Show Navigation in header?</span></label>';
  39.  
  40. }
  41.  
  42. /**
  43. * display sync options
  44. */
  45.  
  46. function display_sync_options(){
  47.  
  48. // sections
  49. add_settings_section("environment-section", "Environments", null, "sync-options");
  50.  
  51. // options
  52. add_settings_field("environments", "Show Navigation?", "display_environments", "sync-options", "environment-section");
  53.  
  54. // register
  55. register_setting("sync-settings", "environments");
  56.  
  57. }
  58.  
  59. add_action("admin_init", "display_sync_options");
  60.  
  61. /**
  62. * setup admin menu
  63. */
  64.  
  65. function add_sync_menu(){
  66.  
  67. add_options_page("Sync Options", "Sync Options", "manage_options", "sync-options", "sync_settings_page");
  68.  
  69. }
  70.  
  71. add_action("admin_menu", "add_sync_menu");
  72.  
  73. /**
  74. * enqueue admin scripts
  75. */
  76.  
  77. function enqueue_admin() {
  78.  
  79. if ( isset($_GET['page']) && $_GET['page'] == 'sync-options' ) {
  80.  
  81. // media
  82. wp_enqueue_media();
  83.  
  84. // admin scripts
  85. wp_register_script('theme-js', get_template_directory_uri() . '/admin-js/theme.js', array('jquery'), null, true );
  86. wp_enqueue_script('theme-js');
  87.  
  88. }
  89.  
  90. }
  91.  
  92. // add_action("admin_init", "enqueue_admin");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement