summaryrefslogtreecommitdiffstats
path: root/include/options-register.php
blob: 506a17babec3776dc7a6f3ab9d2fff4d126e1264 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php

/**
 * Register the set of options required for the plugin to work
 * @since 1.1.1
 */
register_setting( 'dnxup_options', 'dnxup_options', 'dnxup_setup_validate' );

// include the file with the actual markup for the options to display
require( dirname( __FILE__ ) . '/plugin-options.php' );


function dnxup_setup_validate($input) {

	$dnxup_options = get_option('dnxup_options');
	$valid_input = $dnxup_options;
	
	$submit = ( ! empty( $input['submit'] ) ? true : false );
	$reset = ( ! empty( $input['reset'] ) ? true : false );

	if($submit) {
		$default_options = dnxup_db_defaults();
		// Show Gravatar
		$valid_input['show_gravatar'] = ( true == $input['show_gravatar'] ? true : false );
		// Logged out Heading
		$valid_input['logged_out_heading'] = ( '' == $input['logged_out_heading'] ? '' : wp_filter_nohtml_kses($input['logged_out_heading']) );
		// Logged in Heading
		$valid_input['logged_in_heading'] = ( '' == $input['logged_in_heading'] ? '' : wp_filter_nohtml_kses($input['logged_in_heading']) );
		// Logged in Links
		$valid_data = array(
			'a' => array(
				'href' => array(),
				'title' => array(),
				'class' => array(),
				'id' => array()
			)
		);
		$valid_input['logged_in_links'] = ('' == $input['logged_in_links'] ? '' : wp_kses($input['logged_in_links'], $valid_data) );
	} elseif($reset) {
		$default_options = dnxup_db_defaults();
		// Show Gravatar
		$valid_input['show_gravatar'] = $default_options['show_gravatar'];
		// Logged out Heading
		$valid_input['logged_out_heading'] = $default_options['logged_out_heading'];
		// Logged in Heading
		$valid_input['logged_in_heading'] = $default_options['logged_in_heading'];
		// Logged in Links
		$valid_input['logged_in_links'] = $default_options['logged_in_links'];
	}
	return $valid_input;
}
?>