Add a Login/Logout Menu Item to WordPress Navigation Menu

This will add a Login or Logout (depending on state) to your WordPress navigation menu. I have one on mine now; makes it easy to quickly log in/out to test things.

Put the following in your child theme’s custom functions PHP file.

add_filter( 'wp_nav_menu_items', 'add_loginout_link', 10, 2 );
function add_loginout_link( $items, $args ) {
     if (is_user_logged_in()) {
$items .= '<li><a href="'. wp_logout_url() .'">Log Out</a></li>';
elseif (!is_user_logged_in()) {
$items .= '<li><a href="'. site_url('wp-login.php') .'">Log In</a></li>';
return $items;

Portable WordPress

Here is an all-in-one solution for a portable WordPress.  The creator packs MySQL, PHP, Apache and WordPress together and allows you to drop this folder onto a thumbdrive or network share, etc.  It’s nice and small (<30MB) and works well.

WordPress Portable:

It also gives you a system tray icon with a right click context menu.










WordPress Top 10 Plugin: Place Counter in Byline

I was annoyed by how the Top 10 plugin didn’t give me a better control of placement of the Visits/Visited string, so I got to work figuring out where to move things around.

First, I found that the data is printed via a PHP function called echo_tptn_post_count()

I edited my child-theme’s content.php file and modified the following (bold):

<?php if ( is_singular() ) { ?>
<?php if(function_exists('echo_tptn_post_count')) { $foo=echo_tptn_post_count(); } ?>
		<?php echo apply_atomic_shortcode( 'entry_title', '[entry-title]' ); ?>
		<?php echo apply_atomic_shortcode( 'byline', '<div class="byline">' . __( 'Published by [entry-author] on [entry-published]  [entry-comments-link before=" | "] '.$foo.' [entry-edit-link before=" | "]', 'live-wire' ) . '</div>'); ?>

When I viewed the post, I saw it was screwing up and echo’ing the $tptn variable above my entry title!

I went and had a look at the echo_tp_tn_post_count() function in top-10.php in the wp-content/plugins/top-10 directory and changed the following (bold):

function echo_tptn_post_count() {
global $post,$tptn_url,$tptn_path;
$id = intval($post->ID);

$output = '<script type=text/javascript src='.$tptn_url.'/top-10-counter.js.php?top_ten_id='.$id.'></script>';
#echo $output; return $output;

Now, it prints right in the byline after the comments (and it only does this on posts…).


This probably wasn’t the RIGHT way to do it, but I figured it out.

nginx error – 413 Request Entity Too Large

I was getting an error when trying to upload and attach images larger than 2MB via WordPress.

I discovered that nginx has a configuration setting called client_max_body_size that is default set to 1M.

To change this, I altered my nginx vhost configuration and added the following line:

server {
    root /var/www/;
    include /etc/nginx/fastcgi_php;
    client_max_body_size 5M;
    location / {
        index index.php;
        if (!-e $request_filename) {
            rewrite ^(.*)$  /index.php last;

This should suffice for most of my image uploading needs.  However, if you have large uploads you perform to your server through nginx, you may need to increase that!

Reload nginx

/etc/init.d/nginx reload

Here’s nginx configuration’s HttpCoreModule documentation on this configuration value:


syntax: client_max_body_size size
default: client_max_body_size 1m
context: http, server, location

Directive assigns the maximum accepted body size of client request, indicated by the line Content-Length in the header of request.

If size is greater the given one, then the client gets the error “Request Entity Too Large” (413).

It is necessary to keep in mind that the browsers do not know how to correctly show this error.

Note: You’ll need to match your PHP value also.


upload_max_filesize = 5M

Restart php-cgi

/etc/init.d/php-cgi restart


Apache Segfault when Navigating to WP-Admin




When trying to get into WordPress’ administration panel, Apache segfaults.

First troubleshooting steps involved moving all plugins/ to a temporary folder.

This didn’t produce any new results, still segfaulting.

Here are some notes on how I went about debugging this with GDB 7.3

wp-admin crashing

setup core dump in /etc/apache2.conf

CoreDumpDirectory /tmp-apache2/

Restart apache.

/etc/init.d/apache2 restart

install GDB 7.1+ for PIE support (See
gdb Download:

root@nitrous:/tmp-apache2# wget -d
root@nitrous:/tmp-apache2# bzip2 -d gdb-7.3a.tar.bz2
root@nitrous:/tmp-apache2# tar xvf gdb-7.3a.tar
root@nitrous:/tmp-apache2# cd gdb-7.3/
root@nitrous:/tmp-apache2# apt-get install gcc make ncurses-dev apache2-dbg php5-dbg
root@nitrous:/tmp-apache2/gdb-7.3# ./configure && make && make install

navigate to page, wp-admin to create crash

/usr/local/bin/gdb /usr/sbin/apache2 /tmp-apache2/core

(gdb) thread apply all bt full

root@nitrous:/tmp-apache# /usr/local/bin/gdb `which apache2` core
GNU gdb (GDB) 7.3
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
Reading symbols from /usr/sbin/apache2...(no debugging symbols found)...done.
[New LWP 5596]
warning: Can't read pathname for load map: Input/output error.
[Thread debugging using libthread_db enabled]
Core was generated by `/usr/sbin/apache2 -k start'.
Program terminated with signal 11, Segmentation fault.
#0 0x00007f28ad87f5f9 in _zend_hash_add_or_update () from /usr/lib/apache2/modules/
(gdb) bt
#0 0x00007f28ad87f5f9 in _zend_hash_add_or_update () from /usr/lib/apache2/modules/
#1 0x00007f28ad82cae5 in php_register_variable_ex () from /usr/lib/apache2/modules/
#2 0x00007f28ad6a21a9 in ?? () from /usr/lib/apache2/modules/
#3 0x00007f28ad826542 in sapi_getenv () from /usr/lib/apache2/modules/
#4 0x00007f28a3d895d4 in suhosin_log () from /usr/lib/php5/20090626/
#5 0x00007f28a3d84b3e in ?? () from /usr/lib/php5/20090626/
#6 0x00007f28ad8858a5 in ?? () from /usr/lib/apache2/modules/
#7 0x00007f28ad885981 in ?? () from /usr/lib/apache2/modules/
#8 0x00007f28ad87d885 in zend_hash_apply () from /usr/lib/apache2/modules/
#9 0x00007f28ad885df0 in zend_ini_deactivate () from /usr/lib/apache2/modules/
#10 0x00007f28ad87132f in ?? () from /usr/lib/apache2/modules/
#11 0x00007f28ad81cb65 in php_request_shutdown () from /usr/lib/apache2/modules/
#12 0x00007f28ad8fe177 in ?? () from /usr/lib/apache2/modules/
#13 0x00007f28b16a2880 in ap_run_handler ()
#14 0x00007f28b16a621e in ap_invoke_handler ()
#15 0x00007f28b16b3e48 in ap_process_request ()
#16 0x00007f28b16b0cf8 in ?? ()
#17 0x00007f28b16aa478 in ap_run_process_connection ()
#18 0x00007f28b16b8e97 in ?? ()
#19 0x00007f28b16b91aa in ?? ()
#20 0x00007f28b16b94db in ap_mpm_run ()
#21 0x00007f28b168ea90 in main ()
(gdb) bt full
#0 0x00007f28ad868f84 in zend_cleanup_function_data_full () from /usr/lib/apache2/modules/
No symbol table info available.
#1 0x00007f28ad87d885 in zend_hash_apply () from /usr/lib/apache2/modules/
No symbol table info available.
#2 0x00007f28ad868f50 in zend_cleanup_class_data () from /usr/lib/apache2/modules/
No symbol table info available.
#3 0x00007f28ad87d885 in zend_hash_apply () from /usr/lib/apache2/modules/
No symbol table info available.
#4 0x00007f28ad8648f0 in ?? () from /usr/lib/apache2/modules/
No symbol table info available.
#5 0x00007f28ad8712a2 in ?? () from /usr/lib/apache2/modules/
No symbol table info available.
#6 0x00007f28ad81cb65 in php_request_shutdown () from /usr/lib/apache2/modules/
No symbol table info available.
#7 0x00007f28ad8fe177 in ?? () from /usr/lib/apache2/modules/
No symbol table info available.
#8 0x00007f28b16a2880 in ap_run_handler ()
No symbol table info available.
#9 0x00007f28b16a621e in ap_invoke_handler ()
No symbol table info available.
#10 0x00007f28b16b3c6c in ap_internal_redirect ()
No symbol table info available.
#11 0x00007f28aa9e8cb5 in ?? () from /usr/lib/apache2/modules/
No symbol table info available.
#12 0x00007f28b16a2880 in ap_run_handler ()
No symbol table info available.
#13 0x00007f28b16a621e in ap_invoke_handler ()
No symbol table info available.
#14 0x00007f28b16b3e48 in ap_process_request ()
No symbol table info available.
#15 0x00007f28b16b0cf8 in ?? ()
No symbol table info available.
#16 0x00007f28b16aa478 in ap_run_process_connection ()
No symbol table info available.
#17 0x00007f28b16b8e97 in ?? ()
No symbol table info available.
---Type <return> to continue, or q <return> to quit---
#18 0x00007f28b16b91aa in ?? ()
No symbol table info available.
#19 0x00007f28b16b9e34 in ap_mpm_run ()
No symbol table info available.
#20 0x00007f28b168ea90 in main ()
No symbol table info available.

I have no idea where the problem is still.

Some googling found some hints at suhosin possibly, so I modified /etc/php5/apache/config.ini and commented out the

Restarted apache

/etc/init.d/apache2 restart

Navigated to wp-admin – everything works!

Now, why/what is causing suhosin to segfault? That is still under investigation.

WordPress: Quickly Replace Content Across All Blog Entries

I discovered I could change my image paths that were linked against to by using MySQL to REPLACE the string.

After a few minutes of thinking about this, this is a really cool thing — beyond what I just accomplished.

I can use this to update what was once static information (phone number, fax, email, contact information, etc.) quickly!

This is what the syntax looked like:

update blog_posts set post_content = REPLACE(post_content,'', '');

Now using that as a basis, I can use REPLACE(post_content, ”,”) to create quick hacks to change emails on-the-fly that were contained in my posts.