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 / syntaxt_highliter.php
Created July 6, 2024 14:00
Syntax Highliter for BB
<?php
function bbtest_the_content( $content ) {
$search = array( '<pre>' );
$replace = array( '<pre class="wp-block-syntaxhighlighter-code">' );
$content = str_replace( $search, $replace, $content );
$syntax_obj = new SyntaxHighlighter();
<?php
function bbtest_render_app_page_data( $app_page_data, $block_data ) {
if ( isset( $app_page_data['type'] ) && 'bbapp/notifications' === $app_page_data['type'] ) {
$app_page_data['data']['data_source']['route'] = '/buddyboss-app/v1/notifications?&sort_order=DESC&order_by=date_notified';
}
return $app_page_data;
@BhargavBhandari90
BhargavBhandari90 / play_video_in_viewpart.js
Created May 28, 2024 11:37
Play video when in view part
document.addEventListener('DOMContentLoaded', function() {
const video = document.getElementById('video-22_html5_api'); // SET your Video tag ID
let previewStarted = false;
function isElementInViewport(el) {
const rect = el.getBoundingClientRect();
return (
rect.top >= 0 &&
rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
@BhargavBhandari90
BhargavBhandari90 / bb_block.php
Last active May 11, 2024 11:08
Make Custom Block compatible with BuddyBoss App's App Editor
<?php
/**
* Get rid of BBApp block compatibility error.
*
* @param [type] $allow_blocks_for_editor_to_app_editor
* @return void
*/
function bb_allow_blocks_for_editor_to_app_editor( $allow_blocks_for_editor_to_app_editor ) {
@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' );
}