Skip to content

Howtoo: make a WP Plugin.

Now, .. first off, .. none of this PHP coding stuff found here is mine, but in reading the various articles on the matter of plugins: then I kinda’ figured that it could be made a lot easier for the many Noobs out there, of whom I consider myself to be a foundling member of that exclusive camp.


This tutorial will force the internal WordPress editor (tinyMCE), to use the Verdana font as it’s default, and from there: the sky’s literally the limit in what you can get the editor to do, and in fact, WP itself.
And no!
– To make it perfectly clear from the outset: we are *not* talking about that general fuck up called Guttenberg, we are in fact addressing what you can do with the normal classic editor here.


WARING: Also, you can really fuckup your website big time in playing with this shit; so make a fucking well sure that you have a backup of your WordPress site **before** you bloody well start.

I actually get a bit pissy when I see these sensible obstructions to the good stuff, so for all you manic kamikazes out there, ..


1.) — Jump Past the BackUp BS.


For the sensible amongst you, here’s a link to a half decent free backup plugin called WPvivid.

** The programs basic running mode and operation is very good, and after a simple WP install: it is a straight forward series of click click clicks, and then click backup done.

All-in-all, it takes about five minutes, but be aware that the basic backup lite version, (only gives you one location), to save your sites backup zip file(s) in: of which one is your WordPress Installation folder itself.

** Not good on several fronts.

    1. It will add to your overall storage, ..
    2. Doing that is kinda’ like shooting yourself in the foot before setting off for a nice quiet ramble in the countryside.
      1. ** Yes, you can still walk and talk and amicably say hello to all you meet on route, but why would you hobble yourself like that?

In other words, if the WordPress directory gets blown up by terrorists and ultimately corrupted by the flying shrapnel, then you’ve lost all of your precious backups as well. Yes, .. you can still rebuild them from snippets, but you won’t be amicably chatting and nodding whilst also running a marathon anytime soon.

So if at all possible during your click click clicking; then at least save the resulting zip file(s) to your Google Drive or DropBox or Sync offsite backup service, they’re all free to use.

** 0.) I’m not including that total screw-up called OneDrive, because it simply ain’t worth it with it’s constant cross indexed file issues, that it does all the time btw in the background. Use that piece of Mickysoft software mess at your peril, and never rely on it for any of your important stuff.
– And now with a sense of decorum, we will impassionedly review the rest.

    1. DropBox, you are a tight arsed bunch of fucking old has-beens’, who are still restricting your offline storage to a paltry two gig allowance, and to add insult to injury; the poxy dick-wads in charge, have now reduced the install accounts to only three machines, that said: it’s easy to setup and use.
    2. Google Drive is OK with its offering ten meg, but is under the purview of the CIA, so be fucking very pissin’ careful of what you put in there. Not so easy to use and set up, but a good offering.
    3. Sync is Canadian owned, and as such they can’t be got at by the CIA: you also get 5 gig of free storage space, which ain’t half bad.
      ** Out of all of them: they are the best provider, and like drobox and google before, setting up your online account is simplicity itself.

But even with all of their limited offering and weird restrictions, you really haven’t even got an excuse for not backing up your WP installation off-site.


[ Jump Point Zero on Needing (no) Backups. ]


We ain’t quite there yet in proceed any further this raggedy arsed fonting run-through tutorial, because you also need access to your website root folder via an FTP program.

  • And getting one is fraught with problems these days.

2.) — If you’ve got a FTP program to hand, then jump straight to the guts of this NOOBIE Font Tutorial here.


Not got one? .. My advice is to move very *cautiously* when you download a FTP program from the web. From what I’ve discovered quite recently, then I can tell you that they ain’t all created equally, nor are they all supported equally either.

FileZilla is the most popular one out there and very works well, but with a serious proviso attached.

** The link I’ve provided: only points to the general (zip and exe file) download directory, and specifically isn’t directing you to the developers Home Page; that I urge you not to visit, nor even download any of the offerings held therein.

The Home Page version has a virus adware program included in it called fusion.core, (which is a PUP.)
– The added offerings: that you accepted when you clicked [[accept to the terms and conditions,]] are all contained inside the main FTP EXE installer itself.

** Shock horror, stop the presses: the inclusion of the added value viral PUP, is also officially sanctioned and heavily endorsed by the author(s) themselves. (What is the world coming to?)


A quick run through on installing the FTP Program to your machine, ..

Firstly, .. only download the ZIP file from the main FileZilla download page, and nowhere else.

Secondly, .. open (extract), the said ZIP file in your Download directory, or wherever it was that you downloaded it to.

Thirdly, .. go into the folder, (directory), and find the file called filezilla.exe — double click on it, BOOM! – The FTP program runs without any sort of installation being performed.

** I’ve personally moved the extracted directory on my machine to “C:\Program Files\FileZilla”, and from there; set up a shortcut to the filezilla.exe program to be placed on my desktop.
    “-\_(‘v’)_/-” Then all I have to do is simply double click on that shortcut, and we’re cooking on gas, .. Man!


SO! — With the FTP program installed, then you’ll be able to access your website’s root path with it.

** And to do that very very very very simple thing, (ho-ho-fucking-ho!), then you’ll also need these three bits of info to hand, ..

    1. The ftp path name to your site, ..
    2. The ftp username of your site, ..
    3. And the ftp password of your website.

Please be aware that you can’t go any further without them, and that’s on any tutorial that you find out there on the web.


Noob: as the paying registered user of your own website, you can get these bits of info from your Internet-Web-Provider.
    {{_\(*v*)/_}} In actual fact, they should have provided you with them when you initially set up your new domain.
    {{_/(-v-)\_}} As the website’s Admin account holder, you could also try hunting around in your providers control panel: that they should have given you access to when you initially set up your own WordPress site.


FTP in use, .. run the program on your machine, the left hand window will show you your local machines file structure: with the right hand window being blank, it’s normal.

  • Right, now click the picture provided below to enlarge it. The image will show you in great detail: just where the ftp information needs to go in the FileZilla input boxes.

Once the info is entered, and the [quick connect] dropdown is pressed: then the connection is practically instantaneous, .. with the right hand window now showing you your severs root files, and if it isn’t; then you know that you have a problem.

In the right hand window you can poke around your webserver file system to your hearts content, but for god’s sake newbie, don’t delete anything until you know what you’re doing: especially that file called .htaccess, consider it to be out of bounds: forever!

** A running no-no note: You can, (theoretically), use your web providers built in control-panel to manipulate the files on the website’s server, but it’s bloody hard work editing them, and also moving them around if you have too, and you inevitably will have to move some files at some point.

Noob: my advice is to get an FTP program from the outset, and also learn how the bloomin’ thing works, yes: they can be daunting, but eventually the, ..
Left hand [ local-site ], ..
And right [ remote-site ], ..
Panels will make sense. God’s honest true here, it’ll make it a lot easier for other projects that you’ll eventually undertake, .. now: off you go and sort it out.

    • It’s alright, I’ll wait.

Final Jump Point.]

That’s dutifully gone past the Backups and FTP install stuff, and after all that: here it is, the nitty gritty good shit.


The goodies, .. right: making a WordPress Plugin really is dead easy, but every tutorial that I’ve ever read about the process; then goes into a great deal of technical depth and infinite mindboggling detail about (what) goes (where), and does it in fine high class sounding words like [[your plugin folder]], or your [[root directory]] for that, ..
– And in all that clever waffle, they never actually just simply (show) the befuddled noobes (what) actually goes (where), so here it is: the physical layout of (where) a new Plugin actually goes in your WordPress website.

The image above, shows the bog standard file structure of a bog standard WordPress website install, and right off the bat they all look the same.

I’m currently using the Author theme, and it’s the one that’s highlighted. I also have the twentyfourteen theme installed as well: that I could select in the Customizer should the whim take me, but it won’t.


Moving back up the root structure, and shown above; is my WordPress Plugins folder, with all of my own installed Plugins dutifully listed, .. obviously yours will be vastly different.

What we need to understand next, is the role of your own website’s Plugins folder, which in my day was called a (directory) btw.

Here, inside this *directory*, is where you place your own newly created Plugin folder, along with its attendant PHP files, but more of that later.

Again, all WordPress websites are the same in this respect of their internal file layouts, with the public_html/wp-content folder having the themes and plugins folders contained inside it.

** As well as other directories, but we don’t need to discuss them at all.


Here’s how plugins work:-

Now, .. the very existence of your new Plugin folder, makes the WordPress software process all the files that it finds inside the sites “Plugin” directory itself: whereby it then builds up a list of all of the (your) plugins shown in the backend menu Plugins listings, ..

** And the software does this every-flippin-time you select the Plugins link on your Admin backend.


Making your Plugin, .. here we go.

Think of a name for your plugin folder to go on your local machine, make it weird in case of other Plugins having the same name: not a good scenario btw, and guaranteed to fuck up your site somewhat.

I’m gonna’ use mjs-mega-ultimate-plugin as my weird directory (folder) name.

So, .. with your ordinary file manger on your local machine: make a directory called ‘mjs-mega-ultimate-plugin‘.

Go inside it, and then make a text file with your common garden text-editor, and name it for example: ‘my_additional_functions.php‘, but keep in mind that you can call it what you want.

Inside the file put this:-

[ BTW it’s OK to cut and paste the included text. ]

But please keep in mind that [‘] [“] and extra spaces could cause errors, especially if their not in the standard ASCII character format, (in other words), they can’t be in the nice looking swept back and forward style (quotes) “” ” — that some posh text editors offer.

** Attention:- you also need to change the text words ( ??? xx ???  ) to reflect you own name, and additionally your own website’s name: cos it shows up later in the Plugin listings.
          >> By-the-By, you also don’t need to include the question marks (??) – they are just there to get your attention.

<?php
/*
Plugin Name: My Extended Functionality Plugin.

Description: This is where I'm going to put PHP code to basically extend the functions.php file, but without having it overridden when my theme gets updated.

Version: 0.1

License: GPL

Author: ?? Your Name ??

Author URI: ?? Your website's name. ??
*/

add_action( 'after_setup_theme', 'change _editor_font' );

echo '<style>body#tinymce.wp-editor {
font-family: "Verdana", Geneva, sans-serif !important;
}</style>';
}

/* =================================== */

/* Below are some other WP setting that you can change -- NOTE: they are individually, and  currently remed out with the (star) and (forward-slash), as is this text: so to activate that section, just remove the surrounding remed statements that has the '---' lines associated with it. */

/* Number One: This action reduces the width of the tinyMCE editor on the (backend), to then reflect the front end website text widths. I find it easier to layout and write my articles like this.

NB: Be careful not to insert line breaks within the <style> .. </style> code below, tends to break the function somewhat. */

/* ---
add_filter('admin_footer', 'fulleditorwidth', 99 );
function fulleditorwidth() {
echo '<style> #content_ifr { block;margin-left: auto;margin-right: auto;width: 60%!important;}</style>';

echo '<style> .mce-fullscreen #wp-content-wrap .mce-edit-area, .mce-fullscreen #wp-content-wrap .mce-menubar, .mce-fullscreen #wp-content-wrap .mce-statusbar, .mce-fullscreen #wp-content-wrap .mce-toolbar-grp { margin-left: auto; margin-right: auto; padding: 0!important; width: 60%!important;}</style>';
}
--- */

/* Number two: remove the WP version for extra WordPress security. */

/* ---
function remove_wp_version() {
    return ' ' ;
}
add_filter( 'the_generator' , 'remove_wp_version' );
--- */

/* Number Three: change the failed login message for extra WordPress security. */

/* ---
function failed_login() {
    return 'Incorrect login information supplied.';
}
add_filter( 'login_errors' , 'failed_login' );
--- */

/* Here ends the PHP braces for your Plugin code. */
?>

Because the above code has been entered using a Preformatted style layout, then the entire code is all on one long line, (which is good), but a pig to edit: that’s not to say that you can’t re-edited it in your own text editor.


Performing the Plugin Operation, .. OK, so this is the complicated bit, so follow the steps carefully.

  1. Open your website in you favorite browser, and marvel at your WordPress Home-Page, or whatever your using as the main display.
  2. Next, open a new tab to view the backend Admin page.
  3. All good if you press Ctrl-F5 a few times?
    • No issues in reloading your site?

GOOD!

Right then, ..

  • Start your FTP program and connect to your website via your FTP credentials.
    1. Open it at your website’s root folder.
    2. Now, copy your local directory over to your website’s Plugin directory.

Remember: see the picture above for a reminder at what you’re looking at, and where you’re copying what and where to. NB: when finished dragging and dropping; or whatever method you used, please ensure that your new folder, is in-fact: inside the Plugins folder.

IMPORTANT TIP:-

  • KEEP YOUR FTP PROGRAM OPEN.

Now, .. in your favorite browser, and at your site’s Admin backend tab.

  1. Select the ‘Plugins‘ link, and down the list you should see something similar to what’s shown below, along with the links [Activate] and [Delete] included as well.
My Extended Functionality Plugin.

Activate | Delete

This is where I’m going to put PHP code to basically extend the functions.php file, but without having it overridden when my theme gets updated.

Version 0.1 | By Mrs Jessica Simpson

Activate it!

Then in the favorite browser tab that currently still showing your glorious Home-Page, check that your website is still working, (Ctrl-F5) a few times, and also check to see if the added code you’ve written, is actually doing what it should.

  • Then click a load of links on your site, ..
  • All OK?

You can now release your control over the FTP program: don’t close it, but don’t worry about it.

  • If it’s not all OK.

And the browser has crashed out along with your wonderfully crafted website: you can at that point simply delete your Plugin from within the Plugins directory with your currently open FTP program, thusly returning your site to it’s original state.

(Ctrl – F5) a few times will reboot the sites html code to get it back to normal.


This is the no harm, no foul rhythm method of temporary pentation that I employ; mainly to ensure that no untoward bastards being conceived in the sites deep core.


OH’ NO!, .. If you were forced to rapidly withdraw from your own site, and all without any form of real satisfaction being enjoyed at your end: then you could, (can) start debugging the wayward code on your own local machine.

** The above is a popup link to a free program that I use on my own backend.

Running your own WordPress stable is a wonderful, deeply sensuous experience in its own right, and getting yourself to code right off the bat without a worry in the world: really is a brilliant feeling of mindless liberation.

** Please also keep in mind when running your own lodging house, and taking in paying lodgers as one does, that it’s usually just incorrect ASCII characters being allowed in: especially when copying over lodging code from a random John that usually causes the problem, but fingering typos with sick sticky messy client Johns can’t be ruled out either, and relying on them to point it out is inconceivable, .. (Fairy Princess.)

So in conclusion, my Dearly Belove’d, – this is how you make a WordPress Plugin. It’s just straight forward PHP code that’s run after, or even before the site loads with the aid of WordPress’s many built in software hooks: which is a deep mega-thrusting subject in it own right.

 

Thanks for reading, Jessica: Praise be the ORI.

Click to access the login or register cheese

This is a local popup, .. it’s been placed here to advertise the fact that you can have your own **free** local WordPress environment, and at the click of a button.

I’m putting my own reputation on the line to push this local program, and what I can say on the subject: is quite frankly it’s brilliant. The program itself will provide you with a very simple WP environment to go local: simple but powerful.

Setting it up and running it is a breeze, but like everything else software wise out there, you do need to read the docs: just a little bit to get it running.

Did I mention that it’s free!

Download and install it here.

Try it, you won’t be disappointed.