Filter an HTML Select Dropdown in Regex

I have had a repeated need for this.

Baiscally what it does it turns:


Awesome Number
Top Number

into

Awesome Number is 99
Top Number is 100

Sometimes useful, decided to save & share :nerd:

Search:
/([^<]+)/
Replace:
$2 is $1

Canon Powershot SX230HS and CHDK

A while back I heard Douglas Kirkland say “The best camera to use ? The one that you have with you.”, and that phrase has haunted me ever since. Even though I’ve wanted to have a DSLR for a long time now, and still haven’t managed to buy one, today I decided that it was time I got a camera. A camera that I can have, and have with me. And I think it is a good starting point at the moment. More

How to clean an URL with Regex

A regex pattern to fix 1st level domains. Useful for when data is submitted from users:

Turns this:

google.com
www.google.com
google.com/
http://google.com
http://www.google.com
http://www.google.com/

Into This:

http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com
http://www.google.com

Expression:

Search: 
((http://)?(www.)?([wd-]*?.)(w{2,4})/?)
Replace:
http://www.$4$5

PHP Usage:

	# Fix the URL:
	$fixedURL = preg_replace('/((http://)?(www.)?([wd-]*?.)(w{2,4})/?)/i', 'http://www.$4$5', $previousURL);

Danish ZIP Codes (PHP Array)

Just in case someone needs this some day.

Usage: [0] => Region Title, [1] => Min ZIP Number, [2] => Max ZIP Number

$denmark = array(
array('København', 1000, 1799),
array('Frederiksberg', 1800, 2999),
array('Nordsjælland', 3000, 3699),
array('Bornholm', 3700, 3799),
array('Færøerne', 3800, 3899),
array('Grønland', 3900, 3999),
array('Øvrige Sjælland', 4000, 4999),
array('Fyn', 5000, 5999),
array('Sønderjylland', 6000, 6999),
array('Vestjylland', 7000, 7999),
array('Østjylland og Midtjylland', 8000, 8999),
array('Nordjylland', 9000, 9999)
);

Trouble replacing an ampersand ( & ) in PHP with str_replace – Solution

Now this took about a half an hour until I figured this out. Posting this, just in case someone finds it – I hope I save you 30 minutes.
I fetched a link from HTML content with preg_match(), and I had to replace some data in that link.

str_replace("upgrade-plugin&plugin",'update-selected&plugins', $updateItem);

For some reason – the ampersand ( & ) wasn’t found and so the string wasn’t replacing it. At the end I figured it’s the ampersand problem, and here is the fix (sometimes the simplest things…)

str_replace("upgrade-plugin&plugin",'update-selected&plugins', $updateItem);

Update:
I had to use this method, because the ampersand was extracted from HTML document with preg_match. To avoid issues like this – use

html_entity_decode()

Get and Display Custom Taxonomies function

The new WordPress Custom Post types are awesome, and if you do want to categorize them differently, you can even add your own Taxonomies for them (like categories, tags, and even introduce your own names, like “colors”, “style”, etc. etc.). All seem unlimited, but I found myself struggling finding a way to reasonably display them afterwards.
Hope this function helps, if you ever find yourself in my position

function get_taxonomy_display($taxonomy_name) {
return strip_tags( get_the_term_list( $wp_query->post->ID, '$taxonomy_name', '', ', ', '' ) );
}
$custom_categories = get_taxonomy_display('enter_your_taxonomy_name');
echo $custom_categories

Pseudo Class Fix in IE

CSS Pseudo Classes are just plain awesome.

Unfortenatley Internet Explorer 6 and 7 doesn’t support them. I am very thankful that I found a Javascript Fix for that, so I wanted to share.

This little awesome JavaScript not only fixes that, but a whole bunch of unsupported things in IE.

[info]List of fixes: http://ie7-js.googlecode.com/svn/test/index.html [/info]

[download]http://code.google.com/p/ie7-js/[/download]

WordPress archive title display switch

While creating my Blankwork I was looking for different examples of archives pages, since I never used them much. In the end, I was pretty disapointed with all of them.

For example, an else if statement list with opening PHP tags every time, repeating same text and adding comments in between. In my code editor it looked like one big rainbow. An example (which is short and a bit more readable):

Archive for category :

Archive for tag :

I like when everything is clear and easy readable even in code. of course you can dig-through anything, but I made this little snippet just for those, who want a little more clean archives code.

So, I made my own little snippet, which is a bit more Designer friendly, here you go:



Archive

BlankWork – The WordPress Blank Framework

When I first started theming WordPress, most difficult thing for me to do was to find something that I could base my work on. I didn’t exactly start everything from scratch. Well – in the end I had to, because I couldn’t find any blank frameworks for WordPress.
While I did find about 10 stripped down templates – most of them didn’t suit my needs. I wanted a simple tiny framework to base my own code on, not tons of code that I have to dig through and then try to fit my work in.
So – I am working on The BlankWork, which is going to offer a basic (tiny tiny) framework to start your theme on. Currently I’m thinking of making the BlankWork in some ways like Initializr, so when downloading you would get some options (whether you want reset css or not, or maybe you want some predefined css styles, or maybe you want threaded comments, etc. ). This is definitely going to be open-source and I hope that with time I will succeed finding some contributors to the development and updating the theme as well.
I am so sure of this, that I already bought the domain – blankwork.net, I can’t wait, I can’t wait.