Skip to content

Instantly share code, notes, and snippets.

@eddiemoya
eddiemoya / gist:2562465
Last active October 4, 2015 02:28
Basic Widgetized Areas
<?php ## functions.php
/**
* This 'registers' the sidebar and tells WordPress it exists, as well as names it
* and gives it wrapping markup for each widget, and the title if applicable.
*
* Change the markup to meet your needs.
*/
if (function_exists('register_sidebar')) {
register_sidebar(array(
'name' => 'Hero',
@eddiemoya
eddiemoya / print_pre.php
Last active October 5, 2015 15:47
Print Pre
<?php
function print_pre($array){
echo "<pre style='z-index:1000;background-color:rgba(192,192,192,0.9);left:0;top:100px;width:4000px;overflow:scroll;position:absolute;white-space: pre;'>";
print_r($array);
echo "</pre>";
}
@eddiemoya
eddiemoya / category-template-hierarchy-descendants.php
Created June 26, 2012 00:56
Category Template Hierarchy 'descendant-of-category' templates, allow any descendant to inherit the template of a set of parent categories.
add_filter('cth_category_template', 'descendant_templates');
/**
* My plugin will call your function, and pass it the list of all templates
* before sending them off to find which ones match.
*/
function descendant_templates($templates){
if(is_category()){
@eddiemoya
eddiemoya / MFI_more_mime_types.php
Created July 2, 2012 20:31
Allow non-image mime-types in the multiple featured image plugin
// In function kd_meta_box_output() replace
$thumbnail = wp_get_attachment_image( $image_id, array( 266, 266 ) );
//With...
$type = get_post_mime_type($iamge_id);
$icon = in_array($type, array('application/pdf')) ? true : false;
$thumbnail = wp_get_attachment_image( $image_id, array( 266, 266 ), $icon );
@eddiemoya
eddiemoya / wp-config.php
Created July 2, 2012 21:19
WordPress - wp-config.php settings for dynamic host detection.
define( 'WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content' );
define( 'WP_PLUGIN_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins' );
define( 'PLUGINDIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content/plugins' );
define( 'WP_SITEURL', 'http://' . $_SERVER['HTTP_HOST']);
define( 'WP_HOME', 'http://' . $_SERVER['HTTP_HOST']);
define( 'WP_CONTENT_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content');
define( 'WP_PLUGIN_URL', 'http://' . $_SERVER['HTTP_HOST'] . '/wp-content/plugins');
define( 'UPLOADS', 'wp-content/uploads' );
@eddiemoya
eddiemoya / return-template-part.php
Created July 2, 2012 23:06
Return Template Part - WordPress
function return_template_part($template, $specialized_name = ''){
ob_start();
get_template_part($template, $specialized_name);
return ob_get_clean();
}
@eddiemoya
eddiemoya / boilerplate-widget.php
Last active March 4, 2020 16:36
WordPress Boilerplate Widget
<?php /*
Plugin Name: Boilerplate Widget
Description: Starting point for building widgets quickly and easier
Version: 1.0
Author: Eddie Moya
/**
* IMPORTANT: Change the class name for each widget
*/
class Boilerplate_Widget extends WP_Widget {
@eddiemoya
eddiemoya / user-by-taxrole.sql
Created September 7, 2012 21:16
Get users by role with taxonomy sql
SELECT DISTINCT
u.ID,
u.user_login,
u.user_nicename,
u.user_email,
u.display_name,
m2.meta_value as role,
GROUP_CONCAT(DISTINCT m.meta_value) AS terms
FROM wp_users as u
LEFT JOIN wp_usermeta AS m
@eddiemoya
eddiemoya / get_users_by_role_tax_intersection.php
Created September 7, 2012 23:17
Query building function for getting users by role and taxonomy
function get_user_role_tax_intersection($args = array()){
global $wpdb;
$default_args = array(
'hide_untaxed' => true
'terms' => array(),
'roles' => array('administrator')
);
$args = array_merge($default_args, $args);
<!-- OLD -->
<article class="widget content-container span12 image-widget">
<header class="content-header">
<h3>Discover ideas. Ask Questions. Be you. Welcome to the Community.</h3>
</header>
<article class="content-container">
<img src="">
</article>
</article>