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 / 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 / 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 / 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 );
@BhargavBhandari90
BhargavBhandari90 / image-cropper.php
Created January 29, 2023 18:37
Image Cropper With PLUpload & JCrop
<?php
/**
* Enqueues the css and js required by the Image Crop.
*/
function blp_core_cover_image_scripts() {
wp_enqueue_script( 'jcrop', array( 'jquery' ) );
wp_enqueue_script( 'plupload', array(), false, false );
wp_enqueue_style( 'jcrop' );
}
@BhargavBhandari90
BhargavBhandari90 / image_editor.php
Created January 23, 2023 16:54
WordPress Image Editor
<?php
add_shortcode( 'post_list', 'bunty_shortcode' );
function bunty_shortcode( $attr ) {
ob_start();
include_once ABSPATH . 'wp-admin/includes/image-edit.php';
@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 / custom_elementor_display_condition.php
Created August 23, 2022 17:32
Set BB groups in elementor Display Conditions
<?php
add_action(
'elementor/theme/register_conditions',
function( $conditions_manager ) {
class Page_Template_Condition extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base {
public static function get_type() {
return 'singular';
}
@BhargavBhandari90
BhargavBhandari90 / user_custom_profile_field.php
Last active January 12, 2023 01:05
Add custom profile field to edit user profile
<?php
/**
* Add user profile extra fields.
*
* @param object $user
* @return void
*/
function buntywp_extra_user_profile_fields( $user ) {
$extra_field = get_user_meta( $user->ID, 'extra_field', true );