Skip to content

Instantly share code, notes, and snippets.

View pranali333's full-sized avatar
👻
Observing...

Pranali Patel pranali333

👻
Observing...
View GitHub Profile
@pranali333
pranali333 / custom-code-location.php
Created July 27, 2021 19:01
Send the longitude, latitude of the entered location to a third party API in JSON form via webhooks.
add_filter( 'wpforms_webhooks_process_delivery_request_options', function( $options, $webhook_data, $fields, $form_data, $entry_id ) {
if ( empty( $entry_id ) || empty( $form_data['id'] ) ) {
return $options;
}
$body = ! is_array( $options['body'] ) ? json_decode( $options['body'], true ) : $options['body'];
$location = wpforms()->entry_meta->get_meta(
[
'entry_id' => $entry_id,
'type' => 'location',
'number' => 1,
@pranali333
pranali333 / functions.php
Created August 29, 2018 11:28
Keep the Media tab open while visiting BuddyPress group
/**
* This snippet can be used for redirecting users to the BuddyPress group Media tab when clicking on the group name.
* You can use this code under your theme's functions.php file:
*/
function bp_change_group_link( $link ) {
preg_match_all( '~<a(.*?)href="([^"]+)"(.*?)>~', $link, $matches );
$link_changed = preg_replace( "/(?<=href=(\"|'))[^\"']+(?=(\"|'))/", $matches[2][0] . apply_filters( 'rtmedia_media_tab_slug', 'media' ), $link );
@pranali333
pranali333 / functions.php
Created July 11, 2018 14:30
Custom code to keep rtMedia uploader open by default
// Put below code at end of your theme's functions.php file.
add_action( 'wp_head', function() {
?>
<style>
#rtm-media-gallery-uploader {
display: block !important;
}
</style>
<script>
@pranali333
pranali333 / functions.php
Created August 16, 2017 13:31
Add an extra space after content of what's new
/**
* Add space after content of what's new.
*/
function rtmc_add_space_after_content() {
?>
<script>
console.log( rtMediaHook );
if( typeof rtMediaHook == "object" ){ // check if rtMediaHook defined or not
rtMediaHook.register(
'rtmedia_js_file_added', // hook id here
@pranali333
pranali333 / functions.php
Created July 24, 2017 10:09
Change media gallery title with BuddyPress username
/**
* Change title of "Media Gallery" in "media" tab.
* This functions needs "Buddypress" plugin to be activated.
*
* @param string $title Title of Media gallery.
* @return String Updated title.
*/
function rtm_gallery_title( $title ) {
// Get user name for current profile.
if ( ! function_exists( 'bp_get_displayed_user_mentionname' ) ) {
@pranali333
pranali333 / template.php
Created July 13, 2017 09:05
List media from the groups of which a currently logged-in user is a member
<?php
/**
* It will first identify that currently logged-in user is member of which group and pick up the first group
* if there are more than one.
**/
$user_id = get_current_user_id();
$user_groups = (groups_get_user_groups($user_id));
$user_groups = $user_groups["groups"];
@pranali333
pranali333 / functions.php
Last active May 18, 2017 06:13
Custom code to display the liked media in the BuddyPress activity when other user liked it.
<?php
/**
* rtMedia creates activity post if someone likes the media.
* If anyone wants to display the liked media along with the activity post as well then here is the custom code.
* Thanks to community contributor Ignacio_Duran_Sanz for this.
* You can add this code your theme's functions.php file.
*/
// Adding mediato activity when someone likes it
@pranali333
pranali333 / functions.php
Created March 16, 2017 13:20
Custom code to add a custom DropDown under rtMedia uploader.
<?php
/*Here is the custom code to add a custom Dropdown under rtMedia uploader with a hiddenfield.
* You can add this code to your theme's functions.php file
*/
if ( ! function_exists( 'rtmedia_add_custom_dropdown_menu' ) ) {
function rtmedia_add_custom_dropdown_menu( $content ) {
ob_start();
?>
<div id="custom_dropdown_list_wrapper">
@pranali333
pranali333 / custom-javascript.js
Created March 16, 2017 13:15
Custom JavaScript code to set the value in the custom hiddenfield under rtMedia uploader
jQuery( document ).ready( function () {
$custom_dropdown = jQuery( '#custom_dropdown_list' );
$custom_input = jQuery( "#custom_media_type" );
$custom_input.val( $custom_dropdown.val() );
$custom_dropdown.on( 'change', function() {
$custom_input.val( $custom_dropdown.val() );
} );
@pranali333
pranali333 / functions.php
Last active March 8, 2017 14:34
Add conditional check before applying watermark on rtMedia uploads
<?php
// IMPORTANT
// Before using this gist code, make sure you have added this code - https://gist.github.com/pranali333/085e312f18fc2b9bd7333f8c17b56630
add_action( 'init', 'pre_watermark_condition', 11 );
function pre_watermark_condition() {
if ( isset( $_POST['unique_hidden_field'] ) ) {
if ( Media is free ){