Skip to content

Instantly share code, notes, and snippets.

View EmranAhmed's full-sized avatar
🏠
Working from home

Emran Ahmed EmranAhmed

🏠
Working from home
View GitHub Profile
@EmranAhmed
EmranAhmed / docker-compose.yml
Created November 8, 2022 10:37 — forked from glendaviesnz/docker-compose.yml
Basic WordPress docker compose file
version: '3.7'
services:
mysql:
image: mariadb
ports:
- '3306'
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: wordpress
volumes:
@EmranAhmed
EmranAhmed / update-woo-order-billing-when-user-saves-address.php
Created September 20, 2019 06:31 — forked from zgordon/update-woo-order-billing-when-user-saves-address.php
Update WooCommerce Order Address Dynamically When Customer Updates Their Address
<?php
add_action( 'woocommerce_customer_save_address', 'jsforwp_update_address_for_orders', 10, 2 );
function jsforwp_update_address_for_orders( $user_id ) {
$customer_meta = get_user_meta( $user_id );
$customer_orders = get_posts( array(
'numberposts' => -1,
'meta_key' => '_customer_user',
@EmranAhmed
EmranAhmed / letsencrypt_2018.md
Created February 14, 2019 09:35 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SSL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 18.04 (including IPv6, HTTP/2 and A+ SLL rating)


Virtual hosts

Let's say you want to host domains first.com and second.com.

Create folders for their files:

@EmranAhmed
EmranAhmed / custom_embed.php
Created October 21, 2018 10:47 — forked from manchumahara/custom_embed.php
Embed in WordPress Outside of Editor or Content https://manchumahara.com/?p=1135&preview=true
$url = 'https://www.youtube.com/watch?v=08f0tiLdk7w'; //a youtube video url
$autoembed = new WP_Embed(); //initialize the wordpress oEmbed helper class
$content = $autoembed->autoembed($url); //let's parse the url and get the embeded content
@EmranAhmed
EmranAhmed / wc-template-override.php
Created May 6, 2018 20:13 — forked from obiPlabon/wc-template-override.php
Helper class to override WooCommerce templates from plugin
<?php
/**
* WooCommerce template overriding class
*
* @author obiPlabon
*/
class WC_Template_Override {
/**
@EmranAhmed
EmranAhmed / wp-admin-modal-dialog.php
Created February 26, 2018 13:36 — forked from anttiviljami/wp-admin-modal-dialog.php
WordPress admin modal dialog example
<?php
// enqueue these scripts and styles before admin_head
wp_enqueue_script( 'jquery-ui-dialog' ); // jquery and jquery-ui should be dependencies, didn't check though...
wp_enqueue_style( 'wp-jquery-ui-dialog' );
?>
<!-- The modal / dialog box, hidden somewhere near the footer -->
<div id="my-dialog" class="hidden" style="max-width:800px">
<h3>Dialog content</h3>
<p>This is some terribly exciting content inside this dialog. Don't you agree?</p>
$wp_customize->add_setting( 'themeslug_media_setting_id', array(
'sanitize_callback' => 'absint',
'validate_callback' => 'themeslug_validate_image,
) );
$wp_customize->add_control(
new WP_Customize_Media_Control( $wp_customize, 'themeslug_media_setting_id', array(
'label' => __( 'Custom Core Media Setting' ),
'section' => 'custom_section', // Add a default or your own section
'mime_type' => 'image',
@EmranAhmed
EmranAhmed / nginx-tuning.md
Created March 4, 2017 21:29 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@EmranAhmed
EmranAhmed / array.php
Last active March 8, 2017 17:04 — forked from igorbenic/array.php
How to use the Starter Content in your WordPress Theme WP Starter Content, Demo contents
<?php
add_theme_support( 'starter-content', array(
// Content Section for Widgets
'widgets' => array(
// Sidebar
'sidebar-1' => array(
// Widget ID
'my_text' => array(
// Widget $id -> set when creating a Widget Class
@EmranAhmed
EmranAhmed / cookies.js
Last active December 23, 2016 09:14 — forked from CrocoDillon/cookies.js
Export your awesome module using AMD, CommonJS, Node.js or just as global.
/*
* Inspiration (well… copy pasting more or less) from:
* https://github.com/ScottHamper/Cookies/blob/0.3.1/src/cookies.js#L127-L140
*
* Thanks Scott!
*/
(function (global) {
'use strict';
var MyModule = function () {