# WordPress Plugins, Development Planning for New Developers

- Link: https://cagrimmett.com/2016/03/01/wordpress-plugins/
- Published: 2016-03-01T05:00:00-05:00
- Author: Chuck Grimmett

## Today I learned:

### Development planning for new developers

Philosophies like Agile Development are great for teams working on large projects,
but for someone just getting started with development and working on small projects,
they can be a little much. For situations like this, [Readme Driven Development](http://tom.preston-werner.com/2010/08/23/readme-driven-development.html)
strikes the right balance of planning out your project, writing documentation, and
actually doing the work.

Write your Readme first! (H/t to [Eric Davis](http://til.ericdavis.org) for telling
me about this.)

---

### WordPress Plugin Basics

I have a [food & drink website](http://cooklikechuck.com) where I post regularly.
Lately I’ve been trying lots of kinds of coffee to dial in my ROK Espresso maker
and I’m starting to reach the limits of how many I can accurately remember. I’ve
been wanting to make a WordPress plugin for a while, so why not make a plugin that
makes a Coffee Reviews [custom post type](https://codex.wordpress.org/Post_Types#Custom_Post_Types)?(
The main goal here is to write my own plugin and learn how it is done, so please
don’t suggest already made plugins that I could use.)

I’m using WordPress’s [Plugin Handbook](https://developer.wordpress.org/plugins/)
to learn the basics.

#### Barebones

The most basic WordPress plugin is a PHP file with a plugin header comment. Here
is mine:

    ```php
     /* Plugin Name: Coffee Reviews */
    ```

You’ll eventually want a lot more in the header. [Here are the requirements](https://developer.wordpress.org/plugins/the-basics/header-requirements/).

#### Hooks

Hooks allow you to tap into WordPress without editing the core files. (Rule #1 is
to never edit the core files.) You pass functions through hooks to extend or change
WordPress functionality.

The `register_activation_hook()` runs when you press “Activate” on a plugin. Since
I’m making a custom post type, I’ll want to use the activation hook to refresh permalinks
once the post type is created. If your plugin needs a custom database table, you
can create that with a function passed to this hook.

The `register_deactivation_hook()` is basically the reverse of the activation hook.
When you deactivate the plugin, the items passed to this hook fire. I’ll want to
clear the permalinks again.

I made a barebones plugin tonight that registers the custom post type. I definitely
have more work to do, but saving, hitting refresh, and seeing this appear never 
gets old!

![barebones plugin](/img/plugin.png)
