Skip to content

Instantly share code, notes, and snippets.

View nhaskins's full-sized avatar

Nathan A Haskins nhaskins

  • Haskins Information Technology LLC
  • St Louis, MO
View GitHub Profile
@nhaskins
nhaskins / wordpress mysql find and replace localizers
Created May 8, 2010 22:24
wordpress mysql find and replace localizers
update wp_posts set guid = replace(guid, 'simplehelix.com', 'com');
update wp_posts set post_content = replace(post_content, 'simplehelix.com', 'com');
update wp_options set option_value = replace(option_value, 'simplehelix.com', 'com');
update wp_postmeta set meta_value = replace(meta_value, 'simplehelix.com', 'com');
@nhaskins
nhaskins / wordpress quick drop down menus
Created May 8, 2010 22:43
wordpress quick dropdown menus
//I think Kreisi originally wrote this, quite handy
//cutting and pasting this into a header does the trick to
//get rolling on menus in a rush.
//remember to include the jQuery library.
<?php wp_enqueue_script('jquery'); ?>
<script type='text/javascript'>
jQuery(document).ready(function() {
jQuery("#dropmenu ul").css({display: "none"}); // Opera Fix
@nhaskins
nhaskins / HTML skeleton
Created May 10, 2010 01:11
HTML skeleton
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="description" content="">
<meta name="keywords" content="">
<!-- <link rel="stylesheet" href="css/somefile.css" /> -->
<!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> -->
<title></title>
</head>
@nhaskins
nhaskins / .htaccess inline php
Created May 10, 2010 01:12
(mt) .htaccess for inline php in many types
AddHandler php5-script .html .js .php .htm
@nhaskins
nhaskins / php .zip read file names
Created May 10, 2010 01:14
php open .zip and read file names
$za = new ZipArchive();
$za->open('test.zip');
for ($i=0; $i<$za->numFiles;$i++) {
$thing = $za->statIndex($i);
echo $thing[name];
echo "<br /><br />";
}
@nhaskins
nhaskins / wordpress get most recent post by category
Created May 10, 2010 01:16
wordpress get most recent post by category
<?php $my_query = new WP_Query('category_name=yournamehere&posts_per_page=1');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID; ?>
<?php the_title(); ?>
<?php the_content(''); ?>
<?php endwhile; ?>
@nhaskins
nhaskins / wordpress remove images from content
Created May 10, 2010 01:18
wordpress remove images from content
<?php echo preg_replace('/<img[^>]+./','',get_the_content()); ?>
@nhaskins
nhaskins / wordpress override site URL
Created May 10, 2010 01:20
wordpress override site URL
define('WP_HOME','http://');
define('WP_SITEURL','http://');
//add this to the wp-config.php file, omit the trailing slash in the URL
//damn helpful if you move a site, and forget to update the site info
@nhaskins
nhaskins / wordpress nextgen gallery snippits
Created May 10, 2010 01:21
wordpress nextgen gallery snippits
@nhaskins
nhaskins / mailchimp table converter
Created May 11, 2010 02:08
mailchimp table cleaner/font tag adder
//fontThisTable() inserts font tags before and after all the td tags. Size and style are optional.
function fontThisTable($someTable, $fontSize, $fontStyle){
if(!$fontSize){$fontSize = '2';}
if(!$fontStyle){$fontStyle = 'Arial';}
$someTable = preg_replace('|<td.*?>|', '<td>', $someTable);
$someTable = preg_replace('|<td>|', '<td><font face="'.$fontStyle.'" size="'.$fontSize.'">', $someTable);
$someTable = preg_replace('|</td>|', '</font></td>', $someTable);
return $someTable;