Skip to content

Instantly share code, notes, and snippets.

@cgrymala
cgrymala / wpe-ssl-port-fix.php
Created September 1, 2015 14:07
Attempt to fix the way CASMaestro/phpCAS on WPEngine sends the application URL to the CAS server
<?php
if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
if ( isset( $_SERVER['HTTP_X_FORWARDED_PORT'] ) && ! empty( $_SERVER['HTTP_X_FORWARDED_PORT'] ) ) {
$ports = explode(',', $_SERVER['HTTP_X_FORWARDED_PORT']);
error_log( 'The forwarded Port var is set to: ' . $ports[0] );
} else if ( isset( $_SERVER['SERVER_PORT'] ) && ! empty( $_SERVER['SERVER_PORT'] ) ) {
error_log( 'The server Port var is set to: ' . $_SERVER['SERVER_PORT'] );
$_SERVER['SERVER_PORT'] = 443;
}
}
@isotrope
isotrope / arr-ansel.php
Last active September 22, 2015 21:33
Traverse all the arrays
<?php
/***
* ____ _____ _____ _____ _____ _ _ _
* / __ \| __ \|_ _/ ____|_ _| \ | | /\ | |
* | | | | |__) | | || | __ | | | \| | / \ | |
* | | | | _ / | || | |_ | | | | . ` | / /\ \ | |
* | |__| | | \ \ _| || |__| |_| |_| |\ |/ ____ \| |____
* \____/|_|__\_\_____\_____|_____|_| \_/_/ \_\______|
* /\ | __ \| __ \ /\\ \ / /
* / \ | |__) | |__) | / \\ \_/ /
@mjangda
mjangda / 0-env-url-override.php
Created January 18, 2012 22:46
How to use WordPress across environments without needing to mess with URLs in the database.
<?php
// This is the meat of the plugin and should go in mu-plugins/0-env-url-override.php
// Only load these filters if we're not in the production environment
if ( defined( 'ENV_NOT_PRODUCTION' ) && ENV_NOT_PRODUCTION ) {
// This always needs to be filtered
add_filter( 'site_url', 'env_filter_site_url', 0 );
// We don't filter home_url in the admin so that we get production URLs for posts.
// This does break certain links like "Preview/View Post", however.
@DrewAPicture
DrewAPicture / gist:2243601
Last active October 2, 2015 12:28
WordPress responsive captions
<?php
function dap_responsive_img_caption_filter( $val, $attr, $content = null ) {
extract( shortcode_atts( array(
'id' => '',
'align' => '',
'width' => '',
'caption' => ''
), $attr
) );
@kovshenin
kovshenin / options.php
Created April 23, 2012 12:12
Reusable Settings API fields
<?php
/**
* Text Field
*
* A simple text field callback to use with the Settings API. Don't forget to pass in
* the arguments array. Here's an example call to add_settings_field() :
*
* add_settings_field( 'my_option', __( 'My Option' ), 'foo_field_text', 'theme_options', 'general', array(
* 'name' => 'my_theme_options[my_option]',
* 'value' => $options['my_option'], // assuming $options is declared
@stephanieleary
stephanieleary / remove-dashboard-widgets.php
Created May 18, 2012 01:56
Remove Dashboard Widgets
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']); // WordPress Blog
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']); // Other WordPress News
<?php
/**
* Favorite Widget
*
* @package Core_Functionality
* @since 1.0.0
* @link https://github.com/billerickson/Core-Functionality
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@billerickson
billerickson / display_posts_shortcode_output.php
Created August 27, 2011 16:35
Add Facebook Like to Display Posts Shortcode plugin
<?php
/**
* Add Facebook Button to Display Posts Shortcode plugin
* @author Bill Erickson
* @link http://wordpress.org/extend/plugins/display-posts-shortcode/
* @link http://wordpress.org/support/topic/facebook-likeshare-button-at-the-end-of-excerpt
*
* @param $output string, the original markup for an individual post
* @param $atts array, all the attributes passed to the shortcode
* @param $image string, the image part of the output
@ryanhellyer
ryanhellyer / disable-plugin-updates
Created November 29, 2012 19:04
Code to disable WordPress plugin updates
<?php
/*
* Disable plugin updates
*
* @param array $r Response header
* @param string $url The update URL
*/
function slug_hidden_plugin( $r, $url ) {
if ( 0 !== strpos( $url, 'http://api.wordpress.org/plugins/update-check' ) )
return $r; // Not a plugin update request. Bail immediately.
@sheabunge
sheabunge / mini-admin-bar.php
Created March 26, 2013 02:58
Makes the WordPress admin bar a small button on the left and expands on hover.
<?php
/*
* Plugin Name: Mini Admin Bar
* Plugin URI:
* Description: Makes the admin bar a small button on the left and expands on hover.
* Version: 1.0
* Author: Shea Bunge
* Author URI: http://bungeshea.com
* License: MIT
*/