Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
I can't get PremHide to work
supaloopa
New
This is the type of plugin Im looking for but unfortunately it's not working correct on my forum. Every comments and discussions are hidden if Im not logged in. Im using Version 2.0.18.8.
Also is it possible to change the code to ?
0
Comments
To help other Users who will look into this, do you mean that all content is hidden, regardless of the fact that it's wrapped in a premhide tag or not?
That's definitely possible, but I reckon you would have to modify the plugin. By the way, the correct tag is
prem
, notpremhide
.My shop | About Me
@businessdad thanks did not catch they were using wrong tags! Thanks. I didn't use "hide"tag to avoid conflicts, but as you mention people can change as needed easily!
If OP wants blurred image, on content,above tags that will take a lot more work, so I suggest a generic blurred image.
@adriansonline I'm not sure that @supaloopa used the wrong tag, he might have typed it wrong when he posted the message. Regardless, the plugin should still "behave" if wrong tags exist in the content.
Out of curiosity, I had a look at the code and I found a couple of issues, perhaps you might be interested in looking into them:
preg_replace_callback()
incorrectly. The callback you pass is not a valid one, and a warning is raised (although it's probably hidden by Vanilla). You should replace the function withpreg_replace()
./< prem>/
, is correct (note: space after opening angle bracket has been added to allow this forum to display it). I believe that~< prem>(.*?< /prem>~
should be used instead.My shop | About Me
@businessdad as you note the plugin works by searching for "prem" tag and replacing content. It may be that when OP used "premhide" it added the message but did not replace the content. I'll review your other suggestions and update accordingly. I'm self taught PHP so sometimes I pick up bad habits
Okay @businessdad made change to the pattern, but plugin does not work without callback, though, so I am open to other suggestions.
Yes all content is hidden. I might've made a mistake on using the wrong tag, but either way all content is hidden just by enabling the plugin.
Can you upgrade to the new version uploaded and can you use the right tag? Can you also pm me your site so I can look it further as I cannot replicate your issue
I'm not sure what you mean with that. If you use
preg_replace
you don't need a callback. Anyway, you can't passarray($this)
as a callback, as it's not a valid callable.My shop | About Me
If I don't use preg_replace_callback the plugin stops working, that is what I meant. As for not a valid callable, I'm not 100% sure what you mean.
@adriansonline Ok, then this is an issue, because the plugin seems to work, but it's not clear why. I would strongly recommend debugging it and replacing
preg_replace_callback()
withpreg_replace()
, as I suggested, and using the regular expression I posted above.About the "callable"
I posted a link that describes it in detail. A valid callable can have several formats. The most common ones are a simple function name (i.e.
'MyFunction'
) or an object method, passed as an array (i.e.array($SomeObj, 'SomeMethod')
). That is, you cannot just pass an array likearray($this)
, as it's not a valid callback. It works by coincidence, but it throws a warning.If you enable the Debug plugin in your Vanilla, which, if I'm not mistaken, treats warnings as errors, you will probably get an error and the forum won't work anymore.
My shop | About Me
@Businessdad I think I will put a message until I figure how to make it work properly. Thanks for the tips
you are lucky it worked at all
/<prem>(.*?</prem>/
is not a valid pattern. How the hell it work, probably isn't worth getting into, but it will have the change, becuase you can't expect this to work, and won't in most 'sane' cases.I presume you mean
/<prem>(.*?)<\/prem>/
note the closed parenthesis, and the escaping of
/
or easier written as
#<prem>(.*?)</prem>#
grep is your friend.
@x00 it seems I have made an error completely. The pattern does not matter as it seems all content is hidden when users are not logged in regardless of shortcode. I think I'm down the rabbit hole a bit further then my PHP/Vanilla skills can help. I need to rethink this. Obviously there is a need for it, so I will try to figure it out. Thanks for the tips @businessdad as well. Lots to learn & consider
edited: since you solved it.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I think I got it working! @peregrine, you helped me with an earlier question to Tim I had found. I was using your login to debug without seeing your post--but your post did confirm I was on the right track. So now it seems to work.
Yes you are not pre-parsing it correctly, so it will be stripped by HtmLawed as an invalid tag.
However you are using a hook which is before the main formatting, so if you get the pattern matching right it should work.
I think you pattern will also struggle without modifiers depending on the content between the tags.
grep is your friend.
The general principle would be
grep is your friend.
for the pattern I’d use
#<prem>(.*?)</prem>#si
http://php.net/manual/en/reference.pcre.pattern.modifiers.php
grep is your friend.
works for me, easier than using preg_replace_callback - which is a bit of overkill since not much is being done in a callback function.
nice @x00
re if you actually need callbacks in vanilla tip:
http://vanillaforums.org/discussion/comment/165351/#Comment_165351
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.