Skip to content

Instantly share code, notes, and snippets.

View jonathan-dejong's full-sized avatar

Jonathan de Jong jonathan-dejong

View GitHub Profile
@jonathan-dejong
jonathan-dejong / ufw_plex.md
Created May 24, 2020 19:46 — forked from nmaggioni/ufw_plex.md
Plex Media Server UFW rule

/etc/ufw/applications.d/plexmediaserver

[plexmediaserver]
title=Plex Media Server (Standard)
description=The Plex Media Server
ports=32400/tcp|3005/tcp|5353/udp|8324/tcp|32410:32414/udp

[plexmediaserver-dlna]
title=Plex Media Server (DLNA)
description=The Plex Media Server (additional DLNA capability only)
@jonathan-dejong
jonathan-dejong / drop-it-like-its-hot.php
Created March 2, 2020 08:14
Drop cache on ACF options page update
// This is in the context of a namespaced class.
public function acf_save_post( $post_id ) {
// Retrieves all acf option page slugs.
$option_slugs = array_unique(
array_map(
function( $options_page ) {
return $options_page['post_id'];
},
acf_get_option_pages()
)
@jonathan-dejong
jonathan-dejong / csv-split-by-lines.sh
Last active September 18, 2019 18:35
Split CSV files by megabyte and retain head row (row 1)
#!/bin/bash
if [ ! -d "./backup" ]; then
mkdir backup
fi
lines=2000
for i in *.csv; do
split -b ${1:-$lines} $i ${i%.csv}-
for j in ${i%.csv}-a*; do
if [[ "$j" != *-aa ]]
@jonathan-dejong
jonathan-dejong / wpseo-and-BTF
Last active May 9, 2019 07:39
Example of using WordPress SEO By Yoast filters with Beautiful Taxonomy Filters
<?php
/* This file is taken directly from a clients site so it contains strings and conditions not necessarily useful to anyone else.
However it does show how one can use these filters to modify the meta information for the different filtered results */
/* CHANGE META DESCRIPTION ON KLINIK FILTER PAGES */
add_filter('wpseo_metadesc', 'custom_metadesc', 10, 1);
function custom_metadesc($desc){
if(is_tax(array('omrade', 'yrkeskategori', 'specialisering', 'betalningsmedel', 'forsakringsbolag'))){
global $wp_query;
$termID = $wp_query->queried_object->term_id;
<?php
global $post;
if ( function_exists( 'acf_add_local_field_group' ) ) :
acf_add_local_field_group(array(
'key' => 'group_58bff7f25c321',
'title' => 'Garderobsbyggaren',
'fields' => array(),
'location' => array(
array(
@jonathan-dejong
jonathan-dejong / Atom settings
Last active December 19, 2017 13:21
Atom sync!
@jonathan-dejong
jonathan-dejong / apache host
Created May 31, 2017 21:45
host for owncloud
<VirtualHost *:80>
ServerName YOUR-OWNCLOUD-URL
RewriteEngine on
RewriteCond %{SERVER_NAME} =YOUR-OWNCLOUD-URL
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
<VirtualHost *:443>
jQuery(document).bind('FBSDKLoaded', function() {
/*
* Trigger facebook share dialog
*/
jQuery('.facebook-share').click(function(){
var href = window.location.href;
FB.ui({
@jonathan-dejong
jonathan-dejong / readallfilesoftype.php
Created September 15, 2016 14:28
Read all files of specific file type
<?php
/**
* Reads all files of a specific file type in a folder and returns them as an array.
*
*/
public function read_files() {
$uploads_directory = trailingslashit( plugin_dir_path( dirname( __FILE__ ) ) ) . 'uploads/';
$files = array_values( array_filter( scandir( $dir ), function( $file ) {
return ( pathinfo( $file, PATHINFO_EXTENSION ) != 'txt' ? false : true );
} ) );
@jonathan-dejong
jonathan-dejong / changes-to-pickup-plus.php
Created June 21, 2016 12:27
Changes to pickup plus to include user in order note
// make a note of the change
$order->add_order_note(
sprintf( __( 'Pickup location changed to %s', 'woocommerce-shipping-local-pickup-plus' ),
$this->get_formatted_address_helper( $pickup_location, true )
), false, true
);