Skip to content

Instantly share code, notes, and snippets.

@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
@mikejolley
mikejolley / gist:1597957
Created January 12, 2012 01:40
WooCommerce - Replace '' with 'Call for price' when price is left blank
/**
* This code should be added to functions.php of your theme
**/
add_filter('woocommerce_empty_price_html', 'custom_call_for_price');
function custom_call_for_price() {
return 'Call for price';
}
@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.
@ScottPhillips
ScottPhillips / .htaccess
Created February 2, 2012 04:30
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@johnpbloch
johnpbloch / disable-plugins-when-doing-local-dev.php
Created February 11, 2012 20:12 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@marcel
marcel / gist:2100703
Created March 19, 2012 07:24
giftube – Generates an animated gif from a YouTube url.
#!/usr/bin/env ruby
# giftube – Generates an animated gif from a YouTube url.
#
# Usage:
#
# giftube [youtube url] [minute:second] [duration]
#
# ex.
#
@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
) );
@markoheijnen
markoheijnen / gist:2399864
Created April 16, 2012 16:40
Change Post to News
<?php
add_action( 'init', array( &$this, 'change_post_object_label' ), 0 );
add_action( 'admin_menu', array( &$this, 'change_post_menu_label' ), 0 );
add_filter( 'post_updated_messages', array( &$this, 'post_updated_messages') );
function change_post_menu_label() {
global $menu;
global $submenu;
if( isset( $menu[5], $submenu['edit.php'] ) ) {
@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