Skip to content

Instantly share code, notes, and snippets.

View tomaskavalek's full-sized avatar
:octocat:
Hardworking anytime 👍

Tomáš Kavalek tomaskavalek

:octocat:
Hardworking anytime 👍
View GitHub Profile
@tomaskavalek
tomaskavalek / gopay_helper.php
Last active October 2, 2018 09:11
GopayHelper – replace mcrypt functions for PHP 7.2
<?php
public static function encrypt($data, $secureKey) {
return GopayHelper::encrypt_php72($data, $secureKey, 'DES-EDE3');
}
public static function decrypt($data, $secureKey) {
return GopayHelper::decrypt_php72($data, $secureKey, 'DES-EDE3');
}
/**
@tomaskavalek
tomaskavalek / wpscan.sh
Created October 15, 2018 07:42
wpscan with docker
docker pull wpscanteam/wpscan
docker run -i -t f80e1f599e05 /bin/bash --url https://www.example.com
@tomaskavalek
tomaskavalek / gulpfile.js
Created January 25, 2019 08:50
Gulp 4 + Vagrant gulp.watch() fix
// Don't forget to use {usePolling: true}
// Without this options gulp under vagrant ignore file change in synced directory from your machine :-)
gulp.watch(path, {usePolling: true}, ['css']);
@tomaskavalek
tomaskavalek / howto.txt
Created February 12, 2019 13:01
PHP 7.x + Microsoft SQL Driver & Debian (stretch)
Firstly install https://warlord0blog.wordpress.com/2017/12/12/php7-0-microsoft-sql-driver-debian-stretch/
Then https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017
@tomaskavalek
tomaskavalek / woocommerce-products-filter.php
Created February 23, 2019 12:01
WooCommerce Admin Custom Products Filtering
<?php
/**
* Return (render :-D) HTML Select > Option for filtering
*
* @param string $post_type
* @return void
*/
function webona_custom_product_filters(string $post_type): void
{
if ($post_type !== 'product') {
@tomaskavalek
tomaskavalek / @layout.latte
Created January 27, 2020 08:55
Contributte DataGrid FilterDate localisation
<script src="{$basePath}/path/to/bootstrap-datepicker.cs.js"></script>
@tomaskavalek
tomaskavalek / Query
Created February 28, 2020 14:30 — forked from lukecav/Query
MySQL script to get all WooCommerce orders including metadata
select
p.ID as order_id,
p.post_date,
max( CASE WHEN pm.meta_key = '_billing_email' and p.ID = pm.post_id THEN pm.meta_value END ) as billing_email,
max( CASE WHEN pm.meta_key = '_billing_first_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_first_name,
max( CASE WHEN pm.meta_key = '_billing_last_name' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_last_name,
max( CASE WHEN pm.meta_key = '_billing_address_1' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_1,
max( CASE WHEN pm.meta_key = '_billing_address_2' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_address_2,
max( CASE WHEN pm.meta_key = '_billing_city' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_city,
max( CASE WHEN pm.meta_key = '_billing_state' and p.ID = pm.post_id THEN pm.meta_value END ) as _billing_state,
@tomaskavalek
tomaskavalek / woocommerce_admin_move_dashboard_menu_item.php
Last active July 7, 2020 08:41
Allow access WooCommerce orders old way, instead of opening dashboard
<?php
function tk_admin_menu_order()
{
global $submenu;
// WooCommerce
if ( ! isset($submenu['woocommerce'])) {
return false;
}
@tomaskavalek
tomaskavalek / get-random-number-sh
Created November 6, 2020 11:00
Bash – Get random number in interval
#!/bin/bash
# Get random number 0–5
local RANDOM_NUMBER=$(grep -m1 -ao '[0-5]' /dev/urandom | head -n1)
@tomaskavalek
tomaskavalek / wp-admin-menu-debug.php
Created November 16, 2020 17:57
Debug WordPress admin menu – on dashboard only
<?php
if ( ! function_exists('debug_admin_menus')) {
function debug_admin_menus()
{
global $submenu, $menu, $pagenow;
if (current_user_can('manage_options')) {
if ($pagenow === 'index.php') {
echo '<pre>';
print_r($menu);
echo '</pre>';