$value) { if (is_array($value)) { natsort($value); foreach ($value as $v2) { $pairs[] = ($v2 == '') ? "$key=0" : "$key=$v2"; } } else { $pairs[] = ($value == '') ? "$key=0" : "$key=$value"; } } $string = implode('&', $pairs); return $string; } /** * Takes a token response from a request token call, then puts it in an appropriate array. * * @param $response * @return array */ abstract public function parse_token($response); /** * Saves the token in the authentication options. * * @param $token */ public function save_token($token) { $photonic_authentication = get_option('photonic_authentication'); if (!isset($photonic_authentication)) { $photonic_authentication = []; } $photonic_authentication[$this->provider] = $token; update_option('photonic_authentication', $photonic_authentication); } /** * Fetches a token from authentication options * * @return array|null */ public function get_cached_token() { $photonic_authentication = get_option('photonic_authentication'); if (!empty($photonic_authentication) && isset($photonic_authentication[$this->provider])) { return $photonic_authentication[$this->provider]; } return null; } }