Skip to content

Instantly share code, notes, and snippets.

View RiFi2k's full-sized avatar

Reilly Lowery RiFi2k

View GitHub Profile
// Make everything static
class My_Plugin
{
private static $var = 'foo';
static function foo()
{
return self::$var; // never echo or print in a shortcode!
}
<?php update_post_meta( $post_id, $meta_key, $meta_value, $prev_value ); ?>
//add attendee to event ateendee list (relationship)
$event_id = $_POST['post_id'];
$attendee_list = get_field( 'attendees_list', $event_id );
$new_attendee = get_post( $attendee_id );
if( !is_array($attendee_list) ):
$attendee_list = array();
endif;
if (!function_exists('get_post_id_by_meta_key_and_value')) {
function get_post_id_by_meta_key_and_value($key, $value) {
global $wpdb;
$meta = $wpdb->get_results("SELECT * FROM `".$wpdb->postmeta."` WHERE meta_key='".$wpdb->escape($key)."' AND meta_value='".$wpdb->escape($value)."'");
if (is_array($meta) && !empty($meta) && isset($meta[0])) {
$meta = $meta[0];
}
if (is_object($meta)) {
return $meta->post_id;
# Settings for Atom editor
@RiFi2k
RiFi2k / onchange.sh
Created March 12, 2017 02:30 — forked from senko/onchange.sh
Watch current directory and execute a command if anything in it changes
#!/bin/bash
#
# Watch current directory (recursively) for file changes, and execute
# a command when a file or directory is created, modified or deleted.
#
# Written by: Senko Rasic <[email protected]>
#
# Requires Linux, bash and inotifywait (from inotify-tools package).
#
# To avoid executing the command multiple times when a sequence of
@RiFi2k
RiFi2k / iptables.openvpn
Last active July 18, 2019 22:32
Force all traffic through VPN tun, drop any traffic not headed through VPN to prevent DNS leaks. Assuming use of TUN-based routing and redirect-gateway OpenVPN client options.
# https://jamielinux.com/blog/force-all-network-traffic-through-openvpn-using-iptables/
# Force all traffic through VPN tun
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
find /install-path/ -type d -exec chmod 755 {} \;
find /install-path/ -type f -exec chmod 644 {} \;
chmod 400 wp-config.php
#!/bin/bash
# forget old rules
iptables -F
iptables -X
iptables -Z
# set default policy to drop
iptables -P INPUT DROP
iptables -P OUTPUT DROP
@RiFi2k
RiFi2k / iptables.sh
Last active January 18, 2020 20:04
iptables-persistent rules
#!/bin/bash
#!/bin/bash
# forget old rules
iptables -F
iptables -X
iptables -Z
# set default policy to drop
iptables -P INPUT DROP
@RiFi2k
RiFi2k / ssh-hardening-defaults.yml
Created December 28, 2016 23:43
ssh-hardening/defaults/main.yml
# Documentation: https://roots.io/trellis/docs/security/
# Which components to generate the configuration files for.
# If remote machine doesn't have an SSH server then change the ssh_client_hardening to false.
ssh_client_hardening: true # SSH
ssh_server_hardening: true # SSHD
# Set to true if CBC for ciphers is required.
ssh_client_cbc_required: false # SSH
ssh_server_cbc_required: false # SSHD