Skip to content

Instantly share code, notes, and snippets.

@damiencarbery
damiencarbery / sitemap-exclude-post-type.php
Created March 29, 2023 09:25
Sitemap - exclude a custom post type
View sitemap-exclude-post-type.php
<?php
/*
Plugin Name: Sitemap - exclude a custom post type
Plugin URI: https://wpza.net/how-to-exclude-post-types-from-wp-sitemap-xml-in-wordpress/
Description: Exclude a specific custom post type from the WordPress sitemaps.
Version: 0.1
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
*/
@damiencarbery
damiencarbery / genesis-responsive-menu.php
Created March 15, 2023 11:34
For Parallax Pro theme: Add the genesis-responsive-menu class when generating page, to avoid flash of desktop menu on mobile.
View genesis-responsive-menu.php
<?php
/*
Plugin Name: Genesis Responsive Menu in source (Parallax Pro)
Plugin URI: https://www.damiencarbery.com
Description: For Parallax Pro: Add the genesis-responsive-menu class when generating page, to avoid flash of desktop menu on mobile.
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / delete-flamingo-data.php
Last active March 2, 2023 16:52
Delete Contact Form 7 Flamingo submissions - Easily delete a large number of Flamingo (Contact Form 7) messages. https://www.damiencarbery.com/2020/03/delete-contact-form-7-flamingo-submissions/
View delete-flamingo-data.php
<?php $time_start = microtime(true); ?>
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Delete Flamingo messages and contacts</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<h1>Delete Flamingo messages and contacts</h1>
@damiencarbery
damiencarbery / cf7dte-form.txt
Last active February 27, 2023 14:24
Contact Form 7 Product Enquiry form for variable products - Watch the variation dropdowns and copy the values to a CF7DTE hidden field. https://www.damiencarbery.com/2019/12/contact-form-7-product-enquiry-form-for-variable-products/
View cf7dte-form.txt
[dynamichidden selected_variations]
@damiencarbery
damiencarbery / add-gift-wrap-option-to-woocommerce-cart.php
Last active February 13, 2023 09:54
Add option for add-on item to WooCommerce cart - A simple way to allow customers add gift wrap or other small add-on to their order. https://www.damiencarbery.com/2020/06/add-option-for-add-on-item-to-woocommerce-cart/
View add-gift-wrap-option-to-woocommerce-cart.php
<?php
/*
Plugin Name: Add option for add-on item to WooCommerce cart
Plugin URI: https://www.damiencarbery.com/2020/06/add-option-for-add-on-item-to-woocommerce-cart/
Description: A simple way to allow customers add gift wrap or other small add-on to their order.
Author: Damien Carbery
Version: 0.3
*/
@damiencarbery
damiencarbery / acf-date-time-picker-start-end-date-twinned-norwegian.php
Last active January 14, 2023 20:55
ACF Date Time Picker – set end date to after start date - With two related Date Time Picker fields limit the end date to be after the start date. https://www.damiencarbery.com/2021/10/acf-date-time-picker-set-end-date-to-after-start-date/
View acf-date-time-picker-start-end-date-twinned-norwegian.php
<?php
/*
Plugin Name: ACF Date Time Picker - set end date to after start date
Plugin URI: https://www.damiencarbery.com/2021/10/acf-date-time-picker-set-end-date-to-after-start-date/
Description: With two related Date Time Picker fields limit the end date to be after the start date.
Author: Damien Carbery
Version: 0.3
*/
@damiencarbery
damiencarbery / list-active-plugins.php
Last active January 10, 2023 01:39
List name, version and description of active plugins.
View list-active-plugins.php
<?php
/*
// Restrict who can access this script.
$permitted_ips = array('12.34.56.78', );
if (in_array($_SERVER['REMOTE_ADDR'], $permitted_ips) == false) {
header('HTTP/1.0 403 Forbidden');
die();
}
*/
?>
@damiencarbery
damiencarbery / elementor-remove-html-for-hidden-widget.php
Last active January 6, 2023 20:24
Elementor - Remove markup for hidden element - Remove the markup for an element that is set to hidden on desktop, table and mobile. https://www.damiencarbery.com/2021/06/elementor-remove-markup-of-hidden-element/
View elementor-remove-html-for-hidden-widget.php
<?php
/*
Plugin Name: Elementor - Remove markup for hidden element
Description: Remove the markup for an element that is set to hidden on desktop, table and mobile.
Plugin URI: https://www.damiencarbery.com/2021/06/elementor-remove-markup-of-hidden-element/
Version: 0.2
Author: Damien Carbery
*/
defined( 'ABSPATH' ) || exit;
@damiencarbery
damiencarbery / attach-order-files-to-wc-order-email.php
Last active January 4, 2023 09:31
Attach files to WooCommerce order email - Upload files to an order to attach them to the WooCommerce Order Completed email.
View attach-order-files-to-wc-order-email.php
<?php
/*
Plugin Name: Attach files to WooCommerce order email
Plugin URI: https://www.damiencarbery.com/2021/05/attach-files-to-woocommerce-order-email/
Description: Upload files to an order to attach them to the WooCommerce Order Completed email.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.5
*/
@damiencarbery
damiencarbery / add-cron-task.php
Last active January 3, 2023 19:33
WP Cron - how to use and how to extend
View add-cron-task.php
<?php
// Set up task when plugin is activated
register_activation_hook(__FILE__, 'dcwd_cron_status_setup_schedule');
// On an early action hook, check if the hook is scheduled - if not, schedule it.
function dcwd_cron_status_setup_schedule() {
// Add the event only if it is not already scheduled.
if ( ! wp_next_scheduled( 'dcwd_cron_status_status_email' ) ) {
// Schedule weekly at 2:12am.
wp_schedule_event( mktime(2,12,0), 'weekly', 'dcwd_cron_status_status_email');