Skip to content

Instantly share code, notes, and snippets.

<?php
class Sort
{
public const SORT_ASC = 1;
public const SORT_DESC = -1;
public static function sortObjectsByProperty(array $objects, array $properties = ['id'], $direction = self::SORT_ASC): array
{
usort(
$objects,
@tronsha
tronsha / functions.php
Created January 27, 2016 09:44
woocommerce: fix "out of stock" message, if more than 30 variants are existing.
<?php
function custom_wc_ajax_variation_threshold( $qty, $product ) {
return sizeof( $product->get_children() );
}
add_filter( 'woocommerce_ajax_variation_threshold', 'custom_wc_ajax_variation_threshold', 10, 2 );
@tronsha
tronsha / mircryption.php
Last active January 8, 2016 12:40
Mircryption
<?php
function mircryption_decode($text, $key)
{
$encodedTextIvBase64 = str_replace('*', '', $text);
$encodedTextIv = base64_decode($encodedTextIvBase64);
$iv = substr($encodedTextIv, 0, 8);
$encodedText = substr($encodedTextIv, 8);
$plaintext = mcrypt_decrypt(MCRYPT_BLOWFISH, $key, $encodedText, MCRYPT_MODE_CBC, $iv);
return trim($plaintext);
@tronsha
tronsha / aventurisches_datum.php
Last active January 6, 2024 08:35
Aventurisches Datum für Das Schwarze Auge
<?php
$dayOfTheYear = date('z');
if ((date('L') == 1) && ($dayOfTheYear >= 60)) {
$dayOfTheYear = $dayOfTheYear - 1;
}
$avMonthList = array(
'Praios',
@tronsha
tronsha / installphp7.sh
Last active October 13, 2023 00:13
Install PHP7 to Ubuntu
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
apt-get update
apt-get install -y git-core autoconf bison libxml2-dev libbz2-dev libmcrypt-dev libcurl4-openssl-dev libltdl-dev libpng-dev libpspell-dev libreadline-dev make
mkdir -p /etc/php7/conf.d
mkdir -p /etc/php7/cli/conf.d
mkdir /usr/local/php7