• Resolved Forson

    (@forson)


    I am using the plugin “Favorites for WordPress” from https://favoriteposts.com/. I need to add a number to their Favorite Count which is a Real Integer / non-decimal value.

    The value returned by your plugin is always “0”. This is the formula I am using:
    [calculate] 5 + [favorite_count] [/calculate]

    When I display [favorite_count] outside of the [calculate] shortcode it returns “1”. When I add 5+5 within the [calculate] shortcode it returns “10”. I have also tried other integer generating shortcodes and they do not work either – they always return a value of “0” when I try to perform an operation on them within the Calculate plugin.

    Is there something I am missing? I am using version 2.1.1 of the plugin and WP 5.2.

    Any support is appreciated.

    Thanks
    A

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author bhagwad

    (@bhagwad)

    Hi!

    When you use [favorite_count] outside of the plugin, do you get a plain number, or is it wrapped in some HTML? Try this – use the [favorite_count] shortcode and display the result. Then check the source code of the page. Is it just the number, or are there additional characters surrounding it?

    Thread Starter Forson

    (@forson)

    Hi there,

    The value in inspect codes is just 1 with no additional characters – the full code on display is:
    <span data-favorites-post-count-id=”9675″ data-siteid=””>1</span>

    I hope this helps,
    Thanks

    Plugin Author bhagwad

    (@bhagwad)

    Thanks for the debug. Is the HTML:

    <span data-favorites-post-count-id=”9675″ data-siteid=””>

    Inside or outside the [calculate] shortcode?

    Basically when you type:

    [calculate] 5 + [favorite_count] [/calculate]

    Does it become:

    [calculate]5+1[/calculate]

    or

    [calculate]5+<span data-favorites-post-count-id=”9675″ data-siteid=””>1</span>[/calculate] ?

    Thread Starter Forson

    (@forson)

    I think it must be the second one below with all the code… but I cannot be certain since only the 0 shows up,.

    Plugin Author bhagwad

    (@bhagwad)

    That’s the thing. If the shortcode you use returns anything other than a number, the [calcuate] function will fail.

    I think I may need to update the plugin to strip all HTML code before parsing. Let me think about it…

    Thread Starter Forson

    (@forson)

    I think you are right – I am noticing comment code in another shortcode value that doesn’t work with your plugin.

    Is there an easy way of stripping non numeric values from shortcode results?

    Thanks

    Plugin Author bhagwad

    (@bhagwad)

    If you’re familiar with PHP, you can try and use this function by modifying the code of the plugin: https://www.php.net/manual/en/function.strip-tags.php

    If not, just wait a while and I’ll try and update the plugin myself with a new version.

    Thread Starter Forson

    (@forson)

    Unfortunately I am not familiar enough with PHP to implement this in your plugin. But thanks for the guidance.

    Do you have an ETA on an update for the plugin?

    Thanks

    Plugin Author bhagwad

    (@bhagwad)

    I just made an update. Let me know if it works!

    Plugin Author bhagwad

    (@bhagwad)

    Glad to know it’s resolved.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Calculate Values from Favorite Post Plugin’ is closed to new replies.