Skip to content

Instantly share code, notes, and snippets.

View justinwhall's full-sized avatar

Justin W Hall justinwhall

View GitHub Profile
#header.info{display: none !important;}
@justinwhall
justinwhall / gist:1997684
Created March 8, 2012 00:59
PHP: Function WordPress Highlight Authour Comment
function author_highlight() {
global $comment;
if ($comment->user_id == get_the_author_meta('ID')) { echo "highlighted"; }
}
@justinwhall
justinwhall / gist:1997691
Created March 8, 2012 01:01
PHP: Function Latest Tweet
function display_latest_tweets(
$twitter_user_id = 'justinwhall',
$cache_file = 'twitter.txt',
$tweets_to_display = 1,
$ignore_replies = false,
$twitter_wrap_open = '<ul id="twitter">',
$twitter_wrap_close = '</ul>',
$tweet_wrap_open = '<li><span class="status">',
$meta_wrap_open = '</span><span class="meta"> ',
$meta_wrap_close = '</span>',
@justinwhall
justinwhall / gist:1997673
Created March 8, 2012 00:56
PHP: Function e-mail share
//email share function
function direct_email($text="Send by email"){
global $post;
$title = htmlspecialchars($post->post_title);
$excerpt = htmlspecialchars($post->the_excerpt);
$subject = 'Article by '.htmlspecialchars(get_bloginfo('name')).': '.$title . $excerpt;
$body = 'Check out this article from Justin W Hall: '.$title. "\n" . "\n" .get_permalink($post->ID);
$link = '<a rel="nofollow" href="mailto:?subject='.rawurlencode($subject).'&amp;body='.rawurlencode($body).'" title="'.$text.' : '.$title.'">'.$text.'</a>';
return $link;
}
@justinwhall
justinwhall / uploader.js
Created March 8, 2012 01:34
jQuery: WordPress | Uploader for theme options page
jQuery(document).ready(function() {
jQuery('.st_upload_button').click(function() {
/* formfield = jQuery('#st_upload').attr('name'); */
targetfield = jQuery(this).prev('.upload-url');
tb_show('', 'media-upload.php?type=image&amp;TB_iframe=true');
return false;
});
window.send_to_editor = function(html) {
@justinwhall
justinwhall / gist:1997787
Created March 8, 2012 01:18
PHP: Wordpress | replace defualt WP login logo
//Custom Login image
add_action("login_head", "my_login_head");
function my_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/images/newlogo.png') no-repeat scroll center top transparent;
height: 152px;
width: 330px;
}
@justinwhall
justinwhall / form-validator.js
Created March 8, 2012 01:42
jQuery: Form validator
jQuery(document).ready(function() {
jQuery('form#contactForm').submit(function() {
jQuery('form#contactForm .error').remove();
var hasError = false;
jQuery('.requiredField').each(function() {
if(jQuery.trim(jQuery(this).val()) == '') {
//var labelText = jQuery(this).prev('label').text();
jQuery(this).parent().append('<span class="error text-error">&larr; Required field</span>');
hasError = true;
}
@justinwhall
justinwhall / CSS | Centered Menu
Created March 15, 2012 22:43
CSS Centered Menu
#centered{
width:100%;
float: left;
overflow: hidden;
position: relative;
}
#centered ul{
clear:left;
float:left;
list-style:none;
@justinwhall
justinwhall / gist:2051050
Created March 16, 2012 16:46
PHP: WordPress | register basic widget
add_action( 'widgets_init', 'example_load_widgets' );
/**
* Register our widget.
* 'Example_Widget' is the widget class used below.
*
* @since 0.1
*/
function example_load_widgets() {
register_widget( 'Example_Widget' );
@justinwhall
justinwhall / gist:2139927
Created March 20, 2012 19:07
PHP: WordPress | Social_Share_it
//social share
function social_share_it(){
//get the user entered URLS/usernames from WP backend
$twitter = mytheme_option('twitter');
$facebook = mytheme_option('facebook');
$googleplus = mytheme_option('googleplus');
?>
<?php //print he icons ?>
<ul id="social-share">