WP: exec-php & scheduled posts... Anyone came across this problem?

Status
Not open for further replies.

LazyHippy

New member
Apr 9, 2007
3,448
21
0
I'm gonna post on the forum for the exec-php plugin, but thought I'd throw it out here first in case anyone has came across something similar...

Basically when WP posts a scheduled post (created from an imported XML file) it strips part of the php code.

If the post is edited in any way after the import it seems fine.

Here's an example:

Code:

Code:
<?php
echo str_replace('>', ' width=200 height=200>', "<img src='[URL]http://farm4.static.flickr.com/3170/2987975152_e6bc375692.jpg[/URL]' alt='World's most famous zebra crossing'>");
?>
Becomes:

Code:
', ' width=200 height=200>', "<img src='[URL]http://farm4.static.flickr.com/3170/2987975152_e6bc375692.jpg[/URL]' alt='World's most famous zebra crossing'>");
?>
It's removing <?php echo str_replace('> (and also encoding some stuff - which I don't think is a problem).

I've got a feeling it might be something to do with user permissions, but not sure really. Just gonna try with double quotes all the way, see if that makes a difference.

Any help gratefully appreciated! Cheers.
 


Silly question first - do you have the WP visual editor on? In the Users panel.

That should be off if you are using exec-php. Maybe that is why it tries to escape the markup.

Another thing I notice is your code,
Code:
echo str_replace('>', ' width=200 height=200>', "<img src='http://farm4.static.flickr.com/3170/...e6bc375692.jpg' alt='World's most famous zebra crossing'>")
You have some unescaped characters in there as well, which might cause a PHP error when the code is executed. E.g. in the alt tag.

I'd rather make it like so:

Code:
echo str_replace('>', ' width=200 height=200 />', '<img src="http://farm4.static.flickr.com/3170/...e6bc375692.jpg" alt="World\'s most famous zebra crossing">');
I also self-closed the img tag in the above, hence the /> closing tag.

Maybe this helps?

Edit: Even cleaner code (IMO) would be not echoing the str_replace function, but writing it to a variable and echoing the variable in a next step. This is unrelated to your question though :)
 
Silly question first - do you have the WP visual editor on? In the Users panel.
That was my first thought too when I read the post. Try turning off the wysiwyg editor under the user name you post as.

I upload csv's with html in them and if I have it turned on it either strips the code or it just shows up as gibberish.
 
Last edited:
Cheers for your advice.

Visual editor has been off from the start... I might be a bit dumb but not quite that stupid.. I did read the docs before posting here! (and there's also the big warning saying turn it off when you go to post...!)

The reason the code is sloppy is because it is posted via DataPresser. It has a hook to pull images from flickr which uses single quotes around the url, so it will work with double quotes around the image tag, but I can't change what's inside the tag without using php (which is getting fucked up with scheduled posts). Sorry, I should've made that clearer.

I'll try writing it to a variable, can't see how that might affect it but worth a shot.

Probably wasn't the best example, even without any non alphanumberic characters in the alt text it's still breaking the php... but only when it posts a scheduled post.

I'll try more stuff, but as I can't control when it posts and even just editing the post time seems to cure the problem (argh.. why?!) it's going to be a long process I think.
 
It was worth a shot with the visual editor... I had forgotten that it reminds you with a huge message on top. lol.

Anyway - I'm not familiar with DataPresser, but if you look at the code, it will have an output function somewhere. The part where it writes the results into the database. You could modify that part, or alternatively just use str_replace() on it to replace the single quotes with double ones.

I'm also not sure why this only happens with scheduled posts. My assumption is that a post is a post in WP, whether it is being published immediately or at a later time. I'm quite sure that this is a flaw of DataPresser, i.e. sloppy coding. Isn't that a subscription service btw? You should ask for their support, and they should provide. Or at least try to and assist you. I mean - they release a software which doesn't work. They should have accounted for this case in the first place.

Go kick some a** over there.
 
Status
Not open for further replies.