New book on WordPress Theme Development: WordPress Themes In Depth
tips
Tag Archive

Temporary Site Redirect for Visitors during Site Updates

In our article Stupid htaccess Tricks, we present the htaccess code required for redirecting visitors temporarily during periods of site maintenance. Although the article provides everything needed to implement the temporary redirect, I think readers would benefit from a more thorough examination of the process — nothing too serious, just enough to get it right. After discussing temporary redirects via htaccess, I’ll also explain how to accomplish the same thing using only PHP. Read more »

MySQL Magic: Find and Replace Data

Recently, I needed to find and replace all instances of “http://website” in the wp_comments table of the WordPress database. Fortunately, SQL provides a simple way to find and replace data with its wonderful UPDATE function. General Example Using the SQL UPDATE command is straightforward. Here is the general syntax: UPDATE table_name SET field_name = replace( field_name, ‘string_to_find’, ‘string_to_replace’ ) ; Simply replace the table_name and both instances of field_name with your specific information, and then edit string_to_find, and string_to_replace with the desired values. This is pretty standard stuff, but it is always a good idea to backup your database before […] Read more »

Another Mystery Solved..

Recently, after researching comment links for an upcoming article, I realized that my default <input /> values were being submitted as the URL for all comments left without associated website information. During the most recent site redesign, I made the mistake of doing this in comments.php: … <input class=”input” name=”url” id=”url” value=”[website]” onfocus=”this.select();” type=”text” tabindex=”3″ size=”44″ maxlength=”133″ alt=”website” /> … Notice the value=”[website]” attribute? It seemed like a good idea at the time — I even threw in a nice onfocus auto-highlighting snippet for good measure. I ran the form with this in place for around eight weeks before finally […] Read more »

Permanently Redirect a Specific IP Request for a Single Page via htaccess

Not the most interesting title, but “oh well”.. Recently, a reader named Alison left a comment requesting help with a particular htaccess trick. She wanted to know how to permanently redirect (301) all requests for a specific page when requested from a specific IP address. In other words, when a visitor coming from 123.456.789 requests the page requested-page.html, the visitor will be redirected to just-for-you.html. All visitors not coming from that specific IP address are not redirected, and thus will see the originally requested page. Further, the redirect must apply only to requested-page.html, such that every visitor — including the […] Read more »

CSS Throwdown: Preload Images without JavaScript

Clean, easy, effective. You don’t need no stinking JavaScript to preload your images. Nope. Try some tasty CSS and (X)HTML instead! Here’s how.. (only two steps!) Step 1 — Place this in your CSS file: div#preloaded-images { position: absolute; overflow: hidden; left: -9999px; top: -9999px; height: 1px; width: 1px; } Step 2 — Place this at the bottom of your (X)HTML document: <div id=”preloaded-images”> <img src=”http://perishablepress.com/image-01.png” width=”1″ height=”1″ alt=”” /> <img src=”http://perishablepress.com/image-02.png” width=”1″ height=”1″ alt=”” /> <img src=”http://perishablepress.com/image-03.png” width=”1″ height=”1″ alt=”” /> </div> ..and that’s a wrap! All images are preloaded and ready for calling as you please. Completely valid, […] Read more »

Wrapping Your Head around Downlevel Conditional Comments

If you think you understand the logic behind Microsoft’s downlevel conditional comments, you are sadly mistaken. Sure, they seem simple enough on the surface, but as you really try to wrap your head around how and why they work, the subtle complexities of downlevel conditional comments may leave you dazed and confused… In our previous article on Internet Explorer’s exclusive browser-detection method, downlevel conditional comments (DCC), we present an introductory exposition, defining expressions and providing several generalized code examples. Overall, it is a very useful article but partially fails at explaining the logic and functionality behind conditional comments. In this […] Read more »

Computer Flashback: Windows 98 Run Commands

Even with all the fancy-pants new features found in Windows XP and now Vista, Microsoft Windows 98 (Second Edition) remains our favorite Windows-flavored operating system. We love it so much, we still use it on one of our trusty laptops. Over the years, we have discovered several very useful functions available via the command line or even the “Run” prompt (Start → Run…). Anyway, without spending too much time researching or explaining these wonderful tools, we figured posting the information online may prove beneficial at some point in the future. So, without further ado, we present this working repository of helpful MS […] Read more »

Use PHP to Create Symbolic Links without Shell Access

On Unix systems, a symbolic link refers to a file that points to another file or directory. Symbolic links serve as powerful tools for web designers and developers. Using shell access, creating a symbolic link requires only one line of code: ln -s /home/username/public_html/directory1 /home/username/public_html/directory2 Simple enough. Assuming you have access to the linux shell. Unfortunately, many shared hosting environments deny shell access. Fortunately, creating symbolic links — also called “symlinks” — remains a possibility via the PHP symlink() function. Check it out.. Read more »

SEO 101: Best Practices

After studying Peter Kent’s excellent book, Search Engine Optimization for Dummies, several key methods emerged for optimizing websites for the search engines. Although the book is written for people who are new to the world of search engine optimization (SEO), many of the principles presented throughout the book remain important, fundamental practices even for the most advanced SEO-wizards. This article divulges these very useful SEO practices and organizes them into manageable chunks 1. Text Essentials The golden rule for developing a popular website is to create a useful site and share it with as many people as possible. When designing […] Read more »

Go Back via JavaScript and PHP

Use this simple code as a button that will return users to the previous page: <form> <input type=”button” value=”Return to previous page” onClick=”javascript:history.go(-1)” /> </form> Here it is as a simple text link: <p> <a href=”javascript:history.go(-1)” title=”Return to the previous page”>&laquo; Go back</a> </p> You can make things easier by serving PHP and printing the link automatically. Here is the button link: echo “<form><input type=\”button\” value=\”Return to previous page\” onClick=\”javascript:history.go(-1)\”></form>”; And here is the PHP code to print a "Go back" text link: echo “<p><a href=\”javascript:history.go(-1)\” title=\”Return to previous page\”>&laquo; Go back</a></p>”; Better yet, you can kick the accessibility factor […] Read more »

Embed Flash and Video via the object Tag

Embed Windows Media Player via the object tag Here is the general format for including .wmv files in web pages: <object type=”video/x-ms-wmv” data=”http://www.domain.com/path/to/winmovie.wmv” width=”340″ height=”280″> <param name=”src” value=”http://www.domain.com/path/to/winmovie.wmv” /> <param name=”controller” value=”true” /> <param name=”autostart” value=”true” /> </object> Read more »

Maximum and Minimum Height and Width in Internet Explorer

Behold the seventh wonder of the virtual world: max/min-height and max/min-width properties are possible in Internet Explorer! Indeed, by taking advantage of IE’s proprietary CSS attribute, expression, you too can whip IE widths and heights into desirable proportions. The CSS expression attribute enables JavaScript commands to be executed within Internet Explorer. JavaScript via CSS? Thanks, Microsoft! Why is this so great? Well, because in other, standards-compliant browsers, max/min-height and max/min-width properties are easily accomplished with this simple bit of CSS.. Read more »

Rename the Recycle Bin in WinXP

To rename the Recycle Bin in Windows XP, create a new text.txt file in your favorite directory and add the following lines: REGEDIT4 [HKEY_CLASSES_ROOT\CLSID\{645FF040-5081-101B-9F08-00AA002F954E}\ShellFolder] “Attributes”=hex:50,01,00,20″CallForAttributes”=dword:00000000 Next, rename the file extension from ".txt" to ".reg" — the other part of the file name may be whatever you prefer (e.g., RecycleBin.reg). Then, double-click the file to have Windows import it into the Registry. Now go right-click your Recycle Bin and use the new option to Rename it. To remove renaming functionality for the Recycle Bin, replicate the same file you created initially, and replace the last line (i.e., the third line) with […] Read more »

Industrial-Strength Spamless Email Links

In our previous article on creating spamless email links via JavaScript, the presented method, although relatively simple to implement, is not the most effective solution available. Spambots, email harvesters, and other online scumbags relentlessly advance their scanning technology, perpetually rendering obsolete yesterday’s methods. In the case of spamless email links created client-side via JavaScript, many spambots now are able to decipher certain email addresses hidden within the JavaScript code itself. Spambots scan JavaScript for keywords such as "email" or "mail", or even character strings containing ".com" or the "@" symbol. Spambots collect and decipher such data and return the favor […] Read more »

Keep it Dark: Hiding and Filtering CSS

Hiding and filtering CSS rules for specifically targeted browsers is often a foregone conclusion when it comes to cross-browser design considerations. Rather than dive into some lengthy dialogue concerning the myriad situations and implications of such design hackery, our current scheduling restraints behoove us to simply cut to the chase and dish the goods. Having said that, we now consider this post a perpetually evolving repository of CSS filters.. Read more »

Delete index.dat on Windows 98SE

This brief tutorial on removing (and replacing) the "index.dat" file applies to any Windows OS running on MS-DOS. Although I haven’t researched this officially, it appears that all Windows versions released prior to Windows 2000 are running on the 16-bit MS-DOS kernel. Conversely, Win2000 and WinXP operate on a 32-bit kernel and thus do not utilize MS-DOS. Thus, this method focuses on removing the index.dat from machines running Windows 95, 98, and 98SE. As you may be aware, Internet Explorer utilizes a file called "index.dat". The index.dat file serves a log that documents every domain visited through Internet Explorer. Deleting […] Read more »

Latest Tweets Sale on printed copies of .htaccess made easy (with free shipping): htaccessbook.com/printed-htacc…