WordPress.org

Ready to get started?Download WordPress

Forums

PHP Snippets
Minor bug report (2 posts)

  1. shazdeh
    Member
    Posted 2 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];
    		ob_start();
    		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.

    http://wordpress.org/extend/plugins/php-snippets/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 2 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

About this Topic