Skip to content

Instantly share code, notes, and snippets.

@ericjuden
ericjuden / gridview_with_rank.aspx.cs
Last active December 11, 2015 20:29
ASP.NET/C# GridView Rank column
public partial class Leaders : System.Web.UI.Page {
private int rank = 0; // Rank of the current record in GridView
private int currentPage = 0; // tracks current page in GridView
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
// Find label control to update
Label lblRank = (Label)e.Row.FindControl("lblRank");
// On page reload, rank is reset to 0
if (rank == 0) {
@ericjuden
ericjuden / speak-pirate.php
Created January 28, 2013 14:34
Speak Pirate plugin for WordPress
<?php
/**
* Plugin Name: Speak Pirate
* Plugin URI:
* Description: translates text in a shortcode into the equivalent text spoken as a pirate
* Author: ericjuden
* Author URI: http://ericjuden.com
* Version: 1.0
*/
@ericjuden
ericjuden / my-object-oriented-plugin.php
Created January 28, 2013 14:40
Object-Oriented Plugin for WordPress boilerplate
<?php
/**
* Plugin Name: My Object-Oriented Plugin
* Plugin URI: Plugin Website Here
* Description: Your Description Here
* Author: Your Name Here
* Author URI: Your Website Here
* Version: 1.0
*/
@ericjuden
ericjuden / edit-author-name.php
Created January 28, 2013 14:52
Edit Post Author Name in WordPress Feeds
<?php
function my_rss2_ns(){
global $in_rss_feed;
$in_rss_feed = true;
}
add_action('rss2_ns', 'my_rss2_ns');
function my_the_author($author){
global $in_rss_feed;
@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.php
Created February 8, 2013 15:49
WordPress Options Class
<?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 / prepare-sql.php
Last active December 12, 2015 09:58
WordPress St. Louis Developers Meetup: Security Best Practices
<?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);
?>
@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')
@ericjuden
ericjuden / create-sample-tables.php
Last active December 14, 2015 19:29
WordPress Custom Tables
<?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 / default-sections.css
Last active December 16, 2015 15:09
Default Starter Stylesheet
/********************************************************
* Main Body Styles
********************************************************/
/********************************************************
* Header Styles
********************************************************/