';
$output .= '';
if ( isset( $wrap_class ) ) $output .= '';
if ( $description ) {
$output .= $description;
}
echo $output;
}
static function radio( $args ) {
extract( $args );
$options = get_option( $setting );
$default = isset( $default ) ? $default : '';
$value = isset( $options[ $label_for ] ) ? $options[ $label_for ] : $default;
$output = '
';
if ( $description ) {
$output .= $description;
}
echo $output;
}
/**
* Settings Page
* Outputs a select element for selecting options to set scripts for including.
*/
static function select( $args ) {
extract( $args );
$options = get_option( $setting );
$selected = isset( $options[ $label_for ] ) ? $options[ $label_for ] : array();
$output = '';
if ( ! empty( $show_current ) && ! empty( $selected ) ) {
$output .= '' . $show_current;
foreach ( $selected as $handle ) $output .= '' . $handle . ' ';
$output .= '
';
}
echo $output;
}
/**
* Settings Page
* Outputs the Admin Page and calls the Settings registered with the Settings API.
*/
static function take_action() {
global $action, $option_page, $page, $new_whitelist_options;
if ( ! current_user_can( 'manage_options' ) || ! current_user_can( 'unfiltered_html' ) || ( is_multisite() && ! is_super_admin() ) )
wp_die( __( 'Cheatin’ uh?' ) );
// Handle menu-redirected update message.
if ( isset( $_REQUEST[ 'message' ] ) && $_REQUEST[ 'message' ] )
add_settings_error( $page, 'settings_updated', __( 'Settings saved.' ), 'updated' );
if ( ! isset( $_REQUEST[ 'action' ], $_REQUEST[ 'option_page' ], $_REQUEST[ 'page' ] ) )
return;
wp_reset_vars( array( 'action', 'option_page', 'page' ) );
check_admin_referer( $option_page . '-options' );
if ( ! isset( $new_whitelist_options[ $option_page ] ) )
return;
$options = $new_whitelist_options[ $option_page ];
foreach ( (array) $options as $option ) {
$old = get_option( $option );
$option = trim( $option );
$new = null;
if ( isset($_POST[ $option ]) )
$new = $_POST[ $option ];
if ( !is_array( $new ) )
$new = trim( $new );
$new = stripslashes_deep( $new );
$value = array_merge( $old, $new );
// Allow modification of $value
$value = apply_filters( 'sns_options_pre_update_option', $value, $page, $action, $new, $old );
update_option( $option, $value );
}
if ( ! count( get_settings_errors() ) )
add_settings_error( $page, 'settings_updated', __( 'Settings saved.' ), 'updated' );
if ( isset( $_REQUEST[ 'ajaxsubmit' ] ) && $_REQUEST[ 'ajaxsubmit' ] ) {
ob_start();
settings_errors( $page );
$output = ob_get_contents();
ob_end_clean();
exit( $output );
}
// Redirect to new page if changed.
if ( isset( $_POST[ $option ][ 'menu_position' ] ) && ( $value[ 'menu_position' ] != SnS_Admin::$parent_slug ) ) {
switch( $value[ 'menu_position' ] ) {
case 'menu':
case 'object':
case 'utility':
wp_redirect( add_query_arg( array( 'message' => 1, 'page' => 'sns_settings' ), admin_url( 'admin.php' ) ) );
break;
default:
wp_redirect( add_query_arg( array( 'message' => 1, 'page' => 'sns_settings' ), admin_url( $value[ 'menu_position' ] ) ) );
break;
}
}
return;
}
/**
* Settings Page
* Outputs the Admin Page and calls the Settings registered with the Settings API in init_options_page().
*/
static function page() {
?>