Skip to content

Instantly share code, notes, and snippets.

View hiranthi's full-sized avatar

Hiranthi Herlaar hiranthi

View GitHub Profile
@mrl22
mrl22 / ColorHelper.php
Created October 23, 2023 16:38
Laravel / PHP - Check if a hexidecimal colour is dark
<?php
namespace App\Helpers;
class ColorHelper
{
// This function tell you if a color is dark or light.
// It is useful when you want to change the text color to white or black depending on the background color.
public static function isColorDark($hexColor = '#ffffff') {
@sergiu-radu
sergiu-radu / gist:e0c8fe3791ec69b6890f0f651ae83c24
Last active December 6, 2024 19:08
Blocksy CSS Variables
--paletteColor1 -----> --theme-palette-color-1
--paletteColor2 -----> --theme-palette-color-2
--paletteColor3 -----> --theme-palette-color-3
--paletteColor4 -----> --theme-palette-color-4
--paletteColor5 -----> --theme-palette-color-5
--paletteColor6 -----> --theme-palette-color-6
--paletteColor7 -----> --theme-palette-color-7
--paletteColor8 -----> --theme-palette-color-8
--fontFamily -----> --theme-font-family
@miltonbolonha
miltonbolonha / plugins-install.sh
Created April 7, 2021 02:04
bash plugins install for wordpress
sudo chmod -R 775 /home/milton/www/projects/system* && mkdir wp-content/plugins
curl -L https://downloads.wordpress.org/plugin/wp-super-cache.1.7.2.zip -o /tmp/wp-super-cache.1.7.2.zip
curl -L https://downloads.wordpress.org/plugin/advanced-custom-fields.5.9.5.zip -o /tmp/advanced-custom-fields.5.9.5.zip && unzip /tmp/advanced-custom-fields.5.9.5.zip -d ./wp-content/plugins
curl -L https://downloads.wordpress.org/plugin/custom-post-type-ui.1.8.2.zip -o /tmp/custom-post-type-ui.1.8.2.zip && unzip /tmp/custom-post-type-ui.1.8.2.zip -d ./wp-content/plugins
curl -L https://downloads.wordpress.org/plugin/learnpress.zip -o /tmp/learnpress.zip && unzip /tmp/learnpress.zip -d ./wp-content/plugins
curl -L https://downloads.wordpress.org/plugin/shins-pageload-magic.zip -o /tmp/shins-pageload-magic.zip && unzip /tmp/shins-pageload-magic.zip -d ./wp-content/plugins
curl -L https://downloads.wordpress.org/plugin/wordpress-seo.16.0.0.zip -o /tmp/wordpress-seo.16.0.0.zip && unzip /tmp/wordpress-seo.16.0.0.zip -d ./wp-conten
@paaljoachim
paaljoachim / functions.php
Last active March 7, 2023 18:50
WooCommerce: Adding multiple custom fields to the order notes area in the checkout page
/* 1. Adds a custom field. NB. I am using some Norwegian words in the below text.
* 2. Then adds a validate error message if person does not fill out the field.
* 3. Then adds the custom field to the order page.
https://businessbloomer.com/woocommerce-add-custom-checkout-field-php/
https://businessbloomer.com/woocommerce-add-shipping-phone-checkout/
https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-6
*/
add_action( 'woocommerce_before_order_notes', 'my_custom_checkout_field' );
function my_custom_checkout_field( $checkout ) {
@tfirdaus
tfirdaus / wp-cli-convert-to-innodb.sh
Created October 26, 2018 11:07
Convert MyISAM tables to InnoDB with WP-CLI
#!/usr/bin/env bash
# Author Mike https://guides.wp-bullet.com
# Purpose - Convert MyISAM tables to InnoDB with WP-CLI
# create array of MyISAM tables
WPTABLES=($(wp db query "SHOW TABLE STATUS WHERE Engine = 'MyISAM'" --silent --skip-column-names | awk '{ print $1}'))
# loop through array and alter tables
for WPTABLE in ${WPTABLES[@]}
do
@petskratt
petskratt / clinup
Last active May 26, 2024 14:24
Use wp-cli to clean up WordPress installs (force core & plugins reinstall, track changes in git allowing easy reverts etc)
#!/usr/bin/env bash
# for debug output, uncomment:
#set -x
function help {
echo "WordPress cleanup -v 0.5 2018-06-26 / [email protected]
Usage:
@woogists
woogists / wc-auto-add-product-to-cart.php
Last active March 22, 2023 15:31
Automatically add product to cart on visit
/**
* Automatically add product to cart on visit
*/
add_action( 'template_redirect', 'add_product_to_cart' );
function add_product_to_cart() {
if ( ! is_admin() ) {
$product_id = 64; //replace with your own product id
$found = false;
//check if product already in cart
if ( sizeof( WC()->cart->get_cart() ) > 0 ) {
@amboutwe
amboutwe / yoast_seo_title_change-variable.php
Last active March 25, 2025 11:02
Change existing or add custom title or meta template variables
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Change existing title or meta template variable
* Credit: Moshe Harush
* https://stackoverflow.com/questions/36281915/yoast-seo-how-to-create-custom-variables
* Last Tested: Unknown
*/
// define the wpseo_replacements callback
function filter_wpseo_replacements( $replacements ) {
@JeroenSormani
JeroenSormani / hide-shipping-if-free-shipping-is-available.php
Last active December 6, 2024 20:33
New - Hide paid shipping rates when free is available. DOES show Local Pickup. Considered ANY shipping rate that is $0 as free (so the 'Free shipping' shipping method is not a requirement)
<?php
/**
* Copy from here to your (child) themes functions.php
* Recommended to do so via FTP.
*/
/**
* Hide all but the free shipping options when free is available.
*
@corsonr
corsonr / functions.php
Created September 28, 2016 08:33
Display WooCommerce product variations dropdown select on the shop page
<?php
// Display variations dropdowns on shop page for variable products
add_filter( 'woocommerce_loop_add_to_cart_link', 'woo_display_variation_dropdown_on_shop_page' );
function woo_display_variation_dropdown_on_shop_page() {
global $product;
if( $product->is_type( 'variable' )) {