Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / monochrome-pro-remove-hero-avatar.php
Last active May 2, 2024 10:58
Remove the hero image and avatar from single posts in Monochrome Pro theme.
<?php
/*
Plugin Name: Monochrome Pro - remove hero and avatar
Plugin URI: https://www.facebook.com/groups/genesiswp/posts/8077692698948523/
Description: Remove the hero image and avatar from single posts in Monochrome Pro theme.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / flatsome-out-of-stock-to-sold.php
Last active May 2, 2024 09:30
Change Flatsome theme 'Out of Stock' label to 'Sold' - Change the 'Out of stock' banner in Flatsome theme to 'Sold'. https://www.damiencarbery.com/2020/06/change-flatsome-theme-out-of-stock-label-to-sold/
<?php
/*
Plugin Name: Change Flatsome theme 'Out of Stock' label to 'Sold'
Plugin URI: https://www.damiencarbery.com/2020/06/change-flatsome-theme-out-of-stock-label-to-sold/
Description: Change the 'Out of stock' banner in Flatsome theme to 'Sold'. Also works when [ux_products] shortcode is used.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.3
*/
@damiencarbery
damiencarbery / tabs.php
Created April 17, 2024 15:20
Change WooCommerce product tabs to accordion - Modify tabs.php template to use the <details> element for accordion like behaviour for product information. https://www.damiencarbery.com/2024/04/change-woocommerce-product-tabs-to-accordion/
<?php
/**
* Single Product tabs
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product/tabs/tabs.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 / add-an-post-tracking-provider.php
Last active April 14, 2024 11:12
Tracking Info to WooCommerce order - Use CMB2 to add a custom metabox to add tracking information to WooCommerce orders. The information is then added to the "Completed Order" email. https://www.damiencarbery.com/2020/01/add-tracking-info-to-woocommerce-order/
<?php
/*
Plugin Name: Add Tracking Provider
Plugin URI: https://www.damiencarbery.com/
Description: Add new An Post (Irish postal service) as a tracking provider.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1.20240414
*/
@damiencarbery
damiencarbery / wc-export-order-csv.php
Last active April 5, 2024 16:10
A quick proof of concept of using an order ID to generate a CSV of order details.
<?php
/*
Plugin Name: WooCommerce - Export order details as CSV
Plugin URI: https://www.damiencarbery.com/
Description: Allow exporting the details .
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.1
*/
<?php
$request_url = 'http://localhost/wp-json/list_product_stock/v1/list-product-stock/';
$credentials = array();
$credentials = array( 'username: basic_user', 'password: password_for_the_user' );
$curl_handle = curl_init( );
curl_setopt( $curl_handle, CURLOPT_URL, $request_url );
curl_setopt( $curl_handle, CURLOPT_CONNECTTIMEOUT, 0 );
curl_setopt( $curl_handle, CURLOPT_TIMEOUT, 15 );
@damiencarbery
damiencarbery / nf-submissions-date-range.php
Created November 5, 2019 11:18
Retrieve Ninja Forms Submissions for date range - Use a direct query to retrieve Ninja Forms submissions for a specified date range. https://www.damiencarbery.com/2019/11/retrieve-ninja-forms-submissions-for-date-range/
<?php
// Restrict who can access this script.
/*$permitted_ips = array( '12.34.56.78' );
if ( false == in_array($_SERVER['REMOTE_ADDR'], $permitted_ips) ) {
header( 'HTTP/1.0 403 Forbidden' );
die();
}*/
header('HTTP/1.1 200 OK');
@damiencarbery
damiencarbery / autosslftp.pm
Last active January 25, 2024 13:57
Automate creating Let’s Encrypt challenge files - My plans to automate most of the Let's Encrypt SSL certificate renewal process are getting closer. https://www.damiencarbery.com/2020/05/automate-creating-let's-encrypt-challenge-files/
package autosslftp;
use strict;
use warnings;
use Net::FTP;
use constant CONFIG_FIELDS => 10; # Number of fields in config file.
use Exporter qw(import);
# $Id: autosslftp.pm 5151 2020-07-01 19:50:11Z damien $
our @EXPORT = qw(get_config);
@damiencarbery
damiencarbery / view-order-on-front-end.php
Last active January 19, 2024 17:46
View WooCommerce order on front end - Use an encrypted link to allow a customer view order details on the front end. https://www.damiencarbery.com/2024/01/view-woocommerce-order-on-front-end/
<?php
/*
Plugin Name: View WooCommerce order on front end
Plugin URI: https://www.damiencarbery.com/2024/01/view-woocommerce-order-on-front-end/
Description: Use an encrypted link to allow a customer view order details on the front end.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.2
WC tested to: 8.5.1
*/
@damiencarbery
damiencarbery / enable-select2-on-ninja-forms-dropdowns.js
Last active January 15, 2024 16:24
Use Select2 for Ninja Forms dropdowns - When a Ninja Forms form has a dropdown, enable Select2 so that the elements are searchable. https://www.damiencarbery.com/2023/12/use-select2-for-ninja-forms-dropdowns/
// This code enables Select2 to dropdowns as they are rendered.
// Create a new object for custom validation of a custom field.
var dcwdDropdownFieldController = Marionette.Object.extend( {
initialize: function() {
// From: https://developer.ninjaforms.com/codex/field-view-rendering/
this.listenTo( nfRadio.channel( 'listselect' ), 'render:view', this.renderView );
},
renderView: function( view ) {