Skip to content

Instantly share code, notes, and snippets.

@jaredatch
jaredatch / functions.php
Created November 11, 2016 16:20
WPForms add new address field scheme
<?php
/**
* WPForms Add new address field scheme (Canada)
*
* @param array $schemes
* @return array
*/
function wpf_new_address_scheme( $schemes ) {
$schemes['canada'] = array(
@jaredatch
jaredatch / comments.php
Created November 4, 2016 13:29
WordPress Facebook Comments Lazy Load
<?php
/*
* If the current post is protected by a password and
* the visitor has not yet entered the password we will
* return early without loading the comments.
*/
if ( post_password_required() ) {
return;
}
?>
@jaredatch
jaredatch / functions.php
Last active February 28, 2022 22:04
WordPress Search Autocomplete using WP REST API v2
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@jaredatch
jaredatch / functions.php
Last active July 3, 2023 23:10
WordPress Search Autocomplete using admin-ajax.php
<?php
/**
* Enqueue scripts and styles.
*
* @since 1.0.0
*/
function ja_global_enqueues() {
wp_enqueue_style(
'jquery-auto-complete',
@jaredatch
jaredatch / custom-validation.js
Last active September 7, 2023 15:45
WPForms adding a custom validation rule
;(function($) {
var JA_Custom_Validation = {
/**
* Start the engine.
*
* @since 1.0.0
*/
init: function() {
@jaredatch
jaredatch / functions.php
Created September 13, 2016 21:03
WPForms set select fields use raw values (if configured) instead of field label
<?php
/**
* Set the field value to the raw value instead of the field label.
*/
function wpf_select_use_raw_values( $fields, $entry, $form_data ) {
foreach( $fields as $id => $field ) {
// Only do this for select fields that are configured to use raw values
if ( 'select' == $field['type'] && isset( $form_data['fields'][$id]['show_values'] ) ) {
@jaredatch
jaredatch / comment-headings.php
Last active March 28, 2017 18:14
PHP comment heading blocks styling
<?php
// Big sections
// ------------------------------------------------------------------------//
// xxx
// ------------------------------------------------------------------------//
// Small sections
@jaredatch
jaredatch / functions.php
Last active August 16, 2019 14:10
WPForms populate select field from custom post type posts
<?php
/**
* WPForms populate select field from custom post type posts
*
* @param array $field
* @param array $field_atts
* @param array $form_data
* @return array
*/
function wpf_custom_select( $field, $field_atts, $form_data ){
@jaredatch
jaredatch / functions.php
Created August 30, 2016 16:37
WPForms customize the timepicker format (remove AM/PM)
<?php
/**
* WPForms customize the timepicker format (remove AM/PM)
*/
function wpf_timepicker_custom() {
?>
<script type="text/javascript">
var wpforms_pickatime = {
format: 'H:i'
}
@jaredatch
jaredatch / functions.php
Created August 26, 2016 19:34
WPForms preselect dropdown field based on URL parameter
<?php
/**
* Preselect dropdown field based on URL parameter.
*
* @param array $field
* @param array $field_atts
* @param array $form_data
* @return array
*/
function wpf_preselect_dropdown( $field, $field_atts, $form_data ) {