Skip to content

Instantly share code, notes, and snippets.

View dexit's full-sized avatar
🎯
Focusing

Rihards Mantejs dexit

🎯
Focusing
View GitHub Profile
@dexit
dexit / gf-acf-multi-file-upload.php
Created April 29, 2020 18:41 — forked from yanknudtskov/gf-acf-multi-file-upload.php
Connect Gravity Forms Multi File Upload and Advanced Custom Fields Repeating File-Field #gravity-forms #acf
<?php
/**
* Connect Gravity Forms Multi File Upload and Advanced Custom Fields Repeating File-Field and Gallery Field
* REMEMBER: Set ID correctly for forms and fields AND set acf field names
*/
add_action( 'gform_after_submission_4', 'add_form_after_submission', 10, 2 );
function add_form_after_submission( $entry, $form ) {
//getting post
$post = get_post( $entry['post_id'] );
<?php
/**
* Create a new media library entry with a file upload on gravity form submission.
* @see https://joshuadnelson.com/connect-gravity-forms-file-upload-to-acf-gallery-field/
* @author Joshua David Nelson, [email protected]
*/
$gravity_form_id = 1; // gravity form id, or replace {$gravity_form_id} below with this number
add_filter( "gform_after_submission_{$gravity_form_id}", 'jdn_add_image_to_media_library', 10, 2 );
function jdn_add_image_to_media_library( $entry, $form ) {
@dexit
dexit / gp-media-library-attach-media.php
Created May 1, 2020 08:42 — forked from spivurno/gp-media-library-attach-media.php
Gravity Perks // GP Media Library // Auto-attach Uploaded Files to GF-generated Post
</php
/**
* Gravity Perks // GP Media Library // Auto-attach Uploaded Files to GF-generated Post
* http://gravitywiz.com/documentation/gp-media-library/
*/
add_action( 'gform_after_create_post', function( $post_id, $entry, $form ) {
if( is_callable( 'gp_media_library' ) ) {
$file_ids = gp_media_library()->get_file_ids_by_entry( $entry, $form );
if( $file_ids ) {
foreach( $file_ids as $field_id => $_file_ids ) {
@dexit
dexit / wp-custom-post-type-as-submenu-item.php
Created May 1, 2020 15:33 — forked from BODA82/wp-custom-post-type-as-submenu-item.php
Add WordPress custom post type as submenu item of existing admin menu.
<?php
if (! function_exists('gist_register_cpt')) {
/**
* Register Custom Post Type
*/
function gist_register_cpt() {
// Set CPT labels
$labels = array(
<script>
var et_site_url = 'http://webhostingdivi.site';
var et_post_id = '193';
function et_core_page_resource_fallback(a, b) {
"undefined" === typeof b && (b = a.sheet.cssRules && 0 === a.sheet.cssRules.length);
b && (a.onerror = null, a.onload = null, a.href ? a.href = et_site_url + "/?et_core_page_resource=" + a.id + et_post_id : a.src && (a.src = et_site_url + "/?et_core_page_resource=" + a.id + et_post_id))
}
</script>
<title>Divi hosting home | Premium Divi Web Hosting</title>
@dexit
dexit / gist:547a1de28922349dc15f407898f0ee45
Created June 22, 2020 21:35 — forked from remcotolsma/gist:5884430
Gravity Forms calculate number days between 2 date fields
<script type="text/javascript">
jQuery( document ).ready( function( $ ) {
var ms_one_day = 1000 * 60 * 60 * 24;
var form_id = '1';
var date_format = 'dd-mm-yy';
var field_date_start = $( '#input_' + form_id + '_1' );
var field_date_end = $( '#input_' + form_id + '_2' );
<?php
/**
* Gravity Perks // Nested Forms // Delay Child Notifications for Parent Payment
* http://gravitywiz.com/documentation/gravity-forms-nested-forms/
*/
add_filter( 'gpnf_should_send_notification', function( $should_send_notification, $notification, $context, $parent_form, $nested_form_field, $entry, $child_form ) {
if( $context == 'parent' ) {
$parent_entry = GFAPI::get_entry( rgar( $entry, 'gpnf_entry_parent' ) );
$should_send_notification = in_array( rgar( $parent_entry, 'payment_status' ), array( 'Paid', 'Active' ) );
@dexit
dexit / barcode-128-svg.js
Created June 23, 2020 22:58 — forked from jcormont/barcode-128-svg.js
Simple Code-128 (128B) barcode SVG generator, in vanilla JS
var Barcode128Svg = (function () {
function Barcode128Svg(input) {
this.input = input;
this.factor = 2;
this.height = 75;
}
var lookup = {}, data = "212222222122222221121223121322131222122213122312132212221213221312231212112232122132122231113222123122123221223211221132221231213212223112312131311222321122321221312212322112322211212123212321232121111323131123131321112313132113132311211313231113231311112133112331132131113123113321133121313121211331231131213113213311213131311123311321331121312113312311332111314111221411431111111224111422121124121421141122141221112214112412122114122411142112142211241211221114413111241112134111111242121142121241114212124112124211411212421112421211212141214121412121111143111341131141114113114311411113411311113141114131311141411131".split(/(\d{6})/).filter(function (s) { return !!s });
for (var i = 32; i < 127; i++)
lookup[String.fromCharCode(i)] = [i - 32, data[i - 32]];
@dexit
dexit / htaccess.expires.headers
Created August 3, 2020 15:20 — forked from solancer/htaccess.expires.headers
htaccess expires headers
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 1 month"
# CSS
ExpiresByType text/css "access plus 1 year"
# Data interchange
ExpiresByType application/atom+xml "access plus 1 hour"
@dexit
dexit / ResizeImage.php
Created August 21, 2020 09:28 — forked from egulhan/ResizeImage.php
Resize Image Class With PHP
<?php
// @source: http://www.paulund.co.uk/resize-image-class-php
/**
* Resize image class will allow you to resize an image
*
* Can resize to exact size
* Max width size while keep aspect ratio
* Max height size while keep aspect ratio
* Automatic while keep aspect ratio