Skip to content

Instantly share code, notes, and snippets.

View dustinleer's full-sized avatar
🏠
Working from home

Dustin Leer dustinleer

🏠
Working from home
View GitHub Profile
@dustinleer
dustinleer / acf-theme-activation-sync.php
Created June 21, 2022 17:21
Syncs ACF JSON upon theme activation
<?php
/**
* Sets path for ACF json
* This is going to generate local JSON copies in your given folder for each ACF Group.
* When the ACF Group is saved/updated,
*/
define( 'IP_ACF_PLUGIN_DIR_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
function ip_acf_json_save_point( $path ) {
// Update path
@dustinleer
dustinleer / functions.php
Created June 14, 2022 16:22
Contact Form 7 Submission Redirect
<?php
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
$site_url = get_site_url();
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = '<?php echo $site_url; ?>/landing-thank-you/';
@dustinleer
dustinleer / user-class-functions.php
Last active June 10, 2022 18:19
Add User Role Class to Body
<?php
/**
* Add User Role Class to Body
*/
function print_user_classes() {
if ( is_user_logged_in() ) {
add_filter( 'body_class','class_to_body' );
add_filter( 'admin_body_class', 'class_to_body_admin' );
}
}
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 21:03
Add a custom WooCommerce My Account endpoint
<?php
/**
* Add endpoint rewrite.
*/
function ip_custom_endpoint() {
add_rewrite_endpoint( 'edit-wishlists', EP_ROOT | EP_PAGES );
}
add_action( 'init', 'ip_custom_endpoint', 10, 1 );
/**
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 20:53
Reorders WooCommerce menu links
<?php
/**
* Reorder my-account menu
*
* @param array $menu_links Array containing menu items
* @return array Filtered links
*/
function ip_reorder_my_account_menu( $menu_links ){
$logout_link = $menu_links['customer-logout'];
@dustinleer
dustinleer / woocommerce.php
Last active May 25, 2022 20:54
Changes the WooCommerce breakpoint
<?php
function woo_custom_breakpoint( $px ) {
$px = '782px';
return $px;
}
add_filter( 'woocommerce_style_smallscreen_breakpoint', 'woo_custom_breakpoint' );
@dustinleer
dustinleer / woocommerce.php
Created May 25, 2022 15:48
Removes my account menu items
<?php
function remove_my_account_menu_items( $items ) {
unset( $items['edit-address'] );
unset( $items['orders'] );
unset( $items['downloads'] );
return $items;
}
add_filter( 'woocommerce_account_menu_items', 'remove_my_account_menu_items' );
@dustinleer
dustinleer / columns.css
Created March 25, 2022 13:34
Columns css equality
ul.columns {
column-count: 2;
column-gap: 20px;
}
ul.columns li {
font-size: 16px;
line-height: 2;
/* This will keep the li from breaking on to new lines */
-webkit-column-break-inside: avoid;
@dustinleer
dustinleer / important_filter.php
Created February 28, 2022 14:09
Removes the !important
<?php
/**
* Lowering specificity of WordPress global styles.
*/
add_action( 'init', function() {
// WP5.9+ only.
if ( ! function_exists( 'wp_get_global_stylesheet' ) ) {
return;
}
@dustinleer
dustinleer / plugin.php
Created February 3, 2022 20:39
Start a WP plugin
<?php
/**
* Plugin Name:
* Plugin URI :
* Description:
* Version: 1.0.0
* Author: Inverse Paradox
* Author URI: https://inverseparadox.com
* Text Domain:
* Domain Path: /languages