Skip to content

Instantly share code, notes, and snippets.

View mehul0810's full-sized avatar
👋
Hello Folks. Thanks for visiting my GitHub profile

Mehul Gohil mehul0810

👋
Hello Folks. Thanks for visiting my GitHub profile
View GitHub Profile
@mehul0810
mehul0810 / allow-script-tag-for-specific-user-roles.php
Last active January 10, 2024 10:19
Allow Script Tags to be added in content for specific user roles. Works will multisite as well.
<?php
/**
* Allow Script Tags to be used in editor for Administrator user role.
*
* @author Mehul Gohil <hello@mehulgohil.com>
*/
function allow_unfiltered_html_for_administrators( $allowed_tags ) {
// Bailout, if the logged-in user role is not `administrator`.
if ( ! current_user_can( 'administrator' ) ) {
return $allowed_tags;
@mehul0810
mehul0810 / flush-my-dns-cache-macos.sh
Created November 14, 2021 05:07
This macos terminal command will flush the DNS cache. This will help to make the internet working when WIFI is connected and internet not working.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder;
@mehul0810
mehul0810 / get-user-role.php
Created September 29, 2021 09:00
Get user role of the logged in user
<?php
/**
* Get User Role.
*
* This function can be used to get user role of a loggedin user.
*
* @since 1.0.0
*
* @return string
*/
@mehul0810
mehul0810 / third-party-addons-for-givewp.md
Last active December 1, 2022 00:04
A curated list of Third Party Addons for GiveWP WordPress Plugin

Hey folks!

Thanks for visiting this page.

You can always check the official free or paid GiveWP on their official website.

I've curated a list of all the third-party addons for GiveWP - most popular donations plugin for WordPress.

<?php
/**
* This code snippet will help you update the email address on donor as well as WP user profiles when donor updates the email address
* using legacy donor profile `[give_profile_editor]`.
*
* @param int $user_id WP User ID.
* @param array $userdata WP User data.
*
* @return void
*/
<?php
function custom_prefix_modify_currency_symbol( $symbol ) {
if( defined( 'ICL_LANGUAGE_CODE' ) && 'en' === ICL_LANGUAGE_CODE ) {
$symbol = 'AED';
}
return $symbol;
}
add_filter( 'give_currency_symbol', 'custom_prefix_modify_currency_symbol', 10 );
@mehul0810
mehul0810 / add-custom-field-in-csv-givewp.php
Created May 13, 2021 10:29
For GiveWP users, you can easliy add custom field and its data to the donation history CSV export.
<?php
/**
* Add data to CSV column.
*
* @param array $columns List of CSV columns.
*
* @since 1.0.0
*
* @return array
*/
Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[server] => nginx
[date] => Sun, 31 Jan 2021 15:43:18 GMT
[content-type] => text/plain;charset=UTF-8
[content-length] => 639
<?php
add_filter( 'nonce_life', function( $lifespan ) {
return 120;
}
@mehul0810
mehul0810 / mastercard-update-description.php
Last active September 6, 2020 16:51
Update description on payment page for Mastercard (MPGS) for Give
<?php
function mg_update_payment_description( $text, $donationId ) {
$donation_type = give_get_meta( $donationId, 'donation_type', true ); // `donation_type` is the custom field key added by the Form Field Manager.
return "{$text} - {$donation_type}";
}
add_filter( 'mgmcfg_update_form_description', 'mg_update_payment_description', 10, 2 );