Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Dustin Leer dustinleer

🏠
Working from home
View GitHub Profile
@dustinleer
dustinleer / acf-theme-activation-sync.php
Created Jun 21, 2022
Syncs ACF JSON upon theme activation
View acf-theme-activation-sync.php
<?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 Jun 14, 2022
Contact Form 7 Submission Redirect
View functions.php
<?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 Jun 10, 2022
Add User Role Class to Body
View user-class-functions.php
<?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
Add a custom WooCommerce My Account endpoint
View woocommerce.php
<?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
Reorders WooCommerce menu links
View woocommerce.php
<?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
Changes the WooCommerce breakpoint
View woocommerce.php
<?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
Removes my account menu items
View woocommerce.php
<?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 Mar 25, 2022
Columns css equality
View columns.css
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;
View important_filter.php
<?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 Feb 3, 2022
Start a WP plugin
View plugin.php
<?php
/**
* Plugin Name:
* Plugin URI :
* Description:
* Version: 1.0.0
* Author: Inverse Paradox
* Author URI: https://inverseparadox.com
* Text Domain:
* Domain Path: /languages