<?php
/*
Plugin Name: "More On"
Plugin URI: http://code.google.com/p/hungarianmoreon/
Description: Handy plugin for hungarian bloggers. According to the
first letter of current post title, it returns the proper definitive
article. Useful for the "More on" links.
Author: Török Gábor
Version: 0.1
Author URI: http://20y.hu/
*/ 

/**
* According to the first letter of the title returns the proper definitive
* article
*
* @param string $title Title
* @return string Article
*/
function moreon_get_article ($title) {
  // If it already starts with an article, do not duplicate it
  $article = strtolower(trim($title[0] . $title[1]));
  if ('a' == $article || 'az' == $article) {
    return '';
  }
  $vowels = array('a', 'A', 'á', 'Á', 'e', 'E', 'é', 'É', 'i', 'I', 'í', 'Í', 'o', 'O', 'ó', 'Ó', 'ö', 'Ö', 'ő', 'Ő', 'u', 'U', 'ú', 'Ú', 'ü', 'Ü', 'ű', 'Ű');
  if (in_array($title[0], $vowels) || in_array($title[0].$title[1], $vowels)) {
    return 'Az ';
  } else {
    return 'A ';
  }
}

/**
* Returns the title with the proper article
* 
* @param string $title Title
* @return string Title with article
*/
function moreon_get_the_title ($title) {
  return moreon_get_article($title) . $title;
}

?>

