Blog

Make WordPress Plugins in One Step

make wordpress pluginSometimes it’s smart to make WordPress plugins for yourself.

We make WordPress plugins while developing custom websites often, and for a lot of reasons. The number one reason to make WordPress plugins is so that we can mange non-theme based functional enhancements to WordPress.

What’s a example?

Say, for instance, a website uses Gravity Forms. A Gravity Form is being used as an opt-in near the bottom of a long page. When a user submits their email, they get sent to the top of the page. (The site does not have AJAX enabled for some reason.)

The solution is quite easy to find:

//* Make Site Scroll to Gravity Form Confirmation On Submit
add_filter("gform_confirmation_anchor",
create_function("","return true;"));

We could throw the snippet in the theme functions.php and be done with it. But when or if the website gets a theme swap it will loose the customization. If the long page and form still exist, then the poor UX problem will crop up again and someone has to go look up the solution. Equals wasted time.

So make WordPress plugins!

If the function is called to WordPress via a plugin, it will persist through a theme change.

All that you need to do:

  1. Create a directory in your wp-content/plugins folder (really, this is optional – it just keeps things tidy) called whatever you want. A good name may be “custom-functions”
  2. Create a php file in your new directory. Perhaps: custom-functions.php
  3. Edit your custom-functions.php. Enter this code (only the plugin name is required):
<?php
/*

Plugin Name: Plugin Name
Plugin URI: Your website!
Description: Describe what your plugin does!
Author: Your name!
Version: 1.0
Author URI: Your profile!
License: GPL2

*/

 

/* THE FUNCTION GOES HERE*/
//* Make Site Scroll to Gravity Form Confirmation On Submit
add_filter("gform_confirmation_anchor",
create_function("","return true;"));

 

?>

Thats it. Your make WordPress plugin sojourn has ended. You should be able to find your new plugin via the WordPress dashboard. After you activate it, the desired custom function that you added should take effect!

What’s Next

Our Work

Check out some recent work we’re proud of.

Our Blog

Read our latest ideas about tech, features, messaging, and more.

Get in Touch

Want to discuss a project? Hit us up, we’d love to chat!