request( TR_PMD_API_URL . 'products/attributes?token=' . $key . '&client='. TR_PMD_API_CLIENT, 'GET' ); $result = array( 'data' => $result['attributes'], 'message' => __( 'The API Key is valid', 'tr_pmd_locale' ), 'success' => 'true', ); } catch ( \Exception $e ) { $result = array( 'message' => __( 'The API Key is incorrect', 'tr_pmd_locale' ), 'success' => 'false', ); } echo json_encode( $result ); wp_die(); } public function get_all_attributes( $key ) { try{ $result = $this->request( TR_PMD_API_URL . 'products/attributes?token=' . $key . '&client='. TR_PMD_API_CLIENT, 'GET' ); } catch ( \Exception $e ) { return null; } arsort($result['attributes']['purity'][1]); arsort($result['attributes']['purity'][2]); arsort($result['attributes']['purity'][3]); arsort($result['attributes']['purity'][4]); unset($result['attributes']['metal'][5]); return $result['attributes']; } }