Skip to content

Instantly share code, notes, and snippets.

View fieldoffice's full-sized avatar
🚲
Out cycling

Andy Field fieldoffice

🚲
Out cycling
View GitHub Profile
@fieldoffice
fieldoffice / css-borders-using-box-shadow.css
Last active March 14, 2022 15:39
CSS Borders using box-shadow
box-shadow: 0 1px 0 0 palegoldenrod; /* Border bottom */
box-shadow: 0 -1px 0 0 palegoldenrod; /* Border top */
box-shadow: -1px 0 0 0 palegoldenrod; /* Border left */
box-shadow: 1px 0 0 0 palegoldenrod; /* Border right */
box-shadow: 0 0 0 1px palegoldenrod; /* All borders */
@fieldoffice
fieldoffice / react_select.tsx
Created March 2, 2022 11:13
React Select Snippets
// Remove styling from react-select
const styleProxy = new Proxy({}, {
get: (target, propKey) => () => {}
});
// Keep menu open
menuIsOpen='true'
@fieldoffice
fieldoffice / textarea-character-count.html
Last active October 19, 2021 13:01
Text Area Character Count
<textarea id="js-message" rows="4" maxlength="300"></textarea>
<div id="js-counter" class="message__counter">0 / 300</div>
<script>
// Character count
var message = document.getElementById('js-message');
var counter = document.getElementById('js-counter');
message.addEventListener('input', function (e) {
var target = e.target;
@fieldoffice
fieldoffice / custom-walker.php
Created March 12, 2020 10:11
Custom Walker for WordPress. Removes default classes but keeps any custom classes
// Custom walker. Removes default classes but keeps any custom classes
class custom_walker extends Walker_Nav_Menu {
function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) {
$indent = ( $depth ) ? str_repeat( "\t", $depth ) : '';
$class_names = $value = '';
$class_names = join( ' ', apply_filters(
'nav_menu_css_class', (array)get_post_meta( $item->ID, '_menu_item_classes', true ) )
@fieldoffice
fieldoffice / formidable-pardot.php
Created November 26, 2019 13:12
Send Formidable form data to Pardot
<?php
add_action('frm_after_create_entry', 'sendToPardot', 30, 2);
function sendToPardot($entry_id, $form_id){
if($form_id == 5){ // Form ID
/* You can create as many variables as you need, the last number is the field ID number
that you get from the Build or Settings tab of your form */
$pardotEmail = ($_POST['item_meta'][10]);
$pardotFirst = ($_POST['item_meta'][11]);
$pardotPhone = ($_POST['item_meta'][12]);
/* In Pardot you specify whatever External Field Name you want.
@fieldoffice
fieldoffice / acf-options-cpt
Created November 24, 2019 12:28
ACF Options with Custom Post Type
// Functions
if( function_exists('acf_add_options_page') ) {
acf_add_options_sub_page(array(
'page_title' => 'PAGE_TITLE',
'menu_title' => 'MENU_TITLE',
'menu_slug' => 'MENU_SLUG',
'capability' => 'edit_posts',
'parent_slug' => 'edit.php?post_type=POST_TYPE',
));
@fieldoffice
fieldoffice / emmet-basics
Last active January 10, 2021 21:46
Emmet Basics
#Child >
nav>ul>li
#Sibling +
h1+h2+p
#Climb-up ^
div+div>p>span+em^bq
div+div>p>span+em^^bq
@fieldoffice
fieldoffice / wordpress-docker
Last active December 13, 2018 13:09
Running WordPress using Docker
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
@fieldoffice
fieldoffice / wp-nav-simplified.php
Last active July 8, 2018 20:45
Simplified WordPress Nav
<?php
$defaults = array(
'theme_location' => 'primary-menu',
'container' => 'nav',
'container_class' => 'primary-nav',
'echo' => false,
'fallback_cb' => false,
'items_wrap' => '%3$s',
'depth' => 0
);
@fieldoffice
fieldoffice / formidable-email-validation.php
Last active October 31, 2022 17:55
Formidable Forms Email Validation
add_filter('frm_validate_field_entry', 'my_custom_validation', 10, 3);
function my_custom_validation($errors, $posted_field, $posted_value){
$fieldArray = array(001,002);
$blockArray = array("@mail.co.uk","@hotmail.","@googlemail.","@gmail.","@yandex.","@live.","@yahoo.","@mail.","@chemist.","@coolsite.","@comic.","@fastmail.","@outlook.","@me.","@aol.","@lycos.","@gmx.","@home.","@123-reg.");
if(in_array($posted_field->id, $fieldArray)){
foreach ($blockArray as $blockedValue) {
if (stripos($posted_value, $blockedValue))
{
$errors['field'. $posted_field->id] = 'Please use a business email address. We\'re unable to process orders for @'. explode('@', $posted_value, 2)[1] .' email addresses.';
}