Skip to content

Instantly share code, notes, and snippets.

@bolstad
bolstad / hip_has_children.php
Created May 14, 2012 10:18
Does the current page got any children?
if (!function_exists('hip_has_children'))
{
function hip_has_children($child_of = null)
{
// original code based on http://forrst.com/posts/WordPress_has_children_function-DmS
$posttype = get_post_type($child_of);
if(is_null($child_of)) {
global $post;
$child_of = ($post->post_parent != '0') ? $post->post_parent : $post->ID;
@bolstad
bolstad / wpv_filter_shortcode_start-bugfix
Created May 1, 2012 12:35
Bug in wpv_filter_shortcode_start() ?
Hi, I got this strange problem when displaying a View Template on an archive page, everything was working correct and I set Layout Style to 'Table' with 'Include field names in table headings' and I got a nice table with headings.
But the Sort function wasn't working! When clicking on the headings I was linked to one of the pages listed in the table, but with the sorting parameters added to it (
(?wpv_column_sort_id=post-link&wpv_column_sort_dir=desc&wpv_paged=1&wpv_paged_max=0&wpv_widget_view_id=0&wpv_post_id=1288).
I digged trough the source of the page and found that the 'wpv-filter-form ' that handle the sorting had the action-parameter set to the random subpage, and not the current url of the archive page that I was visiting.
I search the wp-views source and and found this, wpv_filter_shortcode_start() - the function that create to form for the sorting, use get_permalink() to set the ACTION-attribute for the form. Since get_permalink() doesn't work well outside the loop and can't give a correct self r
@bolstad
bolstad / gearman on debian
Created April 19, 2012 16:24
setup gearman
apt-get install build-essential libboost1.42-dev libboost-dev libboost-program-options-dev libboost-thread-dev libevent-dev uuid-dev php-pear php5-dev
wget https://launchpad.net/gearmand/trunk/0.32/+download/gearmand-0.32.tar.gz
wget http://pecl.php.net/get/gearman-1.0.2.tgz
<?php
echo "memory use: " . memory_get_usage() . "\n";
$configdir = __FILE__;
$configdir = preg_replace('|wp-content\/.*|','',$configdir);
$configdir .= 'wp-load.php';
error_reporting(E_ALL);
@bolstad
bolstad / bulktimezone.php
Created March 27, 2012 11:47
bulk timezone changer for wordpress
<?php
echo "memory use: " . memory_get_usage() . "\n";
$configdir = __FILE__;
$configdir = preg_replace('|wp-content\/.*|','',$configdir);
$configdir .= 'wp-load.php';
error_reporting(E_ALL);
@bolstad
bolstad / disable-plugins-when-doing-local-dev.php
Created June 24, 2011 12:10 — 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/
*/