forked from iconicwp/WordPress-Settings-Framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpsf-test.php
70 lines (59 loc) · 2.17 KB
/
wpsf-test.php
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
/*
Plugin Name: WP Settings Framework Example
Description: An example of the WP Settings Framework in action.
Version: 1.3
Author: Gilbert Pellegrom
Author URI: http://dev7studios.com
*/
class WPSFTest {
private $plugin_path;
private $plugin_url;
private $l10n;
private $wpsf;
function __construct()
{
$this->plugin_path = plugin_dir_path( __FILE__ );
$this->plugin_url = plugin_dir_url( __FILE__ );
$this->l10n = 'wp-settings-framework';
add_action( 'admin_menu', array(&$this, 'admin_menu'), 99 );
// Include and create a new WordPressSettingsFramework
require_once( $this->plugin_path .'wp-settings-framework.php' );
$this->wpsf = new WordPressSettingsFramework( $this->plugin_path .'settings/settings-general.php' );
// Add an optional settings validation filter (recommended)
add_filter( $this->wpsf->get_option_group() .'_settings_validate', array(&$this, 'validate_settings') );
}
function admin_menu()
{
$page_hook = add_menu_page( __( 'WPSF', $this->l10n ), __( 'WPSF', $this->l10n ), 'update_core', 'wpsf', array(&$this, 'settings_page') );
add_submenu_page( 'wpsf', __( 'Settings', $this->l10n ), __( 'Settings', $this->l10n ), 'update_core', 'wpsf', array(&$this, 'settings_page') );
}
function settings_page()
{
// Your settings page
?>
<div class="wrap">
<div id="icon-options-general" class="icon32"></div>
<h2>WP Settings Framework Example</h2>
<?php
// Output your settings form
$this->wpsf->settings();
?>
</div>
<?php
// Get settings
//$settings = wpsf_get_settings( $this->plugin_path .'settings/settings-general.php' );
//echo '<pre>'.print_r($settings,true).'</pre>';
// Get individual setting
//$setting = wpsf_get_setting( wpsf_get_option_group( $this->plugin_path .'settings/settings-general.php' ), 'general', 'text' );
//var_dump($setting);
}
function validate_settings( $input )
{
// Do your settings validation here
// Same as $sanitize_callback from http://codex.wordpress.org/Function_Reference/register_setting
return $input;
}
}
new WPSFTest();
?>