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 / acf-missing.php
Last active June 2, 2022 20:18 — forked from freezvd/acf-missing.php
WordPress mu plugins to check if "Advanced Custom Fields Pro" is active.
<?php
add_action('plugins_loaded', function() {
if ( !function_exists('is_plugin_active') ) {
/** WordPress Plugin Administration API */
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
}
if ( is_plugin_active( 'advanced-custom-fields-pro/acf.php' ) ) {
return;
@broskees
broskees / don't-break-my-homepage.php
Last active September 10, 2022 17:43
A WordPress mu-plugin to disable visual editing of the homepage and only allow text editing
<?php
/**
* Don't break my homepage mu-plugin
*
*/
add_filter('user_can_richedit', function ($can) {
global $post;
if ($post_ID === (int) get_option('page_on_front')) {
return false;
@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 / 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 / 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;
});