Skip to content

Instantly share code, notes, and snippets.

View danielbachhuber's full-sized avatar

Daniel Bachhuber danielbachhuber

View GitHub Profile
@westonruter
westonruter / WordPress-Dependencies.md
Last active October 11, 2016 22:43
Gathering posts about the development of a core dependency system for WordPress.

I've been noticing that there seems to be a lot of interest and momentum lately surrounding plugn/theme dependencies. I am very excited about this. WordPress desperately needs a core dependency solution so that we can move the route of plugins being tiny interoperable building blocks, like what we've seen with NPM.

Here's a running list of the stuff I've been seeing lately about WordPress dependencies:

  • Strategies to implement selective loading of plugins on StackExchange
  • Nacin's suggestion that Dependencies be tackled for GSoC: > Dependencies. Allow plugins and themes to be dependent of one another. A theme could require a plugin or example, and WordPress would handle installing that plugin when you install that theme. Similar idea: Compatibility metrics. (Or: Can we be sure it is safe to upg
@joehoyle
joehoyle / .zshrc
Last active December 22, 2015 22:19
v() {
DIR=`echo $PWD | sed 's,.*/projects,,'`
ARGS=$*
ssh -t vagrant@192.168.50.10 "cd /srv/www${DIR} ; ${ARGS}" 2> /dev/null
}
alias wp="v wp"
alias grunt="v grunt"
@tomjn
tomjn / gist:6140172
Last active December 20, 2015 13:39
If you're lucky enought o be running WordPress on PHP 5.5, you can use generators for your post loops like this
<?php
// with the above we can now do things like this:
foreach ( posts_loop() as $p ) {
get_template_part( 'content', 'page' );
comments_template( '', true );
}
// put this below in your functions.php:
@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
@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
@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' ) ;
@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
@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
@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 / 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 );