Instantly share code, notes, and snippets.

View get-all-super-admins.php
<?php
/**
* Get all Super Admin users on the current site.
*
* @return array WP_User objects.
*/
function get_all_superadmin_users() {
return get_users([
'login__in' => get_super_admins()
View get-all-non-super-admins.php
<?php
/**
* Get all non-Super Admin users on the current site.
*
* @return array WP_User objects.
*/
function get_all_non_superadmin_users() {
return get_users([
'login__not_in' => get_super_admins()
View language-translation.txt
{
1 => [
'en-us' => [
'name' => 'Puff Pastry',
'description' => 'Sign up for Puff Pastry news...'
],
'fr-ca' => [
'name' => {French translation},
'description' => {French transalation}
]
View forecast-expand-row-tampermonkey-script.js
// ==UserScript==
// @name Expand Forecast Row
// @version 1.0
// @description Expand Forecast Row
// @author Kellen Mace
// @match https://forecastapp.com/485680/schedule/team*
// @grant none
// ==/UserScript==
(function(document) {
View php-sandbox-tampermonkey-script.js
// ==UserScript==
// @name PHP Sandbox
// @version 0.1
// @description Customize PHP Sandbox styles
// @author Kellen Mace
// @match http://sandbox.onlinephpfunctions.com/
// @grant none
// ==/UserScript==
(function() {
View get-template-part-path.php
<?php
/**
* Get template part path. This function is identical to WP's
* get_template_part(), except that it doesn't load the template -
* just returns it so that it can be required elsewhere and have
* access to variables in the local scope.
*
* Example usage:
* $template_data = 'make this variable available in template part';
View get-list-of-beaver-builder-modules-example.php
<?php
function test_get_beaver_builder_module_list() {
$bb_module_list = new KM_Beaver_Builder_Module_List();
// Get a list of the BB modules on the current page.
$current_page_modules_list = $bb_module_list->get();
// Get a list of the BB modules on the page with a post ID of '123'.
$page_123_modules_list = $bb_module_list->get( 123 );
View get-beaver-builder-modules-on-page.php
<?php
/**
* Class for getting a list of Beaver Builder modules.
*/
class KM_Beaver_Builder_Module_List {
/**
* Get the list of Beaver Builder modules.
*
* @param int $post_id The post ID. Default is the current post being
View data-immutability-1.php
<?php
$projects = wds_get_projects();
// ...do some work...
$active_projects = array_filter( $projects, function( $project ) {
return 'active' === $project['status'];
});
View rebuild-tx-data-import.php
<?php
// Pull $username, $password, $client_id, $client_secret from the options table
$connection = new \RebuildTexasMigrations\Core\Connection( $username, $password, $client_id, $client_secret );
$connection->connect();
if ( ! $connection->is_connected() ) {
wp_send_json_error( esc_html__( 'An error occurred while connecting to the Salesforce API. Please check your username and password and try again.', 'rebuild-migration' ) );
}