Skip to content

Instantly share code, notes, and snippets.

View isaumya's full-sized avatar
👨‍💻
Think Twice, Code Once

Saumya Majumder isaumya

👨‍💻
Think Twice, Code Once
View GitHub Profile
@isaumya
isaumya / functions.php
Created September 9, 2016 18:12
Change the the Product Label to Custom Text - Gravity Forms
<?php
//* Changing Price Label in Gravity Forms - Supports the latest version too
//* in gform_product_price_6 the 6 denoted to the FORM ID
add_filter( 'gform_product_price_6', function( $sublabel, $form_id ) {
return 'Donation Amount';
}, 10, 2);
@isaumya
isaumya / functions.php
Created September 9, 2016 20:43
Attach files with Gravity Forms Notification Emails - Gravity Forms
<?php
//* Attaching file to the form notification user email
//* in gform_notification_7, the number 7 is the FORM ID
//* This snippet works with the newer version of Gravity Forms too
add_filter('gform_notification_7', 'add_attachment_pdf', 10, 3); //target form id 7, change to your form id
function add_attachment_pdf( $notification, $form, $entry ) {
//There is no concept of user notifications anymore, so we will need to target notifications based on other criteria,
//such as name or subject
if($notification["name"] == "User Notification - Life Lesson"){
//get upload root for WordPress
@isaumya
isaumya / functions.php
Created September 16, 2016 08:32
Disable WordPress XMLRPC.php without affecting Jetpack Plugin
<?php
add_filter( 'xmlrpc_enabled', '__return_false' );
@isaumya
isaumya / wp-insert-ad-code.php
Created September 19, 2016 15:01
Insert AdSense Ad Code after certain number of paragraphs in your WordPress posts dynamically while ignoring some paragraphs in the paragraph checking/count
<?php
/*
Plugin Name: Insert AdSense Ad Code after certain paragraph
Plugin URI: https://www.isaumya.com/
Description: Insert AdSense Ad code after certain paragraph number while ignoring some paragraphs
Version: 2.0
Author: Saumya Majumder
Author URI: https://www.isaumya.com/
*/
@isaumya
isaumya / wp-insert-ad-code-legacy.php
Created September 19, 2016 15:14
Insert AdSense Ad code after certain paragraph number. Please note that the following code will consider all `p` tags into its consideration while executing
<?php
/*
Plugin Name: Insert AdSense Ad Code after certain paragraph
Plugin URI: https://www.isaumya.com/
Description: Insert AdSense Ad code after certain paragraph number considering all `p` tags
Version: 1.0
Author: Saumya Majumder
Author URI: https://www.isaumya.com/
*/
@isaumya
isaumya / wp-count-total-paragraph.php
Created September 19, 2016 15:16
Count the total number of paragraph on any WordPress blog post
<?php
function __check_paragraph_count_blog( $content ) {
global $post;
if ( $post->post_type == 'post' ) {
$count = substr_count( $content, '</p>' );
return $count;
} else {
return 0;
}
}
@isaumya
isaumya / functions.php
Created September 19, 2016 15:21
Disable sanitization on Gravity Form for WordPress - prior to v2.0 update
<?php
/* Please note this filter will not work on Gravity Forms v2.0+
* If your GF is not capturing values like ajgsdn?12332#?fds#^%
* then use the following filter in GF v2.0 prior
**/
add_filter( 'gform_sanitize_entry_value', '__return_false' );
@isaumya
isaumya / functions.php
Created September 19, 2016 15:25
Increase general user comment editing time in Simple Comment Editing WordPress Plugin
<?php
/**
* Increase general user comment editing time
* @plugin_name: Simple Comment Editing
* @plugin_uri: https://wordpress.org/plugins/simple-comment-editing/
*/
add_filter( 'sce_comment_time', function( $time_in_minutes ) {
return 10;
} );
@isaumya
isaumya / functions.php
Created September 19, 2016 15:27
Changing the default loading icon for editing comments for general users in Simple Comment Editing WordPress Plugin
<?php
/**
* Changing the default loading icon for editing comments for general users
* @plugin_name: Simple Comment Editing
* @plugin_uri: https://wordpress.org/plugins/simple-comment-editing/
*/
add_filter( 'sce_loading_img', function( $default_url ) {
return get_stylesheet_directory_uri() . '/assets/images/spinner.gif';
} );
@isaumya
isaumya / functions.php
Created September 19, 2016 15:32
Fix: CSS minification & combination is not working for WordPress sites with mod_pagespeed or ngx_pagespeed
<?php
/*Allowing mod_pagespeed or nginx_pagespeed to combine CSS files*/
/*By removing the ID field from the css link href*/
add_filter('style_loader_tag', function( $link ) {
// Removing the Style ID from the WordPress CSS output as the ID in `link` causes the issue
return preg_replace("/id='.*-css'/", "", $link);
} );