Skip to content

Instantly share code, notes, and snippets.

View dingo-d's full-sized avatar
🏠
Working from home

Denis Žoljom dingo-d

🏠
Working from home
View GitHub Profile
@da1nonly
da1nonly / gist:2057532
Created March 17, 2012 10:55
wordpress meta box urls
<?php
add_action('admin_init', 'add_meta_boxes', 1);
function add_meta_boxes() {
add_meta_box( 'repeatable-fields', 'Audio Playlist', 'repeatable_meta_box_display', 'post', 'normal', 'high');
}
function repeatable_meta_box_display() {
global $post;
@tmaiaroto
tmaiaroto / Dockerfile
Last active June 30, 2022 08:48
WordPress on Amazon ECS
FROM alpine:3.3
MAINTAINER Tom Maiaroto <tom@outdoorsy.co>
# Install packages
RUN apk --update --repository http://dl-3.alpinelinux.org/alpine/edge/main add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \
@esausilva
esausilva / nonascii.md
Last active August 1, 2022 22:18
Find non-ASCII characters

One-liner for finding non-ASCII characters

# Linux
$ grep --color='auto' -P -n "[\x80-\xFF]" file.js

# Mac OS X after 'brew install pcre'
$ pcregrep --color='auto' -n "[\x80-\xFF]" file.js
@imrodrigoalves
imrodrigoalves / resetWSLSpeeds.bat
Last active October 26, 2022 15:46
Allow WSL Fast Internet
@echo off
wsl exit
powershell -Command "Set-NetAdapterLso -Name 'vEthernet (WSL)' -IPv4Enabled $False -IPv6Enabled $False"
@DomenicF
DomenicF / get_current_post_type.php
Last active December 5, 2022 07:11 — forked from bradvin/get_current_post_type.php
Get the current post_type context in the WordPress admin.
<?php
/**
* gets the current post type in the WordPress Admin
*/
function get_current_post_type() {
global $post, $typenow, $current_screen;
//we have a post so we can just get the post type from that
if ( $post && $post->post_type ) {
return $post->post_type;
@benlk
benlk / 0-toc.md
Last active March 29, 2023 13:13
Collection of notes on WP_UnitTestCase
  1. Table of contents
  2. General information
    1. Terms
    2. General structure of a test
    3. WordPress-specific assertions and test functions
      • enqueues
      • creating posts
      • creating terms
      • attaching images
  • ?
@anderly
anderly / woocommerce-add-custom-product-data-tab.php
Last active June 8, 2023 20:30
WooCommerce - Add Custom Product Data Tab
// First Register the Tab by hooking into the 'woocommerce_product_data_tabs' filter
add_filter( 'woocommerce_product_data_tabs', 'add_my_custom_product_data_tab' );
function add_my_custom_product_data_tab( $product_data_tabs ) {
$product_data_tabs['my-custom-tab'] = array(
'label' => __( 'My Custom Tab', 'my_text_domain' ),
'target' => 'my_custom_product_data',
);
return $product_data_tabs;
}
@billerickson
billerickson / gist:2047229
Last active July 10, 2023 22:04
Improve performance of WP_Query
<?php
$args = array(
// Normal query goes here //
'no_found_rows' => true, // counts posts, remove if pagination required
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...)
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required
);
@wcomnisky
wcomnisky / install-php-amqp.sh
Last active October 27, 2023 12:16
Install PHP AMQp on MacOS
#!/bin/bash
brew search librabbitmq
brew install rabbitmq-c
pecl install amqp
# set the path to librabbitmq install prefix [autodetect] : /usr/local/Cellar/rabbitmq-c/0.10.0
# if it fails follow the following (reference: https://github.com/pdezwart/php-amqp/issues/355#issuecomment-563203121):
@tkihira
tkihira / gist:3014700
Created June 28, 2012 23:28
mkdir, rmdir and copyDir(deep-copy a directory) in node.js
var mkdir = function(dir) {
// making directory without exception if exists
try {
fs.mkdirSync(dir, 0755);
} catch(e) {
if(e.code != "EEXIST") {
throw e;
}
}
};