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 / adding-html-within-php.php
Created September 19, 2016 15:38
Adding HTML within PHP with the help of STR
<?php
/* Option 1 */
$html = '<div>
<p>At the time of creating any blog or news based websites most webmasters gives the least amount of importance to the commenting system of their website, without even understanding the importance of it. Eventually comment section of a website is the only place where people interact with the author when they are exited or happy with the article and helps to grow the whole website community. In most cases they end up using some third party commenting system like Disqus or Spot.im etc. without even realizing what a blunder they are making. I’ve seen many websites (both big & popular as well as small websites) using Disqus commenting system, without even realizing the consequences. And by the time you will realize it, your site would have become so big & popular they you can’t take the risk of changing your commenting system. If you are thinking why, keep reading.</p>
<p><a href="I want to omit this P from counting"><img src="I want to omit this p from counting" /></a></p>
<p
@isaumya
isaumya / mySTPackageList.txt
Last active October 8, 2017 07:06
My Favorite Sublime Text Packages
## Terminal
https://github.com/wbond/sublime_terminal
https://packagecontrol.io/packages/Terminal
## Material Theme for Sublime Text
https://github.com/equinusocio/material-theme
https://packagecontrol.io/packages/Material%20Theme
## A File Icon
https://github.com/ihodev/a-file-icon
@isaumya
isaumya / show-image.php
Created September 26, 2016 20:08
Showing image in WordPress works for both SVG & non SVG image
<?php
/*** Function to show images whether SVG or non SVG ***/
/*** $size & $attribute both can hold array if you want ***/
function show_image( $image_id, $size = null, $attributes = null ) {
//first lets get the file info sto understand what kind of file it is
//as for svg file we will take different approach
$file_info = pathinfo( wp_get_attachment_url( $image_id ) );
//so, if the file type is SVG
if ( $file_info['extension'] === 'svg' ) {
@isaumya
isaumya / wordpress-svg-support.php
Created September 26, 2016 20:13
Add SVG Support in WordPress Media Uploader
<?php
/*** enable svg support ***/
add_filter('upload_mimes', function( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
$mimes['svgz'] = 'image/svg+xml';
return $mimes;
});
@isaumya
isaumya / .htaccess
Created October 10, 2016 11:27
Code for doing 301 HTTPS redirection for any site using .htaccess
<IfModule mod_headers.c>
RewriteEngine on
RewriteBase /
RewriteCond %{http_host} !^www.example.com$ [nc,OR]
RewriteCond %{SERVER_PORT} !^443$
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
</IfModule>
@isaumya
isaumya / .htaccess
Created October 10, 2016 11:36
Disable directory based file listing in Apache servers where there is not a index file present
Options -Indexes
@isaumya
isaumya / some-plugin-file-name.php
Created October 22, 2016 16:57
WordPress basic plugin header example
<?php
/*
Plugin Name: Type a plugin name here
Plugin URI: https://www.isaumya.com/ (This is supposed to link to the plugin's official page, but you can put any link here)
Description: Type a detailed description about the plugin. Like what is does. What changes does it make to the site etc.
Version: 1.0 (Just a version number for your plugin)
Author: Saumya Majumder (Author's Name, i.e. your name)
Author URI: https://www.isaumya.com/ (This is supposed to link to the author's official page, but you can put any link here)
*/
@isaumya
isaumya / html-title-changer.js
Created December 11, 2016 10:35
Change the title of the page if user click on some other tag
/* Let's say the normal title of page in the <title> tag is => iSaumya.com
* but when user will go to some other tab of the browser, it will be changed
* from iSaumya.com to 。◕‿◕。 iSaumya.com
**/
var original_title = document.title;
document.addEventListener("visibilitychange", function(){
if(document.hidden)
document.title = "。◕‿◕。 iSaumya.com";
else
document.title = original_title;
@isaumya
isaumya / console-log-special-message.js
Created December 11, 2016 11:01
Showing special message in the console.log
/* This script will show a special designed message in the console.log section of your website
* for those who looks for something extra in your website.
* Fiddle Link: https://jsfiddle.net/isaumya/vtjswjuL/
**/
jQuery(function ($) {
try{
console.log("%c < ISAUMYA /> ","background: linear-gradient(to right, rgba(231,76,60,1) 0%,rgba(155,89,182,1) 100%););font-size:3em;border-radius:1em;color:#ffffff;font-weight:bold;font-style: italic;");
console.log('%c made with ♥ by Saumya Majumder © 2016', 'color: #e74c3c;font-size:1.1em;');
}
catch(e){}
@isaumya
isaumya / back-button-refresh.php
Created December 23, 2016 12:05
Refresh page when click browser back button
<?php
/**
* Adding a special function to ensure that when the user click on back button,
* it will reload the pages, instead of loading from cache so that the js can run again
**/
add_action( 'wp_footer', 'aicp_refresh_on_back' );
function aicp_refresh_on_back() {
echo '<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){