Skip to content

Instantly share code, notes, and snippets.

View justintadlock's full-sized avatar

Justin Tadlock justintadlock

View GitHub Profile
@justintadlock
justintadlock / attr.php
Created October 7, 2013 00:38
Hybrid Core framework attributes proposal
<?php
/**
* HTML attribute functions and filters. The purposes of this is to provide a way for theme/plugin devs
* to hook into the attributes for specific HTML elements and create new or modify existing attributes.
* This is sort of like `body_class()`, `post_class()`, and `comment_class()` on steroids. Plus, it
* handles attributes for many more elements. The biggest benefit of using this is to provide richer
* microdata while being forward compatible with the ever-changing Web. Currently, the default microdata
* vocabulary supported is Schema.org.
*/
@justintadlock
justintadlock / register-post-type.php
Last active January 8, 2025 22:04
Help file when registering post types.
<?php
# Register custom post types on the 'init' hook.
add_action( 'init', 'my_register_post_types' );
/**
* Registers post types needed by the plugin.
*
* @since 1.0.0
* @access public
<?php
/**
* Plugin Name: Theme Hybrid - API
* Plugin URI: http://themehybrid.com
* Description: API for ThemeHybrid.com
* Version: 0.1.0
* Author: Justin Tadlock
* Author URI: http://justintadlock.com
*/
@justintadlock
justintadlock / hybrid-media-grabber.php
Last active September 3, 2020 01:31
Media grabber class in development.
<?php
/**
* Hybrid Media Grabber - A script for grabbing media related to a post.
*
* Hybrid Media Grabber is a script for pulling media either from the post content or attached to the
* post. It's an attempt to consolidate the various methods that users have used over the years to
* embed media into their posts. This script was written so that theme developers could grab that
* media and use it in interesting ways within their themes. For example, a theme could get a video
* and display it on archive pages alongside the post excerpt.
*
@justintadlock
justintadlock / in-main-loop.php
Last active February 11, 2024 20:23
A conditional tag for checking if we're in the core WP main query + loop.
<?php
/**
* Conditional to test if we're in the loop of the main query on a WordPress page.
* Please note that checking `in_the_loop() && is_main_query()` will NOT work in
* this scenario.
*/
add_action( 'loop_start', 'my_loop_start' );
add_action( 'loop_end', 'my_loop_end' );