Skip to content

Instantly share code, notes, and snippets.

View hsleonis's full-sized avatar
🏝️
Travellers unite.

Hasan Shahriar hsleonis

🏝️
Travellers unite.
View GitHub Profile
@hsleonis
hsleonis / fb-api-user-profile-image.php
Last active October 22, 2023 15:09
Facebook API - How do I get a Facebook user's profile image through the Facebook API (without requiring the user to “Allow” the application)
Basic: (50x50 pixels)
<img src="//graph.facebook.com/nusraatfariaofficial/picture">
Square:
maximum width and height of 50 pixels.
Small
maximum width of 50 pixels and a maximum height of 150 pixels.
Normal
maximum width of 100 pixels and a maximum height of 300 pixels.
Large
@hsleonis
hsleonis / wp-get-theme.php
Created April 3, 2016 12:04
Gets a WP_Theme object for a theme
<?php
/**
* Gets a WP_Theme object for a theme
* Reference: https://developer.wordpress.org/reference/functions/wp_get_theme
*/
// Echo the name of the current active theme
echo wp_get_theme();
// Echo the name of an installed theme
@hsleonis
hsleonis / wp-get-plugin-data.php
Created April 3, 2016 11:59
Parse the plugin contents to retrieve plugin's metadata
<?php
/**
* Parse the plugin contents to retrieve plugin's metadata
* Works only in wp-admin
* Reference: https://codex.wordpress.org/Function_Reference/get_plugin_data
*/
get_plugin_data( $plugin_file, $markup = true, $translate = true );
/*
Return value:
@hsleonis
hsleonis / meta-referer.html
Last active May 6, 2025 04:23
Meta referer
# HTML Inline:
To make specific link send no referer url:
<a rel="noreferrer" href="http://w3schools.com">Link</a>
# JQuery method:
<script>
$(function(){
$("a").attr('rel','noreferrer');
});
</script>
@hsleonis
hsleonis / date-convert.js
Created April 2, 2016 11:12
Convert date format
/**
* Date format received from Yahoo: 2016-04-03T19:00:00+05:30
* Date format needed: Mon, 03 April 2016
*
* Ref.: http://www.w3schools.com/js/js_dates.asp
*/
var d = new Date('2016-04-03T19:00:00+05:30');
document.write(d.toUTCString().slice(0,16));
@hsleonis
hsleonis / replace-external-url-path.php
Created April 2, 2016 11:09
Replace external url with different website URL
<?php
$homepage = file_get_contents('http://www.w3schools.com/games/game_canvas.asp');
$str=str_replace("href=\"", "href=\"http://mysite.com", $homepage );
echo $str;
@hsleonis
hsleonis / jquery-toggle-and-div-wrap.js
Created April 2, 2016 10:13
Toogle css class without conditions
/**
* Toggle two classes
*/
$("#toggler").toggleClass("lightOn lightOff");
/**
* Wrap an HTML structure around each element in the set of matched elements
* Reference: http://api.jquery.com/wrap
*/
$( ".inner" ).wrap( "<div class='new'></div>" );
@hsleonis
hsleonis / popup-window.js
Last active March 31, 2016 15:08
Create popup window with native js
/**
* Syntax: window.open(URL,name,specs,replace)
* Reference: http://www.w3schools.com/jsref/met_win_open.asp
*/
var URL = 'http://w3schools.com';
window.open( URL, "wo_map_console","height=650,width=800,toolbar=no,statusbar=no,scrollbars=yes").focus();
@hsleonis
hsleonis / animated-window-title.js
Last active March 31, 2016 14:19
Animated window title
var strTitle = document.title,
iIndex = 0;
function animateTitle(){
document.title= strTitle.substring(iIndex, iIndex + 145);
if(iIndex == strTitle.length-1){ iIndex = 0;}
else iIndex++;
setTimeout("animateTitle()",200);
}
animateTitle();
@hsleonis
hsleonis / array_remove.js
Created March 31, 2016 11:26 — forked from HiveSolution/array_remove.js
Simple prototype ext. for array to remove elements
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};