danixland

WP validation - options-cart.php

May 2nd, 2013
66
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. add_settings_section('tdg_settings_cart', 'Cart Options', 'tdg_cart_summary', 'tdg_cart_settings');
  3.  
  4. // Cart explanation (text)
  5. add_settings_field('tdg_setting_cart_explanation', 'Cart explanation', 'tdg_setting_cart_explanation', 'tdg_cart_settings', 'tdg_settings_cart', array());
  6. // Cart page (id or slug)
  7. add_settings_field('tdg_setting_cart_page', 'Cart Page', 'tdg_setting_cart_page', 'tdg_cart_settings', 'tdg_settings_cart', array());
  8.  
  9. // This is simply the function that outputs the page summary as called in add_settings_section()
  10. function tdg_cart_summary() { ?>
  11. <p><?php _e( 'Manage the various cart options available for this theme', 'tdg' ); ?></p>
  12. <?php }
  13.  
  14. // Footer Disclaimer Setting
  15. function tdg_setting_cart_explanation() {
  16.     $tdg_options = get_option( 'theme_tdg_options' ); ?>
  17.     <textarea name="theme_tdg_options[tdg_cart_explanation]" rows="10" cols="100" /><?php echo esc_textarea($tdg_options['tdg_cart_explanation']); ?></textarea>
  18.     <div class="description">
  19.         <p><?php _e('Explain how the cart works on this website. You can use the following html tags:', 'tdg'); ?></p>
  20.         <p><code><?php echo allowed_tags(); ?></code></p>
  21.     </div>
  22. <?php }
  23.  
  24. // Contact Page Link Setting
  25. function tdg_setting_cart_page() {
  26.     $tdg_options = get_option( 'theme_tdg_options' );
  27.     if( tdg_use_permalink() ) : // if permalinks are enabled ?>
  28.         <input type="text" name="theme_tdg_options[tdg_cart_page]" value="<?php echo $tdg_options['tdg_cart_page']; ?>" />
  29.         <span class="description"><?php _e('Do not enter the full address, just the page slug', 'tdg'); ?></span>
  30.     <?php else : // permalink are disabled ?>
  31.         <input type="text" name="theme_tdg_options[tdg_cart_page]" value="<?php echo $tdg_options['tdg_cart_page']; ?>" />
  32.         <span class="description"><?php _e('enter the page id for your cart page, something like <code>http://example.com/?page_id=774</code> where 774 is the id of the page', 'tdg'); ?></span>
  33.     <?php endif;
  34. }
RAW Paste Data