Skip to content

Instantly share code, notes, and snippets.

@broskees
broskees / caldera_custom_checkbox_markup.php
Created January 19, 2018 17:05
Custom Caldera Checkbox HTML markup for styling purposes
/*
* Custom checkbox markup to allow for styled checkboxes
* Styling method: https://www.inserthtml.com/2012/06/custom-form-radio-checkbox/
* Must be placed in /caldera/ directory within wordpress theme
*/
<?php echo $wrapper_before; ?>
<?php echo $field_label; ?>
<?php echo $field_before; ?>
<?php
@broskees
broskees / nocache.php
Last active January 10, 2020 22:35
A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option.
<?
/**
* Plugin Name: WordPress Catch All Cache Buster
* Description: A quick catch-all cache-busting WordPress plugin when having clients clear their browser cache isn't an option.
* Version: 1.0.0
* Author: Joseph Roberts
* Author URI: https://github.com/DigitalJoeCo
* License: MIT
* License URI: http://opensource.org/licenses/MIT
*/
@broskees
broskees / zettelkasten_bpm.md
Last active February 20, 2021 19:57
A Zettelkasten like BPM (idea)

A Zettelkasten like BPM

What this is

This is a methodology for managing business procedures and factual references for a company.

Folder Structure

Business Reference
@broskees
broskees / becoming-a-webdev.md
Last active June 26, 2021 02:58
Becoming A Web Developer: A - Z
@broskees
broskees / stripOuterTags.php
Last active September 27, 2021 06:27 — forked from komlenic/DOMElement.innerHTML.php
Strip Outer Tags of an HTML string in PHP
<?php
// See http://www.php.net/manual/en/class.domelement.php#101243
function stripOuterTags($html) {
$doc = new \DOMDocument();
$doc->loadHTML($html);
$element = $doc->documentElement;
$newhtml = '';
foreach($element->childNodes as $node) {
$newhtml .= $element->ownerDocument->saveHTML($node);
@broskees
broskees / assets.php
Last active December 7, 2021 20:03
WordPress CSS & JS enqueue router
<?php
/**
* Routes specific js & css files to enqueue if they exist.
*
* (The idea is to use default.css & default.js for all your global styles,
* then simply include default.css & default.js into your $template.css & template.js files
* so that you can easily keep filesizes small and minimize the number of resources requested.)
*/
add_action( 'wp_enqueue_scripts', function() {
@broskees
broskees / shortcodes.php
Created December 9, 2021 20:00
Year shortcode that shows the next year after december
<?php
add_shortcode('year', function() {
$current_year = date('Y');
$thanksgiving = strtotime("December 1st $current_year");
return $thanksgiving < time() ? $current_year + 1 : $current_year;
});
@broskees
broskees / filters.php
Last active December 9, 2021 20:19
Sage 9 Conditional Sidebars
<?php
add_filter('sage/display_sidebar', function ($display) {
static $display;
isset($display) || $display = in_array(true, [
// The sidebar will be displayed if any of the following return true
is_single(),
is_404(),
is_page_template('views/template-custom.blade.php')
@broskees
broskees / page-template-column.php
Created December 20, 2021 16:18
Add a Page Template column to the WordPress admin "Pages" page
<?php
/**
* Introduces a new column to the 'Page' dashboard that will be used to render the page template
* for the given page.
*
* @param array $page_columns The array of columns rendering page meta data.
*
* @return array $page_columns The update array of page columns.
*/
@broskees
broskees / Zettlekasten ID
Created January 7, 2022 23:42
Readwise to obsidian template - zettlekasten 12 digit id (based on date & time) (Jinja)
{{date|date("Ymd")}}{% for char in time|replace(":", "")|replace("am", "")|replace("pm", "")|list %}{% if loop.index == 1 and time[1] == ":" and "am" in time %}0{{char}}{% elif loop.index < 3 and time[2] == ":" and time[1] == "2" and "am" in time %}0{% elif loop.index == 1 and time[1] == ":" and "pm" in time %}{{char|int() + 12}}{% elif loop.index < 3 and time[2] == ":" and "pm" in time %}{{char|int() + loop.index}}{% else %}{{char}}{% endif %}{% endfor %}