function save_settings() { global $wpdb; check_admin_referer('flickr-gallery'); $options = explode(',', $_POST['page_options']); $out = array(); include_once dirname(__FILE__) . '/phpFlickr.php'; $phpFlickr = new phpFlickr($_POST['fg-API-key'], empty($_POST['fg-secret']) ? null : $_POST['fg-secret']); switch ($_POST['fg-user_id-type']) { case 'name': $user = $phpFlickr->people_findByUsername($_POST['fg-user_id']); $_POST['fg-user_id'] = $user['id']; break; case 'email': $user = $phpFlickr->people_findByEmail($_POST['fg-user_id']); $_POST['fg-user_id'] = $user['id']; break; case 'url': $user = $phpFlickr->urls_lookupUser($_POST['fg-user_id']); $_POST['fg-user_id'] = $user['id']; break; } if ($_POST['fg-db-cache'] == 1) { if (isset($wpdb->charset) && !empty($wpdb->charset)) { $charset = ' DEFAULT CHARSET=' . $wpdb->charset; } elseif (defined(DB_CHARSET) && DB_CHARSET != '') { $charset = ' DEFAULT CHARSET=' . DB_CHARSET; } else { $charset = ''; } $query = ' CREATE TABLE IF NOT EXISTS `' . $wpdb->prefix . 'phpflickr_cache` ( `request` CHAR( 35 ) NOT NULL , `response` MEDIUMTEXT NOT NULL , `expiration` DATETIME NOT NULL , PRIMARY KEY ( `request` ) ) ' . $charset . ' '; $wpdb->query($query); } /* if ( empty($_POST['fg-token']) && !empty($_POST['fg-frob']) ) { $token = $phpFlickr->auth_getToken($_POST['fg-frob']); $_POST['fg-token'] = $token['token']; } */ foreach ($options as $o) { if (get_option($o) === false) { add_option($o, $_POST[$o], null, no); } else { update_option($o, $_POST[$o]); } if (is_array($_POST[$o])) { $out[] = '"' . $o . '":["' . implode('","', $_POST[$o]) . '"]'; } else { $out[] = '"' . $o . '":"' . addslashes($_POST[$o]) . '"'; } } echo '{' . implode(', ', $out) . '}'; exit; }