Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / .gitignore_global
Created February 24, 2018 21:48
Global gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@hellofromtonya
hellofromtonya / functions.php
Last active February 23, 2018 21:07
Testing Beans Fields API for post meta.
add_action( 'admin_init', 'beans_child_test_fields' );
/**
* Test the Fields API for post meta.
*
* @since 1.5.0
*
* @return void
*/
function beans_child_test_fields() {
$beans_uri = get_template_directory_uri();
@hellofromtonya
hellofromtonya / beans-action-encoding-test.php
Created February 11, 2018 19:30
Profile memory usage and execution time when storing in the Beans Action API Container using json_encode
<?php
/**
* Test if we need to encode each action before storing it into the container.
*
* This test will run 1,000,000 cycles using json_encode and take a snapshot of the memory usage and total execution time.
* Then it'll run another million cycles by storing the array into the container, without encoding it.
*
* We'll print out the results.
*/
@hellofromtonya
hellofromtonya / menu.php
Last active January 21, 2018 16:55
Beans - Relocate the primary navigation menu below the site header.
<?php
// Relocate the primary navigation menu below the site header.
beans_modify_action( 'beans_primary_menu', 'beans_header_after_markup', null, 10 );
beans_remove_attribute( 'beans_primary_menu', 'class', 'uk-float-right' );
@hellofromtonya
hellofromtonya / html.php
Created December 8, 2017 18:01
Change `>>` to `...` after "Continue reading" in the Beans framework
<?php
/**
* This line of code removes the >> HTML markup, meaning this HTML will not be sent out to the browser:
*
* <i class="uk-icon-angle-double-right uk-margin-small-left" data-markup-id="beans_next_icon[_more_link]"></i>
*/
beans_remove_markup('beans_next_icon[_more_link]');
/**
@hellofromtonya
hellofromtonya / beans-uikit-nav.js
Created November 9, 2017 16:58
Keep submenus open in Beans and UIKit v2
(function ( $ ) {
"use strict";
// Let's wait a little bit to let UIKit do its thang first.
setTimeout( function () {
$( '.tm-beans-keep-open' ).not('uikit-active').each(openSubmenu);
}, 100 );
/**
* Force open the submenu by targeting the submenu <div> container,
@hellofromtonya
hellofromtonya / term-hierarchical-search.php
Last active February 27, 2024 13:18
WordPress Term Hierarchical Search
<?php
/**
* Term Hierarchical Search
*
* These methods provide a utility interface to find a meta value
* within the term's hierarchy. It walks up the hierarchy starting
* at the given term, i.e. walks to its parent -> grandparent -> N levels.
*
* It's performant as it grabs the records it needs out of the database
* with one SQL query, i.e. to avoid multiple trips to gather each level's
@hellofromtonya
hellofromtonya / term-metadata.php
Last active July 21, 2017 14:51
Grab all of the term ancestors (child and walk up the tree) + the requested metadata.
<?php
/**
* Get the specified metadata value for the term or from
* one of it's parent terms.
*
* @since 1.0.0
*
* @param WP_Term $term Term object
* @param string $meta_key The meta key to retrieve.
@hellofromtonya
hellofromtonya / term-metadata.php
Created July 20, 2017 15:50
Walk the term metadata to get a specific value
<?php
/**
* Get the specified metadata value for the term or from
* one of it's parent terms.
*
* @since 1.0.0
*
* @param WP_Term $term Term object
* @param string $meta_key The meta key to retrieve.
@hellofromtonya
hellofromtonya / asset-versioning.php
Created July 12, 2017 21:35
Better Asset Versioning Utility File for WordPress
<?php
/**
* Asset versioning
*
* @package Better Asset Versioning
* @since 1.0.0
* @author hellofromTonya
* @link https://KnowTheCode.io
* @license GNU-2.0+
*/