Skip to content

Instantly share code, notes, and snippets.

View ajschlosser's full-sized avatar

Aaron John Schlosser ajschlosser

  • California
View GitHub Profile
@ajschlosser
ajschlosser / print_wp_nav_menu
Last active August 29, 2015 14:06
Wraps iterated wp_get_nav_menu_items output in customizable HTML
function print_wp_nav_menu ($menu, $params=array()) {
/**
*
* Wraps iterated wp_get_nav_menu_items output in customizable HTML
*
* @author Aaron John Schlosser <aaron@aaronschlosser.com>
* @link https://gist.github.com/ajschlosser/daf17648f0f42d1597ec#file-acf_make_two_columns
* @copyright Copyright 2014 Aaron John Schlosser
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2
* @param array $params Array containing all other parameters (optional)
@ajschlosser
ajschlosser / ACF_make_two_columns
Last active August 29, 2015 14:06
Breaks an ACF field into two divs of evenish columns
<?php
/**
*
* Breaks an ACF field into two divs of evenish columns
*
* @author Aaron John Schlosser <aaron@aaronschlosser.com>
* @link https://gist.github.com/ajschlosser/daf17648f0f42d1597ec#file-acf_make_two_columns
* @copyright Copyright 2014 Aaron John Schlosser
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2
function put_in_paragraph ($p) { return "<p>" . $p . "</p>"; }
function print_halves ($a) {
$total_length = 0;
for($i = 1; $i <= count($a); $i++) {
$total_length += strlen($a[$i]);
}
$first_half_length = 0;
$second_half_length = 0;
$second_half_index = 0;
$done = false;
<?php
function get_halves ($a) {
$total_length = 0;
for($i = 1; $i <= count($a); $i++) {
$total_length += strlen($a[$i]);
}
echo "Cutting an array of ".count($a)." strings totaling ".$total_length." characters in half:<br><br>";
$first_half_length = 0;
$second_half_length = 0;