ulfben

WordPress plugin settings migration

Dec 19th, 2011
595
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.81 KB | None | 0 0
  1. /* This is my plugin activation_hook. What am I doing wrong? Why are the options not being updated correctly? */
  2. function cud_install_options(){
  3.     $defaults = array(
  4.         'custom_upload_dir' => '',
  5.         'all_parents' => true,
  6.         'flatten_hierarchy' => false,
  7.         'only_leaf_nodes' => false,
  8.         'only_base_nodes' => false,
  9.         'test_ids'  => '-1',
  10.         'template' => ''
  11.     ); 
  12.     $old = get_option('custom_upload_dir');
  13.     if(is_array($old)){
  14.         if(!empty($old['template'])){ //update deprecated placeholders
  15.             $newtags = array('%post_id%','%postname%','%author%','%monthnum%');
  16.             $oldtags = array('%ID%', '%post_name%','%post_author%','%month%');
  17.             $old['template'] = str_replace($oldtags, $newtags, $old['template']);
  18.         }  
  19.         $defaults = array_merge($defaults, $old);  
  20.     }      
  21.     update_option('custom_upload_dir', $defaults);
  22. }
Advertisement
Comments
  • Rteuixl
    217 days
    # text 0.21 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
    6.  
    7. Remove the @
  • Comment was deleted
Add Comment
Please, Sign In to add comment