A WordPress functionality plugin sometimes called a site plugin is a special plugin designed to host theme independent code snippets that extend and customize the features of WordPress.
Most WordPress tutorials instruct you to place custom code snippets into your theme’s functions.php file. Unfortunately, this is not always optimal. Instead you should only place theme specific functionality into your child theme’s functions.php file. Not code that is theme independent.
- Stop users from being able to edit files from within WordPress admin panel
- Add the ability to use shortcodes in widgets
- Prevent WordPress from compressing images
- Limit the number of post revisions
- Remove items from the head section
- Disable XML RPC
- Remove clutter from main dashboard screen
- Remove unwanted core widgets
- Add superscript and subscript to Tiny MCE editor
- Disable all traces of emoji
- Go to GitHub and download plugin
- Go to your WordPress website admin panel
- Select Plugins > Add New > Upload Plugin
- Select Browse > locate on your computer the file “ez-functionality-master.zip” > Click Open > Install Now
- Click Activate Plugin
Fork the Plugin
Features you might want to add to my EZ Functionality plugin include:
- Integrate my EZ White Label WordPress plugin into this plugin
- Include other code you’ve already written and host in your theme’s functions.php file
Why Use a Functionality Plugin?
I can think of several reasons:
- To avoid the the WordPress White Screen of Death. Have you ever copied a piece of code found in a WordPress tutorial, hit save and then found yourself staring at a white screen? I have, and chances are that you have too. For this reason alone, it’s worth considering the use of a WordPress Functionality plugin.
- To allow the website to change themes without losing overall website functionality.
- Example 1: You have a photography website and you used a code snippet that prevents WordPress from compressing your images upon upload. Just because you decided to change themes doesn’t mean you no longer want to prevent WordPress from compressing your images, right?
- Example 2: You decided to set WordPress post revisions to 5. If you placed that code snippet into your theme’s functions.php file and changed themes you will lose that functionality. But if you used a WordPress site functionality plugin, the settings are preserved.
Remove ‘Editor’ from ‘Appearance’ Menu
This stops users and hackers from being able to edit theme and plugin files from within the WordPress admin panel.
define( ‘DISALLOW_FILE_EDIT’, true );
Add the Ability to Use Shortcodes in Widgets
Many times we will want to execute a shortcode from a text widget. Out of the box WordPress does not allow you to execute a shortcode in a text widget. The code below makes it happen.
add_filter( ‘widget_text’, ‘do_shortcode’ );
Prevent WordPress from Compressing Images
Imagine you have a photography website and you tediously tweak your images before posting them to your WordPress website. Out of the box, WordPress will compress your image to 90% of it’s original file size. Most people would be okay with this, but not photographers.
add_filter( ‘jpeg_quality’, create_function( ”, ‘return 100;’ ) );
Limit the Number of Post Revisions
By default, WordPress will keep an unlimited number of post revisions. We choose to limit our revisions to 5. Simply change the number 5 within the function to whatever you prefer and you’re all set. Do not change the number 10 found in the filter.
add_filter( ‘wp_revisions_to_keep’, ‘wpcc_set_revision_max’, 10, 2 );
$num = 5; //change 5 to match your preferred number of revisions to keep
Remove Items From <head>
Remove more code bloat from WordPress.
remove_action( ‘wp_head’, ‘wp_generator’ );
remove_action( ‘wp_head’, ‘wlwmanifest_link’ );
remove_action( ‘wp_head’, ‘rsd_link’ );
remove_action( ‘wp_head’, ‘wp_shortlink_wp_head’, 10, 0 );
remove_action( ‘wp_head’, ‘adjacent_posts_rel_link_wp_head’, 10, 0 );
The example plugin we detailed should get you moving along the way of separating code logically and efficiently. Take the code and tweak it for your specific needs.