Skip to content

Instantly share code, notes, and snippets.

View samjco's full-sized avatar

Sam C. samjco

View GitHub Profile
@michelegiorgi
michelegiorgi / formality_hooks_sample.php
Last active December 20, 2023 00:06
Formality hooks reference
<?php
/**
* Formality hooks reference
*
* @link https://formality.dev
* @since 1.1
* @package Formality
* @author Michele Giorgi <hi@giorgi.io>
*/
@KittenCodes
KittenCodes / modal.js
Created February 20, 2020 13:28
jQuery to create Lightbox popup using Oxygen's Modal element
jQuery('.lightbox-trigger').click( function() {
var image = jQuery(this).attr('src');
jQuery('.lightbox-popup').css('background-image', 'url(' + image + ')');
var caption = jQuery(this).next().text();
jQuery('.lightbox-popup-caption').text( caption );
@eclarrrk
eclarrrk / get-gravity-forms-entries.php
Last active May 29, 2022 22:46
Display Gravity Form entries into WordPress page template
<?php
/*
Official Gravity Forms documentation on get_entries() found here:
https://docs.gravityforms.com/api-functions/#get-entries
*/
/* Gravity Form ID. */
$form_id = '20';
/* Sorting options avalable but left blank for simplicity. */
@wajdijurry
wajdijurry / ArrayManipulation.php
Last active July 6, 2021 15:21
Adding item to array or change existent item position after shifting elements up or down depending on available positions
<?php
/**
* Author:Wajdi Jurry <jurrywajdi@yahoo.com> (https://github.com/wajdijurry)
* Gist: https://gist.github.com/wajdijurry/a00752123134342ccc9d13a480c9f013
*/
class ArrayManipulation
{
private $array;
public function __construct(array $array)
@kasrak
kasrak / create_record.php
Last active June 15, 2021 14:20
Create a record in Airtable using PHP
<?php
$data = array(
"fields" => array(
"Name" => "Hello world"
)
);
$data_json = json_encode($data);
$ch = curl_init("https://api.airtable.com/v0/YOUR_BASE_ID/YOUR_TABLE_NAME?api_key=YOUR_API_KEY");
@dn7734
dn7734 / single-photogallery.php
Created June 12, 2017 08:14
ACF + isotope-layout + magnific-popup.js = gallery
<?php
do_action('get_header');
//get_template_part('templates/header');
?>
<?php //get_template_part('templates/partials/breadcrumbs'); ?>
<?php //get_template_part('templates/base'); ?>
<?php if( have_rows('gallery') ): $i=0;?>
@Shelob9
Shelob9 / all-fields.php
Created May 2, 2017 19:09
Get all field IDs or field slugs or field labels from a Caldera Form
<?php
/**
Get all field IDs or field slugs or field labels from a Caldera Form
*/
//Get form config
$form = Caldera_Forms_Forms::get_form( 'CF58c1e0a4d7c27' );
//Get all fields in order
$fields = Caldera_Forms_Forms::get_fields( $form, true );
<?php
/**
* Delete all form configs, but no entries.
*/
$forms = Caldera_Forms_Forms::get_forms( false, true );
foreach ( $forms as $form ){
Caldera_Forms_Forms::delete_form( $form );
}
<?php
/**
* Get a field value and send to remote API
*/
add_action( 'caldera_forms_submit_complete', function( $form, $referrer, $process_id ) {
//change your form ID here
if( 'cf123..' != $form[ 'ID' ] ) {
return;
}
@ensostyle
ensostyle / ListFieldRowTotal
Created January 11, 2017 12:15
Count the number of rows in a Gravity Forms list field and store the result in another field.
<script>
function ListFieldRowCount( listField, totalField ) {
var totalRows = jQuery( listField ).find('table.gfield_list tbody tr').length;
jQuery( totalField ).val( totalRows ).change();
}
function ListFieldRowTotal( formId, fieldId, totalFieldId ) {
var listField = '#field_' + formId + '_' + fieldId;
var totalField = '#input_' + formId + '_' + totalFieldId;
ListFieldRowCount( listField, totalField );
jQuery( listField ).on( 'click', '.add_list_item', function() {