Skip to content

Instantly share code, notes, and snippets.

View chrisdavidmiles's full-sized avatar
💙

Chris David Miles chrisdavidmiles

💙
View GitHub Profile
@ka215
ka215 / wp-emergency.php
Created June 16, 2017 14:39
This is the tool for WordPress to manually deactivate any plugins and rollback to default theme.
<?php
/**
* WordPress Emergency Tools v1.0
*
* This is a tool to manually deactivate a theme and any plugins when you can not
* access the admin panel due to WordPress theme or plugins bug etc.
* Usage it please place this file in the same directory as "wp-config.php" and
* access it directly from the browser.
* Please delete this file promptly after use (If this file will remain, it will
* be a serious security hole for your service).
@unculturedswine
unculturedswine / functions.php
Created May 24, 2017 15:06
WooCommerce Subscriptions Custom Thank You Page Redirect
add_action( 'template_redirect', 'wc_custom_redirect_after_purchase' );
function wc_custom_redirect_after_purchase() {
global $wp;
if ( is_checkout() && ! empty( $wp->query_vars['order-received'] ) ) {
wp_redirect( '#' );
exit;
}
}
@andreibosco
andreibosco / creative-cloud-disable.md
Last active December 19, 2024 08:28
disable creative cloud startup on mac
@kasperhartwich
kasperhartwich / delete-from-slack.php
Last active January 26, 2021 08:10
Script to delete old files from Slack
#!/usr/bin/env php
<?php
date_default_timezone_set('GMT');
if (count($argv)<2) {
echo $argv[0] . ' <token> <until>' . PHP_EOL;
echo 'Example: ' . $argv[0] . ' abcd-12345678-123456789-12345 \'-3 months\'' . PHP_EOL;
exit;
}
@zgordon
zgordon / gist-oembed-wordpress
Created June 15, 2015 04:45
oEmbed Gist into WordPress
wp_embed_register_handler(
'github-gist',
'/https:\/\/gist\.github\.com\/([^\/]+)\/([^\/]+)/',
function($matches, $attr, $url, $rawattr) {
$embed = "&lt;script src=\"{$url}.js\"&gt;&lt;/script&gt;";
return apply_filters(
'embed_github_gist',
$embed,
$matches,
@joshuadavidnelson
joshuadavidnelson / remove-post-type-from-search-results.php
Last active March 8, 2022 13:56
Remove a post type from search results, but keep all others
<?php
/**
* Modify query to remove a post type from search results, but keep all others
*
* @author Joshua David Nelson, [email protected]
* @license http://www.gnu.org/licenses/gpl-2.0.html GPLv2+
*/
add_action( 'pre_get_posts', 'jdn_modify_query' );
function jdn_modify_query( $query ) {
@blainerobison
blainerobison / gist:e802658da007e6e806b1
Last active August 24, 2022 00:42
wp: Custom Upload Directory By File Type [WordPress]
/**
* Set custom upload directory
*
* Images => /img
* PDF => /pdf
* Misc => /misc
*
* Note: Doesn't work with 'browser uploader'
* Note: Use with 'wp_update_attachment_metadata' hook if we want to define our own attachment metadata
* Allowed file types: http://codex.wordpress.org/Uploading_Files#About_Uploading_Files_on_Dashboard
@lmartins
lmartins / functions.php
Created November 14, 2014 12:44
Sanitize file names during upload to Wordpress
/**
* Sanitize File name during upload
* http://stackoverflow.com/questions/3259696/rename-files-during-upload-within-wordpress-backend
*/
function make_filename_hash($filename) {
$info = pathinfo($filename);
$ext = empty($info['extension']) ? '' : '.' . $info['extension'];
$name = basename($filename, $ext);
return md5($name) . $ext;
}
@thomasfr
thomasfr / warmly.sh
Last active October 12, 2023 06:17
A wget based easy poor man`s cache warmer script
#!/bin/bash
# warmly.sh
# A wget based, easy, poor man`s cache warmer script
# https://gist.github.com/thomasfr/7926314
# The MIT License (MIT)
#
# Copyright (c) 2013,2014 Thomas Fritz <[email protected]> (http://fritzthomas.com)
#
@mxriverlynn
mxriverlynn / 720p.sh
Created September 8, 2012 16:31
Size an OSX window to 720p (1280x720)
#!/usr/bin/env bash
echo "Setting $1 bounds to 720p"
# 720p is 1280x720.
# Bounds is startX, startY, endX, endY. Adjust size from starting position to account for this
osascript -e "tell application \"$1\" to set the bounds of the first window to {250, 220, 1530, 940}"
# activate the app, to bring it to the front
osascript -e "tell application \"$1\" to activate"