Skip to content

Instantly share code, notes, and snippets.

@EddyRespondek
EddyRespondek / gf-suburbs-select.js
Created May 31, 2017 02:08
gf-suburbs-select.js
$("#suburbs_lookup").autocomplete({
minLength:3,
source: function (request, response) {
var term = request.term;
$.ajax({
type: 'POST',
url: 'http://ppdre.com.au/autosuggest/',
dataType: 'json',
data: {
// Gravity Forms - Suburb Auto Suggest.
add_filter( 'gform_add_field_buttons', 'add_suburbs_field' );
function add_suburbs_field( $field_groups ) {
foreach ( $field_groups as &$group ) {
if ( $group['name'] == 'advanced_fields' ) {
$group['fields'][] = array(
'class' => 'button',
'data-type' => 'suburbs',
'value' => __( 'Suburbs', 'gravityforms' ),
@EddyRespondek
EddyRespondek / on-exit-window-top.js
Last active June 16, 2017 19:33
Detect when mouse leaves window top once and do something
var done = false;
function addEvent(obj, evt, fn) {
if (obj.addEventListener) {
obj.addEventListener(evt, fn, false);
}
else if (obj.attachEvent) {
obj.attachEvent("on" + evt, fn);
}
}
@EddyRespondek
EddyRespondek / functions.php
Last active April 27, 2024 08:44
Wordpress - Simple AJAX Pagination
function get_posts_for_pagination() {
$html = '';
$paged = ( $_GET['page'] ) ? $_GET['page'] : 1;
$post_type = $_GET['posttype'];
if ( empty($post_type) ) {
return '';
}
if( filter_var( intval( $paged ), FILTER_VALIDATE_INT ) ) {
<?php
add_action("gform_pre_submission_filter", "after_submission", 10, 2);
function after_submission($form) {
//only process if this is the profile details form
if($form["id"] == 12) {
//save data and notify admin that data has been updated.
<html>
<head>
<title></title>
<script src="jquery.min.js"></script>
<script type='text/javascript' src="http://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.1/jquery.xdomainrequest.min.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/rollups/hmac-sha1.js"></script>
<script src="http://crypto-js.googlecode.com/svn/tags/3.1.2/build/components/enc-base64-min.js"></script>
<script type="text/javascript">
@EddyRespondek
EddyRespondek / wp-permalink-structure-A.php
Last active August 29, 2015 14:07
Wordpress permalink structure
<?php
if ( !class_exists( 'GFForms' ) || !defined( 'WPINC' ) ) {
return;
}
class BTFunds {
/**
* Dashboard-only initialization.
*/
@EddyRespondek
EddyRespondek / poll_element_loaded.js
Created June 17, 2014 06:14
Polls for element creation and then loads a new script. Could be used for just about anything including checking for external file loading. Note: there is also MutationObserver but couldn't find anything reliable. https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
var poll;
var timeout = 100; // gives up after 10 seconds
poll = function () {
setTimeout(function () {
timeout--;
if ( $('#myid').length === 1 ) {
var script= document.createElement('script');
script.type = 'text/javascript';
@EddyRespondek
EddyRespondek / wordpress_domain_replace.sql
Created June 12, 2014 23:10
Wordpress change domain name
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://olddomain.com','http://newdomain.com');
UPDATE wp_posts SET post_content = replace(post_content, 'http://olddomain.com', 'http://newdomain.com');
UPDATE wp_postmeta SET meta_value = replace(meta_value, 'http://olddomain.com', 'http://newdomain.com');