Skip to content

Instantly share code, notes, and snippets.

View BhargavBhandari90's full-sized avatar
🏠
Working from home

Bhargav(Bunty) BhargavBhandari90

🏠
Working from home
View GitHub Profile
@BhargavBhandari90
BhargavBhandari90 / buddypress-group-subtab.php
Last active April 8, 2024 01:04
Add custom tab on buddypress group page
<?php
/**
* Add custom sub-tab on groups page.
*/
function buddypress_custom_group_tab() {
// Avoid fatal errors when plugin is not available.
if ( ! function_exists( 'bp_core_new_subnav_item' ) ||
! function_exists( 'bp_is_single_item' ) ||
@BhargavBhandari90
BhargavBhandari90 / convert_to_wyswing.php
Created April 3, 2024 07:17
Convert BB Discussion/Reply medium editor to WYSWING editor
<?php
// Enable WYSWING editor.
function bbp_enable_visual_editor( $r = array() ) {
$r['tinymce'] = true;
$r['media_buttons'] = true;
// Load WHYSWING.
@BhargavBhandari90
BhargavBhandari90 / show_all_notifications.php
Created March 5, 2024 06:38
BuddyBoss - Show all notifications in one API
<?php
/**
* We have to pass "is_new:0" and apply following filter.
*/
function modify_where( $where_sql, $table_prefix, $r ) {
$where_sql = str_replace( 'AND is_new = 0', '', $where_sql );
@BhargavBhandari90
BhargavBhandari90 / url_to_qr.php
Last active December 20, 2023 17:50
URL to QR Code.
<?php
$url = 'https://bhargavb.com/';
$qr_link = 'https://chart.googleapis.com/chart?chs=224x224&cht=qr&chl='. $url .'&choe=UTF-8';
printf( '<img src="%s" alt="QR Code">', $qr_link );
@BhargavBhandari90
BhargavBhandari90 / get_total_weekday_in_year.php
Last active November 20, 2023 05:49
Get total number of weekdays in a particular year.
<?php
/**
* Get total number of weekdays in a year.
*
* @param string $day Week day. Sun, Mon, Tue,...
* @param string $year Year in 4 digits.
* @return integer Return total number of specified weekday for a year.
*/
function get_total_weekday_in_year( $day = '', $year = '' ) {
@BhargavBhandari90
BhargavBhandari90 / bb_members_search.php
Created October 30, 2023 10:41
Set custom field to Members Search form and get result by that
<?php
function bb_bp_ps_before_search_form( $F ) {
$new = new stdClass();
$new->display = 'selectbox';
$new->code = 'age_from'; // to be removed
$new->html_name = 'age_from';
$new->value = '';
@BhargavBhandari90
BhargavBhandari90 / migration_post_type.php
Created September 7, 2023 12:12
Migaration script scalaton
<?php
function test_callback_migration() {
if ( ! is_admin() && isset( $_GET['migrate_data'] ) ) {
if ( current_user_can( 'administrator' ) ) {
$page = filter_input( INPUT_GET, 'pg', FILTER_SANITIZE_NUMBER_INT );
@BhargavBhandari90
BhargavBhandari90 / functions.php
Last active August 1, 2023 22:41
Custom code for getting profile pic, cover pic etc from Amazon s3 bucket
<?php
/**
* Set selected url structure, selected in rtAmazon settings.
*
* @since 1.4.0
*
* @param string $urls urls in content.
*
* @return array $newurls/$urls return array of all urls in content.
*/
@BhargavBhandari90
BhargavBhandari90 / multiple-user-tabs.php
Created July 9, 2020 18:32
Add multiple custom tabs on user profile for buddyboss and buddypress
<?php
/**
* Add custom sub-tab on user profile.
*/
function buddyboss_custom_user_tab() {
// Avoid fatal errors when plugin is not available.
if ( ! function_exists( 'bp_core_new_nav_item' ) ||
! function_exists( 'bp_loggedin_user_domain' ) ||
empty( get_current_user_id() ) ) {
@BhargavBhandari90
BhargavBhandari90 / short-version-number.php
Last active February 17, 2023 08:51
Converts a number into a short version, eg: 1000 -> 1k
<?php
// Converts a number into a short version, eg: 1000 -> 1k
function thousandsCurrencyFormat( $num ) {
if ( $num > 999 ) {
$x = round( $num );
$x_number_format = number_format( $x );
$x_array = explode( ',', $x_number_format );