Skip to content

Instantly share code, notes, and snippets.

View chrisdavidmiles's full-sized avatar
💙

Chris David Miles chrisdavidmiles

💙
View GitHub Profile
@chrisdavidmiles
chrisdavidmiles / cdm-remove-unwanted-image-sizes.php
Last active August 30, 2022 06:50 — forked from gmmedia/functions.php
WordPress Plugin: Remove Unwanted Image Sizes
<?php
/**
* Plugin Name: Remove Unwanted Default Image Sizes
* Plugin URI: https://gist.github.com/chrisdavidmiles/6fd21201d16f8a7e434b06b903d4706c
* Description: This removes three default image sizes that I don't want: medium_large, 1536x1536, and 2048x2048.
* Author: Jochen Gererstorfer
* Author URI: https://bloggerpilot.com/en/disable-wordpress-image-sizes/
* Version: 0.3
*/
@chrisdavidmiles
chrisdavidmiles / auto-rename-uploads-to-match-post-slug.php
Last active August 25, 2022 01:41 — forked from filipecsweb/functions.php
WordPress Plugin: Auto Rename Uploads to Match Post Slug
<?php
/**
* Plugin Name: Auto Rename Uploads to Match Post Slug
* Plugin URI: https://gist.github.com/chrisdavidmiles/770ffbfe428b440fd007bcb6b08e94d7
* Description: Uploads will be automatically renamed to match the post slug
* Author: Chris David Miles
* Version: 0.1
*/
function auto_rename_uploads_to_post_slug( $filename ) {
@chrisdavidmiles
chrisdavidmiles / cdm-custom-uploads-directory-by-file-type.php
Last active August 24, 2022 00:49 — forked from blainerobison/gist:e802658da007e6e806b1
WordPress Plugin: Custom Uploads Directory By File Type
<?php
/**
* Plugin Name: Custom Uploads Directory By File Type
* Plugin URI: https://gist.github.com/chrisdavidmiles/a7f3fbf09616b4c445a45310c0f88e05
* Description: This plugin automatically sorts uploads into a folder corresponding to their file type. Images go into <code>/img</code>, documents go into <code>/docs</code>, video goes into <code>/img</code>, and the rest goes into <code>/misc</code>. Note: This code doesn't work with 'browser uploader'.
* Author: Forked from Blaine Robison
* Author URI: https://gist.github.com/blainerobison/e802658da007e6e806b1
* Version: 0.2
*/
@chrisdavidmiles
chrisdavidmiles / cdm-automatically-set-featured-image.php
Last active August 24, 2022 00:39 — forked from mestrewp/gist:2820465
WordPress Plugin: Automatically Set the Featured Image
@chrisdavidmiles
chrisdavidmiles / cloudflare-ddns-update.sh
Last active November 29, 2021 18:45 — forked from Tras2/cloudflare-ddns-update.sh
A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#!/usr/bin/env bash
#
# A bash script to update a Cloudflare DNS A record with the external IP of the source machine
#
# Proxy - uncomment and provide details if using a proxy
#export https_proxy=http://<proxyuser>:<proxypassword>@<proxyip>:<proxyport>
# Cloudflare zone is the zone which holds the record
zone=example.com
@chrisdavidmiles
chrisdavidmiles / PostMessageToSlackChannel.php
Created June 6, 2020 22:06 — forked from nadar/PostMessageToSlackChannel.php
Post a message to a slack channel with PHP
<?php
/**
* Send a Message to a Slack Channel.
*
* In order to get the API Token visit: https://api.slack.com/custom-integrations/legacy-tokens
* The token will look something like this `xoxo-2100000415-0000000000-0000000000-ab1ab1`.
*
* @param string $message The message to post into a channel.
* @param string $channel The name of the channel prefixed with #, example #foobar