Skip to content

Instantly share code, notes, and snippets.

View codehooligans's full-sized avatar
🤠
I may be slow to respond.

Paul Menard codehooligans

🤠
I may be slow to respond.
View GitHub Profile
@codehooligans
codehooligans / codehooligans-adding-taxonomy-custom-headers
Created January 13, 2015 18:41
Codehooligans.com: Adding Taxonomy Column Headers
<?php
add_action( 'init', 'product_init' );
function product_init()
{
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
)
);
@codehooligans
codehooligans / codehooligans-register-taxonomy-for-product-packages-v2
Created January 13, 2015 18:31
Codehooligans.com: Register Taxonomy for Product Packages Version 2
<?php
add_action( 'init', 'product_init' );
function product_init()
{
global $wpdb;
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
@codehooligans
codehooligans / codehooligans-edited-product-packages
Created January 13, 2015 18:27
Codehooligans.com: Edited Product Packages
<?php
add_action( 'edited_product_packages', 'save_product_packages', 10, 2);
function save_product_packages($term_id, $tt_id)
{
if (!$term_id) return;
if (isset($_POST['product_package_active']))
update_metadata($_POST['taxonomy'], $term_id, 'product_package_active',
$_POST['product_package_active']);
@codehooligans
codehooligans / codehooligans-product-packages-edit-form-fields
Created January 13, 2015 18:25
Codehooligans.com: Product Packages Edit Form Fields
<?php
add_action( 'product_packages_edit_form_fields', 'edit_product_packages', 10, 2);
function edit_product_packages($tag, $taxonomy)
{
$product_package_active = get_metadata($tag->taxonomy, $tag->term_id, 'product_package_active', true);
// Check/Set the default value
if (!$product_package_active)
$product_package_active = "Yes";
@codehooligans
codehooligans / codehooligans-register-taxonomy-for-product-packages-v1
Last active August 29, 2015 14:13
Codehooligans.com: Register Taxonomy for Product Packages Version 1
<?php
add_action( 'init', 'product_init' );
function product_init()
{
register_taxonomy( 'product_packages', 'products',
array( 'hierarchical' => true,
'label' => __('Product Packages'),
'query_var' => false
)
);
@codehooligans
codehooligans / codehooligans-myHomePostsFilter.php
Last active August 29, 2015 14:13
Codehooligans.com: my Home Posts Filter
<?php
// Used to limit the categories displayed on the home page.
function myHomePostsFilter($query)
{
if ($query->is_home)
{
$query->set('cat','1');
}
return $query;
}
@codehooligans
codehooligans / codehooligans-adding-custom-columns-to-wordpress-post-listing.php
Last active May 13, 2019 11:30
Codehooligans.com: Adding Custom Columns to WordPress Post listing
<?php
add_filter( 'manage_edit-post_columns', 'admin_post_header_columns', 10, 1);
add_action( 'manage_posts_custom_column', 'admin_post_data_row', 10, 2);
function admin_post_header_columns($columns)
{
if (!isset($columns['note']))
$columns['note'] = "Notes";
return $columns;
@codehooligans
codehooligans / codehooligans-page-media-tags-search.php
Last active August 29, 2015 14:11
Codehooligans.com: Media-Tags Search template
<?php
/*
Template Name: Media-Tags Search
*/
// Get the Page permalink. Used later when displaying date links
$page_permalink = get_permalink();
?>
<?php get_header(); ?>
@codehooligans
codehooligans / codehooligans-limit-posts-per-archive-page
Last active August 29, 2015 14:08
Codehooligans.com: Limit Posts per Archive Page
function limit_posts_per_archive_page( $query ) {
// If running within wp_admin or NOT the main $wp_query abort!
if ( is_admin() || ! $query->is_main_query() ) return;
if ( $query->is_category() ) {
$query->set('posts_per_archive_page', 8);
} elseif ( $query->is_search() ) {
$query->set('posts_per_archive_page', 10);
}
@codehooligans
codehooligans / gist:6498950
Last active December 22, 2015 16:19
Snapshot hard-code destination options.
function load_class_destination($d_info) {
$this->destination_info['type'] = "aws"; // ALWAYS aws. Do not change.
$this->destination_info['name'] = "Your name for the destination. "; // Change this if you want.
$this->destination_info['awskey'] = ""; // Your AWS Access Key ID
$this->destination_info['secretkey'] = ""; // Your AWS Access Key Secret
$this->destination_info['ssl'] = "yes"; // Can be 'yes' or 'no'
$this->destination_info['region'] = AmazonS3::REGION_US_E1; // See line 81 for values
$this->destination_info['storage'] = AmazonS3::STORAGE_STANDARD; // See line 92 for values
$this->destination_info['acl'] = AmazonS3::ACL_PRIVATE; // See line 97 for values