Skip to content

Instantly share code, notes, and snippets.

@wptraining
wptraining / wp-theme-install.cl
Created April 21, 2020 06:05
Things you can do with wp-cli
# Install Tortuga from WordPress.org (https://wordpress.org/themes/tortuga/)
wp theme install tortuga
# Install a Theme Store Locally
wp theme install ../tortuga.zip
# Install a Theme Stored Remotely
wp theme install https://github.com/jpen365/five-hacks-for-twenty-seventeen/archive/1.0.zip
@wptraining
wptraining / wp-theme-list.cl
Created April 21, 2020 06:02
Things you can do with wp-cli
wp theme list
@wptraining
wptraining / wp-core-install.cl
Created April 21, 2020 05:58
Things you can do with wp-cli
wp core install --url=example.com --title=Website-Name --admin_user=Unique_User --admin_password=$tron9Pa55w0rd --admin_email=email@example.com
@wptraining
wptraining / wp-core-download.cl
Created April 21, 2020 05:57
Things you can do with wp-cli
wp core download
@wptraining
wptraining / wp-core-config.cl
Created April 21, 2020 05:51
Things you can do with wp-cli
wp core config --dbname=database_name --dbuser=database_user --dbpass=user_password --dbhost=localhost --dbprefix=wp_
@wptraining
wptraining / bp-custom.php
Created November 22, 2019 02:44
BuddyPress Friends-Only Activity Stream Plugin
function friends_only_activity_args($args)
{
if (!bp_is_activity_directory() || !is_user_logged_in())
{
return $args;
}
$user_id = get_current_user_id();
$user_ids = friends_get_friend_user_ids($user_id);
@wptraining
wptraining / google analytics function.php
Created October 15, 2019 03:24
WPMU DEV - Google Analytics plugin
<?php
function wpmudev_google_analytics() { ?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-XX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXXX-XX');
@wptraining
wptraining / Empty function for tracking code.php
Created October 15, 2019 03:20
WPMU DEV Simple google analytics plugin - empty function
<?php
function wpmudev_google_analytics() { ?>
<?php }
add_action( 'wp_head', 'wpmudev_google_analytics', 10 );
@wptraining
wptraining / WPMU DEV Simple Google Analytics Plugin Header.php
Created October 15, 2019 03:00
Simple Google Analytics Plugin - header
<?php
/*
Plugin Name: Simple Google Analytics Plugin
Plugin URI: https://premium.wpmudev.org
Description: Adds a Google analytics tracking code to the <head> of your theme, by hooking to wp_head.
Author: WPMU DEV
Version: 1.0
*/
?>
@wptraining
wptraining / Twenty Nineteen wp_head code.php
Created October 14, 2019 23:55
WPMU DEV Simple Google Analytics Plugin - wp_head
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="profile" href="https://gmpg.org/xfn/11" />
<?php wp_head(); ?>
</head>