Category Archives: WordPress

All things WordPress on Linux. I don’t do WP on Windows as there is no point. If you have a licenced Windows server install Hyoer-V and run up a virtual linux system for apps like WordPress. Its a much more robust process than trying to make Windows do things it was never designed to do.

Which WordPress Contact Form Plugin to use?

Reviewing the plethora of Contact Form plugins for WordPress is daunting.  I have looked at dozens of possible options.

This review is relatively brief and focuses on obvious contenders. The rest can be summarily dismissed:

Contact Form by ContactMe.com reads very well, with all the common features. The catch is that it requires registration at yet another software as a service provider that wants your name and email address and offers ‘features’ that are totally unneccessary for the purpose of a contact form. Not for me.

Custom Contact Forms is another that sounds promising when reading the blurb and it installs smoothly, but then the top line is “Are you looking for a more customizable, reliable, and secure contact form solution for WordPress? Try Gravity Forms” which says to me that this plugin is not reliable or secure or customisable? Just a weird approach to marketing. Did not go further as Gravity Forms is one I am also looking at and if this one promotes Gravity then who am I to argue?

Fast Secure Contact Form is anything but fast with screen after screen of options, fields, and settings in one very long page. While I started to trawl down the list, I was overwhelmed within 30 seconds and decided that it would require far too much thinking and effort when all I want is a simple ‘Contact Us’ page.

BotDetect CAPTCHA is not a contact form tool but a method of adding Captcha processes to an entire WordPress site. The issue is that the plugin install does not include the native Captcha library, which must be downloaded separately and only after registering your email address with the service provider, etc. I had hoped to build a contact form and add this, but it just gave me headaches trying to get it configured.

Contact Form With Captcha is a nice contact form but the Recaptcha process is difficult for some users as the distortion of the words can be too much. In fact I have deployed this one on a number of sites and this review is simply to find an alternative that provides flexibility in the Captcha options.

Contact Form 7 is the one I eventually went with as it provided an easier Captcha option.

 

Turning off WordPress redirects index.php to index.html on Cpanel Apache

I spent a bit of time today trying to research why Apache on Cpanel insisted on redirecting from index.php when it was entered as an explicit URL to the default index.html page in the website home directory.

As it turned out, while I am searching for “cpanel apache redirects” I should have been asking “Why does WordPress redirect…” and that change of question led me to this WordPress forum thread that addressed the actual issue.

Now normally I would not repeat the information here, but just in case that link disappears, I do want to be able to get to it again, so here it is.

The issue actually is not Apache or Cpanel driven, but is an issue with WordPress and the way that it redirects all requests to the home page for the site. Hence despite me trying to access index.php, WordPress was redirecting to index.html, and that prevented me from seeing the new WP site.

Ultimately the purpose of this was to allow for WordPress to be installed alongside an existing page based site and deploy for final user acceptance before switching off the old site and moving to WordPress as the new site.

The trick is simply a manually installed plugin that can be removed after final commissioning to production.

1. Open your site with an FTP program or SSH depending on you preference

2. Navigate to yoursite_folder/wp-content/plugins/

3. Create a new folder for the plugin – call it disable-canonical-redirects – or dcr for short

4. Change to that folder

5. Create a new index.php file and include (copy and paste or re-type) this PHP code into that file:

[text]
<?php
/*
Plugin Name: Disable Canonical URL Redirection
Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above.
Version: 1.0
Author: Mark Jaquith
Author URI: http://markjaquith.com/
*/

remove_filter(‘template_redirect’, ‘redirect_canonical’);
?>
[/text]

5. Visit your WordPress Admin backend and activate this new plugin

6. All is now good to go and access index.html by default or index.php for WordPress explicitly.

Many thanks to Mark and others in that discussion thread.

 

Nextgen Gallery WordPress nggtags template caption option

I have a slightly older version of NGG because I have modded it and have yet to transfer those mods to the latest version. But I just made another minor change that I wanted to document before I forget what I did.

Using the

no images were found

  works well for showing the images from the gallery that are tagged as an automated gallery creation.

But I wanted to get the captions displayed as well like the syntax for the standard gallery by id display

no images were found

.  So I needed to add the ” template=caption” as an option for the nggtags shortcode.

Edit /wp-content/plugins/nextgen-gallery/nggfunctions.php

Around line 867 should start the function into which I inserted the $template value (with relevant comma’s etc.) at 3 places as highlighted with the new text.

[php highlight=”1,13,23″]
function nggShowGalleryTags($taglist, $template = ”) {

// $_GET from wp_query
$pid    = get_query_var(‘pid’);
$pageid = get_query_var(‘pageid’);

// get now the related images
$picturelist = nggTags::find_images_for_tags($taglist , ‘ASC’);

// look for ImageBrowser if we have a $_GET(‘pid’)
if ( $pageid == get_the_ID() || !is_home() )
if (!empty( $pid ))  {
$out = nggCreateImageBrowser( $picturelist, $template);
return $out;
}

// go on if not empty
if ( empty($picturelist) )
return;

// show gallery
if ( is_array($picturelist) )
$out = nggCreateGallery($picturelist, false, $template);

$out = apply_filters(‘ngg_show_gallery_tags_content’, $out, $taglist);
return $out;
}

[/php]

That sorts out the function that is called from the  /wp-content/plugins/nextgen-gallery/lib/shortcodes.php

Around line 114 there is a string evaluation test process that we change to look for a second option referenced as template= etc..  shown in the highlighted line.

[php highlight=”6″]

if ( stristr( $content, ‘[tags’ )) {
$search = "@(?:<p>)*s*[tagss*=s*(.*?)s*]s*(?:</p>)*@i";
if (preg_match_all($search, $content, $matches, PREG_SET_ORDER)) {

foreach ($matches as $match) {
$replace = "

no images were found

}" template="{$match[2]}"]";
$content = str_replace ($match[0], $replace, $content);
}
}
}

[/php]

Finally around line 273 there is the call to the nggShowGalleryTags in the show_tags function. Insert a new line for $template as a parameter and to the output option.

[php highlight=”5,12″]

function show_tags( $atts ) {

extract(shortcode_atts(array(
‘gallery’       => ”,
‘template’  => ”,
‘album’         => ”
), $atts ));

if ( !empty($album) )
$out = nggShowAlbumTags($album);
else
$out = nggShowGalleryTags($gallery, $template);

return $out;
}

[/php]

Now the nggtags option that will create a custom gallery from Tagged images can optionally include the image caption as well.

 

 

WordPress wp_list_pages includes Home link for no reason

Well, it’s never for ‘no reason’ but it can be hard to find.

I have been working with the free download ColorWay theme By InkThemes.com and while I like the theme it was annoying me that when I used the wp_list_pages function to get a list of child pages (which I logged earlier this year), it kept adding the Home page to the list as if it were a child of the page.

As it turns out after much tracking of the source of the issue, I find that the Colorway theme includes an add_filter function to insert the Home link at the top of the wp_list_pages function to build the main menu. I tracked this down to this file:

[text]
wp-contentthemescolorwayfunctionsinkthemes-functions.php
[/text]

What I found was that the add_filter was being applied for the specific purpose and was then left as a persistent process.

at around line 46
[php]
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
[/php]
and at around Line 63
[php]
add_filter(‘wp_list_pages, ‘inkthemes_new_nav_menu_items’);
[/php]

Line 46 was inside a function which builds the main menu:

[php]
function inkthemes_nav_fallback() {
?>
<div id="menu">
<ul class="ddsmoothmenu">
<?php
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
?>
</ul>
</div>
<?php
}
[/php]

Which I modified to basically place the add_filter as a part of this function only and added a remove_filter at the end to put it back to normal.
[php]
function inkthemes_nav_fallback() {
// 20121103 thowden copied from line 63 to place relevant to this function only
add_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
?>
<div id="menu">
<ul class="ddsmoothmenu">
<?php
wp_list_pages(‘title_li=&show_home=1&sort_column=menu_order’);
?>
</ul>
</div>
<?php
// 20121103 thowden added to reset the standard wp_list_pages function
remove_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
}
[/php]

So now the InkThemes menu will still work but will not perpetuate the wp_list_pages function change.

But, the body of the page list is still a problem and that is because line 63 as shown above is NOT in a function and is always applied. So the simple solution is to delete it, or comment it out of the code.

[php]
// 20121103 thowden to remove Home from list pages
//add_filter(‘wp_list_pages’, ‘inkthemes_new_nav_menu_items’);
[/php]

and all is well with the world again…