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 / 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
@dexit
dexit / gw-gravity-forms-disable-autocomplete.php
Created September 9, 2020 09:55 — forked from spivurno/gw-gravity-forms-disable-autocomplete.php
Gravity Wiz // Gravity Forms // Disable Auto-complete
<?php
// Disable auto-complete on form.
add_filter( 'gform_form_tag', function( $form_tag ) {
return str_replace( '>', ' autocomplete="off">', $form_tag );
}, 11 );
// Diable auto-complete on each field.
add_filter( 'gform_field_content', function( $input ) {
return preg_replace( '/<(input|textarea)/', '<${1} autocomplete="off" ', $input );
@dexit
dexit / gp-limit-choices-shared-limits-field.php
Created September 9, 2020 12:56 — forked from spivurno/gp-limit-choices-shared-limits-field.php
Gravity Perks // Limit Choices // Shared Limits Field
<?php
/**
* Gravity Perks // Limit Choices // Shared Limits Field
*
* Share limits across choices of the same field.
*
* @version 1.0
* @author David Smith <[email protected]>
* @license GPL-2.0+
* @link http://gravitywiz.com/documentation/gravity-forms-limit-choices/
@dexit
dexit / gp-populate-anything-populate-child-entries.php
Created September 9, 2020 12:56 — forked from spivurno/gp-populate-anything-populate-child-entries.php
Gravity Perks // Populate Anything // Populate Child Entries
<?php
/**
* Gravity Perks // Populate Anything // Populate Child Entries
*
* Populate child entries from a Nested Form field into any multi-choice field.
*
* Instructional Video:
* https://www.loom.com/share/7b26b18f78624e0ca4bcd2b574636b8b
*
* Step 1 - Configure a Parent Entry Field