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 October 3, 2015 08:29
Showing EDD Review Post link
/*Add option to post review for edd purchased items - TH */
add_action( 'edd_purchase_history_header_after', '__edd_post_review_th', 12 );
function __edd_post_review_th() {
echo '<th class="edd-post-review-th">'. __('Reviews', 'edd') .'</th>';
} // This part is working fine
/*Add option to post review for edd purchased items - TD */
add_action( 'edd_purchase_history_row_end', '__edd_post_review_td', 12, 2 );
function __edd_post_review_td( $payment_id, $purchase_data ) {
// As I'm getting payment id and not post id so I have no idea how to fetch
@isaumya
isaumya / wp-comment-validation.js
Last active January 18, 2016 20:58
Validation for WordPress Default Comments
jQuery(function ($) {
/*Email validation function*/
function isEmail(email) {
var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if( regex.test(email) ){
return true;
} else {
return false;
}
}
@isaumya
isaumya / functions.php
Created November 19, 2015 09:38
Show Back to Page Link in WordPress Blank Comment Posting
<?php
add_action( 'pre_comment_on_post', function ( $comment_post_ID ) {
$go_back = sprintf( __( '<br><a href="javascript:history.go(-1)">Back to "%s" Article</a>' ), get_the_title( $comment_post_ID ) );
// Part-copied from "wp-comments-post.php", with $go_back tagged onto error strings.
$comment_author = ( isset($_POST['author']) ) ? trim(strip_tags($_POST['author'])) : null;
$comment_author_email = ( isset($_POST['email']) ) ? trim($_POST['email']) : null;
$comment_content = ( isset($_POST['comment']) ) ? trim($_POST['comment']) : null;
$user = wp_get_current_user();
if ( get_option('require_name_email') && !$user->exists() ) {
if ( 6 > strlen( $comment_author_email ) || '' == $comment_author ) {
@isaumya
isaumya / dont-crawl.html
Created December 27, 2015 15:33
Google Crawl Off for specific section of a page
<!-- googleoff: all -->CODE<!-- googleon: all -->
@isaumya
isaumya / gapps-response.json
Created February 27, 2016 14:44
GApps Primary Domain Change Response
Request
PUT https://www.googleapis.com/admin/directory/v1/customers/my_customer?fields=customerDomain&amp;key={YOUR_API_KEY}
{
"customerDomain": "extraconfort.com"
}
Response
@isaumya
isaumya / visual-editor-custom-buttons.php
Created May 30, 2016 10:55
Visual Editor Custom Buttons compatibility update for WordPress v4.5+
<?php
/*
Plugin Name: Visual Editor Custom Buttons
Plugin URI: http://eborninteractive.se
Description: Create custom buttons in Wordpress Visual Editor.
Version: 1.5.2.1
Author: Ola Eborn
Author URI: http://eborninteractive.se
Text Domain: visual-editor-custom-buttons
License: GPL
@isaumya
isaumya / adsense-code-diff.html
Last active June 8, 2019 10:54
Google AdSense Code Difference - AMP Page vs Normal Page
################# Normal Google AdSense Code #################
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<ins class="adsbygoogle center top-ad"
style="display:block"
data-ad-client="ca-pub-1234667890"
data-ad-slot="1234567890"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
@isaumya
isaumya / responsive-table.html
Created August 12, 2016 15:03
Responsive Table Structure inside HTML or WordPress
<!-- No need to add the part BELOW on WordPress Site -->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Responsive Table</title>
</head>
<body>
<!-- No need to add the part ABOVE on WordPress Site -->
@isaumya
isaumya / responsive-table.css
Last active August 12, 2016 15:44
Responsive Table CSS for general HTML or WordPress sites
@media only screen and (max-width: 768px) {
table.responsive {
margin-bottom: 0;
overflow: hidden;
overflow-x: scroll;
display: block;
white-space: nowrap;
}
}
@isaumya
isaumya / .htaccess
Created August 17, 2016 12:50
HSTS Add via htaccess file with includeSubdomain and preload directive - Apache
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=31536000;includeSubDomains;preload"
</IfModule>