Skip to content

Instantly share code, notes, and snippets.

View theperfectwill's full-sized avatar
💭
Coding... Working on The WPOnion Framework with Varun

The Perfect Will theperfectwill

💭
Coding... Working on The WPOnion Framework with Varun
View GitHub Profile
@aydinjavadly
aydinjavadly / wp-config.php
Last active November 6, 2021 13:01
WordPress - Enable WP_DEBUG only for specific IP address.
<?php
/**
* File: wp-config.php
*
* Enable WordPress debug only for your IP address
*
* Once you know your IP address you can edit your wp-config.php file and edit the WP_DEBUG constant and replace it with this function and your IP address.
*
* NOTE: If you re-boot your router and have a dynamic IP address you will need to update your IP address in wp-config.php
*/
@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
*/
@yankiara
yankiara / fluid-fonts-and-icons.css
Last active July 10, 2021 04:31
Fluid fonts and icons in CSS
body {
--base: 20;
--scale-headings: 1.44;
--scale-mobile: 0.7;
--scale-mobile-headings: 0.4;
--scale-icons: 1.4;
--min-viewport: 480;
--max-viewport: 1600;
--max-size: var(--base);
}
@damiencarbery
damiencarbery / menu-shortcode.php
Last active January 6, 2020 22:26
Shortcode in a menu - it's possible to use a shortcode as a menu url but it's not trivial - https://www.damiencarbery.com/2019/11/shortcode-in-a-menu/
<?php
/*
Plugin Name: Shortcode in menu - Convert to dynamic url
Plugin URI: https://www.damiencarbery.com
Description: Change a shortcode in menu url to a dynamic url. Advanced WordPress group question: https://www.facebook.com/groups/advancedwp/permalink/2734099893318874/
Author: Damien Carbery
Version: 0.1
*/
@damiencarbery
damiencarbery / index.php
Last active January 6, 2020 22:26
Understanding the WordPress template hierarchy - Use the template hierarchy to change the presentation of a specific page or a bunch of them or all of them. It's your choice! https://www.damiencarbery.com/2019/10/understanding-the-wordpress-template-hierarchy/
<?php
wp_head();
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
the_title();
the_content();
}
}
@damiencarbery
damiencarbery / notify-admin-of-address-change.php
Last active November 14, 2023 17:34
Notify admin of customer address changes - Email the site admin when a customer changes their billing or shipping address in WooCommerce. https://www.damiencarbery.com/2019/09/notify-admin-of-customer-address-changes/
<?php
/*
Plugin Name: Notify admin of customer address changes
Plugin URI: https://www.damiencarbery.com/2019/09/notify-admin-of-customer-address-changes/
Description: Email the site admin when a customer changes their billing or shipping address in WooCommerce.
Author: Damien Carbery
Author URI: https://www.damiencarbery.com
Version: 0.2
WC tested up to: 8.2.2
*/
@damiencarbery
damiencarbery / wc-attribute-name-and-value.php
Last active February 17, 2021 15:16
Display attribute name and value in WooCommerce -Show the attribute name beside the attribute value in WooCommerce (in Cart, Checkout and order emails). https://www.damiencarbery.com/2019/09/display-attribute-name-and-value-in-woocommerce/
<?php
/*
Plugin Name: Display attribute name and value in WooCommerce
Plugin URI: https://www.damiencarbery.com/2019/09/display-attribute-name-and-value-in-woocommerce/
Description: Show the attribute name beside the attribute value in WooCommerce (in Cart, Checkout and order emails).
Author: Damien Carbery
Version: 0.2
*/
add_filter( 'woocommerce_product_variation_title_include_attributes', 'dcwd_product_variation_title_include_attributes', 10, 2 );
// Source: https://blog.templatetoaster.com/update-old-urls-in-database/
// How to Change/Update links with MySQL
update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find string’, ‘replace string’);
// For replacing the URL across all database tables, Click on SQL tab and in the panel type the below code:
UPDATE wp_options SET option_value = replace(option_value, 'Existing URL', 'New URL') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET post_content = replace(post_content, 'Existing URL', 'New URL');
<?php
/**
* Hook: woocommerce_before_main_content.
*
* @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content)
* @hooked woocommerce_breadcrumb - 20
* @hooked WC_Structured_Data::generate_website_data() - 30
*/
<?php
// Init
// -----------------------------------------------------------------------
define('DOING_AJAX', true);
define('SHORTINIT', true);
// WP Load
// -----------------------------------------------------------------------
require('wp-load.php');