Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // If the old 'fl_link_color' hasn't been set
- // Or if the new 'fl_visual_options' hasn't been set
- // Then, add the defaults
- if ((!get_option( 'fl_link_color' )) || (!get_option( 'fl_visual_options' ))) {
- global $options;
- //Create an array to hold the defaults.
- $defaults = array();
- foreach ($options as $value) {
- //Similar to saving. Go through each value grabbing the key & value (item).
- foreach($value as $key => $item) {
- //Match the ids against the key.
- if(preg_match('/^id/i', $key)) {
- //replace the id so we can grab the correct numbered default value.
- $num = preg_replace('/^id(.*)/i', 'std$1', $key);
- //Make sure said value exists as it may not have a default value
- //Notice the use of $value as we want to grab the value from the
- //Previous loop, not this one.
- if(isset($value[$num])) {
- //Store value in the defaults array using the field name as key
- //And grabbing the value from the previous loop using the replaced
- //ID as the key name.
- $defaults[$item] = $value[$num];
- }
- }
- }
- }
- //Store new ones
- update_option( 'fl_visual_options', $defaults);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement