Changeset 2929373
- Timestamp:
- 06/21/2023 07:23:55 PM (3 years ago)
- Location:
- ethereum-price-tooltip/trunk
- Files:
-
- 8 added
- 1 deleted
- 2 edited
-
README.txt (modified) (3 diffs)
-
eth-price-tooltip.php (modified) (2 diffs)
-
includes (added)
-
includes/css (added)
-
includes/css/ticker-style.css (added)
-
includes/css/tooltip-style.css (added)
-
includes/js (added)
-
includes/settings_page.php (added)
-
includes/ticker.php (added)
-
includes/tooltip.php (added)
-
tooltip-style.css (deleted)
Legend:
- Unmodified
- Added
- Removed
-
ethereum-price-tooltip/trunk/README.txt
r2925537 r2929373 1 1 === Ethereum price tooltip === 2 2 Contributors: stefanpejcic, pluginsclub 3 Tags: cryptocurrency, ethereum, finance, bitcoin, eth, tooltip 3 Tags: cryptocurrency, ethereum, finance, bitcoin, eth, tooltip, crypto 4 4 Requires at least: 4.0 5 5 Tested up to: 6.2 6 6 Requires PHP: 5.4 7 Stable tag: 1.4 7 Stable tag: 1.4.2 8 8 Donate link: https://plugins.club/free-wordpress-plugins/ethereum-price-tooltip/ 9 9 License: GPLv2 or later … … 16 16 == Screenshots == 17 17 18 1. Tooltip added to content that shows current ETH price in USD a dnEUR18 1. Tooltip added to content that shows current ETH price in USD and EUR 19 19 20 20 == Frequently Asked Questions == … … 39 39 == Changelog == 40 40 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 41 50 = 1.4 = 42 51 * Images and Figure tags are now excluded -
ethereum-price-tooltip/trunk/eth-price-tooltip.php
r2925553 r2929373 3 3 Plugin Name: Ethereum Price Tooltip 4 4 Description: 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 5 Version: 1.4.2 6 6 Author: plugins.club 7 Author URI: https://plugins.club/free-wordpres s-plugins/ethereum-price-tooltip/7 Author URI: https://plugins.club/free-wordpres-plugins/ethereum-price-tooltip/ 8 8 */ 9 9 10 // Load settings page and Tooltip - Ticker files 11 require_once plugin_dir_path( __FILE__ ) . 'includes/settings_page.php'; 12 require_once plugin_dir_path( __FILE__ ) . 'includes/tooltip.php'; 13 require_once plugin_dir_path( __FILE__ ) . 'includes/ticker.php'; 10 14 11 function add_tooltip_to_eth($the_content) 15 // Add/switch CSS files 16 function add_eth_tooltip_css() 12 17 { 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'); 19 19 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 } 26 add_action('wp_enqueue_scripts', 'add_eth_tooltip_css'); 24 27 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 29 function 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); 34 37 } 35 38 … … 37 40 } 38 41 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 43 add_filter('the_content', 'add_eth_content');
Note: See TracChangeset
for help on using the changeset viewer.