WordPress 3.1 vs 3.0 vs. 3.1.1 and “archives” URL’s

Updated on Apr 07, 2011 @ 02:54:

If you made the change below for 3.1RC-3.1 and/or used manually created tag/category links in 3.1RC-3.1 and just upgraded to 3.1.1, you may find that the links are broken. The reason is that in 3.1.1 the tag and category links returned to the 3.0 style with the word “archives” in the URL.

To make it work you can change .htaccess to the following:

RewriteEngine On
RewriteBase / #or where your blog root is

#RewriteRule archives/category/(.*) category/$1 [L,R=301]
#RewriteRule archives/tag/(.*) tag/$1 [L,R=301]
RewriteRule ^category/(.*) archives/category/$1 [L,R=301]
RewriteRule ^tag/(.*) archives/tag/$1 [L,R=301]

Posted on Feb 25, 2011 @ 00:22:

In WordPress 3.1 the link structure have been changed

from (< =3.0.x):

wp/archives/category and wp/archives/tag
to (>= 3.1.x)
wp/category and wp/tag

If you have existing “hard” links to tags or categories, add the following lines (in red) to .htaccess:

RewriteEngine On
RewriteBase /
RewriteRule archives/category(.*)$ category$1 [L,R=301]
RewriteRule archives/tag(.*)$ tag$1 [L,R=301]

How to serve attachments from a free CDN (Coral)

You can use Coral free CDN to off-load the WordPress attachments (usually images). In order to use Coral you need to add “.nyud.net” to the site DNS address. For example, http://www.alekz.net will become http://www.alekz.net.nyud.net. Coral is usually too slow to serve all static content, so the most effective solution would be to use it only for the biggest files.

Here’s a simple solution. Add the following to functions.php of your current theme:

add_filter ('wp_get_attachment_url', 'freecdn_url');

function freecdn_url ($url)
    if (! is_attachment () ) return $url; 
    $cdn_url = ".nyud.net";
    $decomposed_url = explode ("/", $url);
    $decomposed_url[2] =  $decomposed_url[2] . $cdn_url;
    $url = implode("/", $decomposed_url);
    return $url;

Your theme (e.g. the bundled “TwentyTen”) must use wp_get_attachment_url(), of course. If not – you got the idea, didn’t you? 😉

Also, you can use freecdn_url () function to rewrite any URL you want to download from Coral.

How to replace the WP comment form with a WYSIWYG editor

You can replace the standard WordPress comment form with a built-in WYSIWYG editor TinyMCE.

Find the file where the comment form is defined. Usually it’s comment.php in your theme

For WP <3.0 it looks something like:

Why does x^0 equal 1?

Since basic school we know, that [math]x^0=1[/math], but only recently when our kids began to study mathematics we asked ourselves “why?”.

I came up with this explanation:

[math]x^0=x^{n-n}=x^n \times x^{-n}=\frac {x^n} {x^n}=1[/math]

Also a good test for the Easy LaTeX WordPress plug-in.

And here’s jsxgraph plug-in test:
Continue reading “Why does x^0 equal 1?”

WordPress and TinyMCE

TinyMCE (platform independent web based Javascript HTML WYSIWYG editor) is developed by Moxiecode Systems AB.

Update wp-includes/js/tinymce with files from tinymce/jscripts/tiny_mce

3d party TinyMCE plugins can be downloaded from SourceForge and should be placed in wp-includes/js/tinymce/plugins

To activate plugins and/or tune TinyMCE edit wp-includes/js/tinymce/tiny_mce_config.php (do not forget to make a backup copy first).

To add/remove plugins change $plugins variable. By default (wp2.6) it’s set to:

$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen' , 'wpeditimage');

If you use full version of TinyMCE (e.g. downloaded from Moxiecode) instead of the bundled one, this string may look like (see Plugins reference):

$plugins = array( 'safari', 'inlinepopups', 'autosave', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'advhr', 'advimage', 'advlink', 'emotions', 'inlinepopups', 'insertdatetime', 'layer', 'nonbreaking', 'pagebreak', 'preview', 'searchreplace', 'style', 'table', 'visualchars', 'xhtmlxtras' , 'wpeditimage');

To add buttons to 4 available rows modify corresponding variables $mce_buttons, $mce_buttons_2, $mce_buttons_3 and $mce_buttons_4 (see Control reference). For example:

$mce_buttons = apply_filters('mce_buttons', array('search', 'replace', 'bold', 'italic', 'strikethrough',  'underline', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'link', 'unlink', 'image', 'wp_more', 'pagebreak',  'spellchecker', 'fullscreen', 'table', 'wp_adv' ));

$mce_buttons_2 = apply_filters('mce_buttons_2', array('formatselect', 'code', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|', 'media', 'charmap', '|', 'outdent', 'indent', '|', 'undo', 'redo', 'wp_help', 'advhr', 'emotions', 'insertdate', 'inserttime', 'preview' ));

$mce_buttons_3 = apply_filters('mce_buttons_3', array('fontselect', 'fontsizeselect', 'fullpage'));

The result can be viewed in a browser:

Note: AdBlock Plus Firefox extension blocks the contents of the TinyMCE popups (you will see empty pop-up windows).  You might consider replacing ABP with Adblock or whitelisting your whole site.

WordPress 2.5

WordPress 2.5 has been released! Installed! And? Does it work? Basically yes. But…

TinyMCE pop-ups are blank in Firefox. This is what I found (similar problems):

The Console shows:

Error: tinyMCE.getWindowArg is not a function
Source: http://.../wp/wp-includes/js/tinymce/tiny_mce_popup.js
Line: 53

Error: tinyMCE.getParam is not a function
Source: http://.../wp/wp-includes/js/tinymce/utils/form_utils.js
Line: 10

Error: tinyMCEPopup.requireLangPack is not a function
Source: http://.../wp/wp-includes/js/tinymce/plugins/advimage/js/image.js
Line: 5

Upgrading TinyMCE to v3.0.5 did not help (see this post on how to do that). Neither did the replacing inline pop-ups with real pop-up windows. The content is empty. However, TinyMCE works fine on the Moxiecode example page and locally using the example files. Hence, it’s not the code but the configuration or the method WordPress initializes TinyMCE (tiny_mce_config.php ?)

Update 2008-03-31 @13:48:24 Disabling compression (‘compress’ => false) and/or caching (‘disk_cache’ => false) in tiny_mce_config.php did not help. The WP cache (wp/wp-content/uploads/js_cache) was cleaned manually.