I have just created my first WordPress widget ("hello world" style) and was able to display it correctly. But what I notice that if I change my theme then my created widget disappears from available widget area in admin panel; though there are many widgets which are always showed regardless of chosen theme (Like Text widget). I want to know how can I make my widget available across all the themes?
Put all your custom widget code into a separate php file, add a plugin header:
<?php /** * Plugin Name: Name Of The Plugin * Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates * Description: A brief description of the Plugin. * Version: The Plugin's Version Number, e.g.: 1.0 * Author: Name Of The Plugin Author * Author URI: http://URI_Of_The_Plugin_Author * License: A "Slug" license name e.g. GPL2 */
then upload it to your plugins directory and activate it. That's it!