Skip to content

Instantly share code, notes, and snippets.

@aaronsummers
aaronsummers / _cpt-loop.php
Last active May 29, 2019 11:33
Creating multiple custom post type with a foreach loop
<?php
/**
* Functions to create titles and slugs
* Very rough function !!
* If you require a more customised solution
* Add your single title to a [$post_type__title_single] variable inside the if statement for the post type
*/
function make_single_title($string) {
$to_single = preg_replace("/s\b/", "", $string);
return ucwords( $to_single );
@aaronsummers
aaronsummers / Contact form 7 form builder shortcodes
Last active December 18, 2023 19:45
Contact form 7 all fields and country dropdown
[text text class:classname class:otherclassname placeholder "placeholder"]
[email* email placeholder "Email Address"]
[url* url placeholder "http://..."]
[tel* tel placeholder "Phone no."]
[range* number-slider min:0 max:100 placeholder "Ammount"]
[number* number-spinbox min:0 max:100 placeholder "Ammount"]
@fgilio
fgilio / axios-catch-error.js
Last active April 11, 2024 19:02
Catch request errors with Axios
/*
* Handling Errors using async/await
* Has to be used inside an async function
*/
try {
const response = await axios.get('https://your.site/api/v1/bla/ble/bli');
// Success 🎉
console.log(response);
} catch (error) {
// Error 😨
@alberto-marin
alberto-marin / snippets.cson
Created April 8, 2017 07:53
AMP (Accelerated Mobile Pages) html boilerplate for atom.io
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values
#
# Atom Flight Manual:
# http://flight-manual.atom.io/using-atom/sections/basic-customization/#_cson
#
'.text.html':
'AMP HTML Project':
@tabrindle
tabrindle / webp-convert-directory.sh
Last active June 15, 2024 07:55
Convert all files in directory to webp, with default params, or standard cwebp params passed from command
#!/bin/bash
PARAMS=('-m 6 -q 70 -mt -af -progress')
if [ $# -ne 0 ]; then
PARAMS=$@;
fi
cd $(pwd)
@dannyconnolly
dannyconnolly / translate_woocommerce.php
Created December 18, 2015 13:22
Change SKU text label in woocommerce to Product Code
function translate_woocommerce($translation, $text, $domain) {
if ($domain == 'woocommerce') {
switch ($text) {
case 'SKU':
$translation = 'Product Code';
break;
case 'SKU:':
$translation = 'Product Code:';
break;
@thejamescollins
thejamescollins / woocommerce-shop-archives.php
Created May 1, 2015 04:03
WooCommerce wrap product images in the loop (shop/archive pages)
<?php
/**
* Shop/archives: wrap the product image/thumbnail in a div.
*
* The product image itself is hooked in at priority 10 using woocommerce_template_loop_product_thumbnail(),
* so priority 9 and 11 are used to open and close the div.
*/
add_action( 'woocommerce_before_shop_loop_item_title', function(){
echo '<div class="imagewrapper">';

Deploying Yeoman apps to Heroku

Prerequisites

This assumes you already have a Yeoman app and are ready for publishing

Build for Production

Create production directory & assets

@ramseyp
ramseyp / hide-editor.php
Created November 12, 2012 15:48
Hide the content editor for certain pages in WordPress
<?php
/**
* Hide editor on specific pages.
*
*/
add_action( 'admin_init', 'hide_editor' );
function hide_editor() {
// Get the Post ID.