Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / post.php
Created March 5, 2015 05:07
Add an icon to the featured image HTML - Genesis
<?php namespace tonya;
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );
add_action( 'genesis_entry_header', 'tonya\do_post_grid_image', 1 );
/**
* Echo the post image
*
* @since 1.1.0
*
* @uses render_post_featured_image()
@hellofromtonya
hellofromtonya / post.php
Created April 6, 2015 21:58
Get all Post IDs for the current WP_Query
<?php
add_action( 'loop_end', 'tonya_get_list_of_post_ids_in_current_loop' );
/**
* Get a list of Post IDs for the current Loop.
*
* Hooks into 'loop_end' which occurs when WP_Query is done with the
* loop (see wp-includes/query.php).
*
* @since 1.0.0
@hellofromtonya
hellofromtonya / front-page.php
Last active August 29, 2015 14:19
PHP Closure used as a hook callback for WordPress
<?php
/**
* Add class to the HTML Body tag
*
* @since 1.0.0
*
* @param array $classes
* @return array
*/
@hellofromtonya
hellofromtonya / math.php
Created April 21, 2015 08:49
Demo Calculator to illustrate Closure Dependency Injection
<?php namespace wpdevsclub_demo;
use Closure;
class Calculator {
public function solve( Closure $expression, $args ) {
if ( is_callable( $expression ) ) {
return $expression( $args );
@hellofromtonya
hellofromtonya / variable-variables.php
Created April 27, 2015 16:57
Variable Variables Tutorial in WordPress
<?php
$variable_name = 'post_id';
$$variable_name = 10;
//* Or use curly braces to specify exactly which variable is being used
//* as the variable variable, i.e. variable name
${$variable_name} = 10;
/**
@hellofromtonya
hellofromtonya / class-meta.php
Created April 27, 2015 17:16
WordPress Developers' Club Tutorial - Variable Variables - Meta Class Demo
<?php namespace WPDevsClub_Lesson_Var_Vars;
class Meta implements I_Meta {
protected $post_id = 0;
protected $meta_key = '';
protected $defaults = array();
@hellofromtonya
hellofromtonya / challenge.php
Created May 6, 2015 09:15
WordPress Developers Club Challenge - What is the SQL to get the count of all post meta where post ID = 1?
/**
* Get the number of meta for a specific Post ID
*
* @since 1.0.0
*
* @param integer $post_id Post ID to query for
* @return integer Returns the count number
*/
function tonya_get_meta_count_for_post_id( $post_id ) {
@hellofromtonya
hellofromtonya / restrict-media-library.php
Created May 13, 2015 16:01
Restrict Media Library by User Role
<?php
/**
* Restrict Media Library by User Role
*
* @package Restrict_Media_Library
* @since 1.0.0
* @author hellofromTonya
*/
/**
@hellofromtonya
hellofromtonya / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@hellofromtonya
hellofromtonya / challenge_05182015.php
Created May 19, 2015 00:53
WordPress Challenge for May 18, 2015
<?php
/**
* As part of our weekly challenges, take a crack at this one.
* To play along,
* 1. Copy the code into a Gist,
* 2. Answer each of the questions by supplying the code;
* 3. Provide some notes as to your train of thought;
* 4. Then submit the gist's URL for us to review.
*