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 / gist:4a8319a47e342c6973ad152bd778228f
Created March 22, 2020 16:52
Python data stucture simple array Ice Cream Machine
class IceCreamMachine:
def __init__(self, ingredients, toppings):
self.ingredients = ingredients
self.toppings = toppings
def scoops(self):
final_scoops = []
for ingredient in self.ingredients:
for topping in self.toppings:
@aliaramli
aliaramli / gist:7262c8bebf6daa4366cfa04e2c67de35
Created March 22, 2020 16:14
Python data struct dict group by values
from collections import defaultdict
def group_by_owners(files):
# Grouping dictionary keys by value
res = defaultdict(list)
for key, val in files.items():
res[val].append(key)
return res
if __name__ == "__main__":
@aliaramli
aliaramli / show_seller_bank_details.php
Created March 11, 2020 08:54
wcfm code snippet to display seller bank account details.
<p><?php
$vendor_id = 0;
foreach ( $order->get_items() as $item_id => $item ) {
$meta_data = $item->get_formatted_meta_data();
// Get the meta data value of vendor id from one of the order item
$vendor_id = $item->get_meta("_vendor_id");
break;
}
//get vendor data
//Create folder for the child theme
mkdir -p /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
//Add the customer-on-hold-order.php to the child theme emails template directory
cp /var/www/<your-website-directoy>/wp-content/plugins/woocommerce/templates/emails/customer-on-hold-order.php /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
//Dont forget to grant permission to the folder :D
chown -R www-data:www-data /var/www/<your-website-directoy>/wp-content/themes/child-storefront/woocommerce/emails
@aliaramli
aliaramli / wp_enqueue_script
Created March 3, 2020 03:59
wp_enqueue_script parameters
Parameters #Parameters
$handle
(string) (Required) Name of the script. Should be unique.
$src
(string) (Optional) Full URL of the script, or path of the script relative to the WordPress root directory.
Default value: ''
@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');
}
@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/
//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);
}
$parsed_array_to_json = json_decode($developers);
$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")
);