Created
August 27, 2012 15:59
-
-
Save gilbitron/3489815 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WPSFTest { | |
private $plugin_path; | |
private $wpsf; | |
function __construct() | |
{ | |
$this->plugin_path = plugin_dir_path( __FILE__ ); | |
// 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') ); | |
// ... | |
} | |
// This page is added using add_menu_page() | |
function 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 | |
} | |
function validate_settings( $input ) | |
{ | |
// Do your settings validation here | |
// Same as $sanitize_callback from http://codex.wordpress.org/Function_Reference/register_setting | |
return $input; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment