Support » Plugin: Link Library » [Plugin: Link Library] conflict with Simple Facebook Connect

Viewing 15 replies - 1 through 15 (of 15 total)
  • Also, I just noticed that when the box next to “Allow link submission with empty link” is unticked, submitting with the Link URL field blank produces “New link submitted, it will appear in the list once moderated. Thank you.”, but no link gets submitted. (This has nothing to do with SFC, it also happens with SFC disabled…)

    Shouldn’t it return an error message instead?

    Shortcodes and filters should not have any side effects. In other words, yes, they can be called multiple times. They should be written so as to allow that to work properly, and they should not modify any globals or anything like that.

    Filters are supposed to *filter*. Not do other stuff.

    Plugin Author Yannick Lefebvre


    Hi Otto, We met briefly at the speakers dinner at Wordcamp Montreal this earlier this summer.

    I am not sure what you mean by writing shortcodes to work being called multiple times. By their nature, shortcodes will be called when a text string with square brackets is found in the page body and the shortcode function will return the text that is meant to replace that code. If the content is parsed multiple times for shortcodes, only the first time should result in the replacement of the shortcode by the intended content, right?

    Is there anything else you would recommend doing to work well in this instance? Perhaps an example to point me to?

    If the content is parsed multiple times for shortcodes, only the first time should result in the replacement of the shortcode by the intended content, right?

    No. The shortcode function should return the replacement content for the shortcode every time it is called. You cannot guarantee that the original unmodified content will only be parsed one time per page.

    What if I did this?

    $content_a = apply_filters('the_content',$post->post_content);
    $content_b = apply_filters('the_content',$post->post_content);

    Your shortcode function will be called twice, once to generate $content_a, a second time to generate $content_b. Now, obviously this is a contrived example, but the point is that you can’t control how people call your shortcode or when it gets processed.

    Basically, filters (and by extension shortcodes) should not have side effects. They should not modify globals, ever. They should not do different things at different times. They should only process the content as a filter (or process the shortcode) and return the replacement text. That’s what filters do. That’s all filters *should* do.

    Plugin Author Yannick Lefebvre


    I will go through my code this week-end to correct the echo statements for the link submission and see if I might be doing anything else but returning the replacement text.

    Plugin Author Yannick Lefebvre


    I just released version 5.3 to hopefully address these issues. I made sure that all shortcode output was returned and added a new message when you submit a link without an address when such links are not accepted.

    That being said, the plugin is currently suspended because of a security issue which I had already corrected a week ago. For some reason, the person who contacted me about it last week still reported it on a security site even though I had fixed it, which resulted in a suspension of the plugin.

    Please try updating as soon as version 5.3 is available and let me know if it works better.

    Link library doesn’t look suspended to me:

    thanks for having a look at it!

    Unfortunately, while the new version has fixed the first issue (now there is only one validation message), submitting a link still generates 3 posts in the moderation queue (and sends out 3 emails).

    I’m not sure if that’s easily solvable – I guess it means either the $_POST array needs to be cleared once it has been processed, or it needs to post to another php script to process the submission (via some AJAX voodoo?)…

    I just checked: this also happens when using an external ‘submitted’ page (with [link-library-addlinkcustommsg]).

    Sorry for being the bearer of bad news…

    Plugin Author Yannick Lefebvre


    Hi Axwax,

    Ah, now I understand better what is happening. While you had mentioned that the processing was happening three times, you had not said that the net effect was that you would end up with three copies of the link under your database waiting for moderation.

    This should be fixable since the plugin is supposed to check if links already exist in the database before inserting them. There must be something wrong with that logic. I will be only be able to look into that around next week-end. Hang tight.


    Plugin Author Yannick Lefebvre


    Otto, the plugin was re-opened Sunday around 5pm eastern.

    Oops, sorry for being rather vague on my initial post.
    Btw, I’m happy to test any changes to the plugin before you commit it to (I’ve just sent you a message through your contact form, so you should have my email)
    There’s no rush on my part, as I’ve implemented the workaround mentioned above:


    I have exactly the same problem with running your great link-library plugin and SFC. Every submitted link generates two post for moderation. Would be nice if you can find a fix 😉


    Plugin Author Yannick Lefebvre


    I just released version 5.3.3 to address this issue. There was first a problem with the code to check if a link was already in the system, thus the multiple submissions. Now, the main issue is that the code cannot know if the link was submitted twice because of such a double-shortcode processing or because someone submitted the same twice. Therefore, I created an option to choose if there should be an error message displayed or not when duplicate links are sent. When this option is unchecked, it will just display the moderation message and discard the duplicate.

    Let me know if this helps.

    jack: Perhaps you should move the code that does the processing of submitted links out of the shortcode handler entirely, and into something triggered on the init action or similar.

    Filters, and by extension shortcodes, should not have side effects of any kind. Modifying data in the database is a side-effect.

    Shortcodes should simply return something to be displayed, they shouldn’t do anything of substance. As long as you have a filter/shortcode which takes any form of action, you’ll continually run into these problems.

    Refactor. Move the “doing” code outside the shortcode handler functions.

    Plugin Author Yannick Lefebvre


    Thanks for your advice. I was actually thinking about that after issuing my update last night. I refactored this to send the form post data to an external php file to process, then using a wp_redirect with a URL variable to display a message on the page. So the shortcode no longer has any side-effect.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘[Plugin: Link Library] conflict with Simple Facebook Connect’ is closed to new replies.