Skip to content

Instantly share code, notes, and snippets.

View smchenrybc's full-sized avatar

Sean McHenry smchenrybc

View GitHub Profile
@smchenrybc
smchenrybc / functions.php
Last active April 28, 2025 16:38
Inject <script> added to custom field to header and footer
<?php
/**
* Add script code to page's header
*/
function bc_add_page_script_code_header() {
$script_raw = get_field( 'script_code', get_the_ID(), false );
$script_location = get_field( 'script_location', get_the_ID() );
if ( !is_admin() && $script_raw && $script_location == 'header' ) {
$script_decoded = htmlspecialchars_decode( $script_raw );
@smchenrybc
smchenrybc / javascript.js
Created October 25, 2024 16:57
Learn JavaScript in Y Minutes
// Single-line comments start with two slashes.
/* Multiline comments start with slash-star,
and end with star-slash */
// Statements can be terminated by ;
doStuff();
// ... but they don't have to be, as semicolons are automatically inserted
// wherever there's a newline, except in certain cases.
doStuff()
@smchenrybc
smchenrybc / reset.css
Created October 25, 2024 16:08
A (more) Modern CSS Reset - Piccalilli
/**
* reset.css
*
* Andy Bell's CSS reset used for Set Studio
* Agency and described at Piccalilli blog here:
* https://piccalil.li/blog/a-more-modern-css-reset
*/
/* Box sizing rules */
@smchenrybc
smchenrybc / type-scale.css
Last active October 24, 2024 17:19
Baseline.is Type Scale Generator "Major Third" stylesheet
/**
* type-scale.css
*
* @link https://baseline.is/tools/type-scale-generator
*/
html {font-size: 16px;}
body {
font-family: 'Open Sans', sans-serif;
@smchenrybc
smchenrybc / functions.class.php
Last active September 5, 2024 14:21
Revolution Slider v6.2.22 valid image file function patch
<?php
/**
* @author ThemePunch <[email protected]>
* @link https://www.themepunch.com/
* @copyright 2019 ThemePunch
*/
if(!defined('ABSPATH')) exit();
class RevSliderFunctions extends RevSliderData {
@smchenrybc
smchenrybc / multidownload.php
Created August 2, 2024 13:59 — forked from victormattosvm/multidownload.php
Fastest way to download an array of images using multicurl
<?php
/*
* Fastest way to download an array of images using multicurl
*/
function multi_download(array $urls, $pathToSave)
{
$multi_handle = curl_multi_init();
$file_pointers = [];
$curl_handles = [];
if(!file_exists($pathToSave)){
@smchenrybc
smchenrybc / delete-likes-from-twitter.md
Created July 30, 2024 16:35 — forked from aymericbeaumet/delete-likes-from-twitter.md
[Recipe] Delete all your likes/favorites from Twitter

Ever wanted to delete all your likes/favorites from Twitter but only found broken/expensive tools? You are in the right place.

  1. Go to: https://twitter.com/{username}/likes
  2. Open the console and run the following JavaScript code:
setInterval(() => {
  for (const d of document.querySelectorAll('button[data-testid="unlike"]')) {
    d.click()
 }
@smchenrybc
smchenrybc / functions.php
Last active January 17, 2024 18:28
Bug fixes in functions.php
<?php
/**
* functions.php
*/
/**
* Fix a long-standing issue with ACF, where fields sometimes aren't shown
* in previews (ie. from Preview > Open in new tab).
*
* @link https://support.advancedcustomfields.com/forums/topic/custom-fields-on-post-preview/
@smchenrybc
smchenrybc / local-error-handler.php
Last active September 22, 2023 18:58 — forked from bradyvercher/local-error-handler.php
Suppress errors generated by specified WordPress plugins to make developing with debug mode on less painful.
<?php
/**
* Suppress errors generated by specified WordPress plugins.
*
* Include in the auto_prepend_file php.ini directive to ignore globally.
*
* @see http://plugins.trac.wordpress.org/browser/ostrichcize/tags/0.1/ostrichcize.php#L146
*
* @param string $errno The error number.
* @param string $errstr The error message.
@smchenrybc
smchenrybc / context-functions.php
Created July 28, 2023 14:38
Context functions for RiverWoods theme
<?php
/**
* context-functions.php
*
* @package bc_starter
*/
/**
* Get the primary category set in Yoast SEO
*