Skip to content

Instantly share code, notes, and snippets.

Damien Carbery damiencarbery

Block or report user

Report or block damiencarbery

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@damiencarbery
damiencarbery / grouped-carousel.php
Last active Jun 17, 2019
Use CMB2 to create a carousel: Add photos to multiple groups and randomise group order in a carousel. https://www.damiencarbery.com/2019/06/use-cmb2-to-create-a-carousel/
View grouped-carousel.php
View cart-contents-shortcode.php
<?php
// To the CF7 form add:
// [dynamichidden dynamichidden-cart "cart_contents"]
// In the CF7 Mail add:
// [dynamichidden-cart]
// The "cart_contents" uses this code
add_shortcode( 'cart_contents', 'dcwd_cart_contents' );
function dcwd_cart_contents($atts, $content, $code) {
$cart_contents = array();
@damiencarbery
damiencarbery / ninja-forms-submissions.php
Last active Jun 10, 2019
Display Ninja Forms Submissions - Demonstrate viewing form submission data outside of the admin area. https://www.damiencarbery.com/2019/06/display-ninja-forms-submissions/
View ninja-forms-submissions.php
<?php
header('HTTP/1.1 200 OK');
define('WP_USE_THEMES', false);
/** Loads the WordPress Environment */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
$id = 3;
@damiencarbery
damiencarbery / regular-wc-api.php
Created Jun 7, 2019
Trying WooCommerce REST API and then reverting to regular API
View regular-wc-api.php
<?php
// Convert ThriveCart order to WooCommerce order.
// ThriveCart order data is passed via ThriveCart Webhook into $_POST.
// By Damien Carbery, damien@damiencarbery.com, https://www.damiencarbery.com
//
// $Id: tc-to-wc-order.php 4726 2019-06-07 11:10:43Z damien $
// Avoid warnings about element not being set.
function get_post_parameter( $key, $default ) {
@damiencarbery
damiencarbery / mk-local-order.php
Last active Jun 3, 2019
Duplicate a ThriveCart order in WooCommerce: Convert ThriveCart order data into a WooCommerce order. https://www.damiencarbery.com/2019/06/duplicate-a-thrivecart-order-in-woocommerce/
View mk-local-order.php
<?php
/*
// Restrict who can access this script.
$permitted_ips = array('12.34.56.78', '87.65.43.21');
if (in_array($_SERVER['REMOTE_ADDR'], $permitted_ips) == false) {
header('HTTP/1.0 403 Forbidden');
die();
}
*/
View append-cart-icon-to-menu.php
<?php
/*
Plugin Name: WooCommerce - Append cart icon and count to menu
Plugin URI: https://www.damiencarbery.com/2018/04/woocommerce-append-cart-icon-and-count-to-menu/
Description: Append a cart item to the main menu and show count of items in the cart.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / nf-copy-email-to-hidden.php
Last active May 27, 2019
Ninja Forms - Copy Fields on Submission: Simplify copying Ninja Forms field values between fields early in the submission. https://www.damiencarbery.com/2019/05/ninja-forms-copy-data-during-submission/
View nf-copy-email-to-hidden.php
<?php
/*
Plugin Name: Copy Email field to Hidden
Plugin URI: https://www.damiencarbery.com
Description: Copy the email field to the hidden field using the NinjaFormsCopyFieldsOnSubmission class.
Author: Damien Carbery
Version: 0.1
*/
View playlist-with-download-link.php
@damiencarbery
damiencarbery / genesis-remove-page-title.php
Created May 22, 2019
Remove the entry-header area on pages. Do not change single posts or archives
View genesis-remove-page-title.php
<?php
/*
Plugin Name: Remove page title (Genesis)
Plugin URI: http://www.damiencarbery.com
Description: Remove the entry-header section (with page title, post info and featured image) from pages but not posts or archives.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / aj-demo-ajax-code.js
Last active May 17, 2019
Demo of AJAX in WordPress
View aj-demo-ajax-code.js
jQuery(document).ready( function(){
jQuery('.count_btn').on('click', function(e) {
var post_type = jQuery(this).data( 'type' ); // Get post type via the 'data-type' attribute of the button.
jQuery('#'+post_type+'_count').html('?'); // Clear existing value.
e.preventDefault();
jQuery.ajax({
url : aj_ajax_demo.ajax_url, // Note that 'aj_ajax_demo' is from the wp_localize_script() call.
You can’t perform that action at this time.