Skip to content

Instantly share code, notes, and snippets.

View 1naveengiri's full-sized avatar
🏠
Working from home

Naveen Giri 1naveengiri

🏠
Working from home
View GitHub Profile
@1naveengiri
1naveengiri / functions.php
Last active July 27, 2020 03:21
Geodirectory Add event to google calendar Plugin
<?php
add_shortcode( 'buddy-add-to-calender', 'buddy_add_to_calender' );
function buddy_add_to_calender( $atts, $content = "" ) {
$event_id = get_the_ID();
global $gd_post;
$event_details = maybe_unserialize($gd_post->event_dates);
$title = get_the_title( $event_id );
if( !empty( $event_details['start_date'] ) && !empty( $event_details['start_date'] )){
$start_date = $event_details['start_date'] .' '.$event_details['start_time'];
$end_date = $event_details['end_date'] .' '.$event_details['end_time'];
@1naveengiri
1naveengiri / function.php
Last active January 11, 2023 16:32
Remove Geodirectory scripts and style from non GD pages
<?php
/**
* Dequeue core scripts & styles on non GD pages.
*
* Note: This may cause JavaScript errors when page contains widget/shortcode from GD.
*/
function wpdocs_dequeue_script() {
if ( class_exists( 'AyeCode_UI_Settings' ) && ! geodir_is_geodir_page() && !is_page('piano-bars') && !is_page('piano-lessons') && !is_page('piano-movers') && !is_page('piano-tuners') && !is_front_page() && !is_page('piano-bars') && !is_page('piano-lessons') && !is_page('piano-movers') && !is_page('piano-tuners') && wp_get_post_parent_id( get_the_ID() ) != 2886 ) {
wp_dequeue_script( 'bootstrap-js-bundle' );
wp_dequeue_style( 'ayecode-ui' );
<?php
/**
* Plugin Name: Delete GD post
* Plugin URI: http://buddydevelopers.com
* Description: plugin to delete Gd posts
*/
/**
* Place this file in wp-content/mu-plugins/ folder.
*
@1naveengiri
1naveengiri / function.php
Created April 14, 2020 12:46
edit Yoast SEO meta title, description, og:title, og:Description,
<?php
// og:title
add_filter('wpseo_opengraph_title', 'wpseo_opengraph_title_callback');
function wpseo_opengraph_title_callback( $title ){
// do something here.
return $title;
}
// og:description
add_filter('wpseo_opengraph_desc', 'wpseo_opengraph_desc_callback');
function wpseo_opengraph_desc_callback( $ogdesc ){
@1naveengiri
1naveengiri / function.php
Last active January 3, 2020 08:09
Change Geodirectory map popup layout for specific CPT.
<?php
/**
* I am changing map popup layout of gd_places here.
*/
add_filter('geodir_get_template_part', 'geodir_get_template_part_callback', 10, 3);
function geodir_get_template_part_callback( $template, $slug, $name ){
global $gd_post;
if( 'gd_place' === $gd_post->post_type ){
?>
@1naveengiri
1naveengiri / function.php
Created December 12, 2019 07:57
Instagram feed widget for geodirectory
<?php
/**
* Add custom field to the custom field list.
*
* @param array $custom_fields {
* The custom fields array to be filtered.
*
* @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file.
* @type string $class The class for the field in backend.
<?php
/**
* code to trigger comment email on comment submission.
*/
add_action( 'init', 'gd_custom_comment_post' );
function gd_custom_comment_post() {
remove_action( 'comment_post', 'geodir_new_comment_notify_postauthor', 99999, 1 );
add_filter( 'geodir_should_notify_comment_author', 'geodir_should_notify_comment_author_custom_callback', 10, 2);
add_filter( 'geodir_should_notify_listing_author', 'geodir_should_notify_listing_author_custom_callback', 10, 2 );
add_action( 'comment_post', 'geodir_custom_notify_on_comment_approved', 99999, 1 );
/**
* code to trigger comment email on comment submission.
*/
add_action( 'init', 'gd_custom_comment_post' );
function gd_custom_comment_post() {
remove_action( 'comment_post', 'geodir_new_comment_notify_postauthor', 99999, 1 );
add_filter( 'geodir_should_notify_comment_author', 'geodir_should_notify_comment_author_custom_callback', 10, 2);
add_filter( 'geodir_should_notify_listing_author', 'geodir_should_notify_listing_author_custom_callback', 10, 2 );
add_action( 'comment_post', 'geodir_custom_notify_on_comment_approved', 99999, 1 );
}
@1naveengiri
1naveengiri / function.php
Created June 21, 2019 08:53
Disable comment for CPT
<?php
function wpgeodir_prefix_comments_open( $open, $post_id ) {
$post_type = get_post_type( $post_id );
// allow comments for built-in "post" post type
if ( 'gd_compt_coaching' === $post_type ) {
return false;
}
// disable comments for any other post types
return true;
}
@1naveengiri
1naveengiri / strong-pws-check.php
Last active January 4, 2019 07:01
Awesome Support strong password check
<?php
// this action get fire during registration process.
add_action('wpas_pre_register_account','wpas_pre_register_account_callback', 10, 3);
function wpas_pre_register_account_callback( $user, $redirect_to, $data ){
if( !is_pwd_strong( $user['pwd'] ) ){
wpas_add_error( 'accept_terms_conditions', esc_html__( 'Add strong password', 'awesome-support' ) );
wp_safe_redirect( $redirect_to );
exit;
}
}