Sin descripción
Buscar un archivo
Archivos del repositorio (primero la última confirmación)
Nombre del archivo Mensaje del último instantánea Fecha de la última instantánea
2026-08-23 18:00:29 +02:00
includes Remove dead code. 2026-08-23 18:00:29 +02:00
LICENSE Creation. 2026-08-22 13:59:46 +02:00
README.md Creation. 2026-08-22 13:59:46 +02:00
wp-writing-time.php Creation. 2026-08-22 13:59:46 +02:00

WP Writing Time

A WordPress plugin that automatically tracks the time spent writing a post and dynamically inserts the formatted duration into post content.

Features

  • Pre-fills new posts with a configurable text template containing the {tiempo} placeholder.
  • Allows authors to customize or translate the text per post while keeping the {tiempo} placeholder.
  • Tracks post start time when the post draft is initialized.
  • Tracks post publication timestamp on first publication.
  • Calculates and formats writing time in standard human-readable format (e.g., 71d 5h 32m, 5h 32m, 12m).
  • Replaces {tiempo} dynamically when viewing published posts.
  • Provides a configurable fallback text (e.g., tiempo indeterminado) for posts with a placeholder but no creation timestamp.
  • Does not modify posts without the {tiempo} placeholder.
  • Displays writing time metadata and calculated duration in the post editor sidebar.
  • Configurable via Settings > Writing Time.

Installation

Via Git / Deployer for Git

  1. Clone or add this repository into your wp-content/plugins/ directory:
    git clone https://github.com/JaviLopezG/wp-writting-time.git wp-content/plugins/wp-writing-time
    
  2. Activate the plugin from the Plugins menu in WordPress admin.

Configuration

Navigate to Settings > Writing Time (options-general.php?page=wp-writing-time) to configure:

  1. Default Text Template: The initial text inserted into new posts (default: Para escribir esta entrada he invertido {tiempo}.).
  2. Indeterminate Time Text: The replacement string when no creation time was recorded (default: tiempo indeterminado).
  3. Supported Post Types: Choose which post types support writing time tracking (default: post).

How It Works

  1. When a user clicks Add New Post, WordPress triggers the default_content filter.
  2. The plugin sets the initial content to the default text template and stores the current UTC Unix timestamp in the _wp_writing_time_created_at post meta field.
  3. Authors can edit the post content and adjust the surrounding text around {tiempo} as desired.
  4. When the post is published for the first time, the plugin stores the publication timestamp in _wp_writing_time_published_at.
  5. On the frontend, the the_content filter calculates the elapsed duration between creation and publication, formatting it as [Xd ]Yh Zm and replacing {tiempo}.

Filters

  • wp_writing_time_formatted_duration: Filter the generated duration string.
    add_filter('wp_writing_time_formatted_duration', function($formatted, $seconds, $days, $hours, $minutes) {
        // Custom formatting logic
        return $formatted;
    }, 10, 5);
    

License

This project is licensed under the BSD 3-Clause License. See the LICENSE file for details.