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: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');
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: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>
@codehooligans
codehooligans / show_wp_filters
Created November 9, 2012 23:42
Show WordPress filters
/* Simple function to show existing WordPress filters */
function show_filter($filter_key='') {
if (empty($filter_key)) return false;
global $wp_filter;
if (isset($wp_filter[$filter_key])) {
foreach($wp_filter[$filter_key] as $priority => $filter_sets) {
echo "=== Priority [{$priority}] ===<br />";
foreach($filter_sets as $filter_set_key => $filter_set_data) {
echo $filter_set_key."<br />";
@codehooligans
codehooligans / gist:3799385
Created September 28, 2012 11:59
WPMU DEV Live Stream modification
$item_output .= '<div class="live-stream-text">';
/* Show the User Name */
if (isset($user_data['display_name']))
$item_output .= $author_anchor_begin . $user_data['display_name'] . $author_anchor_end ." ";
if ($item->post_type == "comment") {
$item_output .= __(" commented on ", LIVE_STREAM_I18N_DOMAIN); ;
/* Show the Post Title */
@codehooligans
codehooligans / Events Feed
Created July 16, 2012 19:32
Gist for Stephanie
<?php
add_action('admin_init','my_postdatemeta_init');
add_action('save_post', 'env_save_post_date_meta', 1, 2); // save the custom fields
/*** Add Post Date Metabox */
function my_postdatemeta_init()
{
// Paul: The metaboarcx are really just display for the admin to check the date. Should not be seen for regular users.
if (get_current_user_id() == 1) { // Change the '1' to some other userID
// Paul: changed so all post_types use the same metabox. Don't need one just for Events.
@codehooligans
codehooligans / gist:3124540
Created July 16, 2012 19:32 — forked from smeyer/gist:3119483
attempt to save the same custom meta for blog, news and event posts, then sort a feed containing all of these by the meta
/*** Add Post Date Metabox */
function my_postdatemeta_init()
{
add_meta_box('env_post_date_meta', 'Admin Meta', 'env_post_date_meta', 'post', 'normal', 'low');
add_meta_box('env_post_date_meta', 'Admin Meta', 'env_post_date_meta', 'news', 'normal', 'low');
add_meta_box('env_event_date_meta', 'Admin Meta', 'env_event_date_meta', 'ai1ec_event', 'normal', 'low');
}
add_action('admin_init','my_postdatemeta_init');
@codehooligans
codehooligans / gist:3060004
Created July 6, 2012 12:51
theme_switcher_markup function
function theme_switcher_markup( $style = 'text', $instance = array() ) {
if ( ! $theme_data = wp_cache_get('themes-data', 'advanced-theme-switcher') ) {
$themes = (array) get_themes();
if (!$themes) return;
if ( is_multisite() ) {
//$allowed_themes = (array) get_site_option( 'allowedthemes' );
$allowed_themes = WP_Theme::get_allowed();
@codehooligans
codehooligans / gist:3028498
Created July 1, 2012 13:55
MP Category Exclude
/* Exclude logic for MarketPress Product Categories */
// Add product_categories to exclude here. Note this is an array so multiple category IDs need to be seperated by comma. Also wrapped in single quote.
// The minus sign is not used. You need to update the mp_excluded_categories with the slugs of your excluding categories.
$mp_excluded_categories = array('products');
// Page ID to redirect non-logged in users when viewing a single product page associated with an excluded category
$mp_redirect_archive_page_id = 123;
// Page ID to redirect non-logged in users when viewing a product category archive for an excluded category
@codehooligans
codehooligans / mp_scripts_override.php
Created June 28, 2012 19:53
MarketPress scripts override
<?php
function mp_js_override() {
global $mp;
if (!is_object($mp)) return;
// #1 - Disable AJAX on the Product page.
remove_action( 'template_redirect', array(&$mp, 'store_script') ); //only on front pages
// #2 - Deregister the MP script(s) and reregister in the footer.