You are here: Home » Development

Category Archives: Development

[How To] (De-)register a Style Sheet in WordPress

How do register styles

Just like JavaScript, CSS files shouldn’t be added to WordPress directly, but by using the WordPress API.

If you want to add your own CSS file to WordPress, there are two method calls you should be aware of:

wp_register_style
wp_enqueue_style

the usage is pretty simple:

wp_register_style('css-name', 'location-to-your-css-file', __FILE__), array(), 'version-number', 'screen');
wp_enqueue_style('css-name');

this will register your CSS file and add it to the site header.

How to deregister styles

Now, if you want to get rid of a Style Sheet that is added by your theme or a plugin you use, there is also a simple way to do that (given that the methods mentioned above are used to add the Style Sheet):

wp_deregister_style (unfortunately, no description is available on the WordPress site)

You will have to know the name with which the Style Sheet is registered. For example, if you use my jQuery Colorbox plugin and choose the first theme, the Style Sheet will be registered with the name “colorbox-theme1″.

Now, in order to deregister the Style Sheet, you’ll have to add the following lines to your functions.php:

add_action( 'wp_print_styles', 'custom_deregister_styles', 100 );
function custom_deregister_styles() {
  wp_deregister_style( 'colorbox-theme1' );
}

(links)
wp_register_style @ WordPress Codex
wp_enqueue_style @ WordPress Codex

Also posted in Plugins, WordPress | Tagged , , , , | Leave a comment

[How To] Load Javascript in WordPress

If your WordPress plugin or theme uses JavaScript, it is essential to know how to include it so that you don’t break other JavaScript libraries or plugins/themes that use JavaScript.

The straight forward way to load JavaScript is of course to embed a script tag with the JS file as a src attribute:

<script src="my-plugin/js/jquery.js"></script>

Of course you can load your own custom JavaScript that way, but don’t do that if you are loading a JavaScript library! Check the list of JavaScript libraries supplied by WordPress. Do not include a library with your theme/plugin if WordPress already brings it along!!!

WordPress offers a nice and easy way to load JavaScript libraries, the wp_enqueue_script() function. If you are including a JavaScript file that depends on e.g. jQuery, you can just tell WordPress and it will load jQuery for you!

Example from my jQuery Colorbox plugin:

wp_enqueue_script('colorbox', plugins_url('js/jquery.colorbox-min.js', __FILE__), array('jquery'), '1.3.6');

I tell WordPress to load the Colorbox JavaScript library that depends on jQuery. WordPress makes sure that the jQuery library is loaded before my JavaScript is loaded so everything will work as expected.

(links)
wp_enqueue_script description @ WordPress
JavaScript libraries supplied by WordPress

Also posted in JavaScript, WordPress | Tagged , , , , , , | Leave a comment

[development] WordPress cheat sheets

I have compiled a list of four cheat sheets for WordPress development.

Woorkup WordPress cheat sheet

Woorkup WordPress cheat sheet

(by Woorkup)

Graphicrating WordPress cheatsheet

Graphicrating WordPress cheatsheet

(by Graphicrating)

An extensive list, available online. A reader of that blog uploaded the cheat sheet as a PDF here.

WP TOY Theme development checklist

WP TOY Theme development checklist

(by WP TOY)

Tekka SEO cheat sheet

Tekka SEO cheat sheet

(by Tekka)

Also posted in WordPress | Tagged , , , | 1 Comment

[development] jQuery cheat sheets

It is always difficult to remember the syntax of APIs. This is where cheat sheets come in handy.

These are three jQuery cheat sheets that I found on the web:

Future Colors.ru jQuery cheatsheet

Future Colors.ru jQuery 1.4 cheatsheet

(by Future-Colors.ru)

Impulsestudios.ca jQuery cheatsheet

Impulsestudios.ca jQuery 1.4 cheatsheet

(by Impulsestudios.ca)

Woorkup.com jQuery 1.3 cheatsheet

Woorkup.com jQuery 1.3 cheatsheet

(by Woorkup.com)

Also posted in JavaScript | Tagged , , , | Leave a comment

[development] Increase your jQuery performance

Giulio Bai took the time to sum up ten things to do to speed up jQuery performance.

Read the post here.

Also posted in JavaScript | Tagged , , | Leave a comment

[software] einfache Uebersicht von Git: Git cheatsheet

Zack Rusin hat bereits 2007 eine einfache Uebersicht ueber Git erstellt und auf seinem Blog zur Verfuegung gestellt.

Mir hat es sehr geholfen, daher verlinke ich hier mal darauf.

Git Cheat Sheet

Git Cheat Sheet

(links)
Git Cheatsheet @ Zack Rusin

Also posted in Software | Tagged , , , , | Leave a comment

[software] Pushing and Tracking Remote Branches mit Git

Ich nutze git um meine privaten Projekte zu versionieren.

Da ich auf verschiedenen Rechnern an den Projekten arbeite und die Projekte auch anderen zugaenglich machen moechte, nutze ich github als zentrales Repository.

Branches in git funktionieren nicht ganz so wie wie bei SVN oder Perforce, also will ich hier kurz die Befehle festhalten, die ich brauche, um einen lokalen Branch zu erstellen, diesen auf github zu pushen und dann den lokalen mit dem Branch auf github zu verbinden.

Erstellung eines lokalen Branches:

git branch <local branch name>

Den Branch auf das zentrale Respository pushen:

git push origin <local branch name>

Jetzt gibt es den Branch zwar lokal und auf github, aber der lokale Branch und der zentrale sind nicht verbunden (der lokale trackt nicht den zentralen). Das kann man mit diesem Kommando erreichen (um genau zu sein wird der lokale Branch geloescht und ein neuer erstellt, der den zentralen dann trackt):

git branch -f <local branch name> origin/<remote branch name>

Jetzt kann man lokale Aenderungen mit git push auf den zentralen Branch pushen und Aenderungen vom zentralen Branch holen (git pull).

(links)
git
github

Also posted in Software | Tagged , , , | Leave a comment

[software] Java Decompiler – JD-Gui

Immer wieder mal kommt man an den Punkt, wo man den in einem Jar kompilierten Quellcode ansehen moechte.

Im Moment verwende ich dafuer JD-Gui.

JD-Gui ist einfach und schnell zu bedienen und sogar fuer den kommerziellen Einsatz kostenlos. Leider nicht Open Source, aber man kann ja nicht alles haben…

JD-Gui

JD-Gui

(links)
JD-Gui

Also posted in Software | Tagged , , , , , , , | Leave a comment