Skip to content

Instantly share code, notes, and snippets.

Created December 31, 2015 10:25
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save glueckpress/891029f69f1adcea4f15 to your computer and use it in GitHub Desktop.
Save glueckpress/891029f69f1adcea4f15 to your computer and use it in GitHub Desktop.
[WordPress][WP Rocket] Boilerplate for a custom functionality (MU) plugin.
* Plugin Name: Your Custom Functionality Plugin
* Description: Short description of your plugin here.
* Author: your name here
* License: GNU General Public License v3 or later
* License URI:
// Basic security, prevents file from being loaded directly.
defined( 'ABSPATH' ) or die( 'Cheatin&#8217; uh?' );
/* Prefix your custom functions!
* Function names must be unique in PHP.
* In order to make sure the name of your function does not
* exist anywhere else in WordPress, or in other plugins,
* give your function a unique custom prefix.
* Example prefix: wpr20151231
* Example function name: wpr20151231__do_something
* For the rest of your function name after the prefix,
* make sure it is as brief and descriptive as possible.
* When in doubt, do not fear a longer function name if it
* is going to remind you at once of what the function does.
* Imagine you’ll be reading your own code in some years, so
* treat your future self with descriptive naming. ;)
* Pass your custom function to the wp_rocket_loaded action hook.
* Note: wp_rocket_loaded itself is hooked into WordPress’ own
* plugins_loaded hook.
* Depending what kind of functionality your custom plugin
* should implement, you can/should hook your function(s) into
* different action hooks, such as for example
* init, after_setup_theme, or template_redirect.
* Learn more about WordPress actions and filters here:
* @param string 'wp_rocket_loaded' Hook name to hook function into
* @param string 'yourprefix__do_something' Function name to be hooked
add_action( 'wp_rocket_loaded', 'yourprefix__do_something' );
* Define your custom function here.
* This example just returns true.
* @return bool Boolean value TRUE
function yourprefix__do_something() {
return true;
Copy link

Isn't this file missing a closing of the php-code like this?:


Copy link

No. In pure php files the closing tag should be omitted. See:

If a file is pure PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment