Skip to content

Instantly share code, notes, and snippets.

Sanjay Bhowmick blbwd

Block or report user

Report or block blbwd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@blbwd
blbwd / loop.php
Created Jun 9, 2017
WooCommerce Featured Products loop
View loop.php
<!-- Featured products loop -->
<?php
$args = array(
'posts_per_page' => -1,
'post_type' => 'product',
'post_status' => 'publish',
'tax_query' => array(
array(
'taxonomy' => 'product_visibility',
'field' => 'name',
@blbwd
blbwd / functions.php
Created Apr 26, 2016
Google Map Embed in WordPress Post / Page
View functions.php
<?php
// Google Map embed short code
// Usage: [googlemap src="you_url"]
function GoogleMapEmbed($atts, $content = null) {
extract(shortcode_atts(array(
"width" => '100%',
"height" => '480',
"src" => ''
), $atts));
return '<iframe width="'.$width.'" height="'.$height.'" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="'.$src.'" ></iframe>';
@blbwd
blbwd / database.sql
Created Apr 12, 2016
PayPal IPN Integration - PHP & MySQL
View database.sql
CREATE TABLE IF NOT EXISTS `payments` (
`id` int(6) NOT NULL AUTO_INCREMENT,
`txnid` varchar(20) NOT NULL,
`payment_amount` decimal(7,2) NOT NULL,
`payment_status` varchar(25) NOT NULL,
`itemid` varchar(25) NOT NULL,
`createdtime` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
@blbwd
blbwd / cancel.php
Last active Mar 14, 2016
Simple PayPal Integration
View cancel.php
<?php
echo "<h1>Welcome, Guest</h1>";
echo "<h1>Payment Canceled</h1>";
?>
@blbwd
blbwd / dbconversion.php
Created Sep 10, 2015
Convert MySQL collation from utf8mb4 to utf8
View dbconversion.php
<?php
$dbname = 'your-database-name';
mysql_connect('your-database-hostname', 'your-database-username', 'your-database-password');
mysql_query("ALTER DATABASE `$dbname` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
$result = mysql_query("SHOW TABLES FROM `$dbname`");
while($row = mysql_fetch_row($result)) {
$query = "ALTER TABLE {$dbname}.`{$row[0]}` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
$query = "ALTER TABLE {$dbname}.`{$row[0]}` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
mysql_query($query);
@blbwd
blbwd / search.php
Created Sep 10, 2015
Count your wordpress search results
View search.php
<div>
<?php $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; ?>
<form name="searchform" method="get" action="<?php bloginfo('home');?>">
<input name="s" type="text" value="<?php echo $key;?>" />
<input name="submit" type="submit" value="Search" />
</form>
<div></div>
</div>
<h2>Search Results</h2>
<h3><?php echo $count;?> items found on your search words '<?php echo $key;?>'</h3>
@blbwd
blbwd / postal_lang_long.php
Created Sep 10, 2015
Get Latitude and Longitude from your Postal Address
View postal_lang_long.php
<?php
if ($_REQUEST[where]) {
$where = stripslashes($_REQUEST[where]);
$whereurl = urlencode($where);
// Note - Google key is domain specific!
$location = file("http://maps.google.com/maps/geo?q=$whereurl&output=csv&key=ABQIAAAAvp3__HwvT3VkixIIbsW0axQuKI_6t1bH2P0vC
I_Q8jfpn8qdNBQMnneljxh9czilkau_bYSCXteS_A");
// Sample - $location[0]="200,8,51.369318,-2.133457";
list ($stat,$acc,$north,$east) = explode(",",$location[0]);
$html = "Information for ".htmlspecialchars($where)."
@blbwd
blbwd / template.php
Created Sep 10, 2015
instagram image feed on your website
View template.php
<div class="instram-container">
<?php
$user_id = "xxxxxxxxxx"; //userid
$num_to_display = "8"; //instagram limits to max 20, but you can do less for your layout.
$access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // access token
?>
<div class="instagram-block"></div>
<script type="text/javascript">
$(function() {
$.ajax({
@blbwd
blbwd / functions.php
Created Sep 10, 2015
Setting up responsive image in WordPress
View functions.php
<?php
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
function remove_thumbnail_dimensions( $html )
{
$html = preg_replace( '/(width|height)="d*"s/', "", $html );
return $html;
}
?>
@blbwd
blbwd / remove.php
Created Sep 9, 2015
Destroy all the files in a directory
View remove.php
<?php
$dir = getcwd() . '/';
define('PATH', $dir);
function destroy($dir) {
$mydir = opendir($dir);
while(false !== ($file = readdir($mydir))) {
if($file != "." && $file != "..") {
chmod($dir.$file, 0777);
if(is_dir($dir.$file)) {
chdir('.');
You can’t perform that action at this time.