Skip to content

Instantly share code, notes, and snippets.

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

Deepak Gupta raftaar1191

🏠
Working from home
View GitHub Profile
@raftaar1191
raftaar1191 / functions.php
Created February 7, 2017 14:47
Redirect user to media page when user click on profile picture
<?php
/**
* rtmedia_bp_get_activity_user_link_callback Change the User link to User Media link
*
* @param [type] $link Original link of the Author
*/
function rtmedia_bp_get_activity_user_link_callback( $link ) {
// copy original link to new variable
$new_link = $link;
@raftaar1191
raftaar1191 / functions.php
Last active May 13, 2017 04:57
Disallow some tag for BuddyPress activity content
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_bp_activity_allowed_tags_callback' ) ) {
function rtmedia_bp_activity_allowed_tags_callback( $activity_allowedtags ) {
global $activities_template;
$rtmedia_type = array( 'rtmedia_update', 'rtmedia_like_activity', 'rtmedia_comment_activity' );
// $activities_template exists and type not like $rtmedia_type.
if ( is_object( $activities_template ) && isset( $activities_template->activity ) && is_object( $activities_template->activity ) && isset( $activities_template->activity->type ) && ! in_array( $activities_template->activity->type, $rtmedia_type ) ) {
// check if ul exists.
if ( isset( $activity_allowedtags['ul'] ) ) {
@raftaar1191
raftaar1191 / functions.php
Last active February 24, 2017 12:09
Open media on the same tab when user click on edit media
<?php
// Check if function doest not exists.
if ( ! function_exists( 'rtmedia_wp_footer_add_js_callback' ) ) {
function rtmedia_wp_footer_add_js_callback() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
// Event will fire when someone click on edit button of media.
jQuery( 'body' ).on( 'click', '.rtmedia-gallery-item-actions a',function(){
var target = jQuery( this ).attr( 'target' );
@raftaar1191
raftaar1191 / functions.php
Created March 1, 2017 13:21
Gallery shortcode with sorting parameter to bring sorting option and menu in one lines CSS
<?php
/**
* This snippet is used to fix issue mentioned
* at https://rtmedia.io/ticket/506359/
*/
if ( ! function_exists( 'rtmedia_wp_head_fix_sorting_button' ) ) {
function rtmedia_wp_head_fix_sorting_button() {
// Check if the constant RTMEDIA_SORTING_VERSION exists
if ( defined( 'RTMEDIA_SORTING_VERSION' ) ) {
@raftaar1191
raftaar1191 / functions.php
Created March 2, 2017 14:37
Add sub menu in rtMedia media tab in profile menu
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_add_extra_sub_nav_for_upload' ) ) {
function rtmedia_add_extra_sub_nav_for_upload() {
// IMPORTANT Please change the page_slug
$page_slug = 'file-upload';
// check if function does not exists
if ( function_exists( 'get_page_by_path' ) ) {
@raftaar1191
raftaar1191 / functions.php
Last active March 3, 2017 13:13
Add sub menu in media tab in admin menu
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_add_admin_bar_media_sub_menu_for_upload' ) ) {
function rtmedia_add_admin_bar_media_sub_menu_for_upload() {
// Please change the page_slug if you want from here
$page_slug = 'file-upload';
// check if function does not exists and RTMEDIA_MEDIA_SLUG is alredy defined
@raftaar1191
raftaar1191 / functions.php
Created March 3, 2017 13:09
Add sub menu inside rtMedia media tab in member profiles page
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_add_extra_sub_nav_for_upload' ) ) {
function rtmedia_add_extra_sub_nav_for_upload() {
// Check if user is logged in and RTMEDIA_MEDIA_SLUG is already defined
if ( is_user_logged_in() && defined( 'RTMEDIA_MEDIA_SLUG' ) ) {
// IMPORTANT Please change the page_slug
$page_slug = 'file-upload';
@raftaar1191
raftaar1191 / functions.php
Last active March 14, 2017 13:40
Add sub menu in media tab of admin menu
<?php
// check if function does not exist
if ( ! function_exists( 'rtmedia_add_admin_bar_media_sub_menu_for_upload' ) ) {
function rtmedia_add_admin_bar_media_sub_menu_for_upload() {
// Please change the page_slug if you want from here
$page_slug = 'file-upload';
// check if RTMEDIA_MEDIA_SLUG is already defined
@raftaar1191
raftaar1191 / functions.php
Last active March 3, 2017 13:17
Always show the upload container by default
<?php
// check if function does not exists
if ( ! function_exists( 'rtmedia_after_media_gallery_show_upload_button' ) ) {
function rtmedia_after_media_gallery_show_upload_button() {
// Please change the page_slug from here
$page_slug = 'file-upload';
if ( isset( $_GET[ $page_slug ] ) && ! empty( $_GET[ $page_slug ] ) ) {
@raftaar1191
raftaar1191 / functions.php
Last active March 8, 2017 20:12
Show media count in rtMedia gallery shortcode
<?php
// Check if function doest not exists.
if ( ! function_exists( 'rtmedia_gallery_after_title_add_media_count' ) ) {
function rtmedia_gallery_after_title_add_media_count() {
global $rtmedia_query;
// Check for gallery shortcode
if ( isset( $rtmedia_query->is_gallery_shortcode ) && true === $rtmedia_query->is_gallery_shortcode ) {
// Defalut value for media count.
$media_count = 0;
if ( isset( $rtmedia_query->is_gallery_shortcode ) ) {