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

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:

* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@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
});
@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 / 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 / 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 / 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' ) {
# ----------------------------------------------------------------------
# | 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 / show-wordpress-db-queries.php
Last active November 1, 2015 09:05
Show WordPress database queries at the footer only to the admin if WP_DEBUG is enabled
<?php
/**
* db QUERIES
* Prerequisite: define('SAVEQUERIES', true)
*/
function nano_enqueue_db_queries() {
global $wpdb;
echo '<h2>Database Last Query</h2>';
echo $wpdb->last_query;
echo '<hr>';
@mayeenulislam
mayeenulislam / functions.php
Created February 16, 2016 06:59 — forked from hasinhayder/functions.php
Redirect WordPress posts to the editor if someone types /edit at the end of the permalink
<?php
function init_url_rewrite_rule(){
add_rewrite_endpoint( 'edit',EP_PERMALINK | EP_PAGES | EP_ATTACHMENT );
if(get_option("EDIT_REWRITE_RULE")!=1){
flush_rewrite_rules();
update_option("EDIT_REWRITE_RULE",1);
}
}
function redirect_edit_url(){