コード例 #1
0
 function json_network_partial_data_save()
 {
     if (!current_user_can('manage_network_options')) {
         die;
     }
     $key = @$_POST['part'];
     $old_data = get_site_option($key, false);
     $old_data = is_array($old_data) ? $old_data : array();
     $data = $keys = array();
     $override = $preserve_api = false;
     parse_str($_POST['data'], $data);
     if ('wdfb_network' == $key) {
         $keys = Wdfb_Installer::get_keys();
         unset($keys['widget_pack']);
         $override = (int) @$data['_override_all'];
         $preserve_api = (int) @$data['_preserve_api'];
     }
     $new_data = array_merge($old_data, $data[$key]);
     update_site_option($key, $new_data);
     if ($keys && $override) {
         $page = !empty($data['page']) ? (int) $data['page'] : 0;
         $blogs = $this->model->get_paged_blog_ids($page);
         // Get this list only once
         if (empty($blogs)) {
             die;
         }
         // We're done with paging
         foreach ($keys as $key) {
             if ('api' == $key && $preserve_api) {
                 continue;
             }
             // Preserve API
             $site_opt = get_site_option("wdfb_{$key}");
             foreach ($blogs as $blog) {
                 update_blog_option($blog['blog_id'], "wdfb_{$key}", $site_opt);
             }
         }
         die(json_encode(array("page" => $page + 1)));
         // Paged resource, respond with next page
     }
     die;
 }