Example of writing a simple WordPress Plugin
From the second we begin running a blog on WordPress we set up as many plugins as potential to get the perfect out of the WordPress platform. For the non coder a single line of code appears an insurmountable mountain however it’s not the case. You can also make your very personal WordPress plugin. Despite the fact that I’m no huge coder I can present you how you can create a easy WordPress plugin. It’s that easy.
- Plugin Identify – If you title your plugin be certain that it’s not an identical to another plugin on the market. You may carry out this primary step by simply heading over to your dashboard and keying within the desired title to see if there exists any plugin with that title. Right here I’m going to call the Plugin “Notifier”. A fast search reveals that there isn’t any plugin with that title. Wow! I’m fortunate.
- Model – You may need seen plugins with frequent updates with the three digit model like 2.0.1. On this case since we’re going for a easy one, a two digit model would suffice one thing like 1.0
- Description – When you plan to make plugins for public use then this step is essential. In easy phrases you want to clarify what your plugin does.
- Creator – The title of the creator
- Creator URI – Your web site url.
- Plugin URI – On this case I would go away it empty. This area signifies the devoted web page or help web page on your plugin.
- License – For WordPress plugins a GPL V2 license could be sufficient
- License url- You may hyperlink to the web page with the knowledge on license
Create a .txt file with and title it as yourname-plugin.txt
Right here is the code:
/* Plugin Identify: Notifier
Description: It shows a discover in your WordPress dashboard
Creator: George Mathew
Creator URI: http://URI_of_plugin_author_website
Plugin URI: clean License: often GPLv2
echo ‘<p>This plugin is by Servlet</p>’;
Step 1: Go to your internet hosting account and choose the WordPress web site the place you wish to create a brand new plugin. Within the web site’s file construction you can see a folder below wp-content with the title plugins. Simply click on on that. On the fitting facet you will notice the listing of energetic plugins.
On this case I’m utilizing a take a look at web site.
Step 2- Choose new file from the highest header
Step 3: Identify it as Yournameplugin.php or the rest you need with the php extension.
Step 4: A brand new file opens up. Copy the code from the notepad file and paste it in right here. The features must be added simply above the ?>.
Step 4: Go to the WordPress dashboard and go the the plugin listing and you will notice a brand new plugin.
Step 5: You may at all times edit the plugin from the Edit possibility displayed there.
Step 6: For the second let’s simply activate the plugin
As you’ll be able to see the plugin is activated and you’ll see a discover “See you could have a discover in your dashboard.” You may change it with something that you simply like.
You may need seen some features within the code. Let’s see what they do.
What does add_action do?
Add_action does the magic to our code. Add_action is the wordpress perform that really helps carry out the motion specified by the person. Chances are you’ll not understand this however many of the widespread actions on a WordPress weblog make use of Add_action
Listed below are some widespread examples
- publish_post – referred to as when a submit is printed or when standing is modified into “printed”
- save_post – referred to as when a submit/web page is created from begin or up to date
- trackback_post – referred to as at any time when a brand new trackback is added right into a submit
What does display_admin_notice do?
It simply shows a message. In our case it’s the discover.
So, we simply made our first WordPress plugin. Was it that onerous?
cPanel / WHM
- All about cPanel Customization
- All about cPanel Proxy Tool
- All About cPanel Solo License
- All about CSF Messenger Service
- All about new feature – Domains interface in cPanel
- Automated Email Archiving in Roundcube
- Backup Exim Configuration
- Block Email from a Country or Domain in cPanel
- cPanel Calendars and Contacts – CardDAV/CalDAV
- cPanel Horde Data Conversion from MySQL to SQLite
- cPanel Log Rotation Configuration
- cPanel Plugin File Generator
- cPanel Price Increase And Alternative Control Panels
- cPanel’s Email Deliverability Interface
- cPanel/WHM – WHMCS Integration
- Create Website with RVSiteBuilder in cPanel
- Email Account Password Reset in cPanel
- Email Account Password Reset in cPanel and Webmail
- Email Archiving on cPanel Server
- Email Migration to cPanel Using Outlook
- Enable Force Password Change for cPanel Accounts
- Enable or Disable cPanel Analytics Feature at the User Account Level
- Enable Terminal Application for cPanel
- Error While Adding Addon Domain in cPanel
- Everything about cPanel Web Disk
- File Restoration in cPanel v68
- Find the Origin of Spam Emails in cPanel Using Exim
- Find the Potential Spammer Account in cPanel/Exim
- Finding Your Email Settings in Webmail and cPanel
- Fix cPanel FTP Failed to retrieve Directory Listing Error
- How to Add cPanel/WHM Server on WHMCS?
- How to Block Bots using Robots.txt File?
- How to change cPanel logout URL
- How to Change cPanel Style
- How to Change URL of the Joomla Website in cPanel?
- How to Clone a Git Repository in cPanel?
- How to Configure Email Routing in cPanel
- How to Copy Locales in cPanel and WHM?
- How to Disable AutoSSL Email Notifications from cPanel
- How to Disable cPanel, Webmail, WHM shortcut URLs
- How to Disable eximstats_spam_check Notifications
- How to Edit Locales in cPanel & WHM?
- How to Enable Leech Protection in cPanel?
- How to enable memcached on cPanel shared hosting at WebHostingPeople
- How to Enable/Disable Cachewall from cPanel Account?
- How to Host Git Repositories on a cPanel Account
- How to Increase the Upload Size of MySQL Database in PhpMyAdmin on a cPanel Server?
- How to Install BigTree in cPanel/WHM Server?
- How to Install Concrete5 Manually in cPanel Server
- How to Install Redis and PHP-Redis on cPanel
- How to manage and install Patchman in cPanel
- How to manage API Tokens in cPanel
- How to Manage Email Accounts Suspension in cPanel?
- How to Optimize MySQL Database Using phpMyAdmin in cPanel?
- How to Overcome FTP Max Connection from a Single IP in WHM/cPanel?
- How to Replace MySQL With MariaDB on a cPanel Server?
- How to Reset cPanel Password of an Account from WHM?
- How to Reset cPanel Password?
- How to Reset MySQL Root Password and Restore Database Grants in cPanel Server?
- How to Uninstall AutoSSL for an Addon Domain
- How to View Archived Emails via Webmail?
- Importing Email Accounts using a CSV or Excel File in cPanel
- Importing Email Forwarders using a CSV or Excel File in cPanel
- Install ConfigServer MailScanner on cPanel Server
- Install ConfigServer ModSecurity Control in cPanel
- Install Matomo Self-Hosted Analytics on cPanel
- Install RVSiteBuilder on cPanel and DirectAdmin
- Install SitePad Website Builder in cPanel
- Installing Softaculous on a cPanel Server
- Login to WordPress Dashboard From cPanel
- Manage Email Accounts Suspension in cPanel?
- Manage NodeJS Through cPanel
- Manage Reseller’s IP Delegation in cPanel
- Managing Suspended Accounts in WHM
- Message Highlighting in SquirrelMail
- Migrate cPanel Account from cPanel to CWP
- Migrate Email Accounts from Zoho to cPanel
- Migration from cPanel to Webmin/Virtualmin
- Modify cPanel & WHM News
- Modify IP Block Checking Time Interval in CSF
- Multi Account Functions in cPanel
- New cPanel feature – Backup User Selection
- PageSpeed on cPanel Server
- Permanent Redirection Rules in .htaccess File
- RainLoop Webmail on cPanel
- Reset MySQL Installation in cPanel
- Sent Attachments not showing in Horde Webmail?
- Setting up Railgun on cPanel
- Setup Autoresponder in cPanel webmail
- Setup BoxTrapper in Webmail
- Softaculous Staging Environment
- Some Steps to Reduce Disk Space on cPanel Server (For VPS/Cloud Clients Only)
- SSL/TLS Status feature in cPanel
- The New HTTPS Redirection Feature in cPanel
- Unable to Access PhpMyAdmin in cPanel
- What is mod_pagespeed and how to enable it?
- Show all articles ( 81 ) Collapse Articles
- Access denied for user da_admin – MySQL error in DirectAdmin
- Add Custom PHP Modules with Custombuild in DirectAdmin
- Add Reseller Account in DirectAdmin
- Autodiscover Information For Mail Clients in DirectAdmin
- Backup Management in DirectAdmin
- DirectAdmin dead but subsys locked Error
- DirectAdmin Installation
- DirectAdmin Password Reset or Recover Options
- Directory Structure of DirectAdmin Explained
- DNS Management in Direct Admin
- Enabling Multiple PHP versions On DirectAdmin
- FTP Management in DirectAdmin
- Hostname and the servername you have set in DirectAdmin, do not match
- How to Install Nginx on DirectAdmin
- How to install suPHP on DirectAdmin
- How to manage Autoresponders in DirectAdmin
- How to Use IPv6 Address in DirectAdmin
- Important Log File Locations in DirectAdmin
- Install Laravel on a DirectAdmin Server
- Install mod_ruid2 on DirectAdmin
- Install Redis and Redis-PHP in DirectAdmin
- Install SitePad in DirectAdmin
- Install SSL Certificate in DirectAdmin
- Install WordPress on DirectAdmin Using Installatron
- Install Zend OPcache in DirectAdmin
- LetsEncrypt Support in DirectAdmin Control Panel
- Manage Cron Jobs in Direct Admin
- Manage Email Accounts in DirectAdmin
- Manage SPAM Filters in DirectAdmin
- Migrate accounts from DirectAdmin to DirectAdmin
- MySQL Management in Direct Admin
- Reasons and Fixes for DirectAdmin License Expired Error
- Redirect Website /Path to Use HTTPS in DirectAdmin
- Set up DirectAdmin to Use a Remote MySQL Server
- Setup Domain in DirectAdmin
- SpamAssassin Setup in DirectAdmin
- The Best Web Hosting Control Panels – Overview
- Too Low or 0.00 Disk Usage in DirectAdmin
- Show all articles ( 23 ) Collapse Articles
- 404 Error Page When Logging Into WordPress Admin Page
- About WordPress multisite and it’s features
- About WordPress Nonces
- Adding Audio and Video to Word Press Blog Post
- Adding language translations to your site
- Adding Official LinkedIn Share Button in WordPress
- Blogger to WordPress Redirection Using Plugin
- Change Time Zone in WordPress
- Change WordPress Admin Username from Dashboard
- Choosing a Gallery Plugin for your WordPress Site
- Create a Job Board Website with WordPress
- Create a Staging Site from WordPress Dashboard
- Create Local Business Website without a developer!
- Create Local Restaurant Website without a Developer
- Create New Admin Account in WordPress via MySQL
- Creating a hashed upload directory structure in wordpress for sites with large amounts of files
- Creating and Using Sitemaps: The Basics
- Disable WordPress Plugins via phpMyAdmin
- Easy Digital Downloads Plugin for WordPress
- Easy WP SMTP Plugin
- Enable Litespeed Cache for All WordPress Websites in cPanel
- Example of writing a simple WordPress Plugin
- Fix : WordPress has failed to upload. Unable to create directory.
- Fix the Mixed Content Issue on WordPress
- Fix WordPress Error – Sorry, This File Type Is Not Permitted For Security Reasons
- Free Hacked WordPress Cleanup
- Guide for Creating a Multi-Lingual Website
- How much does it cost to build a website
- How to Add a Bitcoin Donate Button to your wordpress blog?
- How to Add a Contact Form to Your WordPress Blog
- How to Add a PayPal Shopping Cart to Your WordPress Blog
- How to Add a Poll to Your WordPress Blog
- How to Add a Static Front Page to Your WordPress Blog
- How to Add a YouTube Video to Your WordPress Posts
- How to Add an Image Gallery to Your Sidebar in WordPress
- How to Add an RSS Feed to Your WordPress Blog
- How to Add and Manage Categories in WordPress
- How to Add Custom Images Sizes to WordPress
- How to Add Font Awesome Icons to Your WordPress Site?
- How to Add Google Analytics to WordPress?
- How to Add Google Maps to Your WordPress Blog
- How to Add Google Search to Your WordPress Site
- How to add HTML to a WordPress Page or Post?
- How to add Poll to WordPress
- How to Add Social Media Buttons to WordPress Posts
- How to Automatically Cross-Post Your WordPress Posts to Both Medium and LinkedIn Publishing
- How to Back Up Your WordPress Blog
- How to Change Footer Text in WordPress?
- How to Change Site Language in WordPress
- How to Change Site Title and Tagline in WordPress
- How to Change WordPress Site URLs (Best Methods)!
- How to Change WordPress Theme by Editing Database?
- How to change WordPress username?
- How to Check Your WordPress Site for Broken Links
- How to Choose a Page Builder for Your WordPress Site
- How to Clear WordPress Cache with W3 Total Cache and WP Super Cache?
- How to Configure Secure Updates and Installations in WordPress
- How to Configure WordPress Email to Use SMTP Server?
- How to Configure WordPress with External Database
- How to Correct Image Links After WordPress Migration
- How to Create a Favicon for Your WordPress Blog
- How to Create an Art Portfolio Website Using WordPress CMS?
- How to Create WordPress Theme
- How to Customize the 404 Page for Your WordPress Site
- How to Disable Pingbacks and Trackbacks in WordPress
- How to Disable Plugins in WordPress
- How to Disable RSS Feeds in WordPress?
- How to Disable Wp-Cron and Replace It with A Real Cron Job
- How to Enable a Maintenance Mode for Your WordPress Blog
- How to Enable or Disable WordPress Automatic Updates
- How to Enable PHP Error Log for WordPress Sites
- How to Enable Private Mode on WordPress Website?
- How To Fix “Error Establishing Database Connection” In WordPress
- How to Fix SMTP ERROR: Failed to connect to server: Connection refused (111) error on WordPress
- How to Fix the Japanese Keyword Hack in WordPress?
- How to Fix the WordPress Login Page Refreshing and Redirecting Issue
- How to Fix the WordPress White Screen of Death(WSoD)
- How to Fix Too Many Redirects Error in WordPress
- How to Fix WordPress Keeps Logging Out Error
- How to Force Logout All Users in WordPress?
- How to Install a Child Theme in WordPress
- How to Install a Theme on Your WordPress Blog
- How to Install AdSense on Your WordPress Blog
- How to Install Plugins in WordPress
- How to Install WordPress in ISPmanager?
- How to Install WordPress on Webuzo?
- How to Make Your WordPress Blog Pinterest Friendly
- How to Make Your WordPress Site Mobile-Friendly
- How to Make Your WordPress Site SEO-Friendly
- How to Manually Downgrade WordPress to The Previous Version?
- How to Moderate Reader Comments in WordPress
- How to Move WordPress to a New Domain without Affecting SEO
- How to Order Posts in Avada WordPress Theme
- How to Protect WordPress from XML-RPC Attacks
- How to Protect Your WordPress Blog from Spam with Akismet
- How to quickly change the wordpress site url editing wp-config.php
- How to Remove /wordpress/ from Your WordPress Blog URL
- How to Remove Tabs from the WordPress Administrator Dashboard
- How to Repair Database Through WordPress Dashboard?
- How to Reset WordPress Password?
- How to Reset Your Administrator Password in WordPress
- How to resolve “Could not write you may be over quota: Bad file descriptor” Error
- How to Restrict IP Addresses from Accessing WordPress Dashboard?
- How to scale a WordPress website
- How to Schedule a Post in WordPress
- How to Secure WordPress
- How to Set Permalinks in WordPress
- How to Set up Gravatar on WordPress
- How to set up High Availability WordPress with HyperDB
- How to set up Memcached on CentOS 6 and configure WordPress to use it
- How to Setup Redis Object Cache on a WordPress Site
- How to setup WordPress Two-Factor Authentication
- How to Show or Hide Widgets on Specific WordPress Pages
- How to Solve Leverage Browser Caching Warning in WordPress?
- How to Stop WordPress from Creating Additional Image Sizes
- How to Update WordPress
- How to Update WordPress Manually via FTP
- How to Use Widgets in WordPress
- How to use WordPress SEO by Yoast
- Install Avada Theme
- Install WordPress from Plesk
- Install WordPress Manually from cPanel
- Install WordPress on cPanel Using Site Software
- Install WordPress over SSH
- Install WordPress Theme Using FTP Client Filezilla
- Install WordPress using Softaculous in cPanel
- Install WordPress Using WordPress Manager
- Installation, Configuration and Features of Wordfence Security
- LiteSpeed Cache is Disabled Warning on WordPress
- Migrate a WordPress site from localhost to Ubuntu VPS
- Migrating from BlogSpot to WebHostingPeople WordPress Hosting
- Migrating from Weebly to WebHostingPeople WordPress Hosting
- Migrating from Wix to WebHostingPeople WordPress Hosting
- Move from WordPress.com to WebHostingPeople WordPress Hosting
- Prevent Brute Force Attacks in WordPress
- Remove Dashboard Access in WordPress
- Reset WordPress Admin Password Using Emergency Password Reset Script
- Secure WordPress Template for an WebHostingPeople VPS (PHPMMDROP)
- Setup Multiple WordPress Sites on one host a single VPS
- Short codes in WordPress explained
- The most common wordpress compromises of 2015
- Types of WordPress Caching
- Using WP-CLI with WebHostingPeople shared hosting
- What is Permalink and the best practices
- Why Do WordPress Sites get Hacked and How to Prevent It?
- Why WordPress is the Best Blogging Platform?
- Why You Should Manually Install WordPress Instead of Using Fantastico (and How to Do It)
- WooCommerce a Free WordPress Plugin for eCommerce
- WordPress – Changing Site URL and Home Settings
- WordPress Backup Restoration from Softaculous
- WordPress Files and Directory Structure
- WordPress Redirection Using Plugins
- YoastSEO Sitemap XML 404 Not Found
- Show all articles ( 140 ) Collapse Articles
- Articles coming soon
- Articles coming soon
- Articles coming soon
- Articles coming soon