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 / default-args.php
Last active Jul 14, 2019
Display a widget anywhere: Widgets are used inside registered widget areas. Let's display them in other areas. https://www.damiencarbery.com/2019/07/display-a-widget-anywhere/
View default-args.php
<?php
$args = array(
// These two are useful inside a sidebar but should be changed to
// '<div>' and '</div>' when invoking a widget outside a sidebar.
'before_widget' => '<li id="%1$s" class="widget %2$s">',
'after_widget' => "</li>\n",
'before_title' => '<h2 class="widgettitle">',
'after_title' => "</h2>\n",
);
@damiencarbery
damiencarbery / migration-test.php
Last active Jul 10, 2019
Easily check DNS migration changes - see whether a DNS change has propagated when you don't have command line access. https://www.damiencarbery.com/2017/07/easily-check-dns-migration-changes/
View migration-test.php
<?php
/*
Plugin Name: Migration Test
Plugin URI: https://www.damiencarbery.com/2017/07/easily-check-dns-migration-changes/
Description: Display the server name in the footer. Used to easily see when a site migration DNS changes have propagated.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
License: GPL2
*/
@damiencarbery
damiencarbery / wwp-show-regular-prices.php
Last active Jul 10, 2019
Show regular price in cart and checkout when using WooCommerce Wholesale Prices - The plugin does not show regular prices but one developer wanted to see them. https://www.damiencarbery/2019/07/show-regular-price-in-cart-and-checkout-when-using-woocommerce-wholesale-prices/
View wwp-show-regular-prices.php
<?php
/*
Plugin Name: Wholesale Prices - Show Original Prices
Plugin URI: https://www.damiencarbery.com/2019/07/show-regular-price-in-cart-and-checkout-when-using-woocommerce-wholesale-prices/
Description: Show the original prices in the Cart and Checkout pages when using WooCommerce Wholesale Prices plugin.
Author: Damien Carbery
Version: 0.3
$Id: wwp-show-orig-prices.php 4747 2019-07-10 15:13:51Z damien $
*/
@damiencarbery
damiencarbery / allow-wc-rest-api-queries.php
Last active Jun 30, 2019
Disable WooCommerce REST API authentication: Override WooCommerce capability check so that all REST API queries are allowed. https://www.damiencarbery.com/2019/07/disable-woocommerce-rest-api-authentication/
View allow-wc-rest-api-queries.php
<?php
/*
Plugin Name: Disable WooCommerce REST API authentication
Plugin URI: https://www.damiencarbery.com/2019/07/disable-woocommerce-rest-api-authentication/
Description: Override WooCommerce capability check so that all REST API queries are allowed.
Author: Damien Carbery
Version: 0.1
*/
View allow-wc-rest-api-queries.php
<?php
/*
Plugin Name: Disable WooCommerce REST API authentication
Plugin URI: https://www.damiencarbery.com/2019/07/disable-woocommerce-rest-api-authentication/
Description: Override WooCommerce capability check so that all REST API queries are allowed.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / order-details.txt
Last active Jun 21, 2019
WooCommerce REST API authentication: Use Oauth 1 and the WooCommerce REST API to retrieve order details. https://www.damiencarbery.com/2019/06/woocommerce-rest-api-authentication/
View order-details.txt
{
"id": 7755,
"parent_id": 0,
"number": "7755",
"order_key": "wc_order_YjITxJBWgJIFu",
"created_via": "programatically",
"version": "3.6.4",
"status": "completed",
"currency": "EUR",
"date_created": "2019-06-11T08:58:35",
@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
@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();
}
*/
You can’t perform that action at this time.