Advertisement
bowenac

typo

Apr 30th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.92 KB | None | 0 0
  1. <?php
  2. class wctest{
  3.     public function __construct(){
  4.         if(is_admin()){
  5.         add_action('admin_menu', array($this, 'add_plugin_page'));
  6.         add_action('admin_init', array($this, 'page_init'));
  7.     }
  8.     }
  9.    
  10.     public function add_plugin_page(){
  11.         // This page will be under "Settings"
  12.     add_options_page('Settings Admin', 'Settings', 'manage_options', 'test-setting-admin', array($this, 'create_admin_page'));
  13.     }
  14.  
  15.     public function create_admin_page(){
  16.         ?>
  17.     <div class="wrap">
  18.         <?php screen_icon(); ?>
  19.         <h2>Settings</h2>          
  20.         <form method="post" action="options.php">
  21.             <?php
  22.                     // This prints out all hidden setting fields
  23.             settings_fields('test_option_group');  
  24.             do_settings_sections('test-setting-admin');
  25.         ?>
  26.             <?php submit_button(); ?>
  27.         </form>
  28.     </div>
  29.     <?php
  30.     }
  31.    
  32.     public function page_init(){       
  33.     register_setting('test_option_group', 'array_key', array($this, 'check_ID'));
  34.        
  35.         add_settings_section(
  36.         'setting_section_id',
  37.         'Setting',
  38.         array($this, 'print_section_info'),
  39.         'test-setting-admin'
  40.     ); 
  41.        
  42.     add_settings_field(
  43.         'some_id',
  44.         'Some ID(Title)',
  45.         array($this, 'create_an_id_field'),
  46.         'test-setting-admin',
  47.         'setting_section_id'           
  48.     );     
  49.     }
  50.    
  51.     public function check_ID($input){
  52.         if(is_numeric($input['some_id'])){
  53.         $mid = $input['some_id'];          
  54.         if(get_option('test_some_id') === FALSE){
  55.         add_option('test_some_id', $mid);
  56.         }else{
  57.         update_option('test_some_id', $mid);
  58.         }
  59.     }else{
  60.         $mid = '';
  61.     }
  62.     return $mid;
  63.     }
  64.    
  65.     public function print_section_info(){
  66.     print 'Enter your setting below:';
  67.     }
  68.    
  69.     public function create_an_id_field(){
  70.         <input type="text" id="input_whatever_unique_id_I_want" name="array_key[some_id]" value="get_option('test_some_id');" />
  71.     }
  72. }
  73.  
  74. $wctest = new wctest();
  75.  
  76. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement