Skip to content

Instantly share code, notes, and snippets.

View tc33's full-sized avatar

Tom tc33

  • Vibe Agency
  • United Kingdom
View GitHub Profile
@tc33
tc33 / tc33-cache-user-count.php
Last active July 8, 2022 16:53
Handle caching WordPress user counts to avoid slow blocking queries on sites with large user bases. Can be installed directly as an mu-plugin.
<?php
/**
* Returns cached user counts if there are some, otherwise fetches current user counts and stores them for later use.
*
* @param int $count Count to be overridden, will be null when called by pre_count_users.
* @param string $strategy The computational strategy to use when counting the users.
* @param int|null $site_id The site ID to count users for.
*
* @return array Includes a grand total and an array of counts indexed by role strings.
$(function() {
// Tweaked from: https://gist.github.com/mattstauffer/3835881
// No guarantees
// 1. include Isotope.js
// 2. include this file
// 3. customize Isotope options at the bottom of this file
// 4. add "margin: 0 auto" to the isotope container
$.Isotope.prototype._getMasonryGutterColumns = function() {