danixland

WP validation - theme-options.php

May 2nd, 2013
84
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Settings API options initilization and validation
  3. function tdg_register_options(){
  4.     require( get_template_directory() . '/inc/options-register.php' );
  5. }
  6. add_action('admin_init', 'tdg_register_options');
  7.  
  8. [...]
  9.  
  10. function tdg_cart_settings_display() {
  11.     if ( ! current_user_can( 'manage_options' ) ) {
  12.         wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
  13.     } ?>
  14.     <div class="wrap">
  15.         <?php screen_icon('themes'); ?> <h2><?php _e('Cart Settings', 'tdg'); ?></h2>
  16.         <?php if ( isset( $_GET['settings-updated'] ) ) : ?>
  17.             <div class='updated'><p><?php _e('Theme settings updated successfully.', 'tdg'); ?></p></div>
  18.         <?php endif; ?>
  19.         <form action="options.php" method="post">
  20.             <?php settings_fields('theme_tdg_options'); // must be the same as the value in register_settings()
  21.             require( get_template_directory() . '/inc/functions/options-cart.php' );
  22.             do_settings_sections('tdg_cart_settings'); // must be the same as the $id in add_settings_section() ?>
  23.             <p><?php submit_button('Save Changes', 'primary', 'theme_tdg_options[submit-cart]', false, '');
  24.             submit_button('Reset Changes', 'delete', 'theme_tdg_options[reset-cart]', false, ''); ?></p>
  25.         </form>
  26.     </div>
  27. <?php }
  28.  
  29. /**
  30.  * theme options - settings page initialization
  31.  *
  32.  * @since 1.0.1
  33.  */
  34. function tdg_setup_theme_admin_menus() {
  35.     add_menu_page('Theme Settings', 'TDG Settings', 'manage_options', 'tdg_theme_settings', 'tdg_theme_settings_display', '', '2.3');
  36.  
  37.     add_submenu_page('tdg_theme_settings', 'Cart Settings', 'Cart Settings', 'manage_options', 'tdg_cart_settings', 'tdg_cart_settings_display');
  38. }
  39.  
  40. add_action("admin_menu", "tdg_setup_theme_admin_menus");
RAW Paste Data