 page_title.api.php | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 page_title.module  |   2 +-
 2 files changed, 162 insertions(+), 1 deletion(-)

diff --git a/page_title.api.php b/page_title.api.php
new file mode 100644
index 0000000..90e1b68
--- /dev/null
+++ b/page_title.api.php
@@ -0,0 +1,161 @@
+<?php
+
+/**
+ * @file
+ * API documentation for the Page Title module.
+ */
+
+/**
+ * TODO: API Document to be completed and reviewed
+ * Any properties added by page_title?
+ * Any static variables? Any cached variables?
+ * Any modifications to the drupal core objects?
+ * Page Title adds a new property on ...
+ */
+
+/**
+ * Allows other modules to alter statically cached current Page Title.
+ *
+ * The Page Title module defines its own token for a generic current page title
+ * [current-page:page-title]. Replacement of this token is the only case when
+ * this hook is triggered. It provides a convenient method for other modules to
+ * alter title based on path or other settings and a generic way to interact
+ * with the current page title token.
+ *
+ * See more examples of implementation in the modules folder.
+ *
+ * @param $title
+ *   A string containing the title for the current page.
+ *   The title could also be altered by reference, allowing modules to
+ *   implement further logic, such as loading a custom saved Page Title.
+ *
+ * @see: page_title_get_title()
+ * @see: page_title_tokens()
+ * @see: page_title_load_title()
+ * @see: taxonomy_page_title_alter()
+ */
+function hook_page_title_page_title_alter(&$title) {
+  $menu_item = menu_get_item();
+  // If we're looking at a taxonomy term page, get the term title.
+  if ( !strncmp($menu_item['path'], 'taxonomy/term/%', 15) &&
+       ($term = menu_get_object('taxonomy_term', 2)) &&
+       variable_get('page_title_vocab_' . $term->vocabulary_machine_name . '_showfield', 0) &&
+       ($term_title = page_title_load_title($term->tid, 'term')) ) {
+    $title = $term_title;
+  }
+}
+
+/**
+ * Allows other modules to alter defined token patterns
+ * and values before replacement.
+ *
+ * The Page Title module defines default token patterns replacements depending
+ * on the different scopes (such as global, node, term, user, etc...).
+ * This hook provides an opportunity for other modules to alter the patterns or
+ * the values for replacements, before tokens are replaced (token_replace).
+ *
+ * See more examples of implementation in the modules folder.
+ *
+ * @param $pattern
+ *   A string potentially containing replaceable tokens.
+ *   The pattern could also be altered by reference, allowing modules
+ *   to implement further logic, such as tokens lists or masks/filters.
+ * @param $types
+ *   Corresponds to the 'token data' property of the $options object.
+ *   (optional) An array of keyed objects. For simple replacement scenarios
+ *   'node', 'user', and others are common keys, with an accompanying node or
+ *   user object being the value. Some token types, like 'site', do not require
+ *   any explicit information from $data and can be replaced even if it is
+ *   empty.
+ *   To display additional token types on Page Title Admin Settings form, it is
+ *   suggested to implement hook_form_page_title_admin_settings_alter and add 
+ *   types to $form['token_help']['content']['#token_types'].
+ *
+ * @see: page_title_page_get_title()
+ * @see: hook_page_title_settings()
+ * @see: page_title_admin_settings()
+ * @see: page_title_page_title_pattern_alter()
+ */
+function hook_page_title_pattern_alter(&$pattern, &$types) {
+  // If frontpage, then use the frontpage pattern and set the title.
+  if (drupal_is_front_page()) {
+    // Get the frontpage pattern
+    $settings = page_title_get_settings();
+    $pattern = variable_get('page_title_front', $settings['page_title_front']['default']);
+  }
+}
+
+/**
+ * Provides a default configuration for Page Title instance settings.
+ *
+ * Configuration settings are used by Page Title to define scopes in which the
+ * current page title can be overriden based on a replacement pattern.
+ * The machine name (key) of a configuration is used as a system variable to
+ * store configured pattern. Therefore, these variables would have to be
+ * deleted if the module implementing custom configuration settings is
+ * uninstalled. The Page Title settings array is cached in the database so this
+ * hook is only triggered when the cache is flushed.
+ * Since the label and description properties are passed to a t() function call
+ * before being displayed, it is not necessary to add calls to t in the
+ * implementation of this hook for the label or description.
+ *
+ * See more examples of implementation in the modules folder.
+ *
+ * @return
+ *   An array whose keys are Page Title configuration names and whose values
+ *   identify properties that Page Title needs to know about:
+ *   - label: A string for the human-readable name of the settings type. It can
+ *     contain string variables or placeholders in the same format supported by
+ *     format_string(), such as !variable, @variable or %variable, since label
+ *     is passed to a t() function call for replacements.
+ *   - label arguments: An optional array of arguments to pass to the t()
+ *     function to replace placeholders with sanitized values in the label
+ *     property string.
+ *   - scopes: An array of identifiers for token types, typically, an entity
+ *     name or object name, e.g. node, term, vocabulary, etc...
+ *   - show field: A boolean value which provides an additional setting
+ *     checkbox on the Page Title admin settings form, to allow users to
+ *     specify whether a custom Page Title field should be made visible or not
+ *     on corresponding object (node, term, etc...) edit or create form pages.
+ *     This is only useful if a specific logic is implemented related with the
+ *     Page Title field and any particular object through hook_form_alter() or
+ *     hook_form_FORM_ID_alter() in which can be determined whether the field
+ *     should be shown or hidden. Otherwise,  it is recommended to set this
+ *     property to FALSE.
+ *   - description: A string description text for the Page Title pattern
+ *     configuration, visible on the Page Title admin settings form page.
+ *     It can contain string variables or placeholders in the same format
+ *     supported by format_string(), such as !variable, @variable or %variable,
+ *     since description is passed to a t() function call for replacements.
+ *   - description arguments: An optional array of arguments to pass to the t()
+ *     function to replace placeholders with sanitized values in the
+ *     description property string.
+ *   - weight: This optional key specifies the weight of this configuration.
+ *     It is used to determine the order of priority and in which defined
+ *     configurations should be called.
+ *   - default: An optional string to define a default replacement pattern for
+ *     this configuration.
+ *
+ * @see: page_title_get_settings()
+ * @see: page_title_admin_settings()
+ * @see: node_page_title_settings()
+ */
+function hook_page_title_settings() {
+  $settings = array();
+
+  $types = node_type_get_types();
+  foreach ($types as $type) {
+    $settings['page_title_type_' . $type->type] = array(
+      'label' => 'Content Type - %type',
+      'label arguments' => array('%type' => $type->name),
+      'scopes' => array('global', 'node', 'term', 'vocabulary'),
+      'show field' => TRUE,
+      'description' => 'This pattern will be used for all %type node-type pages',
+      'description arguments' => array('%type' => $type->name),
+      'weight' => -49,
+      'default' => '[node:title] | [site:name]',
+    );
+  }
+
+  return $settings;
+}
diff --git a/page_title.module b/page_title.module
index 321a57c..1eb3265 100644
--- a/page_title.module
+++ b/page_title.module
@@ -536,7 +536,7 @@ function page_title_get_title($raw = FALSE, $flush = FALSE) {
   $title = &drupal_static(__FUNCTION__);
 
   if ($flush || is_null($title)) {
-   // Give other modules the oppertunity to use hook_page_title_alter().
+   // Give other modules the opportunity to use hook_page_title_alter().
     drupal_alter('page_title', $title);
   }
 
