Skip to content

Instantly share code, notes, and snippets.

View ebinnion's full-sized avatar

Eric Binnion ebinnion

View GitHub Profile
@ebinnion
ebinnion / gist:4601825
Created January 23, 2013 04:05
WordPress Top Commenters Code
function top_comment_authors($amount = 5){
global $wpdb;
$results = $wpdb->get_results('
SELECT
COUNT(comment_author_email) AS comments_count, comment_author_email, comment_author, comment_author_url
FROM
'.$wpdb->comments.'
WHERE
@ebinnion
ebinnion / gist:4590551
Created January 21, 2013 23:30
Enqueue Script and Js in Plugin
add_action('template_redirect', 'audience_intel_add_js');
function audience_intel_add_js() {
// enqueue script
wp_enqueue_script( 'audience_intel_js',
plugins_url( 'js/script.js' , __FILE__ ),
array('jquery'), audience_intel_version, true
);
// Get current page protocol
$protocol = isset( $_SERVER["HTTPS"] ) ? 'https://' : 'http://';
@ebinnion
ebinnion / gist:4582703
Created January 21, 2013 00:02
Create WordPress Sidebar Shortcode
function sidebar_shortcode() {
$output = '<div class="viral-sidebar">';
ob_start();
dynamic_sidebar( 'sidebar_shortcode' );
$output .= ob_get_contents();
ob_end_clean();
$output .= '</div>';
return $output;
}
add_shortcode('viral_sidebar', 'sidebar_shortcode');
@ebinnion
ebinnion / style.css
Created January 20, 2013 23:51
Form CSS Chronicl
input,textarea {
font-size: 1em;
margin-bottom: 1em;
border-radius: 4px;
}
input[type="text"] {
margin-right: .5em;
}
@ebinnion
ebinnion / header.php
Created January 20, 2013 21:31
WordPress Title Tag
<title><?php
if( is_home() ){
echo 'Art of Blog - The Art of How to Start and Run a Blog';
}
else if ( is_category() ) {
$category = get_the_category();
echo $category[0]->cat_name . ' | Optiniche';
}
else {
single_post_title() .' | Art of Blog';
@ebinnion
ebinnion / category-toolbox.php
Created January 20, 2013 21:31
WordPress Loop Group of Three
<?php if (have_posts()) :
$i=0; // counter
while(have_posts()) : the_post();
if($i%3==0) { // if counter is multiple of 3, put an opening div ?>
<!-- <?php echo ($i+1).'-'; echo ($i+3); ?> -->
<div class="cf">
<?php } ?>
<div class="col3 toolbox">
<div class="head">
<h5 style="text-align:center;"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h5>
@ebinnion
ebinnion / gist:4481629
Created January 8, 2013 06:07
Import large database SQL into MAMP
/applications/MAMP/library/bin/mysql -u root -p wordpress_db < /Applications/MAMP/htdocs/backupDB.sql
@ebinnion
ebinnion / gist:4439337
Last active December 10, 2015 13:09
MySQL queries
CREATE TABLE results(
id INT NOT NULL AUTO_INCREMENT,
1sttitle VARCHAR(100) NOT NULL,
2ndtitle VARCHAR(100) NOT NULL,
3rdtitle VARCHAR(100) NOT NULL,
1stmsg VARCHAR(300) NOT NULL,
2ndmsg VARCHAR(300) NOT NULL,
3rdmsg VARCHAR(300) NOT NULL,
1stscore VARCHAR(100) NOT NULL,
2ndscore VARCHAR(100) NOT NULL,
@ebinnion
ebinnion / create.txt
Last active December 10, 2015 13:09
Create Table MySQL
CREATE TABLE tutorials_tbl(
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(100) NOT NULL,
slug VARCHAR(40) NOT NULL,
content VARCHAR(2000) NOT NULL,
PRIMARY KEY ( id )
) AUTO_INCREMENT=15110;
@ebinnion
ebinnion / gist:4239445
Created December 8, 2012 09:12
jQuery Plugin Skeleton
(function( $ ) {
$.fn.myPlugin = function() {
// Do your awesome plugin stuff here
};
})( jQuery );