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
Last active March 13, 2017 05:39
Return the attribute term count
<?php
if ( ! function_exists( 'rtmedia_get_attributes_count' ) ) {
/**
* Return the media count of the terms
*
* @since 1.2.3
*
* @param string $attributes_slug attribute slug
* @param string $terms_slug terms slug
*
@raftaar1191
raftaar1191 / functions.php
Last active March 10, 2017 14:23
Alert media id after the media is being uploaded
<?php
if ( ! function_exists( 'wp_footer_rtmedia_add_script_callback' ) ) {
/**
* Add javascript in the footer
*/
function wp_footer_rtmedia_add_script_callback() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
rtMediaHook.register('rtmedia_js_after_file_upload', function ( resp ) {
@raftaar1191
raftaar1191 / functions.php
Created March 11, 2017 11:59
Alert the Attachment id of the media that is being upload
<?php
if ( ! function_exists( 'wp_footer_rtmedia_add_script_callback' ) ) {
/**
* Add javascript in the footer
*/
function wp_footer_rtmedia_add_script_callback() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
@raftaar1191
raftaar1191 / functions.php
Last active March 22, 2017 07:20
Add a link below every media in media gallery
<?php
/**
* Add a link below every media in media gallery.
*/
function tmp_rtmedia_rtmedia_after_item_callback() {
global $rtmedia_media;
// Check if $rtmedia_media->id rtMedia id is set and also check for if $rtmedia_media->media_id post id is set
if ( isset( $rtmedia_media->id ) && isset( $rtmedia_media->media_id ) ) {
@raftaar1191
raftaar1191 / pre-commit.sh
Last active March 23, 2017 11:43
Shell Script to add pre-commit symbolic to all the rtMedia addon
#!/bin/bash
echo 'Enter pre-commit DIR>'
read pre_path
if [ ! -f "$pre_path" ]; then
# Will enter here if $pre_path exists, even if it contains spaces
echo 'Pre commit file does not exists'
exit;
fi
Run the below command in the terminal directly
sudo service network-manager restart
Will restart the netowrk manager module completly
@raftaar1191
raftaar1191 / functions.php
Last active March 30, 2017 06:35
BuddyPress issue
<?php
/**
* Add script for mobile device in BuddyPress profile page only.
*
* Change style of uploader that used to change profile picture and cover photo.
*/
function tmp_rtmedia_wp_footer_callback() {
// Check if it is a mobile device and bp_is_my_profile function exist also it an BuddyPress profile page.
if ( wp_is_mobile() && function_exists( 'bp_is_my_profile' ) && bp_is_my_profile() ) {
?>
@raftaar1191
raftaar1191 / functions.php
Created March 31, 2017 09:27
Add JavaScript variable for ajax url
<?php
/**
* Define the 'ajaxurl' JS variable, used by rtMEdia as an AJAX endpoint.
*/
function tmp_rtmedia_core_add_ajax_url_js() {
?>
<script type="text/javascript">var ajaxurl = '<?php echo admin_url( 'admin-ajax.php', is_ssl() ? 'admin' : 'http' ); ?>';</script>
@raftaar1191
raftaar1191 / functions.php
Last active April 5, 2017 14:00
Fix Change sensitivity of lightbox swipe on mobile
<?php
/**
* Fix Change sensitivity of lightbox swipe on mobile.
*
* Issue link: http://community.rtcamp.com/t/change-sensitivity-of-lightbox-swipe-on-mobile/8550
*/
function tmp_rtm_wp_head_callback() {
// Check if it's an mobile device or not.
if ( wp_is_mobile() ) {
@raftaar1191
raftaar1191 / functions.php
Last active April 5, 2017 12:33
Filter to change order of media tabs in rtMedia sidebar widget gallery
<?php
/**
* Change the media order tab in rtMedia sidebar widgets gallery.
*
* @since 1.3.5
*
* @param array $allowed Contain the media tab list that will be going to be display in the rtMedia sidebar widget gallery.
* @param array $widgetid Contain widget id.
*