Skip to content

Instantly share code, notes, and snippets.

View mahbubme's full-sized avatar
🤞
Focusing

Mahbubur Rahman mahbubme

🤞
Focusing
View GitHub Profile
@mahbubme
mahbubme / criticalcss-bookmarklet-devtool-snippet.js
Created September 21, 2018 06:41 — forked from PaulKinlan/criticalcss-bookmarklet-devtool-snippet.js
CriticalCSS Bookmarklet and Devtool Snippet.js
(function() {
var CSSCriticalPath = function(w, d, opts) {
var opt = opts || {};
var css = {};
var pushCSS = function(r) {
if(!!css[r.selectorText] === false) css[r.selectorText] = {};
var styles = r.style.cssText.split(/;(?![A-Za-z0-9])/);
for(var i = 0; i < styles.length; i++) {
if(!!styles[i] === false) continue;
var pair = styles[i].split(": ");
@mahbubme
mahbubme / solution.php
Last active February 6, 2019 17:58
Update product price of WooCommerce based on different conditions
<?php
function update_price_wpuf_form( $post_id ) {
$boolChifre = isset( $_POST['pa_chifre'] ) ? $_POST['pa_chifre'] : 0;
$currentPrice = get_post_meta( $post_id, '_regular_price' );
$images = get_post_meta( $post_id, '_product_image' );
$images = count($images);
if ( $images > 2 ) {
$currentPrice = 35;
}
@mahbubme
mahbubme / solution.php
Created August 18, 2018 10:05
WPUF post edit link
<?php
function wpuf_get_post_edit_link( $post_id ) {
if ( !class_exists( 'WP_User_Frontend' ) || !$post_id ) {
return;
}
$edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_frontend_posting' );
$url = get_permalink( $edit_page );
$url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );
@mahbubme
mahbubme / sublime_setup.md
Created August 10, 2018 06:40 — forked from barnes7td/sublime_setup.md
Sublime Terminal Setup

Setup Terminal for Sublime Shorcut "subl":

Open terminal and type:

1. Create a directory at ~/bin:

mkdir ~/bin

2. Copy sublime executable to your ~/bin directory:

@mahbubme
mahbubme / generate-ssh-key.sh
Created August 9, 2018 06:12 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "[email protected]" -f ~/.ssh/mozilla_rsa
@mahbubme
mahbubme / functions.php
Created August 1, 2018 07:04
Create sticky post with WP User Frontend post form
<?php
function wpuf_stick_post( $post_id ) {
$form_id = $_POST['form_id'];
if ( $form_id == 19102 ) {
stick_post($post_id);
}
}
add_action( 'wpuf_add_post_after_insert', 'wpuf_stick_post' );
@mahbubme
mahbubme / functions.php
Created July 31, 2018 08:37
Add user role name to body tag as class
<?php
// Add user role as body class
function print_user_classes() {
add_filter('body_class','class_to_body');
}
add_action('init', 'print_user_classes');
// Add user role class to front-end body tag
function class_to_body($classes) {
<?php
function wpuf_unique_product_sku_notice( $error ) {
if ( isset( $_POST['_sku'] ) ) {
global $wpdb;
$sku = $_POST['_sku'];
$product_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key='_sku' AND meta_value='%s' LIMIT 1", $sku ) );
@mahbubme
mahbubme / wp_mail.md
Created January 25, 2018 14:29 — forked from johnbillion/wp_mail.md
WordPress Emails

WordPress Emails

This document lists all the situations where WordPress sends an email, along with how to filter or disable each email.

This is accurate as of WordPress 4.9.

There are a few TODOs left. Please bear with me.

@mahbubme
mahbubme / billing-address.php
Created November 19, 2017 06:26
Override billing adddress template
<?php
global $current_user;
$address_fields = array();
if ( isset( $_POST['add_line_1'] )
&& isset( $_POST['city'] )
&& isset( $_POST['state'] )
&& isset( $_POST['zip_code'] )