Skip to content

Instantly share code, notes, and snippets.

@epierpont
epierpont / block-examples.php
Created January 27, 2023 20:51
block examples
<?php
/**
* The blocks class file.
*
* @package WordPress
* @subpackage Swift_News_Theme
*/
namespace Swift;
@epierpont
epierpont / git-gzip-dir-and-files.txt
Created January 11, 2022 20:45
Git gzip all files in all sub-directories
// https://stackoverflow.com/questions/12331633/how-to-gzip-all-files-in-all-sub-directories-into-one-compressed-file-in-bash
tar -zcvf compressed.tar.gz folder-to-compress
@epierpont
epierpont / git-clone-existing.txt
Created July 14, 2021 18:25
GIT clone repo to existing directory
git init
echo * > .gitignore
git remote add origin https://github.com/iBecCreative/REPONAMEHERE.git
git fetch
git checkout origin/production -b production
@epierpont
epierpont / js-random-vid-src-array.js
Created May 12, 2021 18:37
JS random video src from array
<video controlslist="nodownload" autoplay muted width="100%" controls="" id="sbtvidplayer"></video>
<script type="text/javascript">
function shuffleArray(array) {
var currentIndex = array.length,
temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
@epierpont
epierpont / server-change-permissions.txt
Last active July 30, 2021 13:40
Change server file and directory permissions
// used to recursively change files to 664 and directories to 775 from parent level
// dir
find . -type d -exec chmod 775 {} \;
// files
find . -type f -exec chmod 664 {} \;
@epierpont
epierpont / wp-cli-single-search-replace.txt
Created December 9, 2020 20:59
WP-CLI Single Search/Replace
// change domain of single site
date ; wp search-replace --url=oldsite.com oldsite.com newsite.com --debug ; date
@epierpont
epierpont / wp-sql-search-post-content.txt
Created October 21, 2020 11:21
WP SQL search for post_content
// Looking for the string of wp:acf/map within WP post content
SELECT * FROM wp_8_posts WHERE post_content LIKE '%wp:acf/map%'
@epierpont
epierpont / php-url-404-loop.php
Last active October 5, 2020 16:25
PHP URL 404 loop
<?php
// Loop through URL array and look for 404 results.
$url_array = ['https://facebook.com/','https://googlemaps.com/','https://gigglemips54252.com/', 'https://www.airbnb.com/'];
foreach ($url_array as $url_entry) {
$file_headers = @get_headers($url_entry);
$exists = !$file_headers || $file_headers[0] == 'HTTP/1.1 404 Not Found' ? false : true;
echo $exists;
}
@epierpont
epierpont / Footer.js
Created September 21, 2020 13:48
Footer component for Acres USA
@epierpont
epierpont / wp-get-covid-data.php
Last active October 21, 2020 11:19
WP Get Covid-19 Data
<?php
/**
* Get covid data and return as array.
*/
public function get_covid_data() {
$content = [];
$pub_array = $this->pub_counties[$this->pub_name];
if ( false === ( $covid_content = get_transient( 'swift_module_covid_' . $this->pub_name ) ) || empty( get_option( '_transient_timeout_swift_module_covid_' . $this->pub_name ) ) ) {