=== IDM Post Date Archive Link ===
Contributors: ignaziodimaio
Tags: date, archive, link, shortcode, block
Requires at least: 5.9
Tested up to: 6.9
Requires PHP: 7.0
Stable tag: 1.0.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Display the publication (or modification) date in a block or shortcode, with links to date archives and custom formatting.

== Description ==

IDM Post Date Archive Link is a lightweight plugin that provides a dedicated **block** and a **shortcode** for dynamically displaying the publication date, or the last modified date, of a post or page.

Its core function is to offer display flexibility, allowing you to choose between the **publication date** or the **last modified date**. Furthermore, it enables linking the displayed date to different types of date archives.

This tool is perfect for **Full Site Editing (FSE) themes** and for users who require precise control over the date's format and link destination within their templates and content.

== Features ==

* **Gutenberg Block**: Fully compatible with the block editor and FSE themes.
* **Date Selection**: Choose to display the published date (default) or the last modified date.
* **Archive Links**: Option to link the date to the yearly, monthly, or daily archive of the current post, to its permalink, or display it as plain text.
* **Custom Formatting**: Supports date/time formatting using standard PHP formatting characters.
* **CPT Support**: Correctly handles archive links for Custom Post Types by appending their slug to the URL.
* **Shortcode**: Includes the shortcode for backward compatibility and use in widget areas or the Classic Editor.

== Usage ==

= Block =

The block is registered as **"IDM Post Date Archive Link"** under the **Theme** category. Once inserted, you can customize it using the available settings in the Block Inspector sidebar:

* **Use custom format**: Override the default date format (set in the general settings) with a custom one.
* **Enable date link**: Make the date clickable by linking it to the post or a date archive.
* **Display last modified date**: If the post has been modified, display the last modified date instead of the publication date.
* **Date prefix**: Custom text prefix to add before the date (e.g., "Published on:").

The block can be styled using the Styles panel of Block Inspector sidebar. To match the current theme style, apply the class "*wp-block-post-date*" to the block (same class of Post Date core block).
 
= Shortcode =

You can use the `[ipdal]` shortcode in any supported area (shortcode block, widgets, classic editor), or in a classic theme template with: `<?php echo do_shortcode('[ipdal]'); ?>`. 
Available attributes are:

* **`link`** : Make the date clickable by linking it to the post or a date archive.
Accepted Values: `post`, `day`, `month`, `year`, `none`
Default: `post`

* **`modified`** : If the post has been modified, display the last modified date instead of the published date.
Accepted Values: `true`, `false`
Default: `false`

* **`format`** : Override the default date format (set in the general site settings) with a custom one.
Accepted Values: Any [date format string](https://wordpress.org/documentation/article/customize-date-and-time-format/) like "`d/m/Y`" or "`timeago`" for relative date format.
Default: `default`

* **`text`** : Custom text prefix to add before the date.
Accepted Values: Any string (e.g., "Published on:")
Default: `''` (none - empty string) 

*Example:*

`[ipdal modified="true" link="month" format="m/d/Y" text="Updated:"]`

( this sample will displays the last modified date linked to the monthly archive, with the format month/day/year, and "Updated:" as custom text prefix )

The shortcode can be styled with custom CSS by referencing its class: "*idm-post-date-archive-link_shortcode*".

== Installation ==

Install the plugin from the WordPress Plugin Directory, or manually:

1.  Download the plugin ZIP file and upload it via the **Plugins > Add New > Upload Plugin** section of your WordPress dashboard. Alternatively, upload the plugin folder via FTP to `/wp-content/plugins/`.

2.  Activate the plugin from the 'Plugins' menu.

3.  Search for **"IDM Post Date Archive Link"** block in the editor, or use the `[ipdal]` shortcode.

== Frequently Asked Questions ==

= Is the shortcode also available for block themes? =

Yes, the shortcode is available for both block and classic themes, while the block is only available for block themes, of course.

= Does the block and shortcode work on the “page” post type? =

Yes, both block and shortcode work on the “page” post type, but without the ability to link the date to a date archive (since it is not supported by this post type).

== Screenshots ==

1. Block and shortcode as seen from the block editor
2. Block and shortcode as seen from the frontend (block theme)
3. Shortcode as seen from the classic editor
4. Shortcode as seen from the frontend (classic theme)

== Changelog ==

= 1.0.0 =
* Initial release.
