Skip to content

Instantly share code, notes, and snippets.

View ohryan's full-sized avatar

Ryan Neudorf ohryan

View GitHub Profile
<?php
/**
Plugin Name: AI Bot Blocker
Description: Adds an option to the Reading settings to block AI bots via robots.txt.
Version: 1.0
Author: Ryan Neudorf
Author URI: https://ohryan.ca/
*/
function aibotblocker_settings_init()
@ohryan
ohryan / tec-query-loop.php
Last active December 27, 2023 17:00
The Event Calendar - Query Loop
<?php
add_filter( 'query_loop_block_query_vars', 'tec_order_by_date' );
function tec_order_by_date( $query ) {
// ignore if the query block is not using this post type
if ( 'tribe_events' !== $query['post_type'] ) {
return $query;
}
// always exclude events with dates in the past
$query['meta_key'] = '_EventStartDate';
@ohryan
ohryan / EnumList.php
Created February 21, 2023 05:11
Validate a list a comma-seperated list against an Enum
<?php
namespace App\Rules;
use Illuminate\Contracts\Validation\Rule;
class EnumList implements Rule
{
private $enumClass;

Keybase proof

I hereby claim:

  • I am ohryan on github.
  • I am ohryan (https://keybase.io/ohryan) on keybase.
  • I have a public key whose fingerprint is FB18 F81B BA90 F26B 40FB E558 4B65 E1EE DFE2 02D9

To claim this, I am signing this object:

@ohryan
ohryan / bower.json
Created August 6, 2016 03:03
All Bootstrap includes
"overrides": {
"bootstrap-sass": {
"main": [
"./assets/stylesheets/bootstrap/_variables.scss",
"./assets/stylesheets/bootstrap/_mixins.scss",
"./assets/stylesheets/bootstrap/_normalize.scss",
"./assets/stylesheets/bootstrap/_print.scss",
"./assets/stylesheets/bootstrap/_glyphicons.scss",
"./assets/stylesheets/bootstrap/_scaffolding.scss",
"./assets/stylesheets/bootstrap/_type.scss",
@ohryan
ohryan / AppDelegate.swift
Last active October 21, 2022 21:33
TVML TvOS AppDelegate for use with TeeVee for WP, WordPress plugin.
import UIKit
import TVMLKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, TVApplicationControllerDelegate {
var window: UIWindow?
var appController: TVApplicationController?
@ohryan
ohryan / photonify.php
Last active August 29, 2015 14:27
Use Jetpack Photon with arbitrary URLs
<?php
/*
This function allows you to use the Jetpack plugin's Photon CDN for arbitrary images in your theme.
Add this function to your functions.php, then call it by passing an image url.
ex. <img src="<?= photonify(get_template_directory_uri() . /images/logo.png) ?>" alt="company logo">
*/
function photonify( $src ) {
if ( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'photon' ) ) {
@ohryan
ohryan / responsive-align.less
Last active April 30, 2019 17:27
Bootstrap 3 Responsive Text Align
.text-xs-left { text-align: left; }
.text-xs-right { text-align: right; }
.text-xs-center { text-align: center; }
.text-xs-justify { text-align: justify; }
@media (min-width: @screen-sm-min) {
.text-sm-left { text-align: left; }
.text-sm-right { text-align: right; }
.text-sm-center { text-align: center; }
.text-sm-justify { text-align: justify; }
jQuery.extend(jQuery.support, {
DOMElement: function(element, attribute) {
var test = document.createElement(element); // turns out native function is fastest (http://stackoverflow.com/questions/268490/jquery-document-createelement-equivalent)
if (test) {
if ( attribute != null )
return (attribute in test)
else
return true
}
@ohryan
ohryan / jquery.wp.category_collapse.js
Created September 14, 2011 14:16
Collapses Wordpress Categories.
/*
* jQuery Wordpress Category Collapse
*
* Automatically collapses categories in your sidebar
*
*/
$(function() {
var thing = $('#subnmenu .page_item').find('ul.children');
var i = 0;
thing.each(