0

I'm developing a WordPress plugin, but the last changes caused the plugin to stop working. It tells me that I can't activate the plugin because it caused a fatal error. On localhost all is working fine, but after sending to the server, on activation it displays the following:

Can't use function return value in write context in /data/web/virtuals/72282/virtual/www/wp-content/plugins/wp-songbook/inc/wpsongs-shortcs.php on line 83

I really don't understand the context of this message, because the code of this line is:

$ytlink=(isset(get_post_meta(get_the_ID(),'songbook_video_link')))?get_post_meta(get_the_ID(),'songbook_video_link'):false;

Can anyone tell me what's happened?

closed as off-topic by Mark Kaplun, Pieter Goosen, birgire, gmazzap, Johannes Pille Sep 15 '14 at 18:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – Mark Kaplun, Pieter Goosen, birgire, gmazzap, Johannes Pille
If this question can be reworded to fit the rules in the help center, please edit the question.

1

The root of the problem is that isset expects a variable to be passed to it. Also, I'm assuming that you expect the get_post_meta() to return a scalar value and not an array, so I added the third parameter set to true.

// 3rd param: $single. Value of true means get scalar value, not an array.    
$ytlink = get_post_meta( get_the_ID(), 'songbook_video_link', true );

// Will ensure that $ytlink is boolean false, and not an empty string.
$ytlink = ( ! empty( $ytlink ) ) ? $ytlink : false;
  • Sorry, Ive tried to use your code, and got this message (only on domain): The plugin generated 573 characters of unexpected output during activation. If you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin. – user1980807 Sep 14 '14 at 11:12
  • No Problem. That code snippet does not generate any output, so it's not the culprit. Can you please post your code? – Dave Romsey Sep 14 '14 at 18:49
  • I explored, that the trouble was by wrong activation hook function, that returned something... Thank you for help :) – user1980807 Sep 15 '14 at 17:21

Not the answer you're looking for? Browse other questions tagged or ask your own question.