Skip to content

Instantly share code, notes, and snippets.

View sanderlt's full-sized avatar
😀

sanderlt

😀
View GitHub Profile
HIRE Me For Your Project Support :)
Telegram: https://t.me/LinuxGun
#!/bin/bash
# Completely Remove Apache Ubuntu
service apache2 stop
apt purge apache2 apache2-utils apache2.2-bin
apt remove apache2.*
apt autoremove
whereis apache2
disposable_emails = [
"yopmail.com",
"0-mail.com",
"0815.ru",
"0clickemail.com",
"0wnd.net",
"0wnd.org",
"10minutemail.com",
"20minutemail.com",
"2prong.com",
@kreamweb
kreamweb / sort-cart-items-by-price.php
Last active September 12, 2022 22:31
Woocommerce - Sort cart items by price
add_action( 'woocommerce_cart_loaded_from_session', 'wpm_cart_order_items_by_price' );
function wpm_cart_order_items_by_price( $cart ) {
//if the cart is empty do nothing
if ( empty( $cart->cart_contents ) ) {
return;
}
//this is an array to collect cart items
add_filter( 'pre_get_posts', 'add_cpt_to_loop_and_feed' );
/**
* @author Brad Dalton
* @example http://wpsites.net/wordpress-tips/add-custom-post-type-to-rss-feed/
* @copyright 2014 WP Sites
*/
function add_cpt_to_loop_and_feed( $query ) {
if ( is_home() && $query->is_main_query() || is_feed() )
$query->set( 'post_type', array( 'post', 'your-cpt' ) );
@maxrice
maxrice / gist:6541634
Last active April 23, 2020 18:11
WooCommerce - sort the cart alphabetically by the product's title
<?php
add_action( 'woocommerce_cart_loaded_from_session', function() {
global $woocommerce;
$products_in_cart = array();
foreach ( $woocommerce->cart->cart_contents as $key => $item ) {
$products_in_cart[ $key ] = $item['data']->get_title();
}
@mrkmg
mrkmg / genColorCodeFromText.php
Created January 13, 2012 17:22
Generate a unique color based on text input
<?php
/*
* Outputs a color (#000000) based Text input
*
* @param $text String of text
* @param $min_brightness Integer between 0 and 100
* @param $spec Integer between 2-10, determines how unique each color will be
*/
function genColorCodeFromText($text,$min_brightness=100,$spec=10)