Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Скопируйте код, представленный ниже, в файл functions.php,
- который вы сможете найти в папке с вашей действующей темой,
- либо через редактор админ панели WORDPRESS
- <?php
- class marqueeCurrency extends WP_Widget {
- function __construct() {
- parent::__construct('marqueeСurrency','Курс криптовалют', array('description' => 'Отображает актуальные курсы криптовалют бегущей строкой'));
- }
- function widget( $args, $instance ){
- $currencies = file_get_contents('https://api.coinmarketcap.com/v1/ticker/?convert=RUB&limit='.$instance['currenciesLimit']);
- $currencies = json_decode($currencies,true);
- ?>
- <marquee scrollamount="3" behavior="scroll" loop="infinite" direction="left">
- <?
- foreach ($currencies as $key => $currency) {
- ?>
- <span><strong><? echo $currency['name'].' ('.$currency['symbol'].')'; ?></strong> : <? echo number_format($currency['price_rub'], 2, '.', ' ').' руб.';?> </span>
- <?
- }
- ?>
- </marquee>
- <?
- }
- function update( $new_instance, $old_instance ) {
- $instance = $old_instance;
- $instance['currenciesLimit'] = strip_tags( $new_instance['currenciesLimit'] );
- return $instance;
- }
- function form( $instance ) {
- $defaults = array (
- 'currenciesLimit' => 10
- );
- $instance = wp_parse_args((array)$instance, $defaults);
- ?>
- <p>
- <label for="<?php echo $this->get_field_id( 'currenciesLimit' ); ?>"> Выводить <input id="<?php echo $this->get_field_id( 'currenciesLimit' ); ?>" name="<?php echo $this->get_field_name( 'currenciesLimit' ); ?>" value="<?php echo $instance['currenciesLimit']; ?>" style="width:50px;" type="number"/> популярных криптовалют</label>
- </p>
- <?
- }
- }
- register_widget('marqueeCurrency');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement