• Resolved Smaandar

    (@smaandar)


    Hello all,

    I currently am working on writting a custom php script, that is being imported to a Word Press page through PHP via the ‘insert-PHP’ plugin. But that is not the intent of this post. Inside my script I have it print prices, such as ‘$25.00’, through echo. Outside of Word Press it works wonderfully, and without the ‘$’ symbol it continues to work. However, with the ‘$’ symbol, while in Word Press, it removes everything from the ‘$’ symbol to the next space, period, or non integral character.

    This means that ‘$25.00’ Turns into ‘.00’.

    My question, is does Word Press have any built in filtering that is, well, filtering this out? If so, is it possible to override this filter and not remove these characters?

    Thanks in advance,
    ~Smaandar

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Smaandar

    (@smaandar)

    A bit of a good example.

    [insert_php]
    
         echo "$25.00";
    
    [/insert_php]

    prints “.00”

    but

    [insert_php]
    
         echo "25.00";
    
    [/insert_php]

    Prints 25.00

    Thread Starter Smaandar

    (@smaandar)

    The only fix I’ve found is to make a custom page template for the page in question in Word Press, and put my php code into there.

    The dollar sign indicates a variable declaration in PHP. Try the HTML character code $ instead.

    "$25.00"

    Reference: http://www.ascii.cl/htmlcodes.htm

    Thread Starter Smaandar

    (@smaandar)

    The dollar sign indicates a variable declaration in PHP. Try the HTML character code $ instead.

    Yes I know it’s a variable declaration. However, a line such as

    echo("This cost $19.95");

    Should not declare a variable, it should simply be printing “This cost $19.95” without removing half of the value.

    This works outside of WordPress, and as a custom page template. So I think it’s quite possible that it is something in the insert-php plugin that I was using.

    Also, although it is resolved, I would like to note that I cannot use the html character code because it lists titles based on file names. If the file name has $30 in it, it will break the entire title.

    So for now, the solution is to create a custom template file for the page, and include the script through the template php, and NOT from within WordPress through a third party plugin.

    For what it’s worth, your solution is the much better way to go.

    You’re right about echo but that plugin uses eval() without escaping the text first so the $25 is being interpreted as a variable. WordPress is not stripping anything before it gets eval-ed.

    For safe titles, try sanitize:

    echo sanitize_title( $title );
    Thread Starter Smaandar

    (@smaandar)

    Oh, I had no idea it was using eval(), that makes a lot more sense now.

    Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘$25.00 turns into .00, Is something removing my punctuation and numbers?’ is closed to new replies.