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
@mayeenulislam
mayeenulislam / RegEx.md
Last active October 30, 2019 11:28
Regular Expressions for HTML5 Patterns

HTML5 Regular Expressions

DateTime (12 Hour format with AM/PM)

([0-2][0-9]|(3)[0-1])(-)(((0)[0-9])|((1)[0-2]))(-)\d{4} (1[0-2]|0?[1-9]):[0-5][0-9] (AM|PM)

Example

<input type="text" class="form-control" value="" placeholder="Pick a datetime, e.g., 21-02-1952 12:59 PM" pattern="([0-2][0-9]|(3)[0-1])(-)(((0)[0-9])|((1)[0-2]))(-)\d{4} (1[0-2]|0?[1-9]):[0-5][0-9] (AM|PM)">
@mayeenulislam
mayeenulislam / data.json
Last active July 10, 2019 17:08 — forked from hasinhayder/data.json
WP Quick Configurator Data
{
"themes": [],
"plugins": [
"elementor",
"happy-elementor-addons",
"contact-form-7",
"query-monitor",
"regenerate-thumbnails",
"debug-bar",
"debug-bar-console",
@mayeenulislam
mayeenulislam / .gitignore
Last active March 8, 2019 15:55
WordPress Debugging plugins I used to use in most of the development workflow
wp-content/plugins/debug-bar
wp-content/plugins/debug-bar-console
wp-content/plugins/debug-bar-cron
wp-content/plugins/debug-bar-list-dependencies
wp-content/plugins/debug-bar-post-types
wp-content/plugins/debug-bar-remote-requests
wp-content/plugins/debug-bar-shortcodes
wp-content/plugins/debug-bar-transients
wp-content/plugins/log-deprecated-notices
wp-content/plugins/log-viewer
@mayeenulislam
mayeenulislam / wpse-restrict-unwanted-users.php
Last active June 22, 2018 16:27
WP Restrict Unwanted Users - restrict unwanted users from visiting the site (Link: https://wordpress.stackexchange.com/a/306082/22728)
<?php
/**
* Plugin Name: WPSE Restrict Unwanted Users
* Plugin URI: https://wordpress.stackexchange.com/a/306082/22728
* Description: Restrict unwanted users from visiting the site
* Author: Mayeenul Islam
* Version: 1.0.0
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
*/
@mayeenulislam
mayeenulislam / functions.php
Created March 30, 2018 05:25 — forked from lmartins/functions.php
By default WooCommerce redirects the user to the My Account page after a successful login. You may change this and use a custom URL based on the user role, like the Dashboard for admins and My Account page for customers. To do this, add this code at the end of the file functions.php located in wp-content/themes/your-theme-name/ https://support.w…
<?php
/**
* Redirect users to custom URL based on their role after login
*
* @param string $redirect
* @param object $user
* @return string
*/
function wc_custom_user_redirect( $redirect, $user ) {
// Get the first of all the roles assigned to the user
@mayeenulislam
mayeenulislam / bulk-fi-kb.php
Created November 24, 2017 14:14
Set a single featured image to all the NanoSupport Knowledgebase posts on activation. Before activating the plugin set the default post_thumbnail_id on line #19
<?php
/**
* Plugin Name: Bulk Featured Image (KB)
* Description: Set a single featured image to all the NanoSupport Knowledgebase posts on activation. Before activating the plugin set the default post_thumbnail_id on line #19.
* Plugin URI: http://nanodesignsbd.com/
* Author: Mayeenul Islam
* Author URI: http://nanodesignsbd.com/
* Version: 1.0.0
* License: GPL2
*/
<?php
add_action( 'pre-upload-ui', 'get_the_post_type' );
function get_the_post_type() {
$post_type = isset( $_REQUEST['post_type'] ) ? $_REQUEST['post_type'] : 'post';
set_transient( 'attached_post_type', $post_type );
}
add_filter( 'intermediate_image_sizes_advanced', 'add_image_size_for_post_type', 10 );
function add_image_size_for_post_type( $sizes ) {
@mayeenulislam
mayeenulislam / wpmail_exceptions.php
Last active November 2, 2017 05:35 — forked from franz-josef-kaiser/wpmail_exceptions.php
WP Mail Error/Exception handling and SMTP settings. ALWAYS use the Kaiser's version - it's safer. This forked version is just to catch errors in the case of non-admin users.
<?php
/**
* NOTICE_____________________________________________________________________
* ALWAYS use the Kaiser's version - it's safer.
* This forked version is just to catch errors in the case of non-admin users.
* ---------------------------------------------------------------------------
*/
defined( 'ABSPATH' ) OR exit;
/**
@mayeenulislam
mayeenulislam / how-to-secure-your-site-with-https.md
Created May 26, 2017 12:40 — forked from nepsilon/how-to-secure-your-site-with-https.md
How to secure your site with HTTPS? — First published in fullweb.io issue #101

How to secure your site with HTTPS?

With HTTP everything is visible when traveling on the Internet. By generating an SSL certificate and configuring your webserver you can force browsers to use HTTPS. Here is how to proceed:

# 1. Install letsencrypt
sudo pip install letsencrypt
@mayeenulislam
mayeenulislam / gist:a52b78395f9907f466e8dac2d29a60ec
Created March 24, 2017 18:46 — forked from toddlahman/gist:6302280
Save Plugin Error Messages in the database for The Plugin Generated x Characters of Unexpected Output During Activation errors
<?php
function tl_save_error() {
update_option( 'plugin_error', ob_get_contents() );
}
add_action( 'activated_plugin', 'tl_save_error' );
/* Then to display the error message: */