On my Amazon reading list page I wanted to add a progress bar and ahead/behind schedule counter similar to that on Goodreads. For their reading progress meter, you enter how many books you plan to read, and then your account page shows you a progress bar indicating how many books you’ve read and how far […]
Tag: PHP
Install WP-CLI
The wp-cli command-line utility allows you to manage your WordPress sites without going through the WordPress dashboard, much like Drush does for Drupal. To install Composer and wp-cli on Ubuntu 16.04: Install Composer (I’d recommend not doing this as root.) Install wp-cli This installs wp-cli to $HOME/.config/composer/vendor/wp-cli/wp-cli/bin/wp To make things easier on yourself, symlink it:
WordPress: Optimizing Nginx and WP Super Cache
Today we’re going to compare the performance of a WordPress site before and after we install and optimize the WP Super Cache plugin. We’re running Ubuntu 16.04 Server, Nginx 1.10, PHP 7 with the Zend OPcache, MariaDB, and WordPress 4.6 with a few other plugins (Akismet, Jetpack, Yoast SEO, and Google Analytics). The system itself […]
Drupal 7: Display Page Elements Conditionally
In Drupal you often need to show page elements conditionally, usually based on variables like the URL or user identity. Fortunately, the Drupal API offers several functions that can help: hook_html_head_alter() template_preprocess_page() template_preprocess_html() drupal_match_path() drupal_get_http_header() user_is_logged_in() or user_is_anonymous() Modify the Page Header To add a tag to the header on every page, use hook_html_head_alter() in […]
Ubuntu 16.04 Web Server with Apache, PHP, and MySQL
Ubuntu 16.04 LTS has been out for a little while now, and its standard repos offer some nice enhancements over Ubuntu 14: Apache 2.4.18, PHP 7, and MySQL 5.7.12 The process for creating a basic LAMP web server is also streamlined, as a couple of bugs that plagued Ubuntu 14.04 are now eliminated. To create […]
PHP: Database Access With PDO
PDO, or PHP Data Objects, is a database abstraction extension that allows you to use a common set of commands to access any database for which PDO has a driver. This includes MySQL and compatibles (e.g., MariaDB), PostgreSQL, Oracle, Microsoft SQL Server, IBM DB2, SQLite, and others. While it’s nice not having to rewrite all […]
PHP: List Last Updated Files
An old PHP script to list the most recently updated files within a web site using their ‘last modified’ time stamps.
WordPress Plugin Development Tutorial
This article is intended to serve as a simple WordPress plugin development tutorial. For the purpose of demonstration we’ll create a plugin that removes comment spam. For this to work, you have to be running some sort of anti-spam system like Akismet that marks spam comments as such when they’re submitted. Comments are written into […]
PHP Zend OPcache Installation
The Zend OPcache is a caching system that seeks to improve PHP performance by keeping precompiled PHP code in the shared memory of your web server. Since PHP is an interpreted language that has to be compiled into a set of intermediate instructions (“opcodes”) when someone accesses your PHP page or site, not having to […]
WordPress: Installation and Performance
This article describes some of the basics on installing and running WordPress to maximize its performance. The following scripts and text generally assume Debian/Ubuntu, so substitute Red Hat, Arch, etc. as needed. Installation If you’re less lazy than I am, you could combine the whole install routine into a single Bash script, and make it […]