Jump Menu : Content | Explore | Search | Home | Sitemap | Contact | Login | Access.

Articles tagged with “php

Blacklist Candidate Number 2008-04-27
Welcome to the Perishable Press “Blacklist Candidate” series. In this post, we continue our new tradition of exposing, humiliating and banishing spammers, crackers and other worthless scumbags.. Since the implementation of my 2G Blacklist, I have enjoyed ...
Drop-Dead Easy Random Images via PHP
Recently, while restoring my collection of Perishable Press themes, I needed a fast, effective way to randomize a series of images. After playing around with several likely candidates, I finally devised the following drop-dead easy technique:...
Three Unsolved WordPress Mysteries
After several years of using WordPress, I have at least three unanswered questions: What’s up with the WordPress PHP Memory Error? Why do certain phrases trigger “Forbidden” errors when saving or publishing posts? What happened to the Plugin Pages in the WordPress Codex? Let’s have a look at each one of these baffling mysteries.. Unsolved Mystery #1: What’s up with the WordPress PHP Memory Error? Every single day, WordPress generates hundreds of these errors: [20-Feb-2008 19:49:42] PHP ...
Content Negotiation for XHTML Documents via PHP and htaccess
In this article, I discuss the different MIME types available for XHTML and explain a method for serving your documents with the optimal MIME type, depending on the capacity of the user agent. Using either htaccess or PHP for content negotiation, we can serve complete, standards-compliant markup for our document’s header information. This ...
How to Display Your Twitter Posts on Your WordPress Blog
Alright, time for another “How’d-you-do-that-thing-on-your-site?” post. This question comes from the one and only Mr. Graham of ImJustCreative.com. In a recent email, Graham literally begged me to share my “secret recipe” for displaying my latest Twitter Tweets (wow, did I actually just say that?) right here on Perishable Press: ...Would be really really decent of you if you could let me know how to do it? Pretty please? ...
Custom HTTP Errors via htaccess
We all know how important it is to deliver sensible, helpful 404 error pages to our visitors. There are many ways of achieving this functionality, including the well-known htaccess trick used to locally redirect users to custom error pages: # htaccess custom error pages ErrorDocument 400 /errors/400.html ErrorDocument 401 /errors/401.html ErrorDocument 403 /errors/403.html ErrorDocument 404 /errors/404.html ErrorDocument 500 /errors/500.html ..and so on. These directives basically tell Apache to deliver the designated documents for their associated error ...
WordPress Tip: Careful with that Autosave, Eugene
After upgrading WordPress from version 2.0.5 to 2.3.3, I did some experimenting with the “post autosave” feature. The autosave feature uses some crafty ajax to automagically save your post every 2 minutes (120 seconds by default). Below the post-editing field, you will notice a line of text that displays the time of the most recent autosave, similar to the following:...
Blacklist Candidate Number 2008-03-09
Welcome to the Perishable Press “Blacklist Candidate” series. In this post, we continue our new tradition of exposing, humiliating and banishing spammers, crackers and other worthless scumbags.. Imagine, if you will, an overly caffeinated Bob Barker, hunched over his favorite laptop, feverishly scanning his server access files. Like some underpaid ...
Improve Site Performance by Increasing PHP Memory for WordPress
During the recent ASO server debacle, I raced frantically to restore functionality to Perishable Press. Along the way, one of the many tricks that I tried while trying to fix the dreaded “white screen of death” syndrome involved increasing the amount of PHP memory available to WordPress. This fix worked for me, but may not prove effective ...
WordPress Error Fix(?): Increase PHP Memory for cache.php
This trick isn’t guaranteed to prevent all WordPress-generated PHP memory errors, but it certainly seems to help reduce their overall occurrence. For some reason, after my host upgraded their servers to Apache 1.3.41, I began logging an extremely high number of fatal PHP “memory exhausted” errors resulting from the WordPress cache.php script. Here is an example of the countless errors that are generated: [17-Feb-2008 19:26:38] PHP Fatal error: Allowed memory size ...
Blacklist Candidate Number 2008-02-10
Welcome to the Perishable Press “Blacklist Candidate” series. In this post, we continue our new tradition of exposing, humiliating and banishing spammers, crackers and other worthless scumbags.. Scumbag number 2008-02-10, “COME ON DOWN!!” — you’re the next baboon to get banished from the site! Like many bloggers, I ...
Optimizing Google Analytics Performance
It has occurred to me lately that I no longer use Google Analytics for Perishable Press. Instead, I find myself keeping an eye on things using Mint almost exclusively. So, the question now is: do I continue serving the GA JavaScript to keep the profile active just in case I ever need the additional stats? I mean, Mint already does a ...
Advanced PHP Error Handling via PHP
In my previous articles on PHP error handling, I explain the process whereby PHP error handling may be achieved using htaccess. Handling (logging, reporting) PHP errors via htaccess requires the following: Access/editing privileges for htaccess files A server running ...
1-Minute Tutorial: Permanent (301) Redirect via PHP or htaccess
Here is an example of one of the most frequently asked PHP/htaccess-related questions I receive here at Perishable Press: How do I redirect a specific page/URL using PHP/htaccess? So common is this inquiry that I have decided to just post a quick, “one-minute” tutorial describing the technique. Permanent (301) Redirect via PHP To permanently redirect a ...
Advanced PHP Error Handling via htaccess
In my previous article on logging PHP errors, How to Enable PHP Error Logging via htaccess, we observed three fundamental aspects of preventing, preserving, and protecting your site’s PHP errors: Prevent public display of PHP errors via htaccess # supress php errors php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_value docref_root 0 php_value docref_ext 0 Preserve (log) ...
Blacklist Candidate Number 2008-01-02
Come one, come all — today we officially begin a new series of posts here at Perishable Press: the public exposure, humiliation, and banishment of spammers, crackers, and other site attackers. Kicking things off for 2008: blacklist candidate number 2008-01-02! Every Wednesday, I take a little time to investigate my ...
Optimize WordPress: Pure Code Alternatives for 7 Unnecessary Plugins
In this article, my goal is to help you optimize WordPress by replacing a few common plugins with their correspondingly effective code equivalents. As we all know, WordPress can be a very resource-hungry piece of software, especially when running a million extraneous plugins. Often, many common plugins are designed to perform relatively simple tasks, such as redirect ...
How to Enable PHP Error Logging via htaccess
In this brief tutorial, I will show Apache users how to suppress PHP errors from visitors and enable PHP error logging via htaccess. Tracking your site’s PHP errors is an excellent way to manage and troubleshoot unexpected issues related to plugins and themes. Even better, monitoring PHP errors behind the scenes ...
A Dramatic Week Here at Perishable Press..
..And we’re back. After an insane week spent shopping for a new host, dealing with some Bad Behavior, and transferring Perishable Press to its new home on a virtual private server (VPS), everything is slowly falling back into place. Along the way, there have been some interesting challenges and many lessons learned. Here are a few of the highlights.. The tide may be turning ...
5 Easy Ways to Display Syntax Highlighted PHP Code
A great to way to share your PHP code with visitors is to display it directly in the browser with automatically generated syntax highlighting. Here is a screenshot showing an example of syntax-highlighted PHP code: Displaying your ...
Easily Adaptable WordPress Loop Templates
In this article, I present several heavily commented examples of WordPress loops. I have found that many readers appreciate these types of loop examples, as it helps them to understand how the loop works while enabling them to easily copy, paste, and adapt the code for their own purposes. In our first example, we examine a basic WordPress ...
Fixing Mint after Switching Servers
After switching Perishable Press to its current home at A Small Orange, I began noticing an unusual problem with referrer data displayed in Mint. Specifically, the first item recorded in the XXX Strong Mint data panel — for both “Most Recent” and “Repeat” views — displayed several thousand hits for various site resources, all from ...
Hacking WordPress: The Ultimate Nofollow Blacklist
Several days ago, I posted an article explaining how to hack your own WordPress nofollow blacklist. Immediately thereafter, I published an elaborate article focusing on automatic methods of nofollow blacklisting via WordPress plugins. In this article, I expand on the original blacklist hack by ...
Hacking WordPress: Dofollow Whitelist for Commentator Links
Before repenting of my filthy “nofollow” addiction, I experimented briefly with a “dofollow whitelist” for commentator URL links. The idea behind the whitelist is to reward frequent commentators, feed subscribers, site patrons, and other guests by selectively removing the automatically generated nofollow attributes from their associated comment-author links. For nofollow enthusiasts, ...
Hacking WordPress: Nofollow Blacklist for Commentator Links
Previously, in our unofficial “WordPress dofollow upgrade” series, we dished several techniques for removing the antisocial nofollow attributes from default installations of WordPress. After an exhaustive review of available dofollow plugins, we explained how drop-dead easy it is to transform ...
Industrial Strength WordPress Dofollow Upgrade
Encourage Comments by Completely Eliminating All Nofollow Links Want to remove all traces of the hideous nofollow attribute without having to install yet another unnecessary plugin? By default, WordPress generates nofollow links in three different ways — this article will show you how to eliminate all of them.. Some context please.. Note: if you are already familiar with the various functions involved in the nofollow-removal process, please feel free to skip the proceeding discussion and ...
The Deluxe One-Minute Dofollow WordPress Upgrade
After our previous article, we all know how easy it is to kill the default nofollow attributes that WordPress automatically injects into all commentator, trackback, and pingback links. Indeed, our original one-minute upgrade delivers dofollow links across the board, effectively passing the love juice to every type of response. Fine for some, but some need more.. In this article, we improve the original dofollow upgrade by differentiating between the three different response ...
The One-Minute Dofollow WordPress Upgrade
Want to upgrade your blog to official dofollow status but don’t want to install another unnecessary plugin? This article explains how to eliminate nofollow tags from all trackback, pingback, and commentator links in less than one minute.. After finally repenting of my nofollow sins, I began looking for the best way to eliminate the nofollow attributes that WordPress automatically injects into all commentator URL links. Of course, the most ...
Comprehensive Reference for WordPress NoNofollow/Dofollow Plugins
Recently, while deliberating an optimal method for eliminating nofollow link attributes from Perishable Press, I collected, installed, tested and reviewed every WordPress no-nofollow/dofollow plugin that I could find. As of the writing of this post, I have evaluated 12 dofollow plugins, all of which are freely available on the Internet. In this article, I present a concise, current, and comprehensive reference for WordPress no-nofollow and dofollow plugins. ...
Eliminate 404 Errors for PHP Functions
Recently, I discussed the suspicious behavior recently observed by the Yahoo! Slurp crawler. As revealed by the site’s closely watched 404-error logs, Yahoo! had been requesting a series of nonexistent resources. Although a majority of the 404 errors were exclusive to the Slurp crawler, there were several instances of requests that were also coming from Google, Live, and even Ask. Initially, these distinct errors were misdiagnosed as existing ...
Suspicious Behavior from Yahoo! Slurp Crawler
[ Keywords: yahoo, slurp, crawl, crawling, spider, url, 404, errors, suspicious, behavior ] Most of the time, when I catch scumbags attempting to spam, scrape, leech, or otherwise hack my site, I stitch up a new voodoo doll and let the cursing begin. No, seriously, I just blacklist the idiots. I don’t ...
Super Loop: Exclude Specific Categories and Display any Number of Posts
[ Keywords: wordpress, loop, have_posts, category, categories, post, posts, asides, excerpts ] Readers occasionally ask for help with their WordPress loops. Usually, these requests involve modifying the loop with some customized functionality. Frequently, such customization involves one of these popular behaviors: Exclude a specific category Exclude multiple categories Display only one post or excerpt Display some fixed number of ...
Temporary Site Redirect for Visitors during Site Updates
[ Keywords: temporary, redirect, htaccess, php, site, maintenance, 403, 503, http, status, code ] 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 ...
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 ...
Another Mystery Solved..
Recently, after researching comment links for an upcoming article, I realized that my default 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: ... ... Notice the value="[website]" attribute? It seemed like a good idea at the time — I even threw in a ...
WP-ShortStat Slowing Down Root Index Pages
[ Keywords: wp-shortstat, shortstat, wordpress, plugin, slow, country, ip, lookup, root, index, fix ] For over a year now, I have been using Markus Kämmerer’s (Happy Arts Blog) WP-ShortStat plugin for WordPress. The plugin is relatively well-maintained and remains one of my favorite admin tools. Great for popping in on stats without logging into Mint. Nonetheless, due to its IP/country-detection functionality, WP-ShortStat has experienced its share of difficulties (e.g., ...
How to Block IP Addresses with PHP
[ Keywords: block, deny, ip, address, php, spam, htaccess, redirect ] Figuratively speaking, hunting down and killing spammers, scrapers, and other online scum remains one of our favorite pursuits. Once we have determined that a particular IP address is worthy of banishment, we generally invoke the magical powers of ...
Use PHP to Create Symbolic Links without Shell Access
[ Keywords: symbolic, links, symlinks, symlink, shell, access, php ] 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 ...
Compressed JavaScript Compression
[ Keywords: javascript, compression, compress, php, htaccess, gzip, ob_gzhandler ] In this article, we extrapolate our favorite CSS-compression technique for JavaScript. Below, we outline the steps required to auto-compress your JavaScript documents via gzip and PHP. Two different compression methods are presented. The first method does not require htaccess, but rather involves the manual editing of JavaScript files. The second method employs htaccess to do ...
Fast, Effective PHP Compression
PHP compression is an excellent method of conserving bandwidth and reducing client download times. We have already discussed an excellent method for CSS compression, and in this article we share a super-easy technique for compressing all PHP content without editing a single file. Using two PHP files and two corresponding lines of .htaccess, it is possible to compress your PHP files via gzip-encoding. Browsers and other user-agents capable of ...
Go Back via JavaScript and PHP
Use this simple code as a button that will return users to the previous page: Here it is as a simple text link: « Go back You can make things easier by serving PHP and printing the link automatically. Here is the button link: echo ""; And here is the PHP code to print a "Go back" text link: echo "...
Automatic Language Translation Methods
As you may have noticed, Perishable Press recently added automatic language translation to each of our articles. The free, automatic translations are available as a series of image links (via corresponding country flag icons) next to each article’s individual post view. We have found that providing this free service is important as many of our visitors come from countries other than the United States, and therefore may be unable to read our articles as presented in the ...
Time Test
This post exists entirely for the sake of tweaking time functionality in Apache, PHP, SQL, and WordPress.. Immediate findings: Date/time limit into the past for WordPress: December 13, 1901 @ 15:45 WordPress will display December 13, 1901 @ 15:45 properly for all functions except wp_get_archives All dates prior to 12/13/1901 in MySQL will display as December 31, 1969 @ 19:00 in the WP Admin > Post Timestamp panel SQL timestamps of 0000-00-00 00:00:00 display as 0 via $wpdb->get_col("SELECT DISTINCT YEAR SQL timestamps of ...
Perishable Press Triple Loop for WordPress
Two of the themes developed by Perishable Press, Apathy and Information, depend on three WordPress loops to operate as intended. For each of these themes, the three loops consist of two "side" loops and one main loop. The side loops each display posts from one specific category, while the main loop displays posts from every category not specified in the side loops. There are many different multi-loop configurations ...
Compressed CSS Compression
In this article, we have consolidated the priceless information provided in fiftyfoureleven.com’s fine post, The Definitive Post on Gzipping your CSS, which discusses two practical methods for compressing CSS documents. Complete and utter credit for the contents of this article is hereby attributed to fiftyfoureleven.com. Method One Overview: This method involves adding a small PHP script to your CSS document and replacing its .css extension ...
Customize WordPress Quicktags
Note: This condensed tutorial assumes you are working with WordPress 2+ and are familiar with editing .php and/or .js files. WordPress quicktags1 provide shortcuts for adding certain bits of code to your posts. The default set of quicktags includes some handy shortcut buttons for tags such as , , and , as well as a few others. While the default set of quicktag buttons is occasionally useful, a quick bit of quicktag customization can easily transform your personal ...
Auto Clear and Restore Form Elements
Using a small bit of JavaScript, it is possible to auto-clear and restore form elements when users bring focus to them. Simply copy, paste, and modify the following code example to achieve an effect similar to this:   ...
Display the Total Number of WordPress Posts, Comments, and Categories
Would you like to display the total number of posts, comments, and categories for your WordPress-powered website? Here is the code that can make it happen 1!...
Execute External WordPress Functions
To execute WordPress functions in an external directory (i.e., outside of the WordPress install directory), it is necessary to include a call to “wp-blog-header.php” at the top of the external file. For example, if your WordPress-powered blog is located in a subdirectory called “blog” and the external file is in the domain root (e.g., the external file is located directly in http://domain.com/), add the following code to the top of the external file: This may be generalized ...
WordPress Search Function Notes
Code to call an external WordPress search form: Code for a standard, inline WordPress search form: "> Code to try if the search function fails and ...

« Reverse • Up •


Set CSS to lite theme
Set CSS to dark theme