Skip to content

Instantly share code, notes, and snippets.

View paulgibbs's full-sized avatar

Paul Wong-Gibbs paulgibbs

View GitHub Profile
<?php $query = new WP_Query( array( 'posts_per_page' => 100, 'fields' => 'ids' ) ); ?>
<?php if ( $query->have_posts() ) :
$post_ids = $query->posts;
shuffle( $post_ids );
$post_ids = array_splice( $post_ids, 0, 12 );
foreach ( $post_ids as $post_id ) :
$post = get_post( $post_id );
setup_postdata( $post );
?>
<?php
function x_allow_ids_on_tags() {
global $allowedposttags;
$tags = array( 'section', 'article' );
$new_attributes = array( 'id' => array() );
foreach ( $tags as $tag ) {
if ( isset( $allowedposttags[ $tag ] ) && is_array( $allowedposttags[ $tag ] ) )
$allowedposttags[ $tag ] = array_merge( $allowedposttags[ $tag ], $new_attributes );
@paulgibbs
paulgibbs / wp-plugin-path.php
Created June 16, 2012 11:00 — forked from alexkingorg/wp-plugin-path.php
Defining symlink compatible paths for WordPress plugins
<?php
// include this near the top of your plugin file
$my_plugin_file = __FILE__;
if (isset($plugin)) {
$my_plugin_file = $plugin;
}
else if (isset($mu_plugin)) {
@paulgibbs
paulgibbs / html5-notifications.md
Created June 12, 2012 14:04
OS X Notification Center in Safari 5.2

OS X Notification Center in Safari 5.2

OS X Mountain Lion adds Notification Center for managing alerts. Just like growl, but better.

Safari 5.2 exposes HTML5 notifications API to sites. Every site need to have permission for showing notifications.

Specification is very new and completely different from older version Chrome has. Developer doesn't have to watch for complicated NotificationCenter.

The syntax is very simple: