Created
November 20, 2018 19:51
-
-
Save campusboy87/bd93a170ec348f3df560cf70ffb3b478 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function cr_get_data_crypto( $type = '', $symbol = '' ) { | |
| $symbol = $symbol ? $symbol : cr_get_crypto_symbol(); | |
| $cache_key = $symbol . '-coinsnapshot'; | |
| $data = wp_cache_get( $cache_key ); | |
| if ( $symbol && false === $data ) { | |
| $file = CRYPT_REVIEWS_PATH . "data-import/coins/$symbol-coinsnapshot.json"; | |
| $data = is_file( $file ) ? json_decode( file_get_contents( $file ) ) : []; | |
| // Сохраняем данные в кеш | |
| wp_cache_set( $cache_key, $data ); | |
| } | |
| if ( empty( $data->Data ) || ! $data = $data->Data ) { | |
| return ''; | |
| } | |
| foreach ( explode( '/', $type ) as $key ) { | |
| $data = isset( $data->{$key} ) ? $data->{$key} : ''; | |
| } | |
| return $data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment