Skip to content

Instantly share code, notes, and snippets.

@jinsley8
jinsley8 / google-analytics.php
Created February 13, 2022 17:51
Enqueue Google Analytics 4 script without tracking Admin
/**
* Enqueue Google Analytics 4 script
*
*/
/* Add Google Analytics 4 Site Tag as close to
the opening <head> tag as possible
=====================================================*/
define("GA4","G-XXXXXX", false); // Replace GA4 ID
<?php
/**
* Plugin Name: YOUR PLUGIN NAME
*/
include( dirname( __FILE__ ) . '/lib/requirements-check.php' );
$your_plugin_requirements_check = new YOUR_PREFIX_Requirements_Check( array(
'title' => 'YOUR PLUGIN NAME',
'php' => '5.4',
@rachelmccollin
rachelmccollin / dashboard_widget_function.php
Last active March 16, 2018 01:03
WPMU DEV Admin Messages
function rmcc_add_dashboard_widget() {
wp_add_dashboard_widget( 'rmcc_dashboard_welcome', 'Welcome', 'rmcc_welcome_widget_callback' );
}
add_action( 'wp_dashboard_setup', 'rmcc_add_dashboard_widget' );
@luisabarca
luisabarca / get-vimeo-private-video-thumb.php
Last active April 20, 2020 02:15
Get a thumbnail from Vimeo private videos
<?php
// You need Vimeo API https://github.com/vimeo/vimeo.php
require 'path-to-your-lib/vimeo/vimeo.php';
// Get this from your account
$vimeo_client_id = 'xxxxx';
$vimeo_client_secret = 'xxxxxxxxxxx';
// This has to be generated on your site, plugin or theme
$vimeo_token = 'xxxxxx';
@MikeNGarrett
MikeNGarrett / wp-cli-install-rec-plugins
Last active July 12, 2021 07:18
Chained WordPress CLI commands to install and activate recommended plugins.
# wordpress-seo provides ability to edit meta information and provides sitemap.
# w3-total-cache provides advanced caching no matter the server technology available.
# better-wp-security provides brute force protection and a number of WordPress enhancements.
# google-analytics-for-wordpress provides robust Google Analytics integration through the Google API.
# redirection detects 404s and 301s and allows admins to set up redirects in the WP admin.
# ewww-image-optimizer provides automatic optimization of uploaded images with local libraries instead of cloud-based services.
# backupwordpress simple backup solution that can store backups above web root.
# relevanssi provides better site search using a local index.
# cloudflare is the best. Free automatic CDN and security solution.
# jarvis is a quick search for the WordPress admin. Indespensible.
<?php
/*
* Plugin Name: Remove crazy counts slowing down my dashboard
* Plugin URI: https://pmgarman.me
* Description: Those comment counts are such a pain when you have a lot of comments
* Author: Patrick Garman
* Author URI: https://pmgarman.me
* Version: 1.0.0
* License: GPLv2
*/
@nickcernis
nickcernis / mailchimp-popup-for-wordpress.md
Last active July 28, 2022 14:49
MailChimp Popup Script that works with WordPress sites

MailChimp's default popup scripts can break on WordPress sites that use jQuery/jQuery UI unless you include their embed code as the final elements before the closing body tag.

Including them in this way isn't always possible or easy with WordPress.

The code below is an alternative implementation of the loader that forces MailChimp's popup scripts to appear below all other scripts upon page load.

To use it, modify the baseUrl, uuid, and lid attributes with the ones from the original popup script that MailChimp supplies.

@bekarice
bekarice / wc-disable-any-repeat-purchase.php
Last active July 26, 2023 12:19
Disables Repeat Purchase for any WooCommerce product
<?php
/**
* Disables repeat purchase for products / variations
*
* @param bool $purchasable true if product can be purchased
* @param \WC_Product $product the WooCommerce product
* @return bool $purchasable the updated is_purchasable check
*/
function sv_disable_repeat_purchase( $purchasable, $product ) {
INITIALISATION
==============
load wp-config.php
set up default constants
load wp-content/advanced-cache.php if it exists
load wp-content/db.php if it exists
connect to mysql, select db
load object cache (object-cache.php if it exists, or wp-include/cache.php if not)
load wp-content/sunrise.php if it exists (multisite only)
@tamarazuk
tamarazuk / wc-order-status-manager-order-is-editable.php
Last active February 15, 2016 01:03
WooCommerce Order Status Manager: Allow orders with custom statuses to be edited
function sv_wc_order_status_manager_order_is_editable( $editable, $order ) {
// list the slugs of all order statuses that should be editable.
// Note 'pending', 'on-hold', 'auto-draft' are editable by default
$editable_custom_statuses = array( 'packaging', 'awaiting-shipment' );
if ( in_array( $order->get_status(), $editable_custom_statuses ) ) {
$editable = true;
}