Skip to content

Instantly share code, notes, and snippets.

@gerbenvandijk
gerbenvandijk / Mark parent navigation active when on custom post type single page
Last active July 16, 2024 16:53
Mark (highlight) custom post type parent as active item in Wordpress Navigation.When you visit a custom post type's single page, the parent menu item (the post type archive) isn't marked as active. This code solves it by comparing the slug of the current post type with the navigation items, and adds a class accordingly.
<?php
function add_current_nav_class($classes, $item) {
// Getting the current post details
global $post;
// Get post ID, if nothing found set to NULL
$id = ( isset( $post->ID ) ? get_the_ID() : NULL );
@szbl
szbl / wp-singleton-namespace-example.php
Last active December 21, 2018 05:56
Quick Singleton class to be included in WordPress plugin (or theme functions.php file) that will create a simple Person post type and shows some methods of encapsulating functionality in a class as a "namespace," as well as applying filters to things, allowing other users to extend your code.
<?php
class Sizeable_Person
{
const POST_TYPE_SLUG = 'szbl-person';
public static $instance;
public static function init()
{
if ( is_null( self::$instance ) )
<?php
/**
* Plugin Name: Static Templates
*
* If most of your site content is in .php template files, and you're tired of
* creating new pages, assigning them page templates, creating page templates
* then doing it all over again on production, this plugin is for you.
*
* Examples:
*
@amitgaur
amitgaur / kafkasetup
Created June 20, 2014 22:07
Kafka Setup on EC2 Instance
curl -O http://www.scala-lang.org/files/archive/scala-2.10.4.tgz
tar xvf scala-2.10.4.tgz
curl https://archive.apache.org/dist/kafka/0.8.1/kafka_2.10-0.8.1.tgz -O
tar zxvf kafka_2.10-0.8.1.tgz
export PATH=$PATH:$HOME/bin:/home/ec2-user/scala-2.10.4/bin:/home/ec2-user/kafka_2.10-0.8.1/bin
#Start Zookeeper
@denji
denji / dnsmasq
Last active October 5, 2019 20:42
nginx config - dynamic virtual hosts
# sudo apt-get install dnsmasq
# echo "address=/.dev/127.0.0.1" | sudo tee /etc/dnsmasq.conf
# sudo update-rc.d dnsmasq enable
# sudo service dnsmasq restart
@ericelliott
ericelliott / essential-javascript-links.md
Last active March 22, 2025 17:28
Essential JavaScript Links
@lmartins
lmartins / installwp.sh
Last active September 6, 2015 21:45
Wordpress Install Plugins shell command Run with `sh installwp.sh`
#!/bin/sh
wp plugin install be-subpages-widget --activate
wp plugin install bulk-creator --activate
wp plugin install cookie-notice --activate
wp plugin install disable-comments --activate
wp plugin install jigsaw --activate
wp plugin install jetpack --activate
wp plugin install mailchimp --activate
wp plugin install mce-table-buttons --activate
wp plugin install menu-customizer --activate
@DocX
DocX / README.md
Last active September 5, 2023 12:58
Connect to bash inside running ECS container by cluster and service name
@jmshal
jmshal / create-multi-host-swarm-digitalocean.sh
Last active March 16, 2023 13:22
Setup a Docker Swarm multi-host cluster on DigitalOcean
docker-machine create \
--driver=digitalocean \
--digitalocean-access-token=$DO_TOKEN \
--digitalocean-size=512mb \
--digitalocean-region=nyc3 \
--digitalocean-private-networking=true \
--digitalocean-image=ubuntu-15-04-x64 \
docker-swarm-kv-store
docker $(docker-machine config docker-swarm-kv-store) run -d \
@BurlesonBrad
BurlesonBrad / functions.php
Created March 10, 2016 21:34 — forked from TimBHowe/functions.php
Reduce or remove WooCommerce 2.5 minimum password strength requirement for creating a user account. Warning: Use at your own risk.
<?php
/**
*Reduce the strength requirement on the woocommerce password.
*
* Strength Settings
* 3 = Strong (default)
* 2 = Medium
* 1 = Weak
* 0 = Very Weak / Anything
*/