Plugin Directory

Changeset 2929373


Ignore:
Timestamp:
06/21/2023 07:23:55 PM (3 years ago)
Author:
pluginsclub
Message:

1.4.2

Location:
ethereum-price-tooltip/trunk
Files:
8 added
1 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • ethereum-price-tooltip/trunk/README.txt

    r2925537 r2929373  
    11=== Ethereum price tooltip ===
    22Contributors: stefanpejcic, pluginsclub
    3 Tags: cryptocurrency, ethereum, finance, bitcoin, eth, tooltip
     3Tags: cryptocurrency, ethereum, finance, bitcoin, eth, tooltip, crypto
    44Requires at least: 4.0
    55Tested up to: 6.2
    66Requires PHP: 5.4
    7 Stable tag: 1.4
     7Stable tag: 1.4.2
    88Donate link: https://plugins.club/free-wordpress-plugins/ethereum-price-tooltip/
    99License: GPLv2 or later
     
    1616== Screenshots ==
    1717
    18 1. Tooltip added to content that shows current ETH price in USD adn EUR
     181. Tooltip added to content that shows current ETH price in USD and EUR
    1919
    2020== Frequently Asked Questions ==
     
    3939== Changelog ==
    4040
     41= 1.4.2 =
     42* Added Ticker style
     43* Added a settings page where user can choose API provider and Ticker/Tooltip style
     44* Added option to change currency from USD/EUR
     45* Code refactoring
     46
     47= 1.4.1 =
     48* Fixed bug with tooltip appearing on pages with ui tag
     49
    4150= 1.4 =
    4251* Images and Figure tags are now excluded
  • ethereum-price-tooltip/trunk/eth-price-tooltip.php

    r2925553 r2929373  
    33Plugin Name: Ethereum Price Tooltip
    44Description: Plugin will find mentions of Ethereum in your texts and automatically add a toltip to it with actual price in USD and EUR.
    5 Version: 1.4
     5Version: 1.4.2
    66Author: plugins.club
    7 Author URI: https://plugins.club/free-wordpress-plugins/ethereum-price-tooltip/
     7Author URI: https://plugins.club/free-wordpres-plugins/ethereum-price-tooltip/
    88*/
    99
     10// Load settings page and Tooltip - Ticker files
     11require_once plugin_dir_path( __FILE__ ) . 'includes/settings_page.php';
     12require_once plugin_dir_path( __FILE__ ) . 'includes/tooltip.php';
     13require_once plugin_dir_path( __FILE__ ) . 'includes/ticker.php';
    1014
    11 function add_tooltip_to_eth($the_content)
     15// Add/switch CSS files
     16function add_eth_tooltip_css()
    1217{
    13     static $eth_in_text = array(
    14         '0' => 'ETH',
    15         '1' => 'eth',
    16         '2' => 'ethereum',
    17         '3' => 'Ethereum',
    18     );
     18    $selected_option = get_option('ethereum_price_option', 'tooltip');
    1919
    20     $url = "https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD,EUR";
    21     $json = json_decode(file_get_contents($url));
    22     $ethAnswerUsd = $json->USD;
    23     $ethAnswerEUR = $json->EUR;
     20    if ($selected_option === 'tooltip') {
     21        wp_enqueue_style('tooltip-style', plugins_url('includes/css/tooltip-style.css', __FILE__), false, '1.0.0', 'all');
     22    } elseif ($selected_option === 'ticker') {
     23        wp_enqueue_style('ticker-style', plugins_url('includes/css/ticker-style.css', __FILE__), false, '1.0.0', 'all');
     24    }
     25}
     26add_action('wp_enqueue_scripts', 'add_eth_tooltip_css');
    2427
    25     foreach ($eth_in_text as $keyword) {
    26         $pattern = '/(<a\b[^>]*>.*?<\/a>)|\[.*?\]|<img\b[^>]*>|<figure\b[^>]*>.*?<\/figure>|(?<!\w)' . preg_quote($keyword, '/') . '(?!\w)/iu';
    27         $the_content = preg_replace_callback($pattern, function($matches) use ($ethAnswerUsd, $ethAnswerEUR) {
    28             if (!empty($matches[1]) || !empty($matches[0]) && substr($matches[0], 0, 1) === '[' || preg_match('/<img\b[^>]*>/', $matches[0])) {
    29                 return $matches[0];
    30             } else {
    31                 return '<span class="tooltip" data-tooltip="' . $ethAnswerUsd . ' USD / ' . $ethAnswerEUR . ' EUR">' . $matches[0] . '</span>';
    32             }
    33         }, $the_content);
     28// By default display Tooltip, and allow switching
     29function add_eth_content($the_content)
     30{
     31    $selected_option = get_option('ethereum_price_option', 'tooltip');
     32
     33    if ($selected_option === 'ticker') {
     34        $the_content = add_ticker_to_eth($the_content);
     35    } else {
     36        $the_content = add_tooltip_to_eth($the_content);
    3437    }
    3538
     
    3740}
    3841
    39 
    40 function add_eth_tooltip_css()
    41 {
    42     wp_enqueue_style('tooltip-style', plugins_url('tooltip-style.css', __FILE__) , false, '1.0.0', 'all');
    43 }
    44 
    45 add_action('wp_enqueue_scripts', "add_eth_tooltip_css");
    46 add_filter('the_content', 'add_tooltip_to_eth');
     42// Add the content filter for switching between tooltip and ticker
     43add_filter('the_content', 'add_eth_content');
Note: See TracChangeset for help on using the changeset viewer.