Found some PHP that promises to do a thing in WordPress? Lots of guides will say to paste it into your functions.php file in your theme, but there are a lot of potential hazards with that approach. Instead, slap it into a PHP file with this format:
Plugin Name: Blank WP Plugin
Plugin URI: http://abbysdoor.com
Description: Blank Plugin Template
Author: Abby Langner
Author URI: http://abbysdoor.com
License: GNU GPL https://www.gnu.org/copyleft/gpl.html
…and, ta-da! You have created a WordPress plugin. You can upload that baby directly to your wp-content/plugins directory, or you can zip it up to use the Dashboard uploader.
Want to build something a little more robust with good practices? Try the WP Plugin Boilerplate Generator.