Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Bhargav(Bunty) Bhandari BhargavBhandari90

🏠
Working from home
View GitHub Profile
@BhargavBhandari90
BhargavBhandari90 / add_protocol_in_post_content.php
Last active Dec 12, 2020
Add a protocol to URLs from WordPress post content
View add_protocol_in_post_content.php
<?php
/**
* Fix the URLs from the content.
*
* This function will add protocol to URLs which has no protocol added.
*
* For example,
*
* google.com --> http://google.com
@BhargavBhandari90
BhargavBhandari90 / change_tab_lable_bb.php
Created Nov 24, 2020
Change Profile Tab Labels of BuddyPress/BuddyBoss
View change_tab_lable_bb.php
<?php
/**
* Change label to Followed for Suscriptions.
*
* @return void
*/
function bb_forum_profile_menu_tabs() {
// Handle fatal error in case of plugin not available
@BhargavBhandari90
BhargavBhandari90 / custom_post_type.php
Created Jul 26, 2020
Create custom post type in wordpress
View custom_post_type.php
<?php
/**
* Register a custom post type called "book".
*
* @see get_post_type_labels() for label keys.
*/
function wpdocs_codex_book_init() {
$labels = array(
'name' => _x( 'Books', 'Post type general name', 'textdomain' ),
View php_open_ssl_encription_description.php
<?php
// Store a string into the variable which
// need to be Encrypted
$simple_string = "Welcome to GeeksforGeeks\n";
// Display the original string
echo "Original String: " . $simple_string;
// Store the cipher method
@BhargavBhandari90
BhargavBhandari90 / sidebars.php
Created Jul 20, 2020
Create custom widget area
View sidebars.php
<?php
/**
* Create custom sidebars.
* Add this into your theme's php file where you want put all the custom
* widget area code.
*/
function my_register_sidebars() {
/* Register the 'primary' sidebar. */
register_sidebar(
@BhargavBhandari90
BhargavBhandari90 / gist:c7d2f75b93cdbd462db330ab7ba41ca1
Last active Jul 20, 2020
Get total number of weekdays in a particular year.
View gist:c7d2f75b93cdbd462db330ab7ba41ca1
<?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 / multiple-user-tabs.php
Created Jul 9, 2020
Add multiple custom tabs on user profile for buddyboss and buddypress
View multiple-user-tabs.php
<?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() ) ) {
View add-tab-user-profile.php
<?php
/**
* Add custom sub-tab on groups page.
*/
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 / change-default-tab.php
Last active Jun 27, 2020
Change default tab for group and user profile for buddyboss & buddypress
View change-default-tab.php
<?php
/**
* Change default tab for group.
*
* @param string $default_tab Slug of default tab.
* @return string
*/
function buddyboss_groups_default_extension( $default_tab ) {
return 'slug_of_tab'; // Last part of the URL.
}
@BhargavBhandari90
BhargavBhandari90 / buddypress-email-setting-manipulation.php
Last active Jun 23, 2020
Turn email notification OFF for new users for BuddyBoss and BuddyPress
View buddypress-email-setting-manipulation.php
<?php
/**
* Disable email notification.
*
* @param integer $user_id User ID.
* @return void
*/
function buddyboss_set_email_notifications_preference( $user_id ) {