Skip to content

Instantly share code, notes, and snippets.

/*
* Goes in your theme's functions.php, replace '/img/default-image.jpg' with
* the path to the custom placeholder image in your theme.
*/
add_filter ('woocommerce_placeholder_img_src', () => get_stylesheet_directory_uri() . '/img/default-image.jpg');
@ajdinmore
ajdinmore / wp_cron_multisite.sh
Created February 25, 2019 16:20
WordPress Multisite Cron Shell Script
#!/bin/bash
WP_PATH="/srv/example/public_html"
for SITE_URL in $(wp site list --field=url --archived=0 --deleted=0 --path="$WP_PATH")
do
echo -e "\n$SITE_URL"
wp cron event run --due-now --path="$WP_PATH" --url="$SITE_URL"
done
@ajdinmore
ajdinmore / .bash_aliases
Last active October 1, 2024 12:10
Bash Aliases
#/bin/bash
function kt {
(&>/dev/null kate "$@" & exit)
}
function dolp {
(&>/dev/null dolphin "${@:-.}" & exit)
}
cd "$(dirname "$(readlink -f "$0")")" || (echo "Failed to change directory." && exit 1)
@ajdinmore
ajdinmore / DevController.php
Last active September 15, 2022 19:25
Symfony Dev Controller Template
<?php /** @noinspection PhpMultipleClassesDeclarationsInOneFile */
declare(strict_types=1);
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@ajdinmore
ajdinmore / docker-compose.yaml
Last active August 24, 2022 17:02
Quick-start PHP project Docker setup
version: '3.8'
services:
php:
image: ajdinmore/php:8.1-dev
hostname: php
tty: true
volumes:
- ./:/app
- ${COMPOSER_HOME:-~/.composer}:/composer
environment:
<?php
declare(strict_types=1);
/**
* Plugin Name: WooCommerce Import Fix 2022-10-05
* Description: Fixes importing variable product drafts.
*/
add_filter('woocommerce_product_importer_formatting_callbacks', function (array $callbacks, \WC_Product_Importer $importer) {
$key = array_search('published', $importer->get_mapped_keys());
if (false !== $key && isset($callbacks[$key])){
@ajdinmore
ajdinmore / apps-install.sh
Last active August 30, 2023 14:29
Laptop apps install script (work in progress)
#!/bin/bash
if [ "$(id -u)" -ne 0 ]; then
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
xdg-open ~/Downloads &> /dev/null &
xdg-open 'https://www.gitkraken.com/download/linux-deb' &> /dev/null &
xdg-open 'https://www.jetbrains.com/toolbox-app/download/download-thanks.html?platform=linux' &> /dev/null &
xdg-open 'https://slack.com/intl/en-gb/downloads/linux' &> /dev/null &
export GPG_TTY=$(tty)
export DOCKER_BUILDKIT=1
@ajdinmore
ajdinmore / docker-compose.yaml
Created September 19, 2023 15:39
Docker Compose/Stack Placeholder Template Examples
#file: noinspection SpellCheckingInspection
# https://docs.docker.com/engine/reference/commandline/service_create/#create-services-using-templates
# https://docs.docker.com/config/containers/logging/awslogs/#tag
# https://docs.docker.com/config/containers/logging/log_tags/
# https://forums.docker.com/t/example-usage-of-docker-swarm-template-placeholders/73859
services:
service:
image: busybox
command: env
hostname: '{{.Task.Name}}-{{.Node.Hostname}}'