'', 'connected_at' => 0, 'code_hash' => '', 'code_expires' => 0, 'relay' => false, ) ); return array( 'secret' => (string) $settings['secret'], 'connected_at' => (int) $settings['connected_at'], 'code_hash' => (string) $settings['code_hash'], 'code_expires' => (int) $settings['code_expires'], 'relay' => (bool) $settings['relay'], ); } /** * Merges $changes into the stored settings, dropping anything else (0.2.x's gateway key and last * result). Not autoloaded: only the plugin's own requests read it. * * @param array $changes Settings to change. * @return void */ function pirkoo_update_settings( array $changes ) { update_option( PIRKOO_OPTION, array_merge( pirkoo_settings(), array_intersect_key( $changes, pirkoo_settings() ) ), false ); } /** * Whether the store is connected to app.pirkoo.com. * * @return bool */ function pirkoo_is_connected() { return '' !== pirkoo_settings()['secret']; } /** * After an update from 0.2.x: the gateway key and its registration token are no longer used, so * they're removed. A 0.2.x connection doesn't carry over: the store is connected again from the * Plugins screen. * * @return void */ function pirkoo_upgrade() { $saved = get_option( PIRKOO_OPTION, array() ); if ( is_array( $saved ) && ( isset( $saved['api_key'] ) || isset( $saved['last'] ) ) ) { update_option( PIRKOO_OPTION, array( 'secret' => isset( $saved['secret'] ) ? (string) $saved['secret'] : '', 'connected_at' => isset( $saved['secret'] ) ? (int) $saved['connected_at'] : 0, 'code_hash' => '', 'code_expires' => 0, ), false ); delete_transient( 'pirkoo_verify_token' ); } }