Advertisement
sayful

WP option page

Apr 29th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.91 KB | None | 0 0
  1. <?php
  2.     if ( ! isset( $_REQUEST['updated'] ) )
  3.         $_REQUEST['updated'] = false; // This checks whether the form has just been submitted.
  4. ?>
  5. <div class="wrap">
  6.     <h2>WordPress Standard Coding</h2>
  7.  
  8.     <?php if ( false !== $_REQUEST['updated'] ) : ?>
  9.         <div class="updated fade"><p><strong><?php _e( 'Options saved' ); ?></strong></p></div>
  10.     <?php endif; // If the form has just been submitted, this shows the notification ?>
  11.  
  12.     <form method="post" action="options.php">
  13.         <?php
  14.         // Get an array of options from the database.
  15.         $options = get_option( 'sis_plugin_options' );
  16.  
  17.         settings_fields('sis_standard_plugin_options');
  18.         ?>
  19.  
  20.         <table class="form-table">
  21.             <tbody>
  22.                 <!--
  23.                 # Example of input usage
  24.                 -->
  25.                 <tr valign="top">
  26.                     <th scope="row">
  27.                         <label><?php _e('Input option Example') ?></label>
  28.                     </th>
  29.                     <td>
  30.                         <input type="text" name="sis_plugin_options[foo_text]" id="foo_text" value="<?php esc_attr_e($options['foo_text']); ?>" class="">
  31.                         <p class="description"><?php _e('Text for element, can contain HTML. This text will show on tab, pill and link button. Defaults text is &lsquo; Scroll to top &lsquo;') ?></p>
  32.                     </td>
  33.                 </tr>
  34.                 <!--
  35.                 # Example of selected usage
  36.                 # For more about it go to [http://codex.wordpress.org/Function_Reference/selected]
  37.                 -->
  38.                 <tr valign="top">
  39.                     <th scope="row">
  40.                         <label><?php _e('Select Option Example') ?></label>
  41.                     </th>
  42.                     <td>
  43.                         <select name="sis_plugin_options[foo_select]">
  44.                             <!-- Testing the values with if() -->
  45.                             <option value="volvo" <?php if ( $options['foo_select'] == 'volvo' ) echo 'selected="selected"'; ?>>Volvo</option>
  46.                             <option value="saab" <?php if ( $options['foo_select'] == 'saab' ) echo 'selected="selected"'; ?>>Saab</option>
  47.                             <!-- Using selected() instead -->
  48.                             <option value="fiat" <?php selected( $options['foo_select'], 'fiat' ); ?>>Fiat</option>
  49.                             <option value="audi" <?php selected( $options['foo_select'], 'audi' ); ?>>Audi</option>
  50.                         </select>
  51.                         <p class="description"><?php _e( 'For use in select form fields. Compares two given values. For example, a saved option vs. one chosen in a form and, if the values are the same, adds the selected attribute to the current option tag.' ) ?></p>
  52.                     </td>
  53.                 </tr>
  54.                 <!--
  55.                 # Example of checked usage
  56.                 # For more about it go to [http://codex.wordpress.org/Function_Reference/checked]
  57.                 -->
  58.                 <tr valign="top">
  59.                     <th scope="row">
  60.                         <label><?php _e('Checkbox Option Example') ?></label>
  61.                     </th>
  62.                     <td>
  63.                         <!-- Testing the values with if() -->
  64.                         <input type='checkbox' name='sis_plugin_options[foo_check]' value='bike' <?php if ( 'bike' == $options['foo_check'] ) echo 'checked="checked"'; ?> />I have a bike<br>
  65.                         <!-- Using checked() instead -->
  66.                         <input type="checkbox" name="sis_plugin_options[foo_check]" value="car" <?php checked( $options['foo_check'], 'car' ); ?> />I have a car<br />
  67.                         <p class="description"><?php _e( 'For use in checkbox and radio button form fields. Compares two given values. For example, a saved option vs. one chosen in a form and, if the values are the same, adds the checked attribute to the current radio button or checkbox.' ) ?></p>
  68.                     </td>
  69.                 </tr>
  70.                 <!--
  71.                 # Example of radio usage
  72.                 # For more about it go to [http://codex.wordpress.org/Function_Reference/checked]
  73.                 -->
  74.                 <tr valign="top">
  75.                     <th scope="row">
  76.                         <label><?php _e('Radio Button Example') ?></label>
  77.                     </th>
  78.                     <td>
  79.                         <!-- Testing the values with if() -->
  80.                         <input type='radio' name='sis_plugin_options[foo_radio]' value='Male' <?php if ( 'Male' == $options['foo_radio'] ) echo 'checked="checked"'; ?> />Male<br />
  81.                         <!-- Using checked() instead -->
  82.                         <input type="radio" name="sis_plugin_options[foo_radio]" value="Female" <?php checked( $options['foo_radio'], 'Female' ); ?> />Female<br />
  83.                         <p class="description"><?php _e( 'For use in checkbox and radio button form fields. Compares two given values. For example, a saved option vs. one chosen in a form and, if the values are the same, adds the checked attribute to the current radio button or checkbox.' ) ?></p>
  84.                     </td>
  85.                 </tr>
  86.             </tbody>
  87.         </table>
  88.         <p class="submit"><input type="submit" value="<?php _e('Save Changes') ?>" class="button button-primary" id="submit" name="submit"></p>
  89.     </form>
  90. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement