Skip to content

Instantly share code, notes, and snippets.

View Fitoussi's full-sized avatar

Eyal Fitoussi Fitoussi

View GitHub Profile
@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: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",
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: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' ) {
/*
@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: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: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:69f2f4672929c09c900d
Created August 10, 2015 17:57
Posts Locator Order-by Filter tutorial ( part 4 )
function gmw_orderby_dropdown( $gmw ) {
//getting the chosen value so we could pre-select the selected value after page load
$selected = ( isset( $_GET['gmw_orderby' ) && !empty( $_GET['gmw_orderby'] ) ) ? $_GET['gmw_orderby'] : '';
?>
<select class="gmw-orderby-dropdown" name="gmw_orderby">
<option value="distance" selected="selected">Distance</option>
<option value="post_title" <?php if ( $selected == 'post_title' ) echo 'selected="selected"'; ?>>Alphabetically</option>
<option value="post_date" <?php if ( $selected == 'post_date' ) echo 'selected="selected"'; ?>>Post Date</option>
<option value="post_id" <?php if ( $selected == 'post_id' ) echo 'selected="selected"'; ?>>Post ID</option>
@Fitoussi
Fitoussi / gist:db46b4eb3f330321cc3c
Created August 10, 2015 17:56
Posts Locator Order-by Filter tutorial ( part 2 )
gmw_orderby_dropdown( $gmw );
@Fitoussi
Fitoussi / gist:c735a41e3a0833f1c2e3
Created August 10, 2015 17:52
Posts Locator Order-by Filter tutorial ( part 1 )
<?php
function gmw_orderby_dropdown( $gmw ) {
//getting the chosen value so we could pre-select the selected value after page load
$selected = ( isset( $_GET['gmw_orderby'] ) && !empty( $_GET['gmw_orderby'] ) ) ? $_GET['gmw_orderby'] : '';
?>
<select class="gmw-orderby-dropdown" name="gmw_orderby">
<option value="distance" selected="selected">Order By</option>
<option value="distance" <?php if ( $selected == 'distance' ) echo 'selected="selected"'; ?>>Distance</option>
<option value="post_title" <?php if ( $selected == 'post_title' ) echo 'selected="selected"'; ?>>Alphabetically</option>