Skip to content

Instantly share code, notes, and snippets.

View sagarjadhav's full-sized avatar

Sagar Jadhav sagarjadhav

  • rtCamp Inc
  • Pune
View GitHub Profile
@sagarjadhav
sagarjadhav / remove-subnav-item-buddypress.php
Last active December 1, 2015 12:03
Remove subnav item BuddyPress
<?php
function bp_remove_nav_item() {
global $bp;
bp_core_remove_subnav_item( $bp->profile->slug, 'change-avatar' );
}
add_action( 'wp', 'bp_remove_nav_item' );
@sagarjadhav
sagarjadhav / remove-setting-nav-buddypress.php
Created December 1, 2015 12:05
Remove "Nav" items from profile navigation
<?php
/**
* Remove "Nav" items from profile navigation
*/
function bp_remove_settings_nav() {
global $bp;
unset( $bp->bp_nav[ 'settings' ] );
unset( $bp->bp_nav[ 'messages' ] );
unset( $bp->bp_nav[ 'notifications' ] );
<?php
// Define custom post type string
define( 'CUSTOM_POST_TYPE', 'affiliates' );
/**
* Register the meta box
*/
if ( !function_exists( 'page_templates_dropdown_metabox' ) ) {
select {
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
background: url('./images/angle-arrow-down.svg') 98% / 15% no-repeat;
background-size: 9px;
border: 0;
border-bottom: 1px solid #e1e1e1;
border-radius: 0;
@sagarjadhav
sagarjadhav / the_content_by_id.php
Created November 13, 2016 08:57
Get content by page ID
<?php
/*
* Get content by page ID
*/
function marvy_the_content_by_id( $id ) {
if ( isset( $id ) && 0 != $id ) {
global $post;
$post = get_post( $id );
setup_postdata( $post );
<?php
// Xprofile get fileds by group
if ( bp_has_profile( array( 'user_id' => $user_id ) ) ) {
while ( bp_profile_groups() ) : bp_the_profile_group();
$group_name = bp_get_the_profile_group_name();
if ( ( 'Social' == $group_name) && bp_profile_group_has_fields() ) {
echo '<div id="bb-profile-group-fields">';
while ( bp_profile_fields() ) : bp_the_profile_field();
@sagarjadhav
sagarjadhav / flex-clearfix.css
Created December 1, 2016 06:53
Flexbox, clear fix and pseudo elements in Safari and Chrome
.clearfix:before,
.clearfix:after {
flex-basis: 0;
order: 1;
}
@sagarjadhav
sagarjadhav / wp-admin-body-class.php
Created December 3, 2016 10:19
Add class to body in admin section
<?php
// Add class to body in admin section
function admin_body_classes($classes) {
$classes .= 'no-adminbar';
return $classes;
}
add_filter( 'admin_body_class', 'admin_body_classes' );
@sagarjadhav
sagarjadhav / excerpt-limit.php
Created March 8, 2017 07:40
Limit the wp excerpt
<?php
/* !
* Function to trim excerpt
*/
if ( !function_exists( 'limit_excerpt' ) ) {
function limit_excerpt( $lenght, $text ) {
$content = substr( $text, 0, $lenght );
if ( strlen( $content ) < strlen( $text ) ) {
@sagarjadhav
sagarjadhav / css-aspect-ratio-to-have-images-of-same-height.css
Created March 18, 2017 16:38
Css aspect ratio to have images of same height
.img-parent img {
position: relative;
overflow: hidden;
padding-bottom: 69.44%; /* Calculated = height / width * 100 */
display: block;
}
.img-parent img {
position: absolute;
top: 0;