For a new hosting service I am using the new WordPress 3.x multi-site features extensively. For new customers I added a custom theme based on the default Twenty Ten theme. As the main audience aren’t native speakers – English that is – I also need translations for my custom theme. I followed the path twentyten is showing my copying my .mo file into a subdirectory of the theme called languages. Unfortunately the file is not loaded automagically so you need some custom code which I added to my custom theme’s functions.php file.
1
2
3
4
5
6
7
| const MY_THEME = 'name of your theme';
function mytheme_setup() {
// The first occurence of MY_THEME is the name of your textdomain as used in the templates
load_theme_textdomain( MY_THEME, str_replace('twentyten', MY_THEME, TEMPLATEPATH) . '/languages' );
}
// Tell WordPress to run mytheme_setup() when the 'after_setup_theme' hook is run.
add_action( 'after_setup_theme', 'mytheme_setup' ); |
If you are defining your own version of twentyten_setup() just add the line with load_theme_textdomain(…) in there. OOP in WordPress would be nice here and make things so much easier!
For a new hosting service I am using the new WordPress 3.x multi-site features extensively. For new customers I added a custom theme based on the default Twenty Ten theme. As the main audience aren't native speakers - English that is - I also need translations for my custom theme. I followed the ...
keine
Setting up your own website to display a collection of videos hosted on YouTube is as easy as following the six simple steps below.
- Download and install WordPress 3.0
- Download, install and activate the Videographer WordPress Theme
- Download, install and activate the WP YouTube plugin by Jens Törnell
- Download, install and activate the WP-PostRatings plugin by Lester ‘GaMerZ’ Chan
- Follow the rest of the instructions in paragraph Setting up Videographer on the Videographer site.
- You are ready to go to publish your first video!
Have a look what a site for viral videos will be like once filled with lots of content.
Setting up your own website to display a collection of videos hosted on YouTube is as easy as following the six simple steps below.
Download and install Wordpress 3.0
Download, install and activate the Videographer Wordpress Theme
Download, install and activate the WP YouTube plugin by Jens Törnell
Download, install and activate the WP-PostRatings plugin by Lester 'GaMerZ' ...
keine
The Seagull framework which we love to use for our projects offers two built-in methods for session management: files and database.
In our podcast project we started out using the file based sessions years ago. A while back we switched to so-called extended sessions which are saved in the database. Not so long ago we switched back to files again as the requests just for the sessions to the database became a serious bottleneck in our installation.
We did a relaunch of our podcast service beginning of September with sessions still stored to in files. This might have worked well if we had not switched to serving the website’s resources including the sessions through a high available NFS4 server. The server with the active NFS4 export hit its maximum capacity randomly making the service unusable.
I could have tried to switch back to the database handler as we have new, much more powerful machines. But I did not even bother as I assumed I’d eventually run into the same problems as before. Instead I researched sessions saved in memory. I knew that PHP offers shared-memory sessions. I tried that a while ago with no luck. During my research I came across memcached sessions. As I am already using memcache to store objects in the application I thought this would be ideal. And as it turned out today when applying the following changes to our live system it is!
To make Seagull work with memcached sessions only two minor changes to the code base had to be made. In the SGL core library Session.php change the constructor as follows:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
| if ($conf['session']['handler'] == 'database') {
$ok = session_set_save_handler(
array(& $this, 'dbOpen'),
array(& $this, 'dbClose'),
array(& $this, 'dbRead'),
array(& $this, 'dbWrite'),
array(& $this, 'dbDestroy'),
array(& $this, 'dbGc')
);
} elseif ($conf['session']['handler'] == 'memcache') {
session_save_path($conf['session']['save_path']);
} else {
session_save_path(SGL_TMP_DIR);
} |
The second change is in the _init function:
1
2
3
4
5
6
7
8
9
10
11
12
13
| if ($conf['session']['handler'] == 'file') {
// manually remove old session file, see http://ilia.ws/archives/47-session_regenerate_id-Improvement.html
$ok = @unlink(SGL_TMP_DIR . '/sess_'.$oldSessionId);
} elseif ($conf['session']['handler'] == 'database') {
$value = $this->dbRead($oldSessionId);
$this->dbDestroy($oldSessionId);
$this->dbRead(session_id()); // creates new session record
$this->dbWrite(session_id(), $value); // store old session value in new session record
} elseif ($conf['session']['handler'] == 'memcache') {
// do nothing - just do not complain or fail
} else {
die('Internal Error: unknown session handler');
} |
So just add the lines with memcache and below. That’s it!
To make Seagull use the memcache session handler adjust your config accordingly, e.g. my local one looks like the following:
1
2
| $conf['session']['handler'] = 'memcache';
$conf['session']['save_path'] = 'tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15'; |
Live we use several memcache servers which you can address with a comma separated list of servers, e.g.
1
2
| $conf['session']['handler'] = 'memcache';
$conf['session']['save_path'] = 'tcp://127.0.0.1:11211?persistent=1&weight=1&timeout=1&retry_interval=15,tcp://127.0.0.1:11212?persistent=1&weight=2&timeout=1&retry_interval=50'; |
Make sure your memcache server(s) listen(s) on the correct IP address and port. Otherwise you will get a blank screen and/or a nasty error message.
Now you should be ready to go. Experience a never before known speed of your PHP applcation!
The Seagull framework which we love to use for our projects offers two built-in methods for session management: files and database.
In our podcast project we started out using the file based sessions years ago. A while back we switched to so-called extended sessions which are saved in the database. Not so long ago ...
einer
Heute ist WordPress in der Version 2.8 erschienen. Da ich momentan an einem WordPress-Plugin arbeite, interessant mich nicht nur, was sich an der Oberfläche oder am Funktionsumfang geändert hat, sondern auch was es für Neuerungen im Inneren gibt.
Ein diff zwischen WordPress 2.7.1 und WordPress 2.8 gibt mir 1194 Zeilen zurück. Ein Blick auf die Änderungen zeigt mir, dass der Code aufgeräumt. Es kommen jetzt z.B. die neuen Funktionen der esc_-Serie zum Einsatz.
Eine der spannendsten Neuerungen dürfte die neue Widgets API sein. Um ein mehrfach instanzierbares Widget zu erstellen, wird die Klasse WP_Widget erweitert. Die drei Methoden widget(), form() und update() müssen in der eigenen Klasse überschrieben werden.
Die Menüs lassen sich jetzt mittels Plugin aufbauen/umordnen. Einige Fantasie vorausgesetzt, öffnet das ungeahnte neue Möglichkeiten. Das Menü war bisher sehr starr und hat damit das Layout aller Themes stark bestimmt. Mit einem programmatisch änderbaren Menü werden wir interessante, neue Layouts sehen.
Heute ist Wordpress in der Version 2.8 erschienen. Da ich momentan an einem Wordpress-Plugin arbeite, interessant mich nicht nur, was sich an der Oberfläche oder am Funktionsumfang geändert hat, sondern auch was es für Neuerungen im Inneren gibt.
Ein diff zwischen Wordpress 2.7.1 und Wordpress 2.8 gibt mir 1194 Zeilen zurück. Ein Blick auf die ...
keine
Being inspired by a long talk yesterday at Berlin2.0 I decided to dig into Google´s offerings on the AdWords API today. Getting an API code is terrifying difficult. First you have to create a My Customer Center account if you do not have own one, yet. Create your AdWords API account and have a credit card ready. You need it to get the developer and application tokens.
I´d hope to find a toolkit from my favorite package source PEAR or for the Zend Framework but since there is an offering from code.google.com nobody bothered to develop anything. I downloaded the Google APIlity PHP Library for AdWords and the APIlity MySQL Schema to modify it for my own purposes.
Being inspired by a long talk yesterday at Berlin2.0 I decided to dig into Google´s offerings on the AdWords API today. Getting an API code is terrifying difficult. First you have to create a My Customer Center account if you do not have own one, yet. Create your AdWords API account and have ...
keine