Skip to content

Instantly share code, notes, and snippets.

View mahfuzul's full-sized avatar

Mahfuzul Hasan mahfuzul

View GitHub Profile
@mahfuzul
mahfuzul / vc_dependency.php
Last active July 20, 2023 09:27
Visual Composer field dependency variations
<?php
#Visual Composer field dependency examples:
array(
"type" => "attach_image",
"holder" => "div",
"param_name" => "section_title_image",
"dependency" => [
"element" => "title_type",
@mahfuzul
mahfuzul / string_to_ssn.php
Last active September 26, 2023 15:03
Convert string of numbers to SSN format in PHP
// Format string to SSN (Social Security Number) in the format of XXX-XX-XXXX
function string_to_ssn( $ssn = "111223333" ) {
return substr($ssn, 0, 3).'-'.substr($ssn, 3, 2).'-'.substr($ssn,5);
}
// Format string to SSN by preg_replace
function string_to_ssn_2( $ssn = "111223333" ) {
$ssn = preg_replace('/[^\d]/', '', $ssn);
$ssn = preg_replace('/^(\d{3})(\d{2})(\d{4})$/', '$1-$2-$3', $ssn);
@mahfuzul
mahfuzul / gist:5a8da362e03c5a82634b7fd9af753fa8
Created May 8, 2019 11:41 — forked from pedroagabreu/gist:1908892061fcb2b2f3c6
Salesforce web to lead via php-curl.
$sfurl = 'https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8';
$sffields = array(
'oid' => 'someoid',
'lead_source' => 'my website',
'last_name' => urlencode($_POST['name']),
'company' => urlencode($_POST['organization']),
'email' => urlencode($_POST['email']),
'phone' => urlencode($_POST['phone']),
);
foreach($sffields as $key=>$value) { $fieldstring .= $key.'='.$value.'&'; }
@mahfuzul
mahfuzul / Country List with short name.txt
Created July 17, 2018 12:27
All Country List (short name and full name)
AD : Andorra
AE : United Arab Emirates
AF : Afghanistan
AG : Antigua and Barbuda
AI : Anguilla
AL : Albania
AM : Armenia
AN : Netherlands Antilles
AO : Angola
AQ : Antarctica
@mahfuzul
mahfuzul / Country List.txt
Created July 17, 2018 12:25
All Country List (full name only)
Afghanistan
Aland Islands
Albania
Algeria
American Samoa
Andorra
Angola
Anguilla
Antarctica
Antigua and Barbuda
@mahfuzul
mahfuzul / external_link_new_tab.js
Created March 28, 2018 08:11
JS: Third party links will be opened in a new tab/window
@mahfuzul
mahfuzul / WP_add_remove_body_class.php
Created February 6, 2018 10:51
How to add or remove body classes in WordPress
<?php
// WP Add Remove Body Classes
// Add
add_filter( 'body_class','mh_body_classes' );
function my_body_classes( $classes ) {
$classes[] = 'class-name';
$classes[] = 'class-name-two';
@mahfuzul
mahfuzul / ValidateDOB.js
Created October 30, 2017 10:51
Validate age/date 18 years or not
// Validate DOB 18 years or not
jQuery.validator.addMethod( "stValidDOB", function(value, element) {
var dob = value.split("-");
var year = dob[0];
var month = dob[1];
var day = dob[2];
var age = 18;
var mydate = new Date();
@mahfuzul
mahfuzul / EmailValidation.js
Created October 26, 2017 11:17
Custom method for Email validation
// Add Custom method for Email validation
jQuery.validator.addMethod("stEmail", function(value, element) {
return this.optional( element ) || /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( value );
}, 'Please enter a valid email address.');
@mahfuzul
mahfuzul / switch_php_version.sh
Last active December 15, 2017 13:18
Switch between Multiple PHP Version on Ubuntu
##From PHP 5.6 => PHP 7.1
Default PHP 5.6 is set on your system and you need to switch to PHP 7.1. Run the following commands to switch for Apache and command line.
#Apache:-
$ sudo a2dismod php5.6
$ sudo a2enmod php7.1
$ sudo service apache2 restart