Quick easy make a WordPress Plugin – level 1

Quick easy make a WordPress Plugin – level 1

Ever thought to make a WordPress Plugin, I mean your very own one?

Quick easy make a WordPress Plugin – level 1

Well at first you might think, c’mon man, this stuff is for the PRO’s, requires lots of coding and deep knowledge of php, MySql, JavaScript, CSS and so on…

In truth, yeah, if you want something great, than it take great skills, however, if you just want a simple one and you want to try what it feels to make and install your very first “ultra simple plugin”….than this article might be just what you need to read.

So for today’s tutorial, we’ll start our journey in to developing bespoke plugins, with a very easy one, so that you can get accustomed with what it takes and what it is really like to make a WordPress Plugin.

I had many ideas of what to do but I had to scrap them and thing again, I did not want to get too much into the difficult zone. Finally, I decided to make a very simple one that adds the copyright text on the footer of your WordPress website. This is a n easy one to make and is perfect for a beginner, so let’s get on with it!

Make a WordPress plugin that adds your copyright text on footer

To create a WordPress plugin that adds a copyright credit to the footer, you will need to follow these steps:

Step 1

Create a new folder in the wp-content/plugins directory of your WordPress installation, and name it something like “copyright-credit”.

Step 2

Inside the folder, create a new file called “copyright-credit.php”. This file will contain the code for your plugin.

Step 3

In the copyright-credit.php file, add the plugin header information at the top. This will include the plugin name, plugin URI, description, version, and author information. Here is an example:

<?php

/*
Plugin Name: Copyright Credit
Plugin URI: http://www.yourwebsite.com/Copyright_Credit
Description: This plugin allows users to add their social media links to their profile.
Version: 1.0
Author: Your Name
Author URI: http://www.yourwebsite.com
*/

Step 4

Next, you will need to define a function that will output the copyright credit. You can do this by adding the following code to the plugin file:

<?php

function display_copyright_credit() {
echo 'Copyright © ' . date('Y') . ' Your Website';
}

This function will output a copyright credit in the format “Copyright © [current year] Your Website”.

Step 5

To add the copyright credit to the footer of your website, you will need to hook the function to the wp_footer action. You can do this by adding the following code to the plugin file:

<?php

add_action('wp_footer', 'display_copyright_credit');

Watch FREE Internet TV and Listen FREE Internet Radio with dp - IPTV and Radio

Step 6

To center the copyright credit in the footer of your website, you can add some CSS styling to the output of the display_copyright_credit function.

First, you will need to wrap the output in a div element and give it a class name, like this:

<?php

function display_copyright_credit() {
echo '<div class="copyright-credit">Copyright © ' . date('Y') . ' Your Website</div>';
}

Next, you can add the CSS directly to the display_copyright_credit function using the wp_add_inline_style function, like this:

<?php

function display_copyright_credit() {
$css = '.copyright-credit { text-align: center; }';
wp_add_inline_style( 'your-theme-style', $css );

echo '<div style="text-align: center;" class="copyright-credit">Copyright © ' . date('Y') . ' Your Website</div>';
}

Step 7

So your final copyright-credit.php file should now look like this:

<?php


/*
Plugin Name: Copyright Credit
Plugin URI: https://danielepais.com/journal
Description: This plugin adds a copyright credit to the footer of your website.
Version: 1.0
Author: Daniele Pais
Author URI: https://danielepais.com
License: GPL2
*/

function display_copyright_credit() {
$css = '.copyright-credit { text-align: center; }';
wp_add_inline_style( 'your-theme-style', $css );

echo '<div style="text-align: center;" class="copyright-credit">Copyright © ' . date('Y') . ' Your Website</div>';
}

add_action('wp_footer', 'display_copyright_credit');

Step 8

Finally, you will need to activate the plugin in the WordPress admin dashboard. Go to the Plugins menu and find the plugin listed there. Click the “Activate” link to activate it.

your brand new plugin installed and activated

That’s it! Your plugin should now be adding a copyright credit to the footer of your website. Next week we will come back again with this topic (make a WordPress plugin), I am still deciding what sort of plugin it will, I have a few in mind but I haven’t come up with a decision yet.

Here is how your new plugin looks from the front end

One thing is for sure though, as you are now officially a junior WordPress Developer, we will step up a notch on the next one.

Share
Share
Website maintenance by: dp