Share Pastebin
Guest
Public paste!

Ben

By: a guest | Mar 20th, 2009 | Syntax: PHP | Size: 1.12 KB | Hits: 55 | Expires: Never
This paste has a previous version, view the difference. Copy text to clipboard
  1. function try_set_option($key, $value) {
  2.         $old_value = get_option($key);
  3.         echo $key .' is '; var_dump($old_value);
  4.         if ($old_value != $value) {
  5.                 echo "\n\tupdate_option('$key', '$value'); ... ";
  6.                 if ($_GET['action'] == 'run') update_option($key, $value); // XXX
  7.                 echo "ok. The new value is "; var_dump(get_option($key)); echo '.';
  8.         }
  9.         else {
  10.                 echo "\n\tok.";
  11.         }
  12.         echo "\n";
  13. }
  14.  
  15. function widget_subscribe2_change_name() {
  16.         echo '<strong>Checking for old subscribe2 widget name... </strong><small>';
  17.         // update sidebar option
  18.         $sidebars = (array) get_option('sidebars_widgets');
  19.         $changed = false;
  20.         foreach ($sidebars as $i => $sidebar) {
  21.                 if(is_array($sidebar)) {
  22.                         foreach ($sidebar as $k => $widget) {
  23.                                 if ($widget == 'subscribe2widget') {
  24.                                         $sidebars[$i][$k] = 'subscribe2';
  25.                                         echo '<strong>'. $widget.' found and replaced with subscribe2 </strong>, ';
  26.                                         $changed = true;
  27.                                 }
  28.                                 else {
  29.                                         echo $widget .', ';
  30.                                 }
  31.                         }
  32.                 }
  33.         }
  34.         if ($changed) {
  35.                 echo '</small><pre>';
  36.                 try_set_option('sidebars_widgets', $sidebars);
  37.                 echo '</pre>';
  38.         }
  39.         else {
  40.                 echo '.</small> Nothing changed.';
  41.         }
  42. }