As a freelancer, I build a lot of web sites. That's a lot of code changes to track. Thankfully, a Git-enabled workflow with proper branching makes short work of project tracking. I can easily see development features in branches as well as a snapshot of the sites' production code. A nice addition to that workflow is that ability to use Git to push updates to any of the various sites I work on while committing changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Hide the Inventory nav item for everybody except admins and buyers | |
function rw_hide_inventory_link_for_role() { | |
$allowed_roles = ['administrator', 'rw-buyer']; // these user roles can see the item | |
$hide = true; // default to hiding it | |
if ( is_user_logged_in() ) { | |
$user = wp_get_current_user(); | |
$roles = (array)$user->roles; | |
foreach($roles as $role) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Collect and display a sorted, unordered list element containing all children of the current post | |
Supported attributes: | |
`remove` = this string will be removed in the resulting links | |
`exclude` = posts whose title contains one of these comma-separated strings will be omitted | |
TODO: fix both params to be pipe-delimited because flexibility | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
states = { | |
'AK': 'Alaska', | |
'AL': 'Alabama', | |
'AR': 'Arkansas', | |
'AZ': 'Arizona', | |
'CA': 'California', | |
'CO': 'Colorado', | |
'CT': 'Connecticut', | |
'DC': 'District of Columbia', | |
'DE': 'Delaware', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
elements = [".some-class", "#some-id"]; // selectors for each element to suppress events | |
events = ["mouseover", "click"]; // events to suppress | |
document.addEventListener("fullscreenchange", (event) => { | |
// fullscreen event fired | |
elements.forEach((element) => { | |
events.forEach((event) => { | |
if (document.fullscreenElement) { | |
// some element has fullscreen now | |
document.querySelectorAll(element).forEach((el) => { | |
el.addEventListener(event, (e) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState, useEffect} from "react" | |
import {useRouter} from 'next/router' | |
const Event = ({embed}) => { | |
const router = useRouter() | |
const [embedSRC, setEmbedSRC] = useState(embed); | |
// useEffect(() => { | |
// const handleRouteChange = () => { | |
// setEmbedSRC(embed) | |
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ganked this from a FB group thread that linked to a dead E doc page. | |
// Storing here for reference/posterity. | |
function archive_callback( $title ) { | |
// make this a switch if you want to handle a bunch of different CPTs in one go | |
if ( is_post_type_archive('my_cpt_slug') ) { | |
return 'My custom archive title, baybay'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
<style> | |
body, | |
html { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
To Do: | |
1. Deal with multiple iframes. Don't just match the element type and assume it's a player. | |
2. Deal with multiple embedded players? | |
3. Handle a page close/reload event during playback | |
*/ | |
var iframe = document.querySelector("iframe"); | |
if (!iframe) { | |
console.log("No Vimeo player found"); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selector::before { | |
content:""; | |
background-image:url('foo.svg'); | |
position:absolute; | |
top:0; | |
left:2; | |
opacity:0.3; | |
} | |
selector::after { |
NewerOlder