Skip to content

Instantly share code, notes, and snippets.

View mojowill's full-sized avatar
:octocat:

Will Wilson mojowill

:octocat:
View GitHub Profile
@mojowill
mojowill / dl-file.php
Last active September 22, 2017 12:42
Secure Gravity Forms uploads
<?php
require_once('wp-load.php');
is_user_logged_in() || auth_redirect();
$upload_dir = wp_upload_dir();
//Set your path below I am using /gravity_forms/
$basedir = $upload_dir['basedir'] . '/gravity_forms/';
$file = rtrim($basedir, '/') . '/' . str_replace('..', '', isset($_GET['file']) ? $_GET['file'] : '');
if (!$basedir || !is_file($file)) {
status_header(404);
@mojowill
mojowill / wordpress-css-2.php
Created June 11, 2017 17:45
WordPress CSS 2
<?php
function global_css() {
wp_register_style( 'parent_main', get_template_directory_uri() . '/css/main.css' , filemtime( get_template_directory() . '/css/main.css' ), null, 'screen' );
wp_register_style( 'child_main', get_stylesheet_directory_uri() . '/style.css' , filemtime( get_stylesheet_directory() . '/style.css' ), null, 'screen' );
if ( ! is_admin() ) :
wp_enqueue_style( 'parent_main' );
endif;
@mojowill
mojowill / wordpress-css-1.php
Created June 11, 2017 17:44
WordPress CSS 1
<?php
function global_css() {
wp_register_style( 'parent_main', get_template_directory_uri() . '/css/main.css', false, null, 'screen' );
wp_register_style( 'child_main', get_stylesheet_directory_uri() . '/style.css', false, null, 'screen' );
if ( ! is_admin() ) :
wp_enqueue_style( 'parent_main' );
endif;
@mojowill
mojowill / redmine.php
Created June 11, 2017 17:41
Github to Remine
<?php
// Github Details
$github_org = 'organisation'; //Github Organisation Name
$github_repo = 'repository'; //Github Repository Name
$github_user = 'username'; //Github Username
$github_password = 'password'; //Github Password
// Get from Github
$issues_url = "https://$github_user:[email protected]/repos/$github_org/$github_repo/issues?state=closed?per_page=100&quot;;
@mojowill
mojowill / margins.php
Created June 11, 2017 16:25
Fix WordPress margins
<?php
//Remove Stupid 10xp from around the Caption Images
class fixImageMargins{
public $xs = 0; //change this to change the amount of extra spacing
public function __construct(){
add_filter('img_caption_shortcode', array(&$this, 'fixme'), 10, 3);
}
public function fixme($x=null, $attr, $content){
@mojowill
mojowill / avatar.php
Last active May 30, 2017 15:07
Custom WordPress Default Avatar
<?php
function custom_gravatar ( $avatar_defaults ) {
$mytavatar = get_theme_directory_uri . '/images/avatar.jpg'; // Make Sure you change this depending on your image name and location
$avatar_defaults[ $mytavatar ] = 'My Custom Gravatar'; // This is what is displayed in the Admin settings when Picking your Default Avatar
return $avatar_defaults;
}
add_filter( 'avatar_defaults', 'custom_gravatar' );
@mojowill
mojowill / Monokai Bright WordPress.thTheme
Created January 4, 2013 10:16
Modification of the Monokai Bright Theme for SublimeText 2 to support and highlight WordPress function calls.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Monokai Bright WordPress</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@mojowill
mojowill / dl-file.php
Last active February 1, 2018 14:07
Secure your gravity forms uploads
<?php
require_once('wp-load.php');
is_user_logged_in() || auth_redirect();
$upload_dir = wp_upload_dir();
//Set your path below I am using /gravity_forms/
$basedir = $upload_dir[ 'basedir' ] . '/gravity_forms/';
$file = rtrim( $basedir, '/' ) . '/' . str_replace( '..', '', isset( $_GET[ 'file' ] ) ? $_GET[ 'file' ] : '' );
if ( ! $basedir || ! is_file( $file ) ) {
@mojowill
mojowill / gist:3619544
Created September 4, 2012 10:14 — forked from joeytrapp/gist:1201000
Global ignore file
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.log
*.rej
*.swo
*.swp
*.vi
*~
@mojowill
mojowill / users.php
Created August 14, 2012 09:54
User Select for Rilwis Custom Meta Boxes
<?php
$users_list = array();
$users = get_users();
if ( !empty( $users ) )
$users_list = array_combine( wp_list_pluck( $users, 'ID' ), wp_list_pluck( $users, 'display_name' ) );
$meta_box = array(
'title' => 'Project Information',
'pages' => array( 'project' ),