Skip to content

Instantly share code, notes, and snippets.

View mattboon's full-sized avatar

Matt Berridge mattboon

View GitHub Profile
@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: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: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: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: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:4072618
Created November 14, 2012 15:01
WordPress - Add filter to 'event' post type to filter events in the past/future (given by event_date meta field)
<?php
// Add past/future events filter
add_action( 'restrict_manage_posts', 'my_add_past_prev_filter' );
function my_add_past_prev_filter() {
global $typenow;
// get our time period filter (if applied)
$time_period = $_GET['time_period'];
// set our select options
@mattboon
mattboon / gist:4072627
Created November 14, 2012 15:03
WordPress - Add custom taxonomy filters to custom post types
<?php
// Add category filters to WP custom post types
add_action( 'restrict_manage_posts', 'my_add_category_filters' );
function my_add_category_filters() {
global $typenow;
if( $typenow == "event" ){
$taxonomy = 'event_type';
}
elseif( $typenow == "guideline" ){
@mattboon
mattboon / gist:4072631
Created November 14, 2012 15:04
WordPress - Add PDF filter to media library
<?php
// Add PDF filter to media library
add_filter( 'post_mime_types', 'modify_post_mime_types' );
function modify_post_mime_types( $post_mime_types ) {
// select the mime type, here: 'application/pdf'
// then we define an array with the label values
$post_mime_types['application/pdf'] = array( __( 'PDFs' ), __( 'Manage PDFs' ), _n_noop( 'PDF <span class="count">(%s)</span>', 'PDFs <span class="count">(%s)</span>' ) );
// then we return the $post_mime_types variable
return $post_mime_types;
@mattboon
mattboon / gist:4202188
Created December 4, 2012 09:34
WordPress - Split content above and below <!--more--> tag
<?php
$morestring = '<!--more-->';
$explode_content = explode( $morestring, $post->post_content );
$content_before = apply_filters( 'the_content', $explode_content[0] );
$content_after = apply_filters( 'the_content', $explode_content[1] );
?>
@mattboon
mattboon / Different colour logo in print.css
Created December 12, 2012 15:03
For when you need a different logo for print than screen - either a higher quality, different colour etc. Use this in print.css. Doesn't work in IE7 but IE7/print is a bit of an edge case
/* for <a href="#" class="logo"><img src="..."></a> */
.logo,
.logo:before {
height: 75px;
width: 275px;
display: block; }
.logo {
position: relative; }