summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-09-11 15:20:17 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-09-11 15:20:17 +0000
commit93b61271ad288c6031c6b33405711e89a1575be2 (patch)
tree696aaab4050fc517f0a68bf680eeb6d1db10852b
parente30516b2ee40c1c45c8f288c20a3d4372e478624 (diff)
downloadwordpress-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
-rw-r--r--wp-admin/admin-functions.php60
-rw-r--r--wp-admin/options.php85
2 files changed, 68 insertions, 77 deletions
diff --git a/wp-admin/admin-functions.php b/wp-admin/admin-functions.php
index d96d9e8..329f1f6 100644
--- a/wp-admin/admin-functions.php
+++ b/wp-admin/admin-functions.php
@@ -952,6 +952,7 @@ function wp_create_thumbnail($file, $max_side, $effect = '') {
if (!empty ($error)) {
return $error;
} else {
+ apply_filters( 'wp_create_thumbnail', $thumbpath );
return $thumbpath;
}
}
@@ -1924,8 +1925,8 @@ function wp_handle_upload(&$file, $overrides = false) {
return $upload_error_handler($file, __('File type does not meet security guidelines. Try another.'));
}
- // A writable uploads dir will pass this test. Again, there's no point overriding this one.
- if ( ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
+ // A writable uploads dir will pass this test. Override with $uploads = array('path'=>$path, 'url'=>$url);
+ if ( ( empty( $uploads['path'] ) || empty( $uploads['url'] ) ) && ! ( ( $uploads = wp_upload_dir() ) && false === $uploads['error'] ) )
return $upload_error_handler($file, $uploads['error']);
// Increment the file number until we have a unique file to save in $dir. Use $override['unique_filename_callback'] if supplied.
@@ -2079,6 +2080,17 @@ function wp_reset_vars($vars) {
}
}
+// If siteurl or home changed, reset cookies and flush rewrite rules.
+function update_home_siteurl($old_value, $value) {
+ global $wp_rewrite, $user_login, $user_pass_md5;
+ // 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'));
+}
+
function autocomplete_css() {
?>
<style type='text/css'>
@@ -2108,9 +2120,9 @@ function autocomplete_css() {
<?php
}
function autocomplete_textbox( $url, $search_field, $results_field ) {
+ wp_print_scripts('scriptaculous-controls');
?>
-<script type="text/javascript" src="<?php echo get_option( "siteurl" ) ?>/wp-includes/js/scriptaculous/prototype.js"></script>
-<script type="text/javascript" src="<?php echo get_option( "siteurl" ) ?>/wp-includes/js/scriptaculous/scriptaculous.js"></script>
+
<script type="text/javascript">
function load_autocompleter() {
new Ajax.Autocompleter("<?php echo $search_field ?>", "<?php echo $results_field ?>", "<?php echo $url ?>", {paramName: "search", minChars: 3});
@@ -2120,4 +2132,44 @@ addLoadEvent( load_autocompleter );
<?php
}
+add_action('update_option_home', 'update_home_siteurl', 10, 2);
+add_action('update_option_siteurl', 'update_home_siteurl', 10, 2);
+
+function update_blog_public($old_value, $value) {
+ global $wpdb;
+ $value = (int) $value;
+ do_action('update_blog_public');
+ update_blog_status( $wpdb->blogid, 'public', $value );
+}
+
+add_action('update_option_blog_public', 'update_blog_public', 10, 2);
+
+function update_option_new_admin_email($old_value, $value) {
+ if ( $value == get_option( 'admin_email' ) || !is_email( $value ) )
+ return;
+
+ $hash = md5( $value.time().mt_rand() );
+ $newadminemail = array(
+ "hash" => $hash,
+ "newemail" => $value
+ );
+ // TODO: gettext
+ 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}'
+
+Regards,
+The Webmaster" );
+}
+
+add_action('update_option_new_admin_email', 'update_option_new_admin_email', 10, 2);
+
?>
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&#8217; 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);