I reply to all queries on the forums and via email, once per day, Monday to Friday (not weekends).

If you are new here, please see some information on how to ask for support. Thank you!

sweet alerts help – Not Urgent

dashed-slug.net Forums General discussion sweet alerts help – Not Urgent

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #5844
    megeanwasson
    Participant

    Hi Alex,
    This is such a cool addition 🙂
    I have figured out how to style the alerts with css.
    I would however also like to change how the text inside the alert is displayed (not the styling)

    In File: /plugins/wallets/includes/wallets-ko-i18n.php on line 43 you have the alert message:
    __( 'Successfully submitted a withdrawal request of %1$s %2$s to %3$s Please check your e-mail for confirmation instructions.', 'wallets-front' )
    In the text above I have tried <br /> and \n \r\n but none of those usual methods work, they end up just showing those codes instead of doing the actual linebreaks.

    I would like to have it display like this inside the alert box:
    Successfully submitted a withdrawal request of:<br />
    %1$s %2$s<br />
    to %3$s<br />
    Please check your e-mail for confirmation instructions.

    I am not sure how to do that, none of the solutions on google search works.

    Your insight to this would be most useful.
    Regards
    Megan

    #5846
    alexg
    Keymaster

    Hello Megan,

    If you change the single quotes to double quotes, then you can use escaped characters. You should be able to use \n to do a line break. If you are interested, you can learn more about this here.

    Don’t forget to use the filter to replace the strings, so as not to have to apply your changes to the plugin on every update.

    with regards

    EDIT: This solution is not entirely correct. Please stand by and I will give you a full example of how to do this shortly.

    #5848
    megeanwasson
    Participant

    Hey Alex 🙂
    I tried with double quotes did not work, but definitely your link to the php explanation did help. This is what worked, was so simple I did not even think to try it before.

    if ( Dashed_Slug_Wallets::get_option( ‘wallets_confirm_withdraw_user_enabled’ ) ) {
    $translation_array[‘submit_wd’] = apply_filters(
    ‘wallets_ui_text_submit_wd’,
    __( ‘Successfully submitted a withdrawal request of:
    %1$s %2$s
    to %3$s
    Please check your e-mail for confirmation instructions.’, ‘wallets-front’ )

    );
    That worked like a charm 🙂

    #5849
    alexg
    Keymaster

    The problem with the above solution is that once you switch to double quotes, the sprintf placeholders get interpreted by PHP as inline variables, so the $ signs need to be escaped.

    The complete solution suffers from a mild case of LTS, and it is this:

    
    function filter_wallets_ui_text_submit_wd( $string ) {
    	return "Successfully submitted a withdrawal request of %1\$s %2\$s to %3\$s.\nPlease check your e-mail for confirmation instructions.";
    }
    
    add_filter( 'wallets_ui_text_submit_wd', 'filter_wallets_ui_text_submit_wd' );
    
    #5850
    alexg
    Keymaster

    Megan I saw your reply after I posted mine. Good job, but please see my earlier comment about using the filter to avoid problems on plugin updates.

    #5851
    megeanwasson
    Participant

    Yes Thank You I always use filters 🙂

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.