Skip to content

Instantly share code, notes, and snippets.

View BruceMcKinnon's full-sized avatar

BruceMcKinnon

View GitHub Profile
@BruceMcKinnon
BruceMcKinnon / functions.php
Created August 18, 2020 23:56
Simple Job Board customise emails
add_filter('sjb_admin_notification_attachment', 'custom_resume_attachment', 10, 2);
add_filter('sjb_hr_notification_attachment', 'custom_resume_attachment', 10, 2);
function custom_resume_attachment( $resume_path, $post_id ){
$attachment = get_post_meta($post_id, 'resume_path', TRUE);
//fb_log("attach - post ".$post_id . ' = '. $attachment);
return $attachment;
}
add_filter('sjb_applicant_details_notification', 'custom_hr_resume_detail', 10, 3);
@BruceMcKinnon
BruceMcKinnon / functions.php
Created August 7, 2020 06:44
Dynamic navs
/*
* Filters all menu item URLs for a ##anchor-link
*/
function bl_dynamic_menu_items( $menu_items ) {
$current_page = "http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
foreach ( $menu_items as $menu_item ) {
// All the blcontact shortcodes to be used as the URL of custom links.
// Must include a ## before the shortcode. E.g., ##[blcontact type='misc1']
@BruceMcKinnon
BruceMcKinnon / index.html
Created August 4, 2020 00:13
Simple Landing Page
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Coming Soon</title>
<link href="landing.css" rel="stylesheet" type="text/css" >
</head>
<body>
<div class="aligner">
@BruceMcKinnon
BruceMcKinnon / functions.php
Created July 30, 2020 03:57
Gravity Forms - Button to delete file uploads for an entry
add_filter( 'gform_entry_detail_meta_boxes', 'add_delete_attachment_meta_box', 10, 3 );
function add_delete_attachment_meta_box( $meta_boxes, $entry, $form ) {
$my_form_id = 3;
if ( $form['id'] == $my_form_id ) {
if ( ! isset( $meta_boxes['payment'] ) ) {
$meta_boxes['payment'] = array(
'title' => esc_html__( 'Delete Attachments', 'gravityforms' ),
@BruceMcKinnon
BruceMcKinnon / _colors.scss
Created July 13, 2020 02:59
Generic color pallete
$black: #0B1015;
$white: #FBFBFC;
$almost-black: #17202A;
$really-dark-gray: #343C45;
$dark-gray: #8B9095;
$medium-dark-gray: #6E747A;
$medium-gray: #A8ABAF;
$medium-light-gray: #C5C7CA;
$light-gray: #E2E3E4;
@BruceMcKinnon
BruceMcKinnon / functions.php
Created July 9, 2020 00:08
Add footer info to GForm admin notification
add_filter( 'gform_notification', 'custom_gform_notification_signature', 10, 3 );
function custom_gform_notification_signature( $notification, $form, $entry ) {
// append a signature to the existing notification
// message with .=
$notification['message'] .= "<br/>Message via the ".$form['title']." form on ".get_bloginfo("name") ;
return $notification;
}
@BruceMcKinnon
BruceMcKinnon / archive.php
Created June 10, 2020 01:51
AJAX loading archives page
<?php
// AJAX load more button
// This button replaces the standard pagination code
if ( $wp_query->max_num_pages > 1 )
echo '<a class="button" id="load_more">Load More</a>';
?>
@BruceMcKinnon
BruceMcKinnon / functions.php
Created June 2, 2020 00:07
Custom Post templates for specific category
//
// Support custom post templates for the Key Projects category
//
add_filter( 'single_template', function ( $single_template ) {
$parent = '33'; // Key Projects category ID
$categories = get_categories( 'child_of=' . $parent );
$cat_names = wp_list_pluck( $categories, 'name' );
if ( has_category( 'key-projects' ) || has_category( $cat_names ) ) {
$single_template = dirname( __FILE__ ) . '/single-keyprojects.php';
@BruceMcKinnon
BruceMcKinnon / function.php
Created May 12, 2020 22:31
Woo Product page - Display Variations in table with their own Ad to Cart button
//
// Originally posted on https://medium.com/wordpress-knowledge/display-woocommerce-product-variation-in-table-instead-of-drop-down-4b7d31f12987
//
function woocommerce_variable_add_to_cart($product, $post) {
$variations = $product->get_available_variations();
?>
<table>
<tbody>
<?php
@BruceMcKinnon
BruceMcKinnon / functions.php
Created April 30, 2020 00:29
Change Wordpress emails sender adddess and sender name
add_filter('wp_mail_from', 'kmow_mail_from_address');
function kmow_mail_from_address($email){
return '[email protected]';
}
add_filter('wp_mail_from_name', 'kmow_mail_from_name');
function kmow_mail_from_name($from_name){
return "KMOW Web Site";
}