Skip to content

Instantly share code, notes, and snippets.

View Fitoussi's full-sized avatar

Eyal Fitoussi Fitoussi

View GitHub Profile
@Fitoussi
Fitoussi / gist:8ec195db3a0568339695
Created August 10, 2015 17:57
Posts Locator Order-by Filter tutorial ( part 3 )
do_action( 'gmw_search_form_before_distance', $gmw );
@Fitoussi
Fitoussi / gist:39596c1e3c07bb3a1737
Created August 10, 2015 17:59
Posts Locator Order-by Filter tutorial ( part 5 )
apply_filters( 'gmw_pt_location_query_clauses', $clauses, $this->form );
@Fitoussi
Fitoussi / gist:17774bedd050181c113f
Created August 10, 2015 18:00
Posts Locator Order-by Filter tutorial ( part 6 )
geo-my-wp/plugins/posts/includes/gmw-pt-search-functions.php
@Fitoussi
Fitoussi / gist:8eb52f21abf10bdedf25
Created August 10, 2015 18:00
Posts Locator Order-by Filter tutorial ( part 7 )
function gmw_orderby_filter( $clauses, $gmw ) {
global $wpdb;
//check if order-by value was submitted. If it was we will use its value otherwise we set the default value to 'distance'
$orderby_value = ( isset( $_GET['gmw_orderby'] ) && !empty( $_GET['gmw_orderby'] ) ) ? $_GET['gmw_orderby'] : 'distance';
//check the value of the order-by and modify the clause based on that
//when order-by distance
if ( $orderby_value == 'distance' ) {
/*
function gmw_map_styles( $gmw ) {
?>
<script>
jQuery(document).ready(function($) {
//declare new map options array for form ID 1
gmwMapOptions['1'] = [];
});
</script>
<?php
@Fitoussi
Fitoussi / gist:b8131c8753347d828f1c
Created October 22, 2015 23:11
Map Styled 2 - full code
function gmw_map_options( $gmw ) {
?>
<script>
jQuery(document).ready(function($) {
//declare new map options array for form ID 1
gmwMapOptions['1'] = [];
gmwMapOptions['1']['styles'] = [
{
"featureType": "water",
@Fitoussi
Fitoussi / gist:f9daa22755c051ad3abe
Created October 27, 2015 23:48
array_replace_recursive
if ( ! function_exists( 'array_replace_recursive' ) ) {
function array_replace_recursive($base, $replacements) {
foreach (array_slice(func_get_args(), 1) as $replacements) {
$bref_stack = array(&$base);
$head_stack = array($replacements);
do {
end($bref_stack);
@Fitoussi
Fitoussi / gist:e605e012afe7d9612d72
Last active November 9, 2015 11:05
wp_dropdown_categories args
<?php
$args = array(
'show_option_all' => '',
'show_option_none' => '',
'orderby' => 'ID',
'order' => 'ASC',
'show_count' => 0,
'hide_empty' => 1,
'child_of' => 0,
'exclude' => '',
@Fitoussi
Fitoussi / gist:da198dc313db2a323c2a
Last active November 30, 2018 03:58
GEO my WP Modify Taxonomy Drop-down Options
<?php
function gmw_modify_search_form_taxonomy_args( $args, $taxonomy, $gmw ) {
// Limit the fuction to a specific form using it's ID.
if ( 1 !== $gmw['ID'] ) {
return $args;
}
// limit the function to a specific taxonmoy.
if ( "category" !== $taxonomy->name ) {
@Fitoussi
Fitoussi / gist:b45e5476847dafb8de8c
Created December 4, 2015 05:50
Gravity forms geolocation drag on click
drag_marker_onclick : function() {
google.maps.event.addListener( GF_Geo.map.map, 'click', function( event ){
GF_Geo.map.marker.setPosition( event.latLng );
// save some map details
GF_Geo.processing.status = true;
GF_Geo.processing.element = 'map';
GF_Geo.processing.coords = {