Create a class to handle updates Add this to your plugin’s main PHP file or a separate updater file: <?php class GitHub_Plugin_Updater { private $slug; […]
MYSQL: Check User Exists & Grant Privileges On Database
Check if the User Exists SELECT user, host FROM mysql.user WHERE user = ‘your_username’; If the user doesn’t exist, create them first: CREATE USER ‘your_username’@’%’ […]
WordPress: Plugin To Download Random Posts To A CSV File
The following code will create a plugin that allows you to download random posts based on selected categories in an admin page. 3 CVS files […]
WordPress: Spoiler In Post Content Function
The following code can be added to your WordPress functions.php file or added as a plugin to allow you to mark sections of your post […]
Tabbed Navigation With QueryString Open Tab Selection
The following code will create a series of tabbed sections on a single page. Each tabbed section will have a series of boxes that contain […]
Validate UK Postcode
The following script will take the input from the form and validate a post code in UK Format eg. Lettter Letter Number Number Letter Letter […]
Remove First Character From A Field In A Database
Assuming we have the following entry in our database: /go/123456 But we require: go/123456 UPDATE `TABLENAME` SET `FIELDNAME` = SUBSTRING(`FIELDNAME`, 2) WHERE `FIELDNAME` LIKE `/%`;
Replace String In Database Field
The following code will replace a string in a database field UPDATE `TableName` SET `DatabaseField` = REPLACE(`DatabaseField`, ‘OldString’, ‘NewString’) WHERE `DatabaseField` LIKE ‘%OldString%’;
Simple PHP Mailer Function
Send an email with PHP – useful for a simple contact form if (isset($_POST[‘submit’])) // Your submit button or a required form field { $EmailTo […]
Rename SQL Table
If you wish to rename a SQL table use the following code: ALTER TABLE table_name RENAME TO new_table_name;