Skip to content

Instantly share code, notes, and snippets.

@ericjuden
ericjuden / Microsoft.PowerShell_profile.ps1
Created January 28, 2014 22:50
Search for .ps1 files in a given directory
# Search for .ps1 files in a given directory
Get-ChildItem C:\Code\powershell -Include *.ps1 -Recurse -Force | % { . $_.FullName }
@ericjuden
ericjuden / jquery-image-resize.js
Created March 3, 2014 21:16
JQuery Image Resize
$(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 / list-blogs-alpha.php
Created May 15, 2013 12:56
WordPress Multisite: List Blogs Alphabetically
<?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 / functions.php
Last active September 3, 2020 13:07
Taxonomy Dropdown Control for WordPress Theme Customizer
<?php
add_action('customize_register', 'my_customize_register');
function my_customize_register($wp_customize){
require_once(TEMPLATEPATH . '/class/wp_customizer_taxonomy_dropdown.php');
$wp_customize->add_section('my_theme_blog_featured_categories', array(
'title' => __('Blog: Featured Categories'),
'priority' => 36,
));
@ericjuden
ericjuden / wordpress-options-json.php
Last active June 30, 2022 12:33
WordPress Options Class with Support for storing and retrieving JSON
<?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 / create.php
Last active April 3, 2024 12:18
WordPress CRUD
<?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')