diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-09-11 15:20:17 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2006-09-11 15:20:17 +0000 |
commit | 93b61271ad288c6031c6b33405711e89a1575be2 (patch) | |
tree | 696aaab4050fc517f0a68bf680eeb6d1db10852b /wp-admin/options.php | |
parent | e30516b2ee40c1c45c8f288c20a3d4372e478624 (diff) | |
download | wordpress-mu-93b61271ad288c6031c6b33405711e89a1575be2.tar.gz wordpress-mu-93b61271ad288c6031c6b33405711e89a1575be2.tar.xz wordpress-mu-93b61271ad288c6031c6b33405711e89a1575be2.zip |
Use update_option_* actions
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@735 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/options.php')
-rw-r--r-- | wp-admin/options.php | 85 |
1 files changed, 12 insertions, 73 deletions
diff --git a/wp-admin/options.php b/wp-admin/options.php index c521d54..691c1ec 100644 --- a/wp-admin/options.php +++ b/wp-admin/options.php @@ -10,10 +10,21 @@ wp_reset_vars(array('action')); if ( !current_user_can('manage_options') ) wp_die(__('Cheatin’ uh?')); +if( $_GET[ 'adminhash' ] ) { + $new_admin_details = get_option( 'new_admin_email' ); + if( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && $new_admin_details[ 'newemail' ] != '' ) { + update_option( "admin_email", $new_admin_details[ 'newemail' ] ); + delete_option( "new_admin_email" ); + } + wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=true" ); + exit; +} + function sanitize_option($option, $value) { switch ($option) { case 'admin_email': + case 'new_admin_email': $value = sanitize_email($value); break; @@ -71,16 +82,6 @@ function sanitize_option($option, $value) { return $value; } -if( $_GET[ 'adminhash' ] ) { - $new_admin_details = get_option( 'new_admin_email' ); - if( is_array( $new_admin_details ) && $new_admin_details[ 'hash' ] == $_GET[ 'adminhash' ] && $new_admin_details[ 'newemail' ] != '' ) { - update_option( "admin_email", $new_admin_details[ 'newemail' ] ); - delete_option( "new_admin_email" ); - } - wp_redirect( get_option( "siteurl" ) . "/wp-admin/options-general.php?updated=true" ); - exit; -} - switch($action) { case 'update': @@ -96,77 +97,15 @@ case 'update': $options = explode(',', stripslashes($_POST['page_options'])); } - // Save for later. - $old_siteurl = get_option('siteurl'); - $old_home = get_option('home'); - - // HACK - // Options that if not there have 0 value but need to be something like "closed" - $nonbools = array('default_ping_status', 'default_comment_status'); if ($options) { foreach ($options as $option) { $option = trim($option); $value = trim(stripslashes($_POST[$option])); $value = sanitize_option($option, $value); - if( in_array($option, $nonbools) && ( $value == '0' || $value == '') ) - $value = 'closed'; - - if( $option == 'blogdescription' || $option == 'blogname' ) - $value = wp_filter_post_kses( $value ); - - if( $option == 'posts_per_page' && $value == '' ) - $value = 10; - - if( $option == 'new_admin_email' && $value != get_option( 'admin_email' ) && is_email( $value ) ) { - $hash = md5( $value.time().mt_rand() ); - $newadminemail = array( - "hash" => $hash, - "newemail" => $value - ); - update_option( "new_admin_email", $newadminemail ); - wp_mail( $value, "[ " . get_option( 'blogname' ) . " ] New Admin Email Address", "Dear User, - -You recently requested to have the administration email address on -your blog changed. -If this is correct, please click on the following link to change it: -" . get_option( "siteurl" ) . "/wp-admin/options.php?adminhash={$hash} - -You can safely ignore and delete this email if you do not want to -take this action. - -This email has been sent to '{$value}' -" ); - } elseif (update_option($option, $value) ) { - $any_changed++; - } - - if ( 'lang_id' == $option ) { - $value = (int) $value; - update_blog_status( $wpdb->blogid, 'lang_id', $value ); - $any_changed++; - } - if ( 'blog_public' == $option ) { - $value = (int) $value; - update_blog_status( $wpdb->blogid, 'public', $value ); - $any_changed++; - } + update_option($option, $value); } } - if ($any_changed) { - // If siteurl or home changed, reset cookies. - if ( get_option('siteurl') != $old_siteurl || get_option('home') != $old_home ) { - // If home changed, write rewrite rules to new location. - $wp_rewrite->flush_rules(); - // Clear cookies for old paths. - wp_clearcookie(); - // Set cookies for new paths. - wp_setcookie($user_login, $user_pass_md5, true, get_option('home'), get_option('siteurl')); - } - - //$message = sprintf(__('%d setting(s) saved... '), $any_changed); - } - $referred = remove_query_arg('updated' , wp_get_referer()); $goback = add_query_arg('updated', 'true', wp_get_referer()); $goback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $goback); |