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 / gist:4144281
Created November 25, 2012 16:45
Get visible elements from a scrollable container
<html dir="ltr" lang="en-US">
<head>
<meta charset="UTF-8" />
<title>Scroll tester</title>
<style type="text/css">
#scroll-box { margin-top: 100px; width: 100%; background-color: #666bea; font-family: Arial, Helvetica, sans-serif;font-size: 12px;; }
#scroll-box div.scroll-messages-list { position: relative; height:250px; overflow: auto; background-color: #FFFFFF; border:1px solid #CCCCCC; }
#scroll-box div.scroll-messages-list div.row { position: relative; background-color:#FFFFFF; border:1px solid #CCCCCC; height: 100px;}
#scroll-box div.scroll-messages-list div.row span.message { color:#000000; }
</style>
function check_upgrade() {
// Check our version against the options table
if (is_multisite())
$options_version = get_site_option('wpmudev-chat-version');
else
$options_version = get_option('wpmudev-chat-version');
if (version_compare($this->chat_current_version, $options_version) > 0) {
$this->install();
@codehooligans
codehooligans / gist:5825451
Created June 20, 2013 18:44
Hook into the PWAL URL filter pwal_url_to_like
function theme_pwal_url_filter($href='') {
// Just replace 'key1' and 'value1' with your custom URL key1=value1 set
return add_query_arg( array('key1' => 'value1'), $href );
}
add_filter('pwal_url_to_like', 'theme_pwal_url_filter');
@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
@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 / 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-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-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-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-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";