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 December 13, 2023 15:33
Disable admin panel for the subscribers and add wp-login.php to custom login page
<?php
add_filter( 'show_admin_bar' , 'bd_disable_admin_bar');
function bd_disable_admin_bar($show_admin_bar) {
return ( current_user_can( 'administrator' ) ) ? $show_admin_bar : false;
}
add_action('init','redirect_to_login_page');
function redirect_to_login_page(){
global $pagenow;
@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' );
@1naveengiri
1naveengiri / uwp-quora-icon.php
Last active September 21, 2022 04:48
UsersWP quora social icon
<?php
add_filter( 'uwp_form_fields_predefined', 'uwp_form_fields_predefined_custom_callback', 10, 2 );
function uwp_form_fields_predefined_custom_callback( $custom_fields, $type ){
$custom_fields['quora'] = array(
'field_type' => 'url',
'class' => 'uwp-quora',
'field_icon' => 'fab fa-quora',
'site_title' => __( 'quora', 'userswp' ),
'help_text' => __( 'Let users enter their quora url.', 'userswp' ),
'defaults' => array(
@1naveengiri
1naveengiri / function.php
Created May 14, 2022 14:36
Shortcode for overall rating of sub rating
<?php
/**
* This code create a shortcode [buddy-overall-rating].
* It can be used on archive item template.
*/
add_shortcode( 'buddy-overall-rating', function($args){
$plugin_public = new GeoDir_Review_Rating_Manager_Public();
return $plugin_public->show_overall_multiratings();
});
@1naveengiri
1naveengiri / function.php
Last active May 4, 2022 03:22
Search by tags Geodirectory
<?php
add_filter( 'geodir_search_terms_where', 'geodir_search_terms_where_custom_callback');
function geodir_search_terms_where_custom_callback( $terms_where ){
if ( geodir_is_page( 'search' ) ) {
global $wpdb, $geodir_post_type, $plugin_prefix, $dist, $snear, $s, $s_A, $s_SA, $search_term, $geodirectory;
$searc_term_names = explode( ' ', $s );
$table = geodir_db_cpt_table( $geodir_post_type );
$s = trim( $s );
$s = wp_specialchars_decode( $s, ENT_QUOTES );
$s_A = wp_specialchars_decode( $s_A, ENT_QUOTES );
@1naveengiri
1naveengiri / js-function-declaration.js
Created May 3, 2022 02:52
4 ways to define a function in javascript
// < ES5
function x( n1, n2 ){
return n1 + n2;
}
console.log(x(9,2));
// ES5
var y = function(n1, n2){
return n1 + n2;
}
@1naveengiri
1naveengiri / function.php
Created May 2, 2022 05:19
load Neighbourhood on near me field click
<?php
​// non class stuff
add_action( 'wp_footer', 'wpdev_170663_remove_parent_theme_stuff', 0 );
function wpdev_170663_remove_parent_theme_stuff() {
remove_action('wp_footer','geodir_location_autocomplete_script');
}
add_action( 'wp_footer', 'geodir_location_autocomplete_script' );
function geodir_location_autocomplete_script() {
global $geodirectory, $gd_post;
@1naveengiri
1naveengiri / function.php
Created March 26, 2022 02:38
kadence theme options not working for GD page templates
<?php
add_filter( 'kadence_post_layout', 'buddy_check_condition' );
function buddy_check_condition() {
$boxed = 'boxed';
$layout = 'normal';
$feature = 'hide';
$f_position = 'above';
$comments = 'hide';
@1naveengiri
1naveengiri / class-sd-admin-pointer.php
Created January 10, 2018 04:05
Create WordPress Pointer Tutorial For New Users
<?php
/**
* Adds and controls pointers for contextual help/tutorials
*
* @author WooThemes
* @category Admin
* @package WooCommerce/Admin
* @version 2.4.0
*/
@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.