Skip to content

Instantly share code, notes, and snippets.

View mhasan3's full-sized avatar
🎯
Focusing

Mahmudul Hasan mhasan3

🎯
Focusing
View GitHub Profile
@mhasan3
mhasan3 / amp-google-tag-manager.php
Created October 23, 2019 05:10 — forked from westonruter/amp-google-tag-manager.php
Plugin demonstrating how to inject GTM for the AMP plugin, in response to support forum topic: https://wordpress.org/support/topic/amp-with-google-tag-manager/
<?php
/**
* Plugin Name: AMP Google Tag Manager
*
* @package AMP_Google_Tag_Manager
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@mhasan3
mhasan3 / youtube_id_regex.php
Created September 21, 2019 09:58 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
<form name="artist_basic_profile" id="artist_basic_profile" action="" method="post" enctype="multipart/form-data">
<?php if($user->ID){ ?>
<input type="file" id="userProfileImage" name="userProfileImage" >
<input id="submit" type="submit" name="submit" value="Save" >
<?php } ?>
</form>
{
"type": "email",
"customer": {
"email": "{{customer.email}}",
"firstName":"{{customer.firstName}}",
"lastName":"{{customer.lastName}}"
},
"subject": "Low NPS rating from customer {{customer.firstName}} {{customer.lastName}}",
"mailbox": {
"id": MAILBOX-ID
@mhasan3
mhasan3 / gist:21823412e872d3fa2109e40be9605fb5
Created June 21, 2018 10:25 — forked from Mikodes/gist:be9b9ce42e46c3d4ccb6
All Media queries for resolutions
/* (320x480) iPhone (Original, 3G, 3GS) */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) {
/* insert styles here */
}
/* (320x480) Smartphone, Portrait */
@media only screen and (device-width: 320px) and (orientation: portrait) {
/* insert styles here */
}
@mhasan3
mhasan3 / delete-posts.sql
Created May 8, 2018 15:09 — forked from wpsmith/delete-posts.sql
SQL: Delete all posts of a custom post type with its associated meta data (taxonomies, post meta)
DELETE a,b,c
FROM {PREFIX}_posts a
LEFT JOIN {PREFIX}_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN {PREFIX}_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'POST_TYPE' AND a.post_date < '2014-01-01'
@mhasan3
mhasan3 / d8module.install
Created January 26, 2018 13:19 — forked from laradevitt/d8module.install
(Drupal 8) Create a table in a database other than the default during module installation. Database must already be specified in settings.php.
<?php
/**
* @file
* Install, update and uninstall functions for the d8module module.
*/
function d8module_schema_otherdb() {
$schema['mytable'] = array(
'description' => 'My table description',
@mhasan3
mhasan3 / repeatable-fields-metabox.php
Created November 17, 2017 12:31 — forked from helen/repeatable-fields-metabox.php
Repeating Custom Fields in a Metabox
<?
/**
* Repeatable Custom Fields in a Metabox
* Author: Helen Hou-Sandi
*
* From a bespoke system, so currently not modular - will fix soon
* Note that this particular metadata is saved as one multidimensional array (serialized)
*/
function hhs_get_sample_options() {
@mhasan3
mhasan3 / virtual_host.sh
Created October 13, 2017 08:55
how to create virtual host in ubuntu
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
// update_option( 'siteurl', 'http://dev.enl/environmental-leader-v3/' );
// update_option( 'home', 'http://dev.enl/environmental-leader-v3/' );
// function wpb_admin_account(){
// $user = 'admin';
// $pass = 'admin';
// $email = 'email@domain.com';
// if ( !username_exists( $user ) && !email_exists( $email ) ) {
// $user_id = wp_create_user( $user, $pass, $email );