Skip to content

Instantly share code, notes, and snippets.

@febstarer
febstarer / convertolabels.js
Last active April 5, 2022 07:04
JS: Convert labels to placeholders
$("form :input, form textarea, form select").each(function(index, elem) {
var eId = $(elem).attr("id");
if(eId && (label = $(elem).parents("form").find("label[for="+eId+"]")).length == 1){
if($(elem).prop('tagName') == 'SELECT'){
// if it's a dropdown, change the first item ('All') to be the label
$(elem).find('option:first').text('- '+$(label).text()+' -');
}else{
if ($(elem).is(':checkbox') || $(elem).is(':radio')) {
// if it's a checkbox or radio, don't change anything
@rabidgadfly
rabidgadfly / wp_acf_dynamicallyPopulateSelect_1of2.php
Last active February 20, 2023 12:09
Examples of how to dynamically populate an ACF select list
<?php
/*
* In this example, we will load a textarea field from the options page (textarea field is called my_select_values)
* and use the text on each line as a option for the select field’s choices. The select field in this example has a name of “color”.
* Note: This is example 1 of 2
*
* Source: http://www.advancedcustomfields.com/resources/dynamically-populate-a-select-fields-choices/
*
* Add to your functions.php
*/
<?php
/**
* Given a URL, normalize that URL.
* @param String URL
* @return String Normalized URL
*/
function normalizeUrl($url)
{
$newUrl = "";
$url = parse_url($url);
@remyperona
remyperona / gist:13348dbcd2bbb0d9406f
Created April 14, 2015 14:32
WordPress customizer custom tinymce control
class Text_Editor_Custom_Control extends WP_Customize_Control
{
public $type = 'textarea';
/**
** Render the content on the theme customizer page
*/
public function render_content() { ?>
<label>
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
<?php
<?php
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
@salcode
salcode / .gitignore
Last active February 19, 2025 22:44
Please see https://salferrarello.com/wordpress-gitignore/ for the canonical version of this WordPress .gitignore file. Note: I do not receive notifications for comments here (because GitHub does not send notifications on Gists)
# -----------------------------------------------------------------
# .gitignore for WordPress @salcode
# ver 20180808
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore
# to download this file
#
# By default all files are ignored. You'll need to whitelist
# any mu-plugins, plugins, or themes you want to include in the repo.
@mattgipson
mattgipson / gist:6a6e54fc71c50766bc7b
Created February 24, 2015 14:31
Pulsating Arrow CSS Only
/* arrow fades in and out, use for a 'scroll down' indicator for example */
#godown {
position:absolute;
bottom:20px;
left:50%;
margin-left:-10px;
width:20px;height:20px;
display:block;
transform: rotate(45deg) ;
-webkit-transform: rotate(45deg) ;
#!/bin/env sh
lines=$(tput lines)
cols=$(tput cols)
awkscript='
{
letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"
lines=$1
anonymous
anonymous / List-with-Thumbnails.markdown
Created October 8, 2014 03:29
A Pen by Brad Frost.

List with Thumbnails

A list of items that contain a thumbnail image and a block of text, which could be as simple as a headline, but could also contain sub-text or calls to action.

A Pen by Brad Frost on CodePen.

License.

@brock
brock / nodereinstall.sh
Last active March 27, 2025 16:22
Complete Node Reinstall. I've moved this to a repo at http://git.io/node-reinstall
#!/bin/bash
# node-reinstall
# credit: http://stackoverflow.com/a/11178106/2083544
## program version
VERSION="0.0.13"
## path prefix
PREFIX="${PREFIX:-/usr/local}"