Skip to content

Instantly share code, notes, and snippets.

View danielbachhuber's full-sized avatar

Daniel Bachhuber danielbachhuber

View GitHub Profile
@mjangda
mjangda / edit-flow_usergroups_caps.php
Created October 12, 2010 01:58
Add necessary caps to admin and editor roles to manage usergroups
add_action( 'admin_init', 'ef_usergroups_cap_fix' );
function ef_usergroups_cap_fix() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
// Add necessary capabilities to allow management of usergroups and post subscriptions
// edit_post_subscriptions - administrator + editor
@mjangda
mjangda / github-post-receive-pull.php
Created November 16, 2010 06:47
Quick and dirty script that can auto-pull to keep your repo up-to-date any time something is pushed to the remote repo
<?php
// Edit these to match your environment settings
define( 'BASE_PATH', '/home/username/webapps' );
// This is the path to the git executable
define( 'GIT_PATH', get_full_path( '/git/bin/git' ) );
// Edit this array so the key matches the github repo name and the value is path of the repo relative to the BASE_PATH
$repository_paths = array(
'test' => '/git-test'
@ryanpitts
ryanpitts / Hartnett Command Performance
Created May 11, 2011 19:11
Let your Mac read you the latest @wmhartnett updates from Twitter
read -a choices <<<'Agnes Kathy Princess Vicki Victoria Bruce Fred Junior Ralph Albert Bahh Bells Boing Bubbles Cellos Deranged Hysterical Trinoids Whisper Zarvox'; n=${#choices[*]}; voice=${choices[$((RANDOM%n))]}; curl https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=wmhartnett | grep '<description>.*</description>' | sed -e 's/<\/*description>//g' -e 's/ \/ wmhartnett//g' -e 's/wmhartnett: //g' | say -v $voice
@mjangda
mjangda / get-functions-for-hook.php
Created August 10, 2011 18:26
Get all the functions registered to a specific WordPress hook
<?php
function debug_get_functions_for_hook( $hook ) {
global $wp_filter;
if( ! isset( $wp_filter[$hook] ) )
return;
$functions = array();
foreach( (array) $wp_filter[$hook] as $key => $actions ) {
//$functions = array_merge( $functions, $actions );
@nacin
nacin / p2-resolved-posts.php
Created August 14, 2011 21:24
P2 Resolved Posts
<?php
/* Plugin Name: P2 Resolved Posts
* Description: Allows you to mark P2 posts for resolution.
* Author: Andrew Nacin
* Author URI: http://andrewnacin.com/
*/
/* WARNING about studying and copying this code:
*
* P2 is not currently an ideal platform for developing extensions. Some of this
@mjangda
mjangda / ajaxurl.php
Created August 18, 2011 22:15
Get a domain-mapping safe admin-ajax URL on WordPress.com
<?php
/**
* Generates a domain-mapping safe URL on WordPress.com
* Core's ajaxurl uses admin_url() which returns *.wordpress.com which doesn't work for the front-end on domain-mapped sites.
* This works around that and generates the correct URL based on context.
*/
function my_admin_ajax_url( $path = '' ) {
if ( is_admin() )
$url = admin_url( 'admin-ajax.php' );
else
@nickhamze
nickhamze / cpt_contextual_help_starter
Created September 6, 2011 13:01
CPT Contextual Help Starter File
function portfolioposttype_add_help_text($contextual_help, $screen_id, $screen) {
//$contextual_help .= var_dump($screen); // use this to help determine $screen->id
if ('portfolio' == $screen->id ) {
$contextual_help =
'<p>' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes using drag and drop, and can minimize or expand them by clicking the title bar of each box. Use the Screen Options tab to unhide more boxes (Excerpt, Send Trackbacks, Custom Fields, Discussion, Slug, Author) or to choose a 1- or 2-column layout for this screen.') . '</p>' .
'<p>' . __('<strong>Title</strong> - Enter a title for your post. After you enter a title, you&#8217;ll see the permalink below, which you can edit.') . '</p>' .
'<p>' . __('<strong>Post editor</strong> - Enter the text for your post. There are two modes of editing: Visual and HTML. Choose the mode by clicking on the appropriate tab. Visual mode gives you a WYSIWYG editor. Click the last ico
@rinatkhaziev
rinatkhaziev / acm_dfp.php
Created January 18, 2012 05:15
ACM DFP Setup
<?php
// Whitelist default double click url
add_filter( 'acm_whitelisted_script_urls', 'rk_acm_whiltelisted_script_urls');
function rk_acm_whiltelisted_script_urls( $whitelisted_urls ) {
$whitelisted_urls = array( 'ad.doubleclick.net' );
return $whitelisted_urls;
}
// Tokenize url
add_filter( 'acm_default_url', 'rk_acm_default_url' ) ;
@johnpbloch
johnpbloch / Vagrantfile
Created April 16, 2013 03:21
Puppet awesomesauce for Vagrant
config.vm.provision :puppet do |puppet|
# Add a folder in your root named .ppt
puppet.manifests_path = ".ppt/manifests"
# vagrant.pp is your main manifest and goes in .ppt/manifests
puppet.manifest_file = "vagrant.pp"
# Add puppet modules in .ppt/modules as git submodules; they will be pre-installed in Vagrant this way
puppet.module_path = ".ppt/modules"
# Config files, etc. go in .ppt/files. fileserver.conf (see below) defines the path for puppet to add
# when looking for files. That way, you can reference files with puppet:// protocols. Make sure you
# add the directory defined in fileserver.conf as a shared directory in the main Vagrantfile config
@kingkool68
kingkool68 / Seamless Git Deployment
Last active December 17, 2015 05:09
To push code changes to text servers I do this.
We have a private Git running on a server somewhere which we consider our central repository. Inside the .git/hooks/post-recieve is the following:
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then