Skip to content

Instantly share code, notes, and snippets.

Avatar

Steve Taylor gyrus

View GitHub Profile
@gyrus
gyrus / gist:3034668
Created Jul 2, 2012
gitconfig for GitHub -> plugins.svn.wordpress.org
View gist:3034668
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
hideDotFiles = dotGitOnly
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
@gyrus
gyrus / local-config.php
Last active Oct 7, 2015
WordPress local config file
View local-config.php
<?php
/**
* Local configuration of WordPress, for Pilau Starter
*
* @link http://markjaquith.wordpress.com/2011/06/24/wordpress-local-dev-tips/
* @link https://github.com/pilau/starter/wiki/How-to-use
*/
define( 'DB_NAME', '[[local-db-name]]' );
@gyrus
gyrus / sample-html5.html
Created Jul 19, 2012
Sample of HTML5 markup for testing CSS
View sample-html5.html
<!--
Created for testing the Pilau Starter theme
Adapted from: http://www.cs.tut.fi/~jkorpela/www/testel.html
@todo Make it better! Add new HTML5 elements
-->
<div id="content">
<h1>Testing display of HTML elements</h1>
<h2>This is 2nd level heading</h2>
@gyrus
gyrus / gist:3155816
Created Jul 21, 2012
WordPress login link
View gist:3155816
<?php
/**
* Nice WordPress admin login link
*/
function pilau_wp_login_link() {
if ( is_user_logged_in() ) {
echo '<a href="/wp-admin/">' . __( 'Admin' ) . '</a>';
} else {
echo '<a href="' . wp_login_url() . '">' . __( 'Login' ) . '</a>';
@gyrus
gyrus / gist:3155823
Created Jul 21, 2012
Force WordPress login
View gist:3155823
<?php
/**
* Force WordPress login
*/
add_action( 'init', 'pilau_force_login' );
function pilau_force_login() {
if ( ! is_user_logged_in() && $_SERVER["SCRIPT_NAME"] != '/wp-login.php' ) {
wp_redirect( wp_login_url() );
exit();
@gyrus
gyrus / gist:3155850
Created Jul 21, 2012
Remove WordPress content editor
View gist:3155850
<?php
/**
* Remove WordPress content editor from certain pages
* Add page IDs to the array
*/
add_action( 'do_meta_boxes', 'pilau_remove_editor' );
function pilau_remove_editor() {
global $post;
if ( in_array( $post->ID, array( ) ) )
@gyrus
gyrus / gist:3157161
Created Jul 21, 2012
Output first paragraph of WordPress content
View gist:3157161
<?php
/**
* Output first paragraph of WordPress content
*
* @uses get_the_content()
*/
function pilau_the_content_first_paragraph() {
$content = trim( apply_filters( 'the_content', get_the_content() ) );
preg_match( '#<[a-z]+>[^<]+</[a-z]+>#', $content, $matches );
@gyrus
gyrus / gist:3157247
Created Jul 21, 2012
Scroll to an ID
View gist:3157247
/**
* Scroll to an ID
*
* Example:
* <code>$( '#content' ).scrollView();</code>
*
* @link http://stackoverflow.com/questions/1586341/how-can-i-scroll-to-a-specific-location-on-the-page-using-jquery
*/
jQuery.fn.scrollView = function () {
return this.each( function () {
@gyrus
gyrus / gist:3157179
Created Jul 21, 2012
Simple list of download files attached to WordPress post or page
View gist:3157179
<?php
/**
* List of downloads
*
* @uses get_children()
* @uses esc_url()
* @uses apply_filters()
* @uses get_attached_file()
* @uses pilau_format_filesize() (find on Gist)
@gyrus
gyrus / gist:3157188
Created Jul 21, 2012
Format the size of a file (for WordPress)
View gist:3157188
<?php
/**
* Return the formatted size of a file.
*
* @param string|int $input Either the path to a valid file, or a number in bytes
* @param string $default_output Optional. The string to output if the input can't be used (e.g. the file doesn't exist)
* @uses size_format()
* @return string The size, formatted
*/
You can’t perform that action at this time.