There is my first WordPress Widget – PHP Text – Text Box which accepts arbitrary PHP code and can execute it inside sidebar block.
Another requirement is that it is only be allowed to be entered by Admin User.

I have started with the original code for Text Widget and adjusted it to include such restriction.

It has superseded my IFrame solution discussed in prior post and works well except that CSS is not yet applied.

What has been demonstrated by this little project:

  • how to register your own sidebar widget
  • how to support multiple instances of the same widget in the sidebar
  • how to manage widget options from popup options window in Widget  Manager section of your Blog Admin Panel
  • how to store/read widget options
  • how to make your widget properly appear at the sidebar
  • implement some basic user rights manager

If you’d like to use it in your blog, source code is available here – WordPress PHP Text Widget.

I hope this little example would help you started with Plug-in development for your WordPress Blog.

WARNING: Any code injections allowed by dynamic content comes with possible security risk. Please be cautious about what you allow to be executed by the PHP code specified in the widget. I would strongly suggest avoiding use of external sources you have no control over.


0 Comments

Leave a Reply