Skip to content

Instantly share code, notes, and snippets.

View mayeenulislam's full-sized avatar
🤖
AI won't replace you

Mayeenul Islam mayeenulislam

🤖
AI won't replace you
View GitHub Profile
# ----------------------------------------------------------------------
# | Compression |
# ----------------------------------------------------------------------
<IfModule mod_deflate.c>
# Force compression for mangled `Accept-Encoding` request headers
# https://developer.yahoo.com/blogs/ydn/pushing-beyond-gzipping-25601.html
<IfModule mod_setenvif.c>
@mayeenulislam
mayeenulislam / functions.php
Created September 21, 2015 12:28
wp-login.php page redirect
<?php
/**
* Redirect from wp-login.php
* @link http://stackoverflow.com/a/1976804/1743124
*/
function mayeenulislam_wp_login_redirect(){
if( isset($_GET['action']) && $_GET['action'] == 'register' ) {
wp_redirect( home_url('/register') ); //i.e. http://example.com/register
exit();
} else if( isset($_GET['action']) && $_GET['action'] == 'lostpassword' ) {
@mayeenulislam
mayeenulislam / CSS_snapping.css
Created July 21, 2015 04:36
The following CSS will scroll overflowed items just like a slider
.item{
overflow: auto;
scroll-snap-type: proximity;
scroll-snap-points-x: repeat(300px);
}
/* Source: https://twitter.com/supersole/status/615924334675296256 */
@mayeenulislam
mayeenulislam / pending-post-bubble-in-admin-menu.php
Last active July 13, 2021 22:27
Show a pending posts count on Custom Post Type menu label like Plugin Update Notification count. Thanks to Samik Chattopadhyay for the nice snippet.
/**
* Get posts pending count as per Post Type.
* @param string $post_type
* @return integer Pending count.
*/
function project_get_pending_items( $post_type ) {
global $wpdb;
$pending_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = %s AND post_status = 'pending'", $post_type ) );
return (int) $pending_count;
}
@mayeenulislam
mayeenulislam / WordPress- alphabetical order search result
Created May 4, 2015 07:54
WordPress - ascending or alphabetical order search result
<?php
/**
* Ascending order search result - WordPress
* @param object $query
* @return void
*/
function wp20150504_alphabetical_search_query( $query ) {
//checking whether we are in the search result page or not
if ( $query->is_search && $query->is_main_query() ) {
@mayeenulislam
mayeenulislam / enable-lazyload-js
Last active December 8, 2016 02:00
This is a code to enable jQuery LazyLoad into any DOM. It was made according to the guideline (http://www.appelsiini.net/projects/lazyload) and based on the last update on this github repo (https://github.com/tuupola/jquery_lazyload). It is just the basic, you are free doing your tweaks.
jQuery(document).ready(function($) {
var imgs = $('img'); //grabbing all the images of a DOM
imgs.addClass('lazy'); //adding .lazy to all the images
imgs.each(function() {
var img_src = $(this).attr('src'); //grabbing the 'src=""' value of each of the img
$(this).attr('data-original', img_src); //assigning the src value to 'data-original'
$(this).removeAttr('src'); //now deleting the 'src' attribute
});
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}

Keybase proof

I hereby claim:

  • I am mayeenulislam on github.
  • I am mayeenulislam (https://keybase.io/mayeenulislam) on keybase.
  • I have a public key whose fingerprint is CFF1 D104 6905 54AF 01CD 06CB EF58 8473 625B 520A

To claim this, I am signing this object:

@mayeenulislam
mayeenulislam / jQuery - show or hide WP meta boxes on post type selection
Created December 24, 2014 04:59
jQuery - show/hide WP meta boxes on post type selection. To make things work, you have to assure the jQuery is turned on, and you have to enqueue the scripts using `admin_enqueue_scripts()`
jQuery(document).ready(function($) {
$('body.post-new-php #formatdiv input[id="post-format-gallery"], body.post-new-php #formatdiv input[id="post-format-video"]').change(function(){
$('.news-head-div').slideUp();
$('.news-highlight-div').slideUp();
$('#news-position').slideUp();
$('#categorydiv').slideUp();
});
$('body.post-new-php #formatdiv input[id="post-format-0"]').change(function(){
@mayeenulislam
mayeenulislam / content-sidebar-sidebar.css
Created December 23, 2014 11:43
A responsive approach to 3 column layout with 2 sidebars in different formation
/* Aesthetics */
.container{
width: 100%;
max-width: 980px;
margin-left: auto;
margin-right: auto;
}
/* Debugging */
#content,
aside{