Skip to content

Instantly share code, notes, and snippets.

View hellofromtonya's full-sized avatar

Tonya Mork hellofromtonya

View GitHub Profile
@hellofromtonya
hellofromtonya / spa-integration-language-form.php
Last active August 29, 2015 14:14
spa_integration_language_form() Debug & Temp Change to get language fr_FR to work
function spa_integration_language_form() {
include_once SF_PLUGIN_DIR.'/admin/library/sp-languages.php';
global $siteLang, $locale;
# Get user language setting
$siteLang = $locale;
//* var_dump($locale); // Result = 'fr_FR'
//* var_dump($siteLang); // Result = 'fr_FR'
if(!empty($siteLang)) {
@hellofromtonya
hellofromtonya / spa-integration-language-form.php
Last active August 29, 2015 14:14
force $locale when WPLANG is 'fr_FR' to set translation files to -fr.mo
# ------------------------------------------------------------------
# sp_localisation()
# Setup the forum localisation
# ------------------------------------------------------------------
function sp_localisation() {
# i18n support
global $spPaths;
$locale = get_locale();
@hellofromtonya
hellofromtonya / functions.php
Created February 2, 2015 01:37
Replace out HEX characters in WordPress attachment URL
add_filter( 'wp_get_attachment_url', 'lunarwp_modify_attachment_url', 10, 2 );
/**
* Replace out hex characters in an URL
*
* @since 1.0.0
*
* @param string $url Attachment URL
* @param integer $post_ID Optional. Attachment ID. Default 0.
* @return string Returns the amended attachment url
*/
@hellofromtonya
hellofromtonya / hooked_functions.php
Last active August 29, 2015 14:16
WordPress - Print out a list of all the hooked functions for a given tag (or all if no tag is passed). Builds a table showing rowed by priority.
/**
* An example of how to call it
*/
add_action( 'wp_head', function() {
print_list_hooked_functions( 'genesis_header' );
} );
/**
* Print a list of all hooked functions
*
@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();