Skip to:
Content
Pages
Categories
Search
Top
Bottom

:diamond: –> ♦? possible solutions not working


  • getfree
    Participant

    @getfree

    hi,
    I am trying to parse pasted text into something else, where the simplest thing is to change :spade: :club: :diamond: and :heart: to be visualized as ♠♣♦ and ♥ but my solution is not working.

    In the Theme files I edited functions.php by adding the following code (in the staging environment)

    // Function to replace suit representations with symbols
    function replace_suit_symbols($hand_history) {
        // Replace suit representations with symbols
        $hand_history = str_replace(':spade:', '♠', $hand_history);
        $hand_history = str_replace(':heart:', '♥', $hand_history);
        $hand_history = str_replace(':diamond:', '♦', $hand_history);
        $hand_history = str_replace(':club:', '♣', $hand_history);
        
        // Return the modified hand history
        return $hand_history;
    }

    But when I write “:spade”, for instance, nothing changes. What am I missing?
    Hello Theme, WP 6.4.3, bbPress 2.6.9.

Viewing 6 replies - 1 through 6 (of 6 total)

  • Robin W
    Moderator

    @robin-w

    ok so unless you have some further code, nothing is calling that function.

    I presume this is content on bbpress topics and replies – yes?


    getfree
    Participant

    @getfree

    yes, on bbpress forums.

    I got the code from Chat GPT which ensured me that it would work (ie. clicking send would call the function and execute it) and gave me a few other pieces of more or less similar type of code. As you can see I am quite clueless on this stuff albeit I used to know some Python.

    How to proceed..

    This is related to this https://bbpress.org/forums/topic/poker-hand-histories-not-converted/#post-237481
    We have some freelance developers helping out but they didn’t understand at all what I was trying to accomplish, so I am set to do this “alone” for now, with not much success :/


    Robin W
    Moderator

    @robin-w

    ok, the code is probably ok, but chat gpt has a long way to go !

    A function needs something to call it, otherwise it just sits there.

    Not tested, but add these 2 lines before or after (doesn’t matter which) the function

    add_filter( 'bbp_get_reply_content', 'replace_suit_symbols' ) ;
    add_filter( 'bbp_get_topic_content', 'replace_suit_symbols' ) ;

    getfree
    Participant

    @getfree

    That worked. GPT insisted that the function call was not needed even when specifically asked. Also it thought that the square brackets are some short codes that were a must, which confused me even more. The text (a poker hand history from a software) starts like this:
    [converted_hand][hand_history]PokerStars – €0.50 PL Hi FAST (6 max) – Omaha Hi – 6 players
    [url=”http://www.holdemmanager.com”%5DHand converted by Holdem Manager 3[/url]

    BTN: €52.28 (104.6 bb)
    [color=”grey”]SB: €24.25 (49 bb)
    [/color][b]Hero (BB): €84.89 (169.8 bb)
    [/b][color=”grey”]UTG: €52.86 (105.7 bb)
    [/color][color=”grey”]MP: €31.34 (62.7 bb)
    [/color][color=”grey”]CO: €50.00 (100 bb)
    [/color]
    SB posts €0.25, Hero posts BB €0.50

    If I get this thing working I will make sure to update my old question about the hand histories in case some1 else is looking for a similar thing.
    Thanks Robin!


    Robin W
    Moderator

    @robin-w

    I just hope no-one is relying on GPT for anything important 🙂

    Computers have a very long way to go to get to any ‘skeptical’ intelligence, so will simply spout whatever the web says. If lots of sites on the web say the world is flat, I’d expect GPT to accept this as true 🙂


    getfree
    Participant

    @getfree

    Main problem, in addition to my non PHP abilities, was me using GPT 3.5. After a paid upgrade things started going way smoother, and the code works. Some parts of the parsed text such as some colouring are blocked by a theme or a plugin, but that is fine.

    Anyway, it was nice to visualize the symbols and the hand histories to the forum users.

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