PHP Snippets
Minor bug report (2 posts)

  1. shazdeh
    Posted 3 years ago #

    Shortcodes must return values, not echoing them directly. So when you do "You know, today is: [current_date]. Awesome!" first you see the current_date and then the text.
    The solution is rather easy, I modified the __call function in includes/PHP_Snippet.php:

    public function __call($name, $args) {
    	// get the file by name
    	if (isset($this->snippets[$name]) && file_exists($this->snippets[$name])) {
    		$file = $this->snippets[$name];
    		include $this->snippets[$name];
    		$content = ob_get_clean();
    		return $content;
    	else {
    		die('file does not exist: ' . $name);

    BTW, I love the idea of the plugin.


  2. fireproofsocks
    Plugin Author

    Posted 3 years ago #

    Whoops, just saw this now... I guess I wasn't subscribed to updates.

    Yeah, I've been thinking about that -- it's a good point. But that's why we're in beta heehee. Man, I wish ALL of WP returned values instead of printed them.

    You can file bugs and feature requests @ http://code.google.com/p/wordpress-php-snippets/issues/list

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • PHP Snippets
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic