Skip to content

Instantly share code, notes, and snippets.

View kprajapatii's full-sized avatar

Kiran Prajapati kprajapatii

View GitHub Profile
@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.
@kprajapatii
kprajapatii / load add listing map in wpml language.php
Created February 2, 2017 09:23
GeoDirectory: Change load add listing map language in current WPML language.
// Change load add listing map language in current WPML language.
function gd_wpml_default_map_language( $language ) {
if ( defined( 'ICL_LANGUAGE_CODE' ) ) {
$wpml_language = ICL_LANGUAGE_CODE;
if ( $wpml_language == 'en' ) {
$language = 'en';
} else if ( $wpml_language == 'fr' ) {
$language = 'fr';
}
@kprajapatii
kprajapatii / gd-show-upgrade-link-on-success-msg.php
Created February 23, 2017 07:38
GeoDirectory: Show upgrade link on success message.
@kprajapatii
kprajapatii / listing description on bubble map.php
Created March 6, 2017 06:29
Show listing description on bubble map
<?php
// Show listing description on bubble map ( before custom fields )
function gd_profile_description_on_map_bubble_before( $post_id, $post_info, $post_preview ) {
if ( !empty( $post_info->post_id ) ) {
global $post;
$temp_post = $post;
$post = get_post( $post_info->post_id );
@kprajapatii
kprajapatii / geodirectory-event-schedule-as-a-tab.php
Created March 8, 2017 05:59
GeoDirectory: Display event schedule as a tab on event detail page.
<?php
/* START */
// GeoDirectory: Display event schedule as a tab on event detail page.
function gd_show_event_schedule_as_tab( $template ) {
if ( has_filter( 'geodir_detail_page_sidebar_content', 'geodir_event_detail_page_sitebar_content' ) ) {
remove_filter( 'geodir_detail_page_sidebar_content', 'geodir_event_detail_page_sitebar_content', 2 );
add_filter( 'geodir_detail_page_tab_list_extend', 'gd_detail_page_tab_event_schedule', 10, 1 );
add_action( 'geodir_after_tab_content', 'gd_detail_page_tab_content_event_schedule', 10, 1 );
@kprajapatii
kprajapatii / wordpress-allow-html-tags-in-category-tag-description.php
Created March 29, 2017 04:20
By default WordPress does not allows HTML tags in category & tag descriptions. WordPress strips the HTML tags from category & tag descriptions. You can use HTML tags by adding this code snippet to your theme functions.php file.
<?php
/*
Example:
<center>
<h2>Lorem Ipsum</h2>
<h3>"Lorem Ipsum is simply dummy text of the printing and typesetting industry..."</h3>
</center>
<p><strong>Lorem Ipsum</strong> is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
*/
@kprajapatii
kprajapatii / geodiredctory - display price packages as a select list.php
Last active April 27, 2017 05:10
Geodirectory: Display price packages as a select list. Put code in theme functions.php or via any snippet plugin.
// Display price packages as a select list
function gd_build_payment_select_list() {
global $post, $package_id;
$listing_type = !empty( $_REQUEST['listing_type'] ) ? sanitize_text_field( $_REQUEST['listing_type'] ) : '';
$listing_type = empty( $listing_type ) && !empty( $post->post_type ) ? $post->post_type : $listing_type;
if ( isset( $_REQUEST['package_id'] ) ) {
$package_id = $_REQUEST['package_id'];
} else if ( !empty( $post->package_id ) ) {
@kprajapatii
kprajapatii / filter-location-description-everywhere-text.php
Created June 15, 2017 08:31
Change 'Everywhere' text in location description. Add custom text in meta title/description when full location is empty. Add custom text in meta title/description when location_single is empty.
// Change 'Everywhere' text in location description.
function gd_custom_location_description_everywhere_text( $everywhere_text ) {
$everywhere_text = __( 'Kimberley & The Northern Cape', 'geodirectory' ); // Change text here.
return $everywhere_text;
}
add_filter( 'geodir_location_description_everywhere_text', 'gd_custom_location_description_everywhere_text', 10, 1 );
// Add custom text in meta title/description when full location is empty.
function gd_custom_meta_description_location_empty_text( $location_text, $location_array, $gd_page, $sep ) {
@kprajapatii
kprajapatii / gd-custom-website-url-as-label.php
Created October 2, 2017 04:30
GeoDirectory: Display website url as a link label for geodirectory listing.
// Website url as a label
function _gd_custom_website_url_as_label( $title, $website, $post_ID ) {
//$website = str_replace( array( 'https://', 'http://' ), '', $website ); // Remove comment to hide https:// & http:// from label
$website = trim( $website, '/' );
return $website;
}
add_filter( 'geodir_custom_field_website_name', '_gd_custom_website_url_as_label', 10, 3 );
@kprajapatii
kprajapatii / [GeoDirectory] Create event from data via script.php
Last active November 8, 2017 22:39
[GeoDirectory] Create event from data via script
<?php
function _gd_custom_create_event_from_data() {
global $wpdb, $gd_session;
$gd_post = array();
$gd_post['post_type'] = 'gd_event';
$gd_post['status'] = 'publish';
$gd_post['title'] = 'Italian Market Festival';
$gd_post['content'] = 'There is so much great eating in and around the Italian Market that you will want to return again and again.';