Skip to content

Instantly share code, notes, and snippets.

View mikaelz's full-sized avatar

Michal Zuber mikaelz

View GitHub Profile
docker run --rm -l traefik -p 8080:8080 -p 80:80 \
-v $PWD/traefik.toml:/etc/traefik/traefik.toml \
-v /var/run/docker.sock:/var/run/docker.sock traefik
@mikaelz
mikaelz / docker-etc-hosts
Created July 26, 2018 10:00 — forked from Zaffy/docker-etc-hosts
Docker: print ips and containers' names suitable for use in /etc/hosts
for i in `docker ps -a -q | awk '{print $1}'`; do echo $(docker inspect --format="{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" $i) $(docker ps | grep $i | awk '{print $NF}') ; done
@mikaelz
mikaelz / add_magazin_link_to_breadcrumbs.php
Created May 2, 2018 07:00
Add custom list item to Breadcrumbs NavXT
@mikaelz
mikaelz / fix-embed-shortcode.php
Created April 10, 2018 12:51
Fix rendering of YouTube player of link in do_shortcode
<?php
// Hack due https://core.trac.wordpress.org/ticket/23431 issue
$embed = new WP_Embed();
$content = $embed->run_shortcode( $wp_query->queried_object->description );
echo '<div class="category-description">' . do_shortcode( $content ) . '</div>';
@mikaelz
mikaelz / functions.php
Created March 31, 2018 08:31
Remove Products list item from Breadcrumb NavXT
/**
* Remove products breadcrumb
*
* @param object $breadcrumb_obj Breadcrumb object.
*/
function my_bcn_after_fill( $breadcrumb_obj ) {
if ( is_category() || is_tag() || is_tax() ) {
foreach ( $breadcrumb_obj->breadcrumbs as $key => $item ) {
if ( 'Products' === $item->get_title() ) {
unset( $breadcrumb_obj->breadcrumbs[ $key ] );
@mikaelz
mikaelz / class-pie-wcwl-waitlist-mailout.php
Created November 2, 2017 12:27
Fix waitlist allowed memory limit error
diff --git a/wp-content/plugins/woocommerce-waitlist/classes/class-pie-wcwl-waitlist-mailout.php b/wp-content/plugins/woocommerce-waitlist/classes/class-pie-wcwl-waitlist-mailout.php
index e77ed03..2e41933 100644
--- a/wp-content/plugins/woocommerce-waitlist/classes/class-pie-wcwl-waitlist-mailout.php
+++ b/wp-content/plugins/woocommerce-waitlist/classes/class-pie-wcwl-waitlist-mailout.php
@@ -83,6 +83,9 @@ if ( ! class_exists( 'Pie_WCWL_Waitlist_Mailout' ) ) {
public function add_user_to_archive( $product_id, $user_id ) {
$existing_archives = get_post_meta( $product_id, 'wcwl_waitlist_archive', true );
$today = strtotime( date( "Ymd" ) );
+ if (empty($existing_archives)) {
+ $existing_archives = array();
@mikaelz
mikaelz / add-woocommerce-category-to-menu.php
Created October 4, 2017 11:04
Create WooCommerce product category menu entry
<?php
$args = array(
'menu-item-object-id' => $term['term_id'],
'menu-item-object' => 'product_cat',
'menu-item-parent-id' => 0,
'menu-item-type' => 'taxonomy',
'menu-item-status' => 'publish',
);
$res = wp_update_nav_menu_item( MENU_ID, 0, $args );
@mikaelz
mikaelz / wp-sentry-integration.php
Created September 28, 2017 13:32
Just install plugin https://wordpress.org/plugins/wp-sentry-integration/ and add the following code into wp-content/mu-plugins/wp-sentry-integration.php
<?php
/**
* Plugin Name: WordPress Sentry
* Plugin URI: https://github.com/stayallive/wp-sentry
* Description: A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.
* Version: must-use-proxy
* Author: Alex Bouma
* Author URI: https://alex.bouma.me
* License: MIT
*/
@mikaelz
mikaelz / youtube-result-titles-text.js
Created September 28, 2017 05:08
Get YouTube result titles text
var parsed = [], titles = $$('h3 a');
for (i in titles) {
parsed.push((titles[i].text).trim());
}
console.log(parsed);
//copy(parsed); // Copy to clipboard
@mikaelz
mikaelz / ssh-connections.sh
Created September 16, 2017 08:29
List estabilished SSH service connections
#!/bin/bash
ss -tnpa |grep ESTAB |grep ssh