Skip to content

Instantly share code, notes, and snippets.

View Stiofan's full-sized avatar

Stiofan O'Connor Stiofan

  • AyeCode Ltd
  • Ireland
View GitHub Profile
@Stiofan
Stiofan / distance_to.php
Created March 17, 2017 17:51
Distance to - custom field
<?php // you proably don't need this line
// add the custom field to the custom field list
function geodir_custom_field_distance_to($custom_fields,$post_type){
$custom_fields['distance_to'] = array( // The key value should be unique and not contain any spaces.
'field_type' => 'text', //
'class' => 'gd-distance-to',
'icon' => 'fa fa-map-marker',
'name' => __('Distance To', 'geodirectory'),
'description' => __('Adds a input for GPS coordinates that will then output the place distance to that point.', 'geodirectory'),
@Stiofan
Stiofan / cf.php
Last active March 17, 2017 12:06
Custom fields in custom places
<?php
// Add a new output location to the list of places a custom field can be output.
add_filter('geodir_show_in_locations','_content_location_below_profile_content',10,3);
function _content_location_below_profile_content($show_in_locations,$field_info,$field_type){
$show_in_locations['[below_content_tab]'] = __("Below Content Tab", 'geodirectory');
return $show_in_locations;
}
// Output the custom field info in a new place, in this case below the profile tab content.
@Stiofan
Stiofan / more_info_name.php
Created March 16, 2017 16:30
Change More Info tab name
<?php
add_filter('geodir_detail_page_tab_list_extend','_my_more_info_tab_name',10,1);
function _my_more_info_tab_name($tabs){
if(isset($tabs['post_info'])){
$tabs['post_info']['heading_text'] = __( 'Something else', 'geodirectory' );
}
return $tabs;
}
@Stiofan
Stiofan / snippet.php
Created March 7, 2017 14:47
Show default desc if blank on list view
<?pho // you probably dont need this
add_action('geodir_after_listing_post_excerpt','_my_default_desc_listview',10,1);
function _my_default_desc_listview($post){
if($post->post_content==''){
echo "this is a default description, if blank";
}
}
@Stiofan
Stiofan / default_cat.php
Last active January 14, 2017 19:14
Set a default category
<?php
// replace 222 with the category id
remove_filter('geodir_custom_field_input_taxonomy','geodir_cfi_taxonomy',10,2);
add_filter('geodir_custom_field_input_taxonomy','_my_default_taxonomy',10,2);
function _my_default_taxonomy($html,$cf){
if(isset($cf['post_type']) && $cf['post_type']=='gd_place'){
$html = "<input type='hidden' name='post_category[gd_placecategory][]' value='222' />";
}
@Stiofan
Stiofan / claimed_on_map.php
Last active January 28, 2017 12:52
Only show claimed listings on maps
<?php
// filter home map to only show claimed listings
add_filter('geodir_marker_search','_my_filter_home_map_claimed',10,1);
function _my_filter_home_map_claimed($search){
$search = " AND pd.claimed=1 " . $search;
return $search;
}
@Stiofan
Stiofan / geodir_filter_title_variables_vars.php
Created January 11, 2017 18:46
geodir_filter_title_variables_vars example
<?php
add_filter('geodir_filter_title_variables_vars','_my_new_title_meta_vars',10,4);
function _my_new_title_meta_vars($title, $location_array, $gd_page, $sep){
if ( strpos( $title, '%%post_address%%' ) !== false ) {
global $post;
$var = geodir_get_post_meta($post->ID,'post_address',true);
$title = str_replace( "%%post_address%%", $var, $title );
}
@Stiofan
Stiofan / admin_bcc.php
Last active December 9, 2016 11:43
Add extra info to admin BCC email
<?php
add_filter('geodir_sendEmail_message_admin_bcc','_my_admin_bcc_extra_info',10,11);
function _my_admin_bcc_extra_info($message, $fromEmail, $fromEmailName, $toEmail, $toEmailName, $to_subject, $to_message, $extra, $message_type, $post_id, $user_id){
if($message_type == 'post_submit'){
$message .= " \n \n";
$message .= "PACKAGE ID: ".geodir_get_post_meta($post_id, 'package_id', true);
$message .= " \n";
$message .= "COUNTRY : ".geodir_get_post_meta($post_id, 'post_country', true);
@Stiofan
Stiofan / schema.php
Created November 24, 2016 11:33
Edit details page schema
<?php
add_filter('geodir_details_schema','_my_new_schema',10,2);
function _my_new_schema($schema,$post){
$schema = array();// this will reset the scheme, maybe you just want to edit what is there?
$schema['telephone'] = '1234'; // edit an existing schema
$schema['telephoneX'] = '1234'; // add a new schema value
unset($schema['telephone']); // remove a schema key/value
@Stiofan
Stiofan / cat_map_marker.php
Last active November 10, 2016 16:11
Make map on GD cat pages show marker of cat and not main cat of post
<?php
add_filter('geodir_create_marker_jason_of_posts','_my_change_cat_map_markers_to_current_cat',11,2);
function _my_change_cat_map_markers_to_current_cat($marker_json,$post){
global $gd_cur_term_icon_url;
if(geodir_is_page('listing') && is_tax()){
if(!$gd_cur_term_icon_url){
$term_icon_url = get_tax_meta(get_queried_object()->term_id, 'ct_cat_icon', false, $post->post_type);