Skip to content

Instantly share code, notes, and snippets.

🎯
Focused on NanoSupport

Mayeenul Islam mayeenulislam

View GitHub Profile
@mayeenulislam
mayeenulislam / .gitignore
Last active Mar 8, 2019
WordPress Debugging plugins I used to use in most of the development workflow
View .gitignore
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 Jun 22, 2018
WP Restrict Unwanted Users - restrict unwanted users from visiting the site (Link: https://wordpress.stackexchange.com/a/306082/22728)
View wpse-restrict-unwanted-users.php
<?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 Mar 30, 2018 — 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…
View functions.php
<?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 Nov 24, 2017
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
View bulk-fi-kb.php
<?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
*/
View How to create different thumb size for different post type.php
<?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 Nov 2, 2017 — 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.
View wpmail_exceptions.php
<?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 — 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
View how-to-secure-your-site-with-https.md

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 Mar 24, 2017 — forked from toddlahman/gist:6302280
Save Plugin Error Messages in the database for The Plugin Generated x Characters of Unexpected Output During Activation errors
View gist:a52b78395f9907f466e8dac2d29a60ec
<?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: */
@mayeenulislam
mayeenulislam / how-to-disable-html-links-with-css.md
Created Mar 21, 2017 — forked from nepsilon/how-to-disable-html-links-with-css.md
How to disable HTML links with CSS? — First published in fullweb.io issue #92
View how-to-disable-html-links-with-css.md
@mayeenulislam
mayeenulislam / functions.php
Created Feb 7, 2017 — forked from EmranAhmed/functions.php
Hook Info. Get Action hook info. What functions are hooked to an action / filter in WordPress? How can I see all the actions attached to an "add_action" hook?
View functions.php
<?php
if ( ! function_exists( 'hippo_plugin_hook_info' ) ):
function hippo_plugin_hook_info( $hook_name ) {
global $wp_filter;
$docs = array();
$template = "\t - %s Priority - %s.\n\tin file %s #%s\n\n";
echo '<pre>';
You can’t perform that action at this time.