Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Register theme_tdg_options array to hold all theme options
- register_setting( 'theme_tdg_options', 'theme_tdg_options', 'tdg_validate' );
- function tdg_validate( $input ) {
- // default options
- $tdg_default_options = tdg_get_default_options(); # returns an array with the default options as stored initially on the database
- // Determine which form action was submitted
- [...]
- $submit_cart = ( ! empty($input['submit-cart'] ) ? true : false );
- $reset_cart = ( ! empty($input['reset-cart'] ) ? true : false );
- if ( $submit_cart ) { // if cart Settings Submit
- // Cart explanation text
- $input['tdg_cart_explanation'] = ( '' == $input['tdg_cart_explanation'] ? $tdg_default_options['tdg_cart_explanation'] : wp_kses_data($input['tdg_cart_explanation']) );
- // Cart page address
- if( tdg_use_permalink() ) { # true if "pretty" permalinks are active, false otherwise
- $input['tdg_cart_page'] = ( '' == $input['tdg_cart_page'] ? $tdg_default_options['tdg_cart_page'] : sanitize_title($input['tdg_cart_page']) );
- } else {
- $input['tdg_cart_page'] = ( '' == $input['tdg_cart_page'] ? $tdg_default_options['tdg_cart_page'] : intval($input['tdg_cart_page']) );
- }
- } elseif ( $reset_cart ) { // if cart Settings Reset Defaults
- $tdg_default_options = tdg_get_default_options();
- // Cart Explanation text
- $input['tdg_cart_explanation'] = $tdg_default_options['tdg_cart_explanation'];
- // Cart Page address
- $input['tdg_cart_page'] = $tdg_default_options['tdg_cart_page'];
- }
- return $input;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement