Anyone see any problems?
What you have done doesn't create a sidebar panel in the backend at wp-admin->Widgets (I tested it) so you can't really use your sidebar like a widgetized sidebar anyway. You'd have to programmatically add widgets to your sidebar, but if you are going to be doing that why bother with the sidebar at all? Why not just add the markup you want at the top of your post content and be done with it? I don't understand the need for this overhead.
Yes, shortcodes wouldn't work because you have short circuited the filter process. By echoing $content
instead of returning it you are interfering with the rest of the filters that should be running before the content is finally echoed. do_shortcode
is not the only one that you'd need to replace, but don't do that, just return $content
.
Echoing inside the filter seems to work but I wouldn't rest too easily. There are ways that could go wrong. I'd worry about someone doing something like this:
$content = get_the_content();
$content = 'abc'.$content.'def';
$content = apply_filters('the_content',$content);
Imagine somebody does that early in the page load, maybe even before the headers are sent? (Possibly to use the content as a meta description or something?) Your content is echoing at a very wrong place. It could break attempts to get content over AJAX as well. JSON is very picky.
Other things that come to mind...
If you echo content rather than return it you are are essentially breaking any other hook to the_content
.
It is also possible that some other plugin could hook before yours and echo something even earlier, probably violating your intentions and making a further mess of design.
I won't get into whether you should insert a sidebar before the content but I am fairly sure you should not do it this way.