Skip to content

Instantly share code, notes, and snippets.

View mattboon's full-sized avatar

Matt Berridge mattboon

View GitHub Profile
@mattboon
mattboon / gist:4045215
Created November 9, 2012 11:21
Update WP user_login via SQL
<?php
// Force update our username (user_login)
global $wpdb;
$tablename = $wpdb->prefix . "users";
// method 1
//$sql = $wpdb->prepare("UPDATE %s SET user_login=%s WHERE ID=%d", $tablename, $user_email, $user_id);
//$wpdb->query($sql);
@mattboon
mattboon / gist:4044735
Created November 9, 2012 09:22
PHP - in_array equivalent for recursive arrays (containing stdClass objects)
<?php
function in_array_r($needle, $haystack) {
$found = false;
foreach ($haystack as $item) {
if ($item === $needle) {
$found = true;
break;
} elseif (is_array($item)) {
$found = in_array_r($needle, $item);
@mattboon
mattboon / gist:3913271
Created October 18, 2012 16:57
HTML - Typography Patterns
<p>Sed consequat <a href="#">dapibus mauris vitae sagittis</a>. Phasellus pellentesque <b>magna commodo</b> purus dictum euismod. <em>Vivamus ac orci vel purus</em> lobortis faucibus. <strong>Nullam porttitor</strong> tincidunt sodales. Nullam in orci sit amet purus euismod gravida nec <i>at metus</i>. Proin sit amet lorem lectus, convallis ornare massa.</p>
<ins>In at sodales nisl. In lacus libero, egestas eget venenatis vitae, posuere porttitor elit.</ins>
<p>Quisque laoreet <code>auctor felis</code> at congue. Ut nisl eros, <abbr title="abbr">dignissim</abbr> eget auctor non, mattis vitae dolor. Donec posuere <kbd>massa</kbd> eu dolor commodo luctus. In at sodales nisl. In lacus libero, egestas eget venenatis vitae, posuere porttitor elit. <dfn>Vivamus vel tristique magna</dfn>. Morbi non elit ante, sed venenatis diam. Vivamus vehicula orci sed quam aliquet sagittis. Quisque auctor placerat pharetra.</p>
<pre>
p {
font-size:1em;
<mark>margin-bottom: 1.5em;</mark>
}
</pre>
<h2>Vivamus vel tristique magna.
@mattboon
mattboon / gist:3853620
Created October 8, 2012 17:02
Fublo Edit Profile function
<?php
function fublo_gf_profile_update( $entry, $form )
{
// make sure that the user is logged in
// we shouldn't get here because the form should check for logged in users...
if ( !is_user_logged_in() )
{
wp_redirect( home_url() );
exit;
@mattboon
mattboon / gist:3839766
Created October 5, 2012 13:19
a[alt] ?
a[alt]:before {
content: "";
display: block;
width: 500px;
height: 252px;
background-image: url('http://bukk.it/curses.gif');
}
@mattboon
mattboon / gist:3780739
Created September 25, 2012 09:01
WordPress - Local Admin CSS broken
<?
// no idea why this works but add to wp-config.php
define('SCRIPT_DEBUG', true);
@mattboon
mattboon / gist:3637228
Created September 5, 2012 14:11
Opt-in Typography
/*----------------------------------------------------------------------------------------*/
/* Opt-in typography - http://goo.gl/H6sGd
* Zero off common semantic elements to stop re-definition
* Use .text class on the parent of anything requiring text styles
/*----------------------------------------------------------------------------------------*/
$baseline: 1.5em;
@mixin zero-text-elements {
h1, h2, h3, h4, h5, h6, blockquote, pre,
@mattboon
mattboon / gist:3577343
Created September 1, 2012 15:30
WordPress - Create in-section navigation for a given (hierarchical) post type
<?php
// Return link by post ID
// -------------------------------------------------------------
function link_by_id($post_id) {
echo '<a href="'.get_permalink($post_id).'">'.get_the_title($post_id).'</a>';
}
// Return the root parent ID
// -------------------------------------------------------------
@mattboon
mattboon / gist:3250150
Created August 3, 2012 18:20
WordPress - Events and Projects post types each with categories
<?
// EVENTS
add_action('init', '_init_event_post_type');
function _init_event_post_type() {
// Create taxonomy
register_taxonomy(
'event_category',
@mattboon
mattboon / gist:3184843
Created July 26, 2012 21:58
WordPress- Include template using shortcode
<?
// include template using WP shortcode
function my_shortcode_include() {
ob_start();
// include your template e.g. /inc/random-panel.php
get_template_part('inc/random-panel');
$output_string = ob_get_contents();
ob_end_clean();
return $output_string;