Archive

Archive for the ‘php’ Category

Contact Form for wordpress

February 23rd, 2010 admin No comments

For a client of mine, i’ve been using the PEAR-package HTML_QuickForm which is ’superseded’ by now and isn’t compatible to php 5.2, whereas the followup package HTML_Quickform2 is still in alpha state. Since the client switched his server and that is running php 5.2, i had to come up with a new solution. I tried out many wordpress contact-form-plugins but they all did not satisfy me fully.

The only form-plugin that i truly would recommend is cForms II. It is flexible, can handle more than one form template. Forms can be inserted via template files or via tags inside posts or pages. I think this is the only plugin that supports individual Fieldsets (this can be very handy for designing complex layouts). The verification of the user input is done with very individual regular expressions. The admin can set Form field name, tooltip and default value and even let the default value be auto-cleared once the form field is activated. cForms II supports multi-page forms (which i didn’t use, though) and it can autoconfirm emails to the user (which i didn’t use either). Spam detection is done not only with the individual regular expressions, but also with a captcha-plugin or alternativey with a simple Q&A-field (like, ‘what color is snow?’). The possible questions for the Q&A field can be set manually. You can even backup and restore the form settings! Furthermore the admin can chose from a dozen css-layouts and manually change them.

Here are the other plugins, that i tried out:

  • Contact Form 7: It didn’t seem to have a template tag, that i could use in the theme files.
  • Form Builder: Very bad design. It features div-tags that are floated. If your design uses floating objects, it will break it or be broken itself!
  • Scaleable Contact Form plugin: Nearly no option to verify the user input. Supports Captcha, but it uses the plugin “simple captcha” for that, which doesn’t seem to support wordpress 2.9.
  • Spam-Free Contact Form: simply crap. don’t use that.
  • Visitor Contact: only interesting, if you like using external web applications on your own blog.
Categories: Programming, php, wordpress Tags: , ,

Wordpress 2.8 announced and installed

May 18th, 2009 admin 1 comment

The Wordpress version running on this blog is now "2.8-beta1-11380". After the first beta has been announced, i switched the svn installation to trunk again (after having it to branches/2.7) and updated the blog.

There is a problem with gengo though: Right after upgrading i got this warning:

CODE:
  1. Warning: Invalid argument supplied for foreach() in /.../wp-includes/classes.php on line 255

The line in question looks like this:

PHP:
  1. foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t)

I really didn't have the time to get into this, so in order to get the blog going, i used the workaround suggested here and changed the line to:

PHP:
  1. foreach ((array) $GLOBALS['wp_taxonomies'] as $taxonomy => $t)

Categories: Programming, php, wordpress Tags:

Pingbacks and Trackbacks work again in Wordpress

December 18th, 2008 admin No comments

For quite some time, i had a problem getting pingbacks and trackbacks working. Receiving them wasn't a problem, but i couldn't send any. It seems, i'm not alone and no where were any answers to be found..

I think i found the problem: the function spawn_cron (/wp-includes/cron.php, 153) opens a socket to then wp-cron.php file after adding a new scheduled item. For that reason it runs the function wp_remote_post which also accepts a timeout parameter. That parameter is set to 0.01 by default. I guess these are seconds (which means these are 10 milliseconds!) and for some webservers this value is simply too small. Change that to something bigger (i'm using 0.1 or 1) and pingbacks and trackbacks should work again..

Now what about the old trackbacks and pingbacks that didn't get sent? Actually you'll simply need to write a new post and all the old unsent pings should be scheduled for sending. If you don't want to do that, you could install the plugin Wp-Crontrol where you can specify a hook to be scheduled to a specific time. Schedule the hook "do_pings" to be triggered any time soon (parameter should be empty = "[]") and it should take care of the old pingsbacks.

Gengo and Wordpress 2.7

November 17th, 2008 admin 3 comments

I had an issue with gengo getting into an endless redirect loop once i activate the option "Gengo should append language codes to permalinks automatically.". I thought this was an issue of gengo-compatibility and deactivated the option making many links unusable. Now i just found this thread over at wordpress.org where joshreisner suggests simply saving the permalink structure again:

i just upgraded to 2.6.1 using the automatic updater and it caused a redirect loop on my site. whenever i would visit it it would be like "the address /en/en/en/en/en/en/en etc was in a repeat loop that would never be resolved"

i pulled my hair out for a minute but then figured it out. just go to the permalinks settings page (in wp, not gengo) and hit save. no change, just save. that fixed the problem!

Thanks. This works. It seems gengo uses some action that is being pulled once the permalink structure is saved..

Categories: Programming, php, wordpress Tags: , ,

Using nanocms to create a simple site with news

October 18th, 2008 admin No comments

For a client of mine i've been looking for a way to host his very simple and small site. The site (which can be found here in its old outfit) consists of some rather static pages, two formulas, which have to be sent by email and a news section that is split into two categories (events and tours). Both news categories land in a collective archive after a specific date.

Until now, the site has been using a selfmade content management system, which reads custom files in some directories. Every time i wanted to change the content of an event article, add a new one or move it to the archive i had to manually change the files. You have to have in mind, that the customer asked for a rather minimalistic server hosting solution and i didn't see it as necessary for him to have a database in the hosting package. The problem is that most content management systems are in need of a database of some sort (mostly mysql). Yes i am aware of plugins for cmss that can do the job. But mostly the systems are too complicated to setup for this simple site..

In come nanocms. Nanocms is being developed by Kalyan Chakravarthy who runs his own blog over at kalyanchakravarthy.net (last update about nanocms). From the description of the project:

Nano CMS is the tinyest CMS you can find around...:)
The user interface and the functionality are very very simple and easy to use.
NanoCMS is filebased, so no database blah,. Easy to install

Through this CMS you can create pages without actually touching any code.
You can manage website pages very easily and the links in the sidebar are generated automatically...

Indeed nanocms is really small and well written for that. The main functionality consists of creating pages, which are then stored in distinct files in a specific folder. The only way to sort the pages on the site is to include them in different categories (each page can be a member in different categories) and then using those categories for displaying menus. There is no way of specifying a hierarchy for the pages. The sort order of the pages inside each category though can be changed independently.

Now, this functionality doesn't provide exactly what i needed, since i wanted some "pages" (/posts) to be shown on the same webpage - like a blog. Also, i needed submenus to allow the navigation the client was asking for.

So, this is what i did..

To extend the functionality of nanocms i created "customfunctions.php" with the following two functions:

PHP:
  1. <?php
  2.  
  3. function show_contents($cat){
  4.     global $cap;
  5.     $itemlist = get_links_array($cat);
  6.     foreach( $itemlist as $slug=>$title ){
  7.         show_content($slug);
  8.         echo '<hr />';
  9.     }
  10. }
  11.  
  12. function show_content($slug){
  13.     $contentFile = pageDataDir( $slug );
  14.     if( file_exists( $contentFile ) ) {
  15.         runTweak( 'slug_load_before' );
  16.         require_once( $contentFile );
  17.         runTweak( 'slug_load_after' );
  18.     }
  19.     else {
  20.         header("HTTP/1.0 404 Not Found");
  21.         echo "404 : File Requested was Not Found";
  22.     }
  23. }
  24. ?>

The function "show_contents" is a near-copy of the native function "show_links" which shows all the links to the pages inside a category. "show_content" is a near-copy of "show_content_slug" with the only difference, that "show_content_slug" doesn't accept any argument and gets the page slug from the global variable $cap.

With those two functions i'm now able to show a page inside another page (which i use to display the "Kontakt"-page under the welcome message) and i'm able to show the content of a category.

So, the content of "Aktuelles" becomes the following small script:

PHP:
  1. <h2>Aktuelles</h2>
  2.  
  3. <?php show_contents('aktuelles'); ?>

And here is a link to the site, as i proposed it to the client: www.campuscultur.de/nano/

Categories: Programming, php Tags: , ,

Project: Mosaics in the United Arab Emirates

September 17th, 2008 admin No comments

I've nearly finished the website emirates-mosaic.ae, which enables the customers searching for mosaic art to buy those created by this very artist.

The request was to create a gallery as the main theme of the site and to build some rather static pages around it to explain more about mosaics and how to buy them and such. Furthermore a list of favorite mosaics was to be placed at the right side of the screen.

After considering many platforms, i decided to use wordpress and to extend it's normal behavior to include the mosaic gallery. Right now, there is no blog on the site so every blog post (technically) is a mosaic-article.

What's special?

There were some features that had to be incooperated into the whole thing, like a special gallery-shortcode. So instead of putting the shortcode 'gallery' into a post, i include the custom shortcode [mosaicg] which includes all the images in the gallery of the post and includes links to the images themselves (not to their respective attachment pages). They're also formated in a different way: first image is shown as 'medium'-sized, all others are thumbnails.

Rather than creating own plugins, i included the code for the shortcode and some special widgets into the functions.php of the theme. I think this feature of wordpress should be preserved as it enables a theme developer to easily imitate a plugin and to change the behavior of wordpress fundamentally.

The following plugins were used:

  • All in One SEO Pack - that's a must for most sites
  • cforms - For making an offer
  • Featplug - for displaying the featured mosaics
  • Google Sitemaps - very useful to get different search engines to know your site completely.
  • jQuery Lightbox - i changed it to fit the needs here
  • StatTraq - the statistics plugin that i myself am maintaining
  • Stattraq Queries - a little something i call SEO-wonder. will be released shortly.
  • Wordpress Navigation List Plugin NAVT - WOW! You wanna 'click' your navigation together and display only those pages/categories/etc. that you want? This is the plugin for you! Honestly, i didn't expect someone to have the time to code this really awesome plugin
  • Wordpress Newsletter subscription Opt-in for SendBlaster - maybe will change that..

Go have a look at emirates-mosaic.ae and tell me, if there's something not working.

Erste Version von wp-stattraq veröffentlicht

August 11th, 2008 admin No comments

Eben gerade habe ich die erste neue Version von wp-stattraq auf wordpress.org freigegeben. Ich habe das Plugin nur insoweit verändert, als ich es für wordpress 2.6 lauffähig gemacht habe und dabei die Ausgabe des Plugins in die normale Administrationsobefläche integriert habe.

Später möchte ich noch einige Mankos des Plugins (die ich als langzeitiger Nutzer gut kenne) beseitigen. Aber vorerst müssen einige Integrationsprobleme (wie die automatische Installation bereinigt werden).

Wer Änderungswünsche und -vorschläge hat, sollte diese bitte direkt im trac-system als ticket eintragen:

http://trac.toomuchcookies.net/trac/wiki

Auch in Planung (code ist eigentlich schon fertig) ist ein plugin, das bei der seo-optimierung helfen soll und das soll die Daten von wp-stattraq nutzen. Dazu später mehr..

First version of wp-stattraq is released

August 11th, 2008 admin 2 comments

Some seconds ago i've uploaded the first new version of wp-stattraq to the wordpress plugin directory. I've changed the plugin to be incooperated into the administration panel and work with version 2.6 of wordpress (which it didn't up until now).

I'm planning to put more features into the plugin and squash more bugs, but right now, i'm concentrating on releasing a stable version (as in 2.6-stable) as fast as possiblem, that can be easily installed. This first version is mainly meant for those, who were running wordpress already and need this update to be able to work with wordpress 2.6.

You can follow the updates and file tickets by visiting the trac-system i set up:

http://trac.toomuchcookies.net/trac/wiki

Also, i'm planning on releasing more plugins related to wp-stattraq that contribute to seo-work.. Look forward for more to come..