Sin descripción
- PHP 100%
| Nombre del archivo | Mensaje del último instantánea | Fecha de la última instantánea |
|---|---|---|
| includes | ||
| LICENSE | ||
| README.md | ||
| wp-writing-time.php | ||
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
- 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 - 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:
- Default Text Template: The initial text inserted into new posts (default:
Para escribir esta entrada he invertido {tiempo}.). - Indeterminate Time Text: The replacement string when no creation time was recorded (default:
tiempo indeterminado). - Supported Post Types: Choose which post types support writing time tracking (default:
post).
How It Works
- When a user clicks Add New Post, WordPress triggers the
default_contentfilter. - The plugin sets the initial content to the default text template and stores the current UTC Unix timestamp in the
_wp_writing_time_created_atpost meta field. - Authors can edit the post content and adjust the surrounding text around
{tiempo}as desired. - When the post is published for the first time, the plugin stores the publication timestamp in
_wp_writing_time_published_at. - On the frontend, the
the_contentfilter calculates the elapsed duration between creation and publication, formatting it as[Xd ]Yh Zmand 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.