Skip to content

Instantly share code, notes, and snippets.

View aliaramli's full-sized avatar
🎯
Focusing

alia aliaramli

🎯
Focusing
  • Malaysia
View GitHub Profile
@aliaramli
aliaramli / sample-intl-tel-input.php
Last active January 13, 2020 09:10
Example of intl-tel-input initialization on wordpress custom plugin and handling on wc-ajax=checkout_update_order_review
function init_tel(){
$utils_url = plugins_url('/js/utils.js', __FILE__);
?>
<script>
var input = document.querySelector("#phone");
var iti = window.intlTelInput(input,{
utilsScript: "<?php echo $utils_url; ?>",
// the countries at the top of the list. defaults to united states and united kingdom
preferredCountries: [ "my", "us", "gb" ],
autoPlaceholder: null,
@aliaramli
aliaramli / bash-create-wordpress-uploads-folders.sh
Created January 13, 2020 09:08
Steps to create Wordpress uploads folders using bash command Linux
# 1. create the folder of the year in your wordpress project folder
mkdir -p /project_folder/wp-content/uploads/2020
# 2. then create child folders for every month!!!!!
#this is for 01-09
for i in {1..9}; do mkdir -p /project_folder/wp-content/uploads/2020/0$i; done
#this is for 10-12
for i in {0..2}; do mkdir -p /project_folder/wp-content/uploads/2020/1$i; done
$developer = array("name"=>"alia", "job"=>"freelancer", "age"=>"30");
$parsed_array_to_json = json_decode($developer);
//javascript
var developer = <?php echo $parsed_array_to_json; ?>;
//access the value.
console.log(developer.name, developer.age, developer.job);
$developers = array(
array("name"=>"alia", "job"=>"freelancer", "age"=>"30"),
array("name"=>"naruto", "job"=>"freelancer hokage", "age"=>"30"),
array("name"=>"sasuke", "job"=>"freelancer spy", "age"=>"30")
);
$parsed_array_to_json = json_decode($developers);
//javascript
var developers = <?php echo $parsed_array_to_json; ?>;
//access the value.
developers.forEach(logData);
function logData(value, index, array) {
console.log(value.name, value.age, value.job);
}
@aliaramli
aliaramli / prepare_child_theme_assets_directories.sh
Created March 3, 2020 03:50
Copy files to our wordpress child theme directory
//create the directories first in our child theme
mkdir -p /var/www/our-wordpress-site/wp-content/themes/child-storefront/assets/js
mkdir -p /var/www/our-wordpress-site/wp-content/themes/child-storefront/assets/css
//copy files from our machine to the server site.
scp utils.js alia@xxx:/var/www/our-wordpress-site/wp-content/themes/child-storefront/assets/js/
scp utils.css alia@xxx:/var/www/our-wordpress-site/wp-content/themes/child-storefront/assets/css/
@aliaramli
aliaramli / add_scripts_to_wordpress_theme.php
Last active December 10, 2020 15:18
Sample adding Javascript and CSS files to Wordpress
function wp_add_javascripts() {
wp_enqueue_script('utils-js',
get_stylesheet_directory().'/assets/js/utils.js', array('jquery'),'1.1', true);
}
function wp_add_styles() {
wp_enqueue_style('utils-css',
get_stylesheet_directory().'/assets/css/utils.css');
}