| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Register the set of options required for the plugin to work |
| 5 | * @since 1.1.1 |
| 6 | */ |
| 7 | register_setting( 'dnxup_options', 'dnxup_options', 'dnxup_setup_validate' ); |
| 8 | |
| 9 | // include the file with the actual markup for the options to display |
| 10 | require( dirname( __FILE__ ) . '/plugin-options.php' ); |
| 11 | |
| 12 | |
| 13 | function dnxup_setup_validate($input) { |
| 14 | |
| 15 | $dnxup_options = get_option('dnxup_options'); |
| 16 | $valid_input = $dnxup_options; |
| 17 | |
| 18 | $submit = ( ! empty( $input['submit'] ) ? true : false ); |
| 19 | $reset = ( ! empty( $input['reset'] ) ? true : false ); |
| 20 | |
| 21 | if($submit) { |
| 22 | $default_options = dnxup_db_defaults(); |
| 23 | // Show Gravatar |
| 24 | $valid_input['show_gravatar'] = ( true == $input['show_gravatar'] ? true : false ); |
| 25 | // Logged out Heading |
| 26 | $valid_input['logged_out_heading'] = ( '' == $input['logged_out_heading'] ? '' : wp_filter_nohtml_kses($input['logged_out_heading']) ); |
| 27 | // Logged in Heading |
| 28 | $valid_input['logged_in_heading'] = ( '' == $input['logged_in_heading'] ? '' : wp_filter_nohtml_kses($input['logged_in_heading']) ); |
| 29 | // Logged in Links |
| 30 | $valid_data = array( |
| 31 | 'a' => array( |
| 32 | 'href' => array(), |
| 33 | 'title' => array(), |
| 34 | 'class' => array(), |
| 35 | 'id' => array() |
| 36 | ) |
| 37 | ); |
| 38 | $valid_input['logged_in_links'] = ('' == $input['logged_in_links'] ? '' : wp_kses($input['logged_in_links'], $valid_data) ); |
| 39 | } elseif($reset) { |
| 40 | $default_options = dnxup_db_defaults(); |
| 41 | // Show Gravatar |
| 42 | $valid_input['show_gravatar'] = $default_options['show_gravatar']; |
| 43 | // Logged out Heading |
| 44 | $valid_input['logged_out_heading'] = $default_options['logged_out_heading']; |
| 45 | // Logged in Heading |
| 46 | $valid_input['logged_in_heading'] = $default_options['logged_in_heading']; |
| 47 | // Logged in Links |
| 48 | $valid_input['logged_in_links'] = $default_options['logged_in_links']; |
| 49 | } |
| 50 | return $valid_input; |
| 51 | } |
| 52 | ?> |