Skip to content

Instantly share code, notes, and snippets.

Avatar

Damien Carbery damiencarbery

View GitHub Profile
View magazine-pro-no-menu-single-posts.php
<?php
/*
Plugin Name: Magazine Pro - Hide menu on single posts
Plugin URI: https://www.damiencarbery.com
Description: Hide the After Header Menu when on single posts. Asked on Genesis Facebook group.
Author: Damien Carbery
Version: 0.1
*/
add_action( 'genesis_after_header', 'mp_omit_after_header_menu_on_single_posts', 5 );
@damiencarbery
damiencarbery / email-order-details.php
Created Oct 18, 2020
Add column to WooCommerce order email - Add an extra column to the WooCommerce order email. https://www.damiencarbery.com/2020/10/add-column-to-woocommerce-order-email/
View email-order-details.php
<?php
/**
* Order details table shown in emails.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-order-details.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does
* happen. When this occurs the version of the template file will be bumped and
@damiencarbery
damiencarbery / json-encoded-markup.js
Created Oct 4, 2020
Randomise order of items - Randomise the order that a group of items are displayed, even when the page is cached. https://www.damiencarbery.com/2020/10/randomise-order-of-items/
View json-encoded-markup.js
document.addEventListener("DOMContentLoaded", function(event) {
let logos = ["<div class=\"item\"><img src=\"https:\/\/dummyimage.com\/400x400\/306933\/afb3f0.png&text=1\" \/><\/div>", "etc", "etc"];
fisherYates(logos); // Shuffle the array.
var logos_html = "";
logos.forEach(function(item, index, array) {
logos_html += item;
})
var container = document.getElementById( "logos" );
container.innerHTML = logos_html;
});
@damiencarbery
damiencarbery / accordion-block-export.xml
Created Sep 28, 2020
Distribute Genesis Custom Block in a plugin - Include the Genesis Custom Block definition as part of the plugin to simplify distribution. https://www.damiencarbery.com/2020/09/distribute-genesis-custom-block-in-a-plugin/
View accordion-block-export.xml
<item>
<title>Accordion block</title>
<link>https://example.com/genesis_custom_block/accordion-block/</link>
<pubDate>Tue, 15 Sep 2020 12:16:12 +0000</pubDate>
<dc:creator><![CDATA[me]></dc:creator>
<guid isPermaLink="false">https://example.com/?post_type=genesis_custom_block&#038;p=8</guid>
<description></description>
<content:encoded><![CDATA[{"genesis-custom-blocks\/accordion-block":{"name":"accordion-block","title":"Accordion block","excluded":[],"icon":"list","category":{"slug":"widgets","title":"Widgets","icon":null},"keywords":[""],"fields":{"title":{"name":"title","label":"Title","control":"text","type":"string","order":0,"location":"editor","width":"100","help":"","default":"","placeholder":"","maxlength":null},"content":{"name":"content","label":"Content","control":"textarea","type":"textarea","order":1,"location":"editor","width":"100","help":"","default":"","placeholder":"","maxlength":null,"number_rows":4,"new_lines":"autop"}}}}]]></content:encoded>
<excerpt:encoded><![CDATA[]]></excerpt:
@damiencarbery
damiencarbery / css-slider.php
Last active Sep 21, 2020
Pure CSS slider - proof of concept - A slider using only CSS transitions. https://www.damiencarbery.com/2020/09/pure-css-slider-proof-of-concept/
View css-slider.php
<!DOCTYPE html>
<html>
<head>
<title>CSS fade in/out slider</title>
</head>
<?php
$slides = array( '<div><img src="http://placekitten.com/g/612/612"/></div>',
'<div><img src="https://unsplash.it/id/237/612/612"/></div>',
'<div><img src="https://unsplash.it/id/400/612/612"/></div>',
'<div><img src="https://unsplash.it/id/181/612/612"/></div>',
@damiencarbery
damiencarbery / truncated-archives-widget.php
Last active Sep 9, 2020
Truncated Archives Widget - A variation on the core Archives widget where it is like a yearly list in addition to the months of the current year. https://www.damiencarbery.com/2020/09/truncated-archives-widget/
View truncated-archives-widget.php
<?php
/*
Plugin Name: Truncated Archives Widget
Plugin URI: https://www.damiencarbery.com/2020/09/truncated-archives-widget/
Description: A variation on the core Archives widget where it is like a yearly list in addition to the months of the current year.
Author: Damien Carbery
Version: 0.1
*/
class Truncated_Archives_Widget extends WP_Widget {
@damiencarbery
damiencarbery / cta-over-hero-on-inner-pages.php
Last active Aug 17, 2020
CTA over hero image on inner pages in Essence Pro - Add a CTA on the Essence Pro hero image on inner pages (i.e. not on home page) https://www.damiencarbery.com/2020/08/cta-over-hero-image-on-inner-pages-in-essence-pro/
View cta-over-hero-on-inner-pages.php
<?php
/*
Plugin Name: CTA over hero image on inner pages in Essence Pro
Plugin URI: https://www.damiencarbery.com/2020/08/cta-over-hero-image-on-inner-pages-in-essence-pro/
Description: Add a CTA on the Essence Pro hero image on inner pages (i.e. not on home page).
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / recovery-mode-email.php
Last active Aug 23, 2020
Set recovery mode email address - Change the recovery mode email address to which the fatal error emails are sent to, instead of bothering and potentially confusing the site admin. https://www.damiencarbery.com/2020/08/set-recovery-mode-email-address/
View recovery-mode-email.php
<?php
/*
Plugin Name: Change Recovery Mode Email
Plugin URI: https://www.damiencarbery.com/2020/08/set-recovery-mode-email-address/
Description: Set the recovery mode email address to which the fatal error emails are sent to, instead of bothering and potentially confusing the site admin. From: https://developer.wordpress.org/reference/hooks/recovery_mode_email/#comment-3265
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version 0.1
*/
@damiencarbery
damiencarbery / post-order-by-category.php
Last active Aug 31, 2020
Change post order by category - Order a specific category by date, rest alphabetically. https://www.damiencarbery.com/2020/08/change-post-order-by-category/
View post-order-by-category.php
<?php
/*
Plugin Name: Change post order by category
Plugin URI: https://www.damiencarbery.com/2020/08/change-post-order-by-category/
Description: Order a specific category by date, the rest alphabetically.
Author: Damien Carbery
Version: 0.1
*/
View cta-over-hero-on-inner-pages.php
<?php
/*
Plugin Name: CTA over hero image on inner pages
Plugin URI: https://www.damiencarbery.com
Description: Add a CTA on the hero image on inner pages (i.e. not on home page).
Author: Damien Carbery
Version: 0.1
*/
//<a class="button primary" href="#newsletter">Join Us Today</a>
You can’t perform that action at this time.