Ben
By: a guest | Mar 20th, 2009 | Syntax:
PHP | Size: 1.12 KB | Hits: 55 | Expires: Never
function try_set_option($key, $value) {
$old_value = get_option($key);
echo $key .' is '; var_dump($old_value);
if ($old_value != $value) {
echo "\n\tupdate_option('$key', '$value'); ... ";
if ($_GET['action'] == 'run') update_option($key, $value); // XXX
echo "ok. The new value is "; var_dump(get_option
($key)); echo '.';
}
else {
echo "\n\tok.";
}
echo "\n";
}
function widget_subscribe2_change_name() {
echo '<strong>Checking for old subscribe2 widget name... </strong><small>';
// update sidebar option
$sidebars = (array) get_option
('sidebars_widgets');
$changed = false;
foreach ($sidebars as $i => $sidebar) {
foreach ($sidebar as $k => $widget) {
if ($widget == 'subscribe2widget') {
$sidebars[$i][$k] = 'subscribe2';
echo '<strong>'. $widget.' found and replaced with subscribe2 </strong>, ';
$changed = true;
}
else {
echo $widget .', ';
}
}
}
}
if ($changed) {
echo '</small><pre>';
try_set_option('sidebars_widgets', $sidebars);
echo '</pre>';
}
else {
echo '.</small> Nothing changed.';
}
}