Skip to content

Instantly share code, notes, and snippets.

View corypina's full-sized avatar

Cory Piña corypina

View GitHub Profile
@corypina
corypina / wp-custom-image-sizes.php
Last active March 6, 2019 05:11
Register custom image sizes in WordPress
<?php
// Add featured image sizes
add_image_size( 'custom-small', 500, 300, true ); // name, width, height, crop
add_image_size( 'custom-large', 1840, 793, true );
// Register the image sizes for the Add Media modal
add_filter( 'image_size_names_choose', function( $sizes ) {
return array_merge( $sizes, array(
'custom-small' => __( 'Custom Small' ),
@corypina
corypina / textexpander-gist-retrieval.txt
Last active February 7, 2019 20:07
TextExpander Snippet to retrieve Gist
#!/usr/bin/php
<?php
// What is the URI of the Gist? Make sure you've provided a path to the "raw" Gist.
$GistURI = 'http://...';
// Select "Shell Script" from TextExpander content type!
print file_get_contents($GistURI);
@corypina
corypina / wp-plugin-jumpstart.php
Last active October 7, 2020 17:24
A jumpstart for new WordPress plugins
<?php
/*
Plugin Name: [Your Great Plugin Name Goes Here]
Description: [Along with a Great Description]
Version: 0.1
Author: Cory Piña
Author URI: http://thisiscory.com
*/
// HOW TO USE THIS
@corypina
corypina / flywheel-backup-local-time.js
Created January 31, 2019 04:58
Show local time and date for backups in Flywheel (converted from UTC)
// ==UserScript==
// @name Flywheel Backups to Local Date
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Convert UTC dates to local Time
// @author Cory Piña
// @match https://app.getflywheel.com/*/backups
// @grant none
// ==/UserScript==
@corypina
corypina / beaver-default.php
Created November 15, 2018 06:12 — forked from JeremyEnglert/beaver.php
Set BeaverBuilder as Default Editor
<?php
// Sets Beaver Builder as the default editor.
function make_beaver_builder_default( $post_ID, $post, $update ) {
if ( ! $update ) {
update_post_meta( $post_ID, '_fl_builder_enabled', true );
}
}
add_action( 'wp_insert_post', 'make_beaver_builder_default', 10, 3 );
@corypina
corypina / instagram-rss.php
Created November 3, 2018 20:20
Grab a user's Instagram feed without need for API access
<?php
// Grab and display a user's Instagram feed without need for API access
// Replace USERNAME with username as string.
// IMPORTANT: This relies on the queryfeed.net service, which may or may not always be available
function instagramFeed() {
// Grab and load the feed as a variable
$user = "USERNAME";
$feed = "https://queryfeed.net/instagram?q=" . $user;
@corypina
corypina / custom-admin-notice.php
Created October 18, 2018 00:52
Add a custom admin notice in the WordPress admin
<?php
// This will display native-style admin notice in the WordPress admin area
function displayCustomNotice() { ?>
<div class="notice notice-information">
<p>Your text here!</p>
</div>
@corypina
corypina / jump-above-hash.js
Created October 11, 2018 22:17
Jump above the anchor a given amount of pixels on click
window.addEventListener("hashchange", function () {
window.scrollTo(window.scrollX, window.scrollY - 100);
});
@corypina
corypina / include-all-files.php
Last active November 3, 2018 20:22
Include all PHP files in a folder, except those prepended with an underscore "_"
<?php
// Include all PHP files in FOLDERNAME
$dir = plugin_dir_path(__FILE__);
foreach(glob($dir . "FOLDERNAME/[!_]*.php") as $file){
require $file;
}
@corypina
corypina / custom-admin-css.php
Created September 20, 2018 17:48
Run custom CSS in WordPress admin screens
<?php
/**
* Add CSS to Events Admin pages
*/
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts() {
// Get current screen if targeting post type is necessary