Skip to content

Instantly share code, notes, and snippets.

View mikeyhoward1977's full-sized avatar
🏠
Working from home

Mike Howard mikeyhoward1977

🏠
Working from home
View GitHub Profile
@mikeyhoward1977
mikeyhoward1977 / kbs-ems-stop-processing-email-addresses.php
Last active March 17, 2018 23:07
KBS Email Support - Stop email processing if sender matches address
<?php
/**
* Do not process emails from specified addresses
*
* @param bool $process True to process, false to halt
* @param array $data Array of email data
* @return bool
*/
function kbs_ems_stop_processing_email_addresses( $process, $data ) {
if ( $process ) {
@mikeyhoward1977
mikeyhoward1977 / kbs_ems_additional_flags.php
Last active April 30, 2020 22:45
Adding IMAP flags within KB Support - Email Support
/**
* Add novalidate-cert flag to mailbox connection for KBS Email Support.
*
* This flag is required if your IMAP/POP3 mail host does not have a valid SSL certificate.
*
* Add this code to your child theme functions.php file, or to a custom plugin.
*/
function kbs_ems_additional_flags( $flags ) {
$flags[] = 'novalidate-cert';
<?php
$terms = wp_get_post_terms( $post_id, 'ticket_category' );
if ( $terms ) {
$output = array();
foreach( $terms as $term ) {
$output[] = $term->name
}
@mikeyhoward1977
mikeyhoward1977 / mp-plugin-upgrade-basic.php
Last active April 23, 2018 16:11
WordPress Plugin Upgrade (Basic)
<?php
/**
* Runs during admin_init hook to determine if our plugin has been upgraded.
*
* Determine if any processes need to be executed and call them as required.
*
* - Replace 'mp_plugin_version' with the option name used to store your plugin version in the DB
* - Replace 'mp_plugin_version_upgraded_from' with the option name you want to use to store the version upgraded from
* - Replace 'MP_PLUGIN_VERSION' with the constant you use to store your plugin version
*/
@mikeyhoward1977
mikeyhoward1977 / mikes-plugins-wordpress-boilerplate.php
Last active April 23, 2018 16:07
WordPress Plugin Boilerplate
<?php
/**
* Plugin Name: Mikes Plugin Boilerplate
* Plugin URI: https://mikesplugins.co.uk
* Description: A basic boilerplate for writing WordPress plugins
* Version: 1.0
* Date: 23 April 2018
* Author: Mike Howard
* Author URI: https://mikesplugins.co.uk/
* Text Domain: mikes-plugins
<?php
/**
* Runs during admin_init hook to determine if our plugin has been upgraded.
*
* Determine if any processes need to be executed and call them as required.
*
* - Replace 'mp_plugin_version' with the option name used to store your plugin version in the DB
* - Replace 'mp_plugin_version_upgraded_from' with the option name you want to use to store the version upgraded from
* - Replace 'MP_PLUGIN_VERSION' with the constant you use to store your plugin version
*/
@mikeyhoward1977
mikeyhoward1977 / kbs-update-orphaned-ticket-status.php
Last active June 13, 2018 08:25
KB Support: Search for tickets with an orphaned status and update
<?php
/**
* Find tickets that are set to a status that is no longer registered
* and update their status to the value of the $new_status variable.
*
* @written by Mike Howard
* @for KB Support - https://wordpress.org/plugins/kb-support
*/
function kbs_update_orphaned_ticket_status() {
global $wpdb;
@mikeyhoward1977
mikeyhoward1977 / epd-welcome-panel.php
Last active August 20, 2018 19:06
Example welcome panel from Easy Plugin Demo
<style>
.welcome-panel .welcome-register:before { content: "\f481"; }
.welcome-panel .welcome-themes:before { content: "\f100"; }
.welcome-panel .welcome-plugins:before { content: "\f106"; top: -3px; }
.welcome-panel .welcome-docs:before { content: "\f118"; top: -2px; }
.welcome-panel .welcome-rate:before { content: "\f155"; top: -2px; }
.welcome-panel .welcome-support:before { content: "\f125"; top: -2px; }
</style>
<h2><?php _e( 'Welcome to the {demo_product_name} (EPD) Demo!', 'easy-plugin-demo' ); ?></h2>
@mikeyhoward1977
mikeyhoward1977 / redirect-agent-login.php
Last active October 31, 2018 09:17
Redirect agents to ticket admin when they login via the Ticket Manager front end
<?php
/**
* Redirect agents to the ticket admin screen.
*
* Effective when agents login via the KBS front end login form.
*
* @param string $redirect_to The redirect URL
* @param int $user_id ID of user logging in
* @return string Redirect URL
@mikeyhoward1977
mikeyhoward1977 / epd-hide-registration-form-fields.php
Last active August 11, 2020 15:25
This code snippet enables the hiding of input fields on the Easy Plugin Demo registration form
<?php
/**
* Remove registration fields from required fields list.
*
* @param array $fields Array of required field names
* @return array Array of required field names
*/
function custom_epd_remove_required_fields( $fields ) {
// Uncomment the array values you want to remove from the required fields list