Skip to content

Instantly share code, notes, and snippets.

View scribu's full-sized avatar

Cristi Burcă scribu

View GitHub Profile
@scribu
scribu / tabbed-widgets.diff
Created September 16, 2010 15:06
tabbed widgets fix
We couldn’t find that file to show.
@scribu
scribu / array_insert.php
Created September 20, 2010 18:53
array_insert()
<?php
/**
* Insert an array into another array before/after a certain key
*
* @param array $array The initial array
* @param array $pairs The array to insert
* @param string $key The certain key
* @param string $position Wether to insert the array before or after the key
* @return array
@scribu
scribu / category-custom-fields.php
Created October 8, 2010 13:24
Category Custom Fields
<?php
/*
Plugin Name: Category Custom Fields
Author: scribu
*/
class Category_Custom_Fields {
function init() {
@scribu
scribu / copy-widgets.php
Created October 12, 2010 08:04
Copy entire sidebar configuration from one site to another
<?php
/**
* Copy entire sidebar configuration from one site to another
*
* @param int $old_site The id of the original site
* @param int $old_site The id of the site to copy the widgets to
*/
function copy_widgets($old_site, $new_site) {
global $wpdb, $blog_id;
@scribu
scribu / gist:625748
Created October 14, 2010 07:12
Backtrace Deprecated
<?php
/*
Plugin Name: Better Deprecation Warnings
Author: scribu
Version: 1.0
*/
class Backtrace_Deprecated {
function init() {
@scribu
scribu / backtrace-errors.php
Created October 14, 2010 07:25
Backtrace Errors
<?php
// Forked from: http://stackoverflow.com/questions/1159216/how-can-i-get-php-to-produce-a-backtrace-upon-errors/1159235#1159235
function process_error_backtrace($errno, $errstr, $errfile, $errline) {
if(!(error_reporting() & $errno))
return;
switch($errno) {
case E_WARNING :
case E_USER_WARNING :
case E_STRICT :
@scribu
scribu / gist:626060
Created October 14, 2010 11:32
php ini
# add these lines in your .htaccess file
php_value memory_limit 128M
php_value upload_max_filesize 128M
php_value post_max_size 128M
php_value max_execution_time 120
@scribu
scribu / gist:626355
Created October 14, 2010 15:19
locate_skin_url()
<?php
function locate_skin_url( $name ) {
$dir = false === strpos($name, '.css') ? 'js' : 'css';
if ( file_exists(STYLESHEETPATH . "/$dir/$name")) {
$url = get_bloginfo('stylesheet_directory') . "/$dir/$name";
} elseif ( file_exists(TEMPLATEPATH . "/$dir/$name") ) {
$url = get_bloginfo('template_directory') . "/$dir/$name";
} else {
@scribu
scribu / gist:636827
Created October 20, 2010 17:02
WP_Query Debug
<?php
function wp_query_debug() {
global $wp, $wp_query;
echo '<pre>';
var_dump($wp->matched_rule);
print_r($wp_query);
echo '</pre>';
}
@scribu
scribu / gist:642361
Created October 23, 2010 16:04
get_ascii_array()
<?php
/**
* Returns an array containing the ASCII codes of a string (useful for decomposition)
* Example: print_r(get_ascii_array('ș'))
*
* @param string $str
* @return array
*/
function get_ascii_array($str) {