=== Flexi Recent Posts ===
Contributors: Mhd Wahyu NZ
Tags: recent posts, shortcode, posts, widget, flexible posts, custom posts display
Requires at least: 6.8
Tested up to: 6.8.2
Requires PHP: 8.0
Stable tag: 2.4.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://mwahyunz.id/

Flexibly displays a list of recent posts anywhere using a shortcode with customizable attributes.

== Description ==

Flexi Recent Posts gives you the ease to display a list of recent posts on any page, post, or widget using a simple shortcode `[flexiposts]`. The main advantage of this plugin is its flexibility; you can control almost every element displayed—from the title, image, and excerpt, to the post's metadata—directly from the shortcode attributes. This plugin is designed to be lightweight and efficient by utilizing the WordPress Transient API for caching, so it does not overload your server. With several display modes and rich customization options, you can tailor the output to match your website's design.

Key Features:
* **Simple Shortcode**: Just use `[flexiposts]` to get started.
* **Full Customization**: Easy-to-use attributes to show/hide the title, image, date, author, categories, tags, and excerpt.
* **Three Display Modes**: Choose a layout with the image on the left, right, or top.
* **Flexible Image Size**: Set the featured image width in pixels or use the default percentage width.
* **Efficient**: Uses a caching system to ensure fast performance.
* **Modern Styling**: Comes with clean and modern built-in CSS, which is easy to override.
* **Secure & Optimized**: Enhanced security with input validation and optimized database queries.
* **Modern Standards**: Compatible with WordPress 6.8+ and PHP 8.0+.

== Installation ==

1.  **Via WordPress Dashboard (Easiest Way)**:
    * Go to `Plugins > Add New`.
    * Search for "Flexi Recent Posts".
    * Click `Install Now`, then `Activate`.
2.  **Via Upload in WordPress Dashboard**:
    * Download the Flexi Recent Posts plugin `.zip` file.
    * Go to `Plugins > Add New` and click the `Upload Plugin` button.
    * Choose the `.zip` file you downloaded, then click `Install Now`.
    * Activate the plugin after the installation is complete.
3.  **Via FTP (Manual Method)**:
    * Extract the plugin's `.zip` file.
    * Upload the `flexi-posts` folder to the `/wp-content/plugins/` directory on your server.
    * Go to the `Plugins` menu in your WordPress dashboard and activate the "Flexi Recent Posts" plugin.

After activation, use the `[flexiposts]` shortcode in your post or page editor.

== Shortcode and Attributes ==

Use the basic `[flexiposts]` shortcode or add attributes inside it to customize the display.

**Basic Example**:
`[flexiposts]`

**Advanced Example**:
`[flexiposts mode="3" number="5" image="1" imagesize="300" cat="0" author="0"]`

---

### List of Available Attributes

* `mode`
    Determines the display layout mode.
    **Values**: `1` (image left), `2` (image right), `3` (image top).
    **Default**: `1`

* `number`
    The number of recent posts to display (1-100).
    **Values**: Number (integer).
    **Default**: `3`

* `image`
    Shows or hides the featured image.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

* `imagesize`
    Determines the width of the featured image in pixels (0-2000). **This attribute is ignored if `mode="3"` is used.**
    If set to `0`, the width will be set automatically (30% for modes 1&2, 100% for mode 3).
    **Values**: Number (integer).
    **Default**: `100`

* `title`
    Shows or hides the post title.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

* `excerpt`
    Shows or hides the post excerpt.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

* `limit`
    Limits the number of characters in the excerpt (1-1000).
    **Values**: Number (integer).
    **Default**: `80`

* `more`
    Shows or hides the "Read more »" link at the end of the excerpt.
    **Values**: `1` (show), `0` (hide).
    **Default**: `0`

* `cat`
    Shows or hides the post categories.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

* `tag`
    Shows or hides the post tags.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

* `author`
    Shows or hides the author's name.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`
    
* `authorlink`
    Enables or disables the link on the author's name to their archive page.
    **Values**: `1` (enabled), `0` (disabled).
    **Default**: `1`

* `date`
    Shows or hides the post's publication date.
    **Values**: `1` (show), `0` (hide).
    **Default**: `1`

== Frequently Asked Questions ==

* **How can I change the colors and font styles?**
    You can override the plugin's default CSS styles by adding your own CSS code via the `Appearance > Customize > Additional CSS` menu in your WordPress dashboard. Use class selectors like `.frp-item`, `.frp-title a`, or `.frp-terms a` to target specific elements.

* **Does this plugin support Custom Post Types?**
    Currently, version 2.4.0 is designed only to display standard posts ('post'). Support for Custom Post Types may be considered in a future update.

* **Can the shortcode be used in a widget?**
    Yes, you can add the `[flexiposts]` shortcode inside a "Text" or "Custom HTML" widget on your widgets page.

* **What are the minimum requirements?**
    WordPress 6.8 or higher and PHP 8.0 or higher are required for optimal security and performance.

== Screenshots ==

1.  Default view (Mode 1) with the image on the left.
2.  Example of Mode 2 view with the image on the right.
3.  Example of Mode 3 view with the image above the text.
4.  View of the post list without featured images (`image="0"`).

== Changelog ==

= 2.4.0 - 2025-11-17 =
* Security: Enhanced input validation and sanitization for all shortcode attributes.
* Security: Added range validation for numeric attributes (number: 1-100, limit: 1-1000, imagesize: 0-2000).
* Security: Improved database query security with proper prepared statements.
* Security: Added comprehensive validation for taxonomy existence and term objects.
* Security: Enhanced post object validation before processing.
* Performance: Optimized WP_Query with `no_found_rows` and `update_post_meta_cache` for better performance.
* Performance: Improved transient deletion to support object cache systems.
* Performance: Added version number to cache keys to auto-invalidate on updates.
* Compatibility: Added explicit WordPress 6.8+ and PHP 8.0+ requirements.
* Improvement: Added plugin constants (FRP_VERSION, FRP_PLUGIN_DIR, FRP_PLUGIN_URL).
* Improvement: Added cleanup on plugin deactivation to remove transients.
* Improvement: Added hooks for 'trashed_post' and 'untrashed_post' to flush cache.
* Code Quality: Enhanced code documentation and type safety.
* Code Quality: Removed unnecessary variable assignments and improved logic flow.

= 2.3.0 - 2025-09-22 =
* Tweak: In `mode="3"`, the `imagesize` attribute is now ignored to consistently enforce a 100% image width.
* Fix: Removed unnecessary bottom margin on the image in `mode="3"` to ensure uniform vertical spacing between all elements.
* Technical: Updated plugin and CSS file versions.

= 2.2.0 - 2025-09-21 =
* Improvement: Optimized the loaded image size. The plugin now uses the 'thumbnail' size for modes 1 & 2, and the 'medium' size for mode 3 to improve efficiency and visual quality.
* Technical: Updated the plugin version in the header file.

= 2.1.0 - 2025-09-20 =
* Feature: Added the `more` attribute to display a "Read more »" link at the end of the excerpt.
* Fix: The "Read more »" link logic is no longer tied to the `title` attribute but is controlled by the new `more` attribute.
* Tweak: Changed the default value for the `imagesize` attribute from `0` to `100`.
* Documentation: Updated the `limit` attribute description to clarify that the limit is based on characters, not words.
* Documentation: Updated the header and attribute list in the readme.txt file.

= 2.0.0 - 2025-09-19 =
* Feature: Main shortcode changed to `[flexiposts]` for simplicity.
* Feature: Added the `imagesize` attribute to set a custom width for the featured image.
* Feature: Links on categories, tags, and the author's name now open in a new tab.
* Feature: Automatically added a "Read More »" link to the excerpt if the title was hidden.
* Fix: The featured image is no longer linked to the post page to prevent unwanted hover behavior.
* Style: A complete overhaul of the CSS file for a new color scheme, layout, and element spacing.
* Structure: Refactored code in the `frp-display.php` file to improve readability and implement new display logic.

= 1.0.0 =
* Initial release.

== Upgrade Notice ==

= 2.4.0 =
Major security and performance update. Enhanced input validation, optimized database queries, and improved compatibility with WordPress 6.8+ and PHP 8.0+. Recommended for all users.