Skip to content

Instantly share code, notes, and snippets.

View janboddez's full-sized avatar

Jan Boddez janboddez

View GitHub Profile
$('#search').keyup(function() {
// Input field was changed (or typed into).
// If input contains any text.
if ($(this).val() != '') {
// Convert search term(s) to lowercase, split into words.
var searchTerms = $(this).val().toLowerCase().split(/\s+/);
// Traverse all results table rows. Well, except the header row.
$('#results tbody tr').each(function() {
@janboddez
janboddez / invoice_ninja_automatic_update_script_v4.5.8.sh
Created May 19, 2018 12:55
Automatic Update Script for Invoice Ninja
#!/bin/bash -ue
#Invoice Ninja Self-Hosted Automatic Update
#This version will check https://invoiceninja.org for an updated version and install if found.
#Tested and works with cron. Lines 51, 54, & 79 output timestamps so you can pipe to a logfile.
#USE AT YOUR OWN RISK
#Replace lines 13, 57, and 62 with your specifics (omit <>), obviously.
#!!IMPORTANT!! Be sure to edit lines 16 & 17 if www-data is not the owner/group for /ninja/storage!
#SET INITIAL VARIABLES
<?php
/**
* Turns posts created through "Press This" into "read" posts.
*/
add_filter( 'press_this_save_post', function( $data ) {
$data['post_type'] = 'iwcpt_read';
$content = wp_unslash( $data['post_content'] );
<?php
/**
* Quick and dirty way to import a Twitter export into WordPress
*/
define('WP_USE_THEMES', false);
require './wordpress/wp-load.php';
$username = '<your-username>';
<?php
/**
* Post "Reads" to F-Stop, a feed reader not unlike Aperture.
*/
add_filter( 'wp_insert_post_data', function( $data, $postarr ) {
if ( ! empty( $postarr['ID'] ) ) {
// Not a new post. Bail.
return $data;
}
<?php
/**
* Adds a "copy" of your site's "blog" page at `/stream/`. Visit "Settings >
* Permalinks" to flush rewrite rules after adding this code.
*/
add_action( 'init', function() {
add_rewrite_rule( '^stream/feed/?', 'index.php?feed=rss2', 'top' );
add_rewrite_rule( '^stream/page/([0-9]{1,})/?', 'index.php?paged=$matches[1]', 'top' );
add_rewrite_rule( '^stream/?', 'index.php', 'top' );
<?php
add_action( 'webmention_post_send', function( $response, $source, $target, $post_id ) {
if ( is_wp_error( $response ) ) {
// Something went wrong.
error_log( 'Error trying to send webmention to ' . esc_url_raw( $target ) . ': ' . $response->get_error_message() );
} else {
error_log( 'Sent webmention to ' . esc_url_raw( $target ) . '; response code: ' . wp_remote_retrieve_response_code( $response ) );
}
<?php
/**
* Plugin Name: Webmention Widget
* Description: Add recent webmentions’ status to WordPress’ dashboard.
* Version: 0.1
* Author: Jan Boddez
* Author URI: https://jan.boddez.net/
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*
<?php
add_filter( 'pre_get_posts', function( $query ) {
if ( is_admin() ) {
return $query;
}
if ( is_feed() ) {
return $query;
}