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 / mp-query-filter
Created June 19, 2012 15:26
WordPress MarketPress query filter
add_filter( 'query', 'mp_query_filter');
function mp_query_filter($query) {
global $wpdb;
if ( preg_match( '/('. $wpdb->base_prefix .'mp_terms|'. $wpdb->base_prefix .'mp_term_relationships)/i', $query ) ) {
$query_after = str_replace($wpdb->base_prefix."mp_terms", $wpdb->base_prefix."terms", $query);
$query_after = str_replace($wpdb->base_prefix."mp_term_relationships", $wpdb->base_prefix."mp_term_relationships", $query_after);
// DEBUG START - This following is just for debug to check the output. This will write
@codehooligans
codehooligans / popup_newsletter
Created June 20, 2012 16:08
WPMUDEV Newsletter within Popover
Test popover message. Test popover message. Test popover message. Test popover message. Test popover message. Test popover message. Test popover message. Test popover message.
Test popover message. Test popover message. Test popover message. Test popover message. Test popover message. Test popover message.
<form id="subscribes_form_popover" action="" method="post" name="subscribes_form_popover">
<input id="newsletter_action_popover" type="hidden" name="newsletter_action" value="" />
<div style="padding: 10px 5px 2px 10px;"><h5><input id="e_newsletter_email_popover" type="text" name="e_newsletter_email" /></h5></div>
<div style="padding: 10px 5px 2px 10px;"><input id="new_subscribe_popover" style="height: 2em; width: 10em;" type="button" value="Subscribe" /></div>
</form>
@codehooligans
codehooligans / wp_theme_customize_iframe.php
Created June 21, 2012 22:43
WordPress theme customizer iframe
<?php
/*
* Template Name: Theme Custom
*/
?>
<?php
if ( ! current_user_can( 'edit_theme_options' ) ) {
?><p>You doe not have access to custom this theme</p><?php
} else {
?><iframe src="http://local.wp34.com/wp-admin/customize.php" width="800" height="800"></iframe><?php
@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.
@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 / 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: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 / 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: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 / 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 />";