Instantly share code, notes, and snippets.

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' ) );
}
View Salesforce REST API Response
"dataCells": [
{
"escapedLabel": "Aransas Pass Chamber of Commerce - Mar 2018",
"label": "Aransas Pass Chamber of Commerce - Mar 2018",
"value": "Aransas Pass Chamber of Commerce - Mar 2018"
},
{
"label": "a0q1I000000xh0Y",
"value": "a0q1I000000xh0YQAQ"
},
View remote-image-file-exists-usage.php
<?php
$image_url = 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png';
if ( km_remote_image_file_exists( $url ) ) {
echo 'The remote image exists! Hooray!';
} else {
echo 'The remote image does not exist. Boooooo.';
}