dashed-slug.net › Forums › Faucet extension support › coin ticker hide
- This topic has 7 replies, 2 voices, and was last updated 3 years, 7 months ago by
LeinAd.
-
AuthorPosts
-
January 19, 2021 at 4:12 pm #9790
LeinAd
Participanti really have to say that your work has a lot of potential. now i wanted to set up a “votin page” and hide the coin ticker. it’s the “balance-static.php template”, right? i would duplicate it and change the code. however, i’m not sure about the ticker what all needs to be removed
sincerly – LeinAd
Attachments:
You must be logged in to view attached files.January 20, 2021 at 12:04 pm #9805alexg
KeymasterHello,
The balance-static.php template corresponds to the shortcode
[wallets_balance template="static"]
. This is for rendering the balance UI on the server side. You get no live updates to the values, but you can pass theuser_id
orsymbol
attributes. All of this mess will be resolved in wallets6.The best way to control the symbol next to amounts is not to override the templates, but to use the special filter for this purpose.
From the documentation to the JSON-API.
Amounts pattern
Cryptocurrency amounts in the frontend are passed through an
sprintf()
function. The JavaScript implementation used is https://github.com/alexei/sprintf.js.–
wallets_sprintf_pattern_XYZ
– Display pattern for amounts of coin with symbolXYZ
.To override the frontend display format for Bitcoin amounts:
public function filter_wallets_sprintf_pattern_BTC( $pattern ) { return 'BTC %01.8f'; } add_filter( 'wallets_sprintf_pattern_BTC', 'filter_wallets_sprintf_pattern_BTC' );
So you can use this filter in your theme or child theme to modify the pattern that amounts are shown for any currency. (Note that this filter has been re-implemented in the upcoming REST API in wallets6, so you can expect it to continue to work into the future.)
Hope this helps. Let me know if you encounter any diffculty implementing this solution.
with regards
January 20, 2021 at 2:15 pm #9806LeinAd
Participanti become a critical error with
public function filter_wallets_sprintf_pattern_BTC( $pattern ) { return 'BTC %01.8f'; } add_filter( 'wallets_sprintf_pattern_BTC', 'filter_wallets_sprintf_pattern_BTC' );
i will try it later
January 21, 2021 at 5:51 am #9807alexg
KeymasterSorry, I copied the code from inside a class and forgot there was a visibility modifier in there 🙂
Try again without the
public
keyword.with regards
January 21, 2021 at 9:38 am #9809LeinAd
Participantit’s kinda not my day. when i paste this in the copy of balance-static i get “Fatal error: Cannot redeclare” and when i use it in functions php nothing happens at all 🙁
January 21, 2021 at 1:25 pm #9810LeinAd
Participantso ok i tried it again but i have the coin symbol still there. But i have to hide this, outherwise my meter bar wont work :o(
Attachments:
You must be logged in to view attached files.January 22, 2021 at 8:54 am #9817alexg
KeymasterOh OK I see now.
The filter modifies the JSON-API responses. The JSON-API data is used by the dynamic UIs.
If you are going to use template=”static”, then yes, the best way to do this is to modify the template.
Instead of
if ( isset( $adapters[ $atts['symbol'] ] ) ) { $balance_str = sprintf( $adapters[ $atts['symbol'] ]->get_sprintf(), $balance ); } else { $balance_str = sprintf( "$atts[symbol] %01.8f", $balance ); }
You could have something like:
$balance_str = sprintf( "%01.8f", $balance );
You should place your modified copy of the template under your theme directory, at
/templates/wallets/balance-static.php
, as described here.Hope this helps, and apologies for the confusion.
January 22, 2021 at 10:42 am #9822LeinAd
Participantvery great. now it is working. thank you
-
AuthorPosts
- You must be logged in to reply to this topic.