Skip to content

Instantly share code, notes, and snippets.

View walshyb's full-sized avatar
howdy

Super walshyb

howdy
View GitHub Profile
@walshyb
walshyb / upload_svg_if_admin.php
Last active May 25, 2017 19:55
In WordPress, allow uploading of svgs through the Admin Panel to the media library if the current user is an administrator.
<?php
function enable_svg_upload_if_admin($mimes) {
$current_user_roles = wp_get_current_user()->roles; // get roles of current user
// check if user is administrator and user is in the admin panel (not in the frontend)
if(in_array('administrator', $current_user_roles) && is_admin()) {
$mimes['svg'] = 'image/svg+xml';
return $mimes; // if administrator, enable svg upload
}
@walshyb
walshyb / sendIP.py
Created August 29, 2015 01:38
Simple script that checks if there's internet connection and if there is, then use the Mandrill API to send the client's current IP address to a specified email address.
import mandrill
import socket
REMOTE_SERVER = "www.google.com"
#checks if there is internet connection
def is_connected():
try:
# see if we can resolve the host name -- tells us if there is
# a DNS listening