Skip to content

Instantly share code, notes, and snippets.

Eric ericjuden

Block or report user

Report or block ericjuden

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:e79519f279bcddc43233
<?php
$args = array(
'post_type' => 'services'
);
$the_query = new WP_query( $args );
?>
<?php if ( have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post() ;?>
View jquery-image-resize.js
$(document).ready(function() {
$('.story-small img').each(function() {
var maxWidth = 100; // Max width for the image
var maxHeight = 100; // Max height for the image
var ratio = 0; // Used for aspect ratio
var width = $(this).width(); // Current image width
var height = $(this).height(); // Current image height
// Check if the current width is larger than the max
if(width > maxWidth){
@ericjuden
ericjuden / wordpress-options-json.php
Last active Jun 16, 2019
WordPress Options Class with Support for storing and retrieving JSON
View wordpress-options-json.php
<?php
class My_Plugin_Options {
var $options;
var $option_name;
var $is_site_option; // Are we using Multisite and saving to global options?
function My_Plugin_Options($option_name, $is_site_options = false){
$this->option_name = $option_name;
$this->is_site_option = $is_site_options;
if($this->is_site_option){
@ericjuden
ericjuden / Microsoft.PowerShell_profile.ps1
Created Jan 28, 2014
Search for .ps1 files in a given directory
View Microsoft.PowerShell_profile.ps1
# Search for .ps1 files in a given directory
Get-ChildItem C:\Code\powershell -Include *.ps1 -Recurse -Force | % { . $_.FullName }
@ericjuden
ericjuden / list-blogs-alpha.php
Created May 15, 2013
WordPress Multisite: List Blogs Alphabetically
View list-blogs-alpha.php
<?php if(is_front_page()){ ?>
<h1>Blog Directory</h1>
<?php
global $wpdb;
$aBlogs = array();
$query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path";
$blogs = $wpdb->get_results($query);
@ericjuden
ericjuden / list-blogs.php
Created May 15, 2013
WordPress Multisite: List Blogs
View list-blogs.php
<?php if(is_front_page()){ ?>
<h1>Blog Directory</h1>
<?php
global $wpdb;
$query = "SELECT blog_id FROM " . $wpdb->base_prefix . "blogs WHERE spam != '1' AND archived != '1' AND deleted != '1' AND public = '1' AND blog_id != '1' ORDER BY path";
$blogs = $wpdb->get_results($query);
echo '<ul>';
@ericjuden
ericjuden / default-sections.css
Last active Dec 16, 2015
Default Starter Stylesheet
View default-sections.css
/********************************************************
* Main Body Styles
********************************************************/
/********************************************************
* Header Styles
********************************************************/
@ericjuden
ericjuden / create-sample-tables.php
Last active Dec 14, 2015
WordPress Custom Tables
View create-sample-tables.php
<?php
/*
Plugin Name: Create Sample Tables Plugin
Plugin URI: http://ericjuden.com
Description: Create some dummy tables
Version: 1.0
Author: ericjuden
Author URI: http://ericjuden.com
*/
@ericjuden
ericjuden / create.php
Last active Feb 3, 2019
WordPress CRUD
View create.php
<?php
// Create a new record in a table
global $wpdb;
// data to be added
$data = array(
'post_title' => __('This is a test'),
'post_content' => __('This is really long text'),
'post_status' => __('draft')
@ericjuden
ericjuden / prepare-sql.php
Last active Dec 12, 2015
WordPress St. Louis Developers Meetup: Security Best Practices
View prepare-sql.php
<?php
global $wpdb;
// Clean SQL before running
$sql = $wpdb->prepare('SELECT * FROM ' . $wpdb->posts . ' WHERE status = %s AND post_type = %s', 'publish', 'page');
// Return results
$results = $wpdb->get_results($sql);
?>
You can’t perform that action at this time.