Skip to content

Instantly share code, notes, and snippets.

@blogtutor
blogtutor / woo-no-live-badge.php
Created September 15, 2024 18:10 — forked from ChrisCree/woo-no-live-badge.php
Remove WooCommerce 9.3 "Live" badge from Admin Bar. This code goes in theme's functions.php file.
<?php // Do not copy opening php tag
/**
* Remove WooCommerce site visibility "Live" badge from the admin bar.
*
* @param WP_Admin_Bar $wp_admin_bar The WP_Admin_Bar instance, passed by reference.
*/
add_action( 'admin_bar_menu', 'khp_remove_woocommerce_site_visibility_badge', 999 );
function khp_remove_woocommerce_site_visibility_badge( $wp_admin_bar ) {
$wp_admin_bar->remove_node( 'woocommerce-site-visibility-badge' );
@blogtutor
blogtutor / gtag.js adjusted bounce rate
Last active March 28, 2019 16:18
Adjusted Bounce Rate for Google Global Site Tag
/* insert after gtag('config') */
/* setTimeout("gtag('event', 'adjusted bounce rate', {'event_label':'More than 20 seconds'})",20000 ); */
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-12345678-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
@blogtutor
blogtutor / wp-cli-search-replace
Last active September 23, 2018 15:03
Search & Replace with WP-CLI
# Sample code to run search & replace in your WordPress database from the command line with WP-CLI
# Use at your own risk! I make no warranties that this will actually work properly and not blow up your site! (I recommend trying this on a development server first.)
# Make a database backup first with "wp db export"
# Replace "domain.com" with your domain (also include www if used)
# https://developer.wordpress.org/cli/commands/search-replace/
# Simple change from http to https
wp search-replace 'http://domain.com' 'https://domain.com' --skip-columns=guid
# Remove /year/month/ from permalinks