an issue with a wordpress plugin calling external shortcodes

Discussion in 'PHP' started by asgsoft, May 25, 2012.

  1. #1
    Hey guys,

    I've been stuck with this issue for a wile and need some help.

    So I've made a basic wordpress plugin which creates a short tag "[review id=1]"

    This short tag would then query a mysql database and display the info for the review with $id 1 which works fine.

    The problem is, part of the review calls on another plugin, http://wordpress.org/extend/plugins/...review-rating/ to display the rating as in stars by displaying "[Rating:4/5]"

    However, rather than displaying the picture, "[Rating:4/5]" is written down whereas normally I'd get 4 stars.

    Is there anyway I can fix that?

    What I have so far is on: http://pastebin.com/FWB3qbcP

    Cheers
     
    asgsoft, May 25, 2012 IP
  2. iMarcus

    iMarcus Active Member

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #2
    Hi there, just a quick thought: perhaps the rating plugin is called before your plugin, therefore the [rating] shortcode isnt getting parsed? check the priority of both your plugin and the ratings one.
    hope this helps!
     
    iMarcus, May 25, 2012 IP
  3. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Hey Marcus,

    Any ideas how I could check that?

    Cheers
     
    asgsoft, May 25, 2012 IP
  4. iMarcus

    iMarcus Active Member

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #4
    In the php file for the ratings plugin, look for where it adds the action or filter.
    the priority can be set here for example:

    add_filter( 'hook_name', 'callback_name', 100 );

    where 100 is the plugin priority on a scale of 0 - n, 0 being the highest priority and 10 being the default.

    There is also a way of ensuring your plugin loads first, here's a link that explains it much better :)

    http://wordpress.org/support/topic/how-to-change-plugins-load-order
     
    Last edited: May 25, 2012
    iMarcus, May 25, 2012 IP
  5. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #5
    Playing around with the priorities gives me this error:

    Any ideas what's causing that?
     
    asgsoft, May 25, 2012 IP
  6. iMarcus

    iMarcus Active Member

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #6
    Hi, did you change the priority of your plugin to be before the rating plugin? I think yours should be called after the rating plugin, then you will have access to the function which is called by the shortcode.

    Another idea would be to call the rating function directly from your code, and wrap it with " if (function_exists('name_of_rating_func')) ". This way you avoid using the shortcode altogether.
     
    iMarcus, May 26, 2012 IP