How to enable multi user support in WordPress 3.0

Since version 3.0, regular WordPress and WordPress MU are merged into WordPress 3. All betas of WP 3.0 had Site Admin section in backend (even if upgraded from regular WordPress), but since RC and final release this option disappeared. It is a hidden part of WordPress 3.0 and has to be activated manually with a a few edits to a WordPress installations wp-config.php file. You need FTP or shell access to do it.

Follow the simple 10 minutes max. instructions to activate Multi User functionality in your WordPress 3.0 installation:

  1. Disable all plugins. You can re-enable them after multi-site has been configured.
  2. Activate the multi-site features of WordPress 3.0 by adding this line of code to your wp-config.php file:
    /** Enable or disable Worpress Multi-site features **/
    define('WP_ALLOW_MULTISITE', true);
  3. Refresh your Dashboard then visit Tools -> Network. You will see a screen that looks similar to the one in the picture below. Read onwards before you make any configuration changes.
  4. If you want to install your additional blogs on sub-domains instead of sub-directories you will need to create a wildcard DNS record on your server to enable the virtual host (sub-domain) functionality of WordPress 3.0. Your server must support wildcard DNS records for you to do this.
  5. You need to install the now activated WordPress 3.0 Network settings
    • Find the Network settings page in your WordPress admin panel (Tools -> Network)
    • Choose whether you want to use sub-domains or sub-folders for the additional blogs
    • Type a name for your network of sites
    • Set your admin email address
    • Click “Install”
  6. After a minute or two you will be presented with a configuration screen. Back up your .htaccess and wp-config.php files before you proceed to follow the instructions provided on that configuration screen.
    • As a precautionary measure to prevent visitors of non-existent sites from being greeted by 404 error messages, redirect them to a URL of your choice by adding the below code to the bottom your wp-config.php file:
      /* Send visitors to non-existent blogs here */
      define( 'NOBLOGREDIRECT', 'http://yourdomain.com/' );

      change http://yourdomain.com/ to the main blog you want to redirect to.

    • Log out then log back in.
  7. You will now need to go through your settings to enable or disable the new options provided by WordPress Multi Site.

Be careful when adding plugins!

Not all WordPress plugins are Multi Site compatible. If you activate an incompatible plugin you could kill your network of sites!

To fix a broken network try deleting the folder of the plugin that caused the outage from /wp-content/plugins/.

Disable default WordPress search query


If you’re going to implement your custom wordpress search (not wordpress native) on search.php template – for example using Google Custom Search or Bing – you might have everything working ok, but wordpress is still performing search queries to database which can slow down your site. This is because wordpress treats search.php template as search page, no matter what is inside and prepares post list before it’s loaded.

So to avoid this, you need to use the following code:

function _cancel_query( $query ) {

	if ( !is_admin() && !is_feed() && is_search() ) {
		$query = false;
	}

	return $query;
}

add_action( 'posts_request', '_cancel_query' );

And to remove search form from that page (probably you won’t need it) you can use following:

add_filter( 'get_search_form', create_function( '$a', "return null;" ) );

This can be embedded to any of your plugin code or functions.php inside your theme.

Search & Replace via command line in Linux

I needed to replace domain name in MySQL DB dump which was 700MB, so i’ve googled a bit to find a command line expression. If you need to search/replace in files via command line, you can simply use following command (if perl is installed):

perl -pi -w -e 's/search/replace/g;' *.php
-e means execute the following line of code.
-i means edit in-place
-w write warnings
-p loop

For example we can replace css link in all template files:

As each expression is a regular expression you’ve got to escape the special characters such as forward slash and .

\.\.\/css\/all\.css

So the final line of code ends up as:

perl -pi -w -e 's/\.\.\/css\/style\.css/all\.css/g;' *.php

How to make iPhone ringtone for free by yourself

Bought an iPhone and have no idea how to make personal ringtones? Wish to have your ringtone from previous phone? Or just don’t want to pay Apple for ringtone? No problem. Actually adding your ringtone to iPhone is really easy. It should be a file with .m4r extention which is actually .m4a file. So just convert your song from mp3 or another format to AAC, change extension to .m4r and you’re done! NOTE: A song duration must be not longer than 40 seconds to be imported as ringtone.

Here’s the step-by-step howto:

  1. Open iTunes.
  2. Find the song that you want to make into a ringtone.
  3. Listen to the song and find the part of it you want to use. The chorus may be a good place to start.
  4. Write down the start and stop times of the clip.
  5. Right-click the song and select “Get Info.”
  6. Click the “Options” tab.
  7. Type in the start time of your ringtone in the text box next to “Start Time” in the minutes:seconds (i.e. 2:01) format.
  8. Type in the end time of your ringtone in the text box next to “Stop Time.” Make sure the ringtone is no more than 40 seconds long.
  9. Click “OK.”
  10. Right-click your song again and select “Convert Selection to AAC.” Wait for iTunes to convert your song. It will create a duplicate version.
  11. Right-click the ringtone and select “Delete.”
  12. Click on the “Keep Files” button.
  13. Find the file. It’s usually in your User folder under Music > iTunes > iTunes Music and under the band’s name. It will have an extension of “m4a.”
  14. Replace the “m4a” extension of your ringtone with “m4r”. You can either double-click slowly to rename your file, or right-click and select “Get Info” on a Mac or “Rename” on a Windows PC.
  15. Click “Use .m4r” or the PC equivalent when the system warns you that the change may affect the use of your file.
  16. Double-click the ringtone file. ITunes will automatically add it to your ringtones folder in your iTunes Music Library.
  17. Connect your iPhone and sync your ringtones.

How to make Magento’s checkout in a one page

magento_logo

Dealing with Magento we’ve noticed there’s with 6 steps checkout. Magento is not very flexible to customize so 1 step there’s 1 step checkout plugins you can buy for this. Here’s what I’ve found about that.

Basicaly a page can be shown in Magento using simple Core_Template type. Basically all code is set inside the .phtml file so it can be shown on every possible page or block, meaning it’s object independent, no inheritance. Something you can call from with your layout files like


If you have such special requirements for your site below is the code that you can place on whatever file you wish and include it yout tempalte as block type core/template.

$checkout = Mage::getSingleton(’checkout/type_onepage’);
/*
* One page checkout consists of following steps
* (1) Customer login method aka Checkout method
* (2) Billing information (address)
* (3) Shipping information (address)
* (4) Shipping method
* (5) Payment information
* (6) Order review, in short: DO THE ORDER
*/

//STEP(1)
$checkout->saveCheckoutMethod(’guest’);

//STEP(2)
$checkout->saveBilling($billingAddress, false);

//STEP(3)
$checkout->saveShipping($shippingAddress, false);

//STEP(4)
$checkout->saveShippingMethod(’flatrate_flatrate’);

//STEP(5)
$checkout->savePayment(array(’method’=>’checkmo’));

//STEP(6)
/*
* $checkout->saveOrder() returns array holding empty object
* of type Mage_Checkout_Model_Type_Onepage
*/
$checkout->saveOrder();

And here is the example of how the $address variables are supose to look

[billing] => Array
(
[address_id] => 5
[firstname] => Branko
[lastname] => Ajzele
[company] => Surgeworks
[email] => [email protected]
[street] => Array
(
[0] => Address part 1
[1] => Address part 2
)

[city] => Osijek
[region_id] =>
[region] =>
[postcode] => 31000
[country_id] => HR
[telephone] => 0038531000331
[fax] => 0038531000332
[customer_password] =>
[confirm_password] =>
[save_in_address_book] => 1
)

[shipping] => Array
(
[address_id] => 6
[firstname] => Ivan
[lastname] => Weiller
[company] => Surgeworks
[street] => Array
(
[0] => Address part 1
[1] => Address part 2
)

[city] => Osijek
[region_id] =>
[region] =>
[postcode] => 31000
[country_id] => HR
[telephone] => 0038531000333
[fax] => 0038531000334
[save_in_address_book] => 1
)

And you can wrapp the above checkout code into something like

if($this->getRequest()->getParam(’submitCustomCheckout’))
{
//Checkout code from above…
}

Where ubmitCustomCheckout is the name of the submit button or submit input field. To extract addresses you can use something like

$billingAddress = $this->getRequest()->getParam(’billing’);
$billingAddress['use_for_shipping'] = 0;
$shippingAddress = $this->getRequest()->getParam(’shipping’);

That’s it. Simple, predefined checkout by whitch order can be make on one click.

Improving WordPress .htaccess – optimize WP’s 404 response

wordpress_404_page

WordPress has a 404.php template that’s generated for not found posts/pages. That’s fine, but what happens if post contains an image that’s deleted or moved from your blog or just path is set incorrect? It will output this 404.php template to the browser that’s actually doubles the traffic for a single page (for every not found object it will multiply traffic/load for every page)! Also, some bot’s request some strange urls never existed on your site that also slows down the server. To fix that I recommend to add elegant rules to WP’s .htaccess file:

RewriteCond %{REQUEST_FILENAME} !^.*\.png [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.jp?g [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.css [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.xml [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.html [NC]

So updated .htaccess file will look like that:

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !^.*\.png [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.jp?g [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.gif [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.css [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.js [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.xml [NC]
RewriteCond %{REQUEST_FILENAME} !^.*\.html [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

New ITL.ua Launched!

Congrats, ITL, we’ve launched new site design of the ITL Company Corporate Site, designed by my team of web-designers and programmers. We’ve worked all around this site’s user interface to make it clean, modern, user-friendly and different to other WordPress sites.

www.itl.ua

If you don’t already know, ITL is a telecom company that represent the whole range of solutions for household use, private and public organizations, large corporations. Such as Internet Service, Corporate Channels, Telephony, IPTV, Web Hosting etc. Also, ITL Company is founder and operator of KH-IX – Kharkiv Internet Exchange Point.

We are proud of working on this site and hopefully you’ll love it.

How to Override Inline CSS Styles

This is not new stuff, but anyway I decided it to re-post it for others.
css_logo_medium
One of the most powerful features of CSS is the cascading. Knowing how a browser chooses and applies your styles is invaluable knowledge. Novices can find it especially confusing given that style use is influenced by the method used to include the CSS, the order of the rules, how the selectors are specified, and special declarations such as !important.

Inline styles are those defined in the HTML itself, e.g.

inline style that should be blue .

nline styles have the highest priority of all CSS. In general, I would recommend you avoid using them and place your CSS declarations in external files. However, you may not have that luxury if you are working on a legacy system or do not have direct access to the HTML code.

Fortunately, there is a way to override inline styles from an external stylesheet:

strong[style] { color: blue !important; }

This will force the text in the strong tag to become blue in the example above. The method appears to work in all major browser, including:

  • Internet Explorer 8.0
  • Mozilla Firefox 2 and 3
  • Opera 9
  • Apple Safari, and
  • Google Chrome

Internet Explorer 6 and 7 are the notable exceptions. However, this technique is not something you should use on a day-to-day basis. Keep your CSS clean and only override inline styles when there is absolutely no alternative.

How to run multiple copies of Application in Mac OS X

scr11

Sometimes I needed several windows of FileZilla on my Mac to work with several servers simultaneously, but it doesn’t support multiple sessions (yet?). And Mac OS X doesn’t allow to launch another copy of application, so I googled a bit to find a solution… So you can run it by launching another instance of the app by typing this to command line:

/Path/To/Application.app/Contents/MacOS/Application &

E.g.:

/Applications/FileZilla.app/Contents/MacOS/filezilla &

Type that as many times as instances of FileZilla you want running. The & lets you close the Terminal and keep working with the launched instances.

Or using PathFinder – open contents of the package and find an appropriate binary:
scr3

But this will launch copy of App with default settings so i suggest to use much simplier solution – Just copy the application to another location (or copy to the same with an0ther filename) and launch.

scr2

It will automatically bring up your app settings from your user folder. But I don’t recommend to edit them (read only) because of concurrent running of >= 2 apps, using sama settings folder.