Skip to content

Instantly share code, notes, and snippets.

View kprajapatii's full-sized avatar

Kiran Prajapati kprajapatii

View GitHub Profile
@kprajapatii
kprajapatii / multiple-google-maps-api-fix.php
Last active September 5, 2016 05:43
Fixing Google Maps error "You have included the Google Maps API multiple times on this page. This may cause unexpected errors." Put code in your current theme functions.php file.
<?php
// Fixing Google Maps error "You have included the Google Maps API multiple times on this page. This may cause unexpected errors."
function geodirectory_fix_multiple_google_maps_api() {
$dequeue_handle = 'google-maps'; // script handle to dequeue script
if ( wp_script_is( 'geodirectory-googlemap-script', 'enqueued' ) && wp_script_is( $dequeue_handle, 'enqueued' ) ) {
wp_dequeue_script( $dequeue_handle );
}
}
add_action( 'wp_enqueue_scripts', 'geodirectory_fix_multiple_google_maps_api', 101 );
@kprajapatii
kprajapatii / event-date-in-more-info-tab.php
Last active October 10, 2016 06:18
Display the event date in more info tab on event detail page.
<?php // YOU MOST LIKELY DON'T NEED THIS LINE, SO DON'T COPY PASTE THIS LINE WITH BELOW CODE
/***** CODE STARTS HERE *****/
// Display the event date in more info tab on event detail page.
function gd_event_date_in_more_info_tab() {
// The $post var contains all the listing info so we can add conditions.
global $post;
// Only show if the post type is "gd_event".
@kprajapatii
kprajapatii / display-author-on-listings.php
Created October 17, 2016 04:35
Display listing author on GeoDirectory listing pages.
<?php // YOU MOST LIKELY DON'T NEED THIS LINE, SO DON'T COPY PASTE THIS LINE WITH BELOW CODE
/***** CODE STARTS HERE *****/
// Display listing author on listing pages.
function geodirectory_author_link_on_listings_page( $post ) {
if ( !empty( $post ) && !empty( $post->post_author ) && geodir_is_page( 'listing' ) ) {
$author_link = get_author_posts_url( $post->post_author );
$author_link = geodir_getlink( $author_link, array( 'geodir_dashbord' => 'true', 'stype' => $post->post_type ), false );
@kprajapatii
kprajapatii / add-event-show-all-businesses.php
Last active October 24, 2016 03:31
Display all business listings in businesses dropdown list on event add/edit page.
<?php // YOU MOST LIKELY DON'T NEED THIS LINE, SO DON'T COPY PASTE THIS LINE WITH BELOW CODE
/***** CODE STARTS HERE *****/
// Display all business listings in businesses dropdown list on event add/edit page.
function geodirectory_event_show_business_fields_html() {
global $wpdb, $post, $current_user, $post_info, $gd_session;
$package_info = array();
$package_info = geodir_post_package_info( $package_info , $post );
@kprajapatii
kprajapatii / filter-linked-cpt-widget-settings.php
Created November 9, 2016 06:54
Filter the linked cpt widget settings .
<?php // YOU MOST LIKELY DON'T NEED THIS LINE, SO DON'T COPY PASTE THIS LINE WITH BELOW CODE
/***** CODE STARTS HERE *****/
// Filter the linked cpt layout.
function geodirectory_cpt_linked_listing_view( $layout ) {
$layout = 'gridview_onehalf'; // one of gridview_onehalf, gridview_onethird, gridview_onefourth, gridview_onefifth, listview
return $layout;
}
@kprajapatii
kprajapatii / add-review-link-in-detail-sidebar.php
Last active November 10, 2016 04:46
Add link to submit a review in the detail sidebar
@kprajapatii
kprajapatii / neighbourhood-link-on-detail-page-sidebar.php
Last active January 5, 2017 06:36
Display neighbourhood location link on GeoDirectory listing detail page sidebar.
@kprajapatii
kprajapatii / Fix HTML 5 Map and GD booster caching.php
Last active January 10, 2017 09:49
Fix HTML 5 Map and GD booster caching
if (!function_exists('gd_geodir_booster_exclude_js')) {
// Fix HTML 5 Map and GD booster caching
function gd_geodir_booster_exclude_js( $continue, $content ) {
if (strpos($content, "uscanadahtml5map_js_data=true") !== false || strpos($content, "var BPLA_data = {") !== false || strpos($content, "callback=bp_location_profile.initMap") !== false || strpos($content, "/bp-location-autocomplete.min.js") !== false || strpos($content, "/jquery.js") !== false || (strpos($content, "new FlaShopUSCanadaMap(") !== false && strpos($content, "html5map_onclick(") !== false)) {
$continue = true;
}
return $continue;
}
}
@kprajapatii
kprajapatii / breadcrumb-with-only-neighbourhood.php
Created January 24, 2017 05:25
// Hide "Location", "Country", "Region", "City" for location neighbourhood breadcrumb
// Hide "Location", "Country", "Region", "City" for location neighbourhood breadcrumb
function gd_location_neighbourhood_breadcrumb( $breadcrumb, $separator, $echo = false ) {
if ( geodir_is_page( 'location' ) ) {
$location_link = geodir_get_location_link('base');
$location_prefix = get_option('geodir_location_prefix');
$breadcrumb = '<div class="geodir-breadcrumb clearfix"><ul id="breadcrumbs">';
$breadcrumb .= '<li><a href="' . home_url() .'">' . __( 'Home', 'geodirlocation' ) . '</a></li><li>';
@kprajapatii
kprajapatii / invoicing-add-custom-checkout-fields.php
Created January 27, 2017 08:02
Adding custom fields to the checkout form is easy to do with just a couple of functions. The code below will allow you to add two additional fields, one for Alternate Phone and Company Short Description.
/**
* Adding a custom field to the Invoicing checkout form.
*
* Covers:
*
* Adding the alternate phone & company short description fields to the checkout.
* Making the alternate phone field mandatory.
* Setting an error when the alternate phone field is empty.
* Storing the alternate phone & company short description fields into the invoice payment meta.
* Adding the alternate phone & company short description to the invoice view/print page.