Skip to content

Instantly share code, notes, and snippets.

View coulterpeterson's full-sized avatar
🤓
Always learning

Coulter Peterson coulterpeterson

🤓
Always learning
View GitHub Profile
/*
* COOKIE HANDLING FUNCTIONS
* Source: http://www.quirksmode.org/js/cookies.html
*/
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@coulterpeterson
coulterpeterson / snippet.php
Created January 2, 2020 21:27
Remove #WordPress admin menu items
//CREDIT: https://digwp.com/2016/06/remove-toolbar-items/
/* METHOD 1 */
function shapeSpace_remove_toolbar_node($wp_admin_bar) {
// replace 'updraft_admin_node' with your node id
$wp_admin_bar->remove_node('updraft_admin_node');
@coulterpeterson
coulterpeterson / functions.php
Last active August 23, 2021 18:21
Disable #Divi Builder Scripts on Non-Divi Pages (#WordPress)
// START DIVI DISABLE ON NON-DIVI PAGES (AVOIDS CONFLICTS)
if( function_exists('divi_deregister_script') ) {
// Thanks to Adam Haworth: https://adamhaworth.com/dequeue-divi-builder-plugin-scripts-and-styles-when-not-needed/
function divi_deregister_script() {
$is_page_builder_used = et_pb_is_pagebuilder_used( get_the_ID() );
if( !$is_page_builder_used ) {
wp_dequeue_script('et-builder-modules-global-functions-script');
wp_dequeue_script('google-maps-api');
@coulterpeterson
coulterpeterson / main-plugin-file.php
Created January 12, 2020 02:32
#WordPress #plugin boilerplate
<?php
/* /wp-content/plugins/my-amazing-plugin/my-amazing-plugin.php */
/*
Plugin Name: My Amazing Plugin
Description: Your Plugin Description.
Version: 1.0
Author: Your Name
Author URI: http://yourwebsite.com
@coulterpeterson
coulterpeterson / setup-local.sh
Created January 20, 2020 19:02 — forked from eriktdesign/setup-local.sh
Configurations for a Local WordPress site
#!/usr/bin/php
<?php
# Script Options
$shortopts = "";
# $shortopts .= "p:"; // Required value
# $shortopts .= "v::"; // Optional value
$shortopts .= "i"; // Use http
$longopts = array(
@coulterpeterson
coulterpeterson / backup_public_html.sh
Last active February 14, 2020 02:29
#bash #shell script to backup public_html to a .tar.gz
#!/bin/bash
# To make script executable for everyone: chmod a+x backup_public_html.sh
# To later unzip the file below: tar xvzf 2020-01-29_23-20-11_backup.tar.gz -C ./test
curdate=$(date '+%Y-%m-%d_%H-%M-%S')
tar -czf ./backups/${curdate}_backup.tar.gz --exclude='../backup_scripts/*' ../
echo "Backup Complete"
@coulterpeterson
coulterpeterson / header.html
Created February 1, 2020 00:19
Toggleable snowflakes snippet that can be stuck in the <head> of an #html page. Modified from the CSS snowflakes created by pajasevi
<!-- Start Snowflakes -->
<style>
.snow-toggle {
position: fixed;
bottom: 0;
right: 0;
background: #fff;
border: #efefef solid 1px;
padding: 10px 15px;
display:flex;
@coulterpeterson
coulterpeterson / functions.php
Created February 5, 2020 17:54
Temporarily block users from editing in the #WordPress Dashboard #php
// Maintenance mode function
add_action('admin_head', 'block_admin_editing_style');
function block_admin_editing_style() {
echo "<style>
#wpwrap{
display:none!important;
}
</style>
<script>
@coulterpeterson
coulterpeterson / cheatsheet.md
Last active February 5, 2020 18:36
#rsync #cheatsheet