=== Read More Button  - Expand Content Without Refresh ===
Contributors: josevarghese
Tags: read more, expand content, show more, truncate text, excerpt
Requires at least: 5.0
Tested up to: 6.9
Requires PHP: 7.4
Stable tag: 1.0.8
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Donate link: https://superwebshare.com/read-more-plugin-donate

Easily add a customizable Read More button to expand long posts. Reveal hidden content automatically and smoothly without a page refresh.

== Description ==

The **Read More Button** plugin is the ultimate solution for managing long content on your WordPress site. Whether you have lengthy blog posts, detailed product descriptions, or extensive service pages, this **content expander** tool allows you to keep your layout clean and user-friendly.

By adding a customizable **read more button**, you can **truncate text** after a specific number of lines, encouraging users to click to **expand content**. This improves the user experience by preventing large blocks of text from overwhelming your visitors. The best part? The content expands instantly **without refresh**, ensuring a seamless reading experience.

**Why Use a Read More Plugin?**
Improving readability is key to retaining visitors. A **read more tag** or button ensures that your users see the most important information first. This **expand text** functionality is perfect for mobile users who prefer scrolling through concise summaries before diving into deep content.

**Key Features:**

* **Customizable Read More Button**: Style your **show more** button to match your theme.
* **Collapse / Show Less Button**: After expanding, a "Show Less" button lets users collapse the content back. Both button labels are fully configurable.
* **Automatic Content Truncation**: Automatically **limit posts** and pages by line count.
* **Instant Expansion**: Smoothly **reveal text** and **show hidden content** **without page reload**.
* **Shortcode Support**: Use `[read_more_button]` anywhere in post content for manual control.
* **Keyboard Accessible**: Fully operable with keyboard - buttons respond to Enter/Space and focus is managed correctly after each interaction.
* **SEO Friendly**: Hidden content remains accessible to search engines.
* **Exclusion Options**: Exclude specific pages/posts by ID
* **Post Type Selection**: Choose which post types to apply the functionality to
* **Flexible Content Control**: Set after how many lines the button should appear
* **Custom Button Text**: Change the button text to match your site's tone
* **Public CPT Support**: Works with all public custom post types
* **Performance Optimized**: Lightweight code that only loads where needed

**Perfect for:**

* Blog posts with long content
* Product descriptions
* Service pages
* News articles
* Any content where you want to improve readability and user engagement

**Easy Setup:**

1. Install and activate the plugin
2. Go to Settings > Read More Button
3. Configure your preferences (colors, text, line count, post types)
4. The button will automatically appear on your selected content types


Love using this plugin? Please consider [donating](https://superwebshare.com/read-more-plugin-donate) to support its development.

== Installation ==

1. Upload the plugin files to the `/wp-content/plugins/click-to-read-more-button` directory, or install the plugin through the WordPress plugins screen directly.
2. Activate the plugin through the 'Plugins' screen in WordPress.
3. Use the Settings > Read More Button screen to configure the plugin.
4. The Read More button will now appear on your selected post types after the specified number of lines.

== Frequently Asked Questions ==

= How do I customize the button appearance? =

Go to Settings > Read More Button in your WordPress admin. You can customize:
* Button background color
* Button hover color
* Text color
* Button text

= Can I choose which post types show the Read More button? =

Yes! In the settings page, you can select which post types should display the Read More button. By default, it's enabled for posts only, but you can enable it for pages and all public custom post types.

= How do I exclude specific pages or posts? =

In the settings page, there's an "Exclude Pages/Posts by ID" field where you can enter comma-separated IDs of pages/posts you want to exclude (e.g., 1,2,3).

= What happens when someone clicks the Read More button? =

The full content is revealed smoothly and a "Show Less" button appears, allowing users to collapse the content back at any time. Both button labels are configurable from the settings page.

= Can I use a shortcode instead of the automatic filter? =

Yes! Use the `[read_more_button]` shortcode anywhere in post content to manually control which content gets truncated. It supports three optional attributes:

* `text` - overrides the Read More button label (e.g., `text="Continue Reading"`)
* `lines` - overrides the line count (e.g., `lines="10"`)
* `collapse_text` - overrides the Show Less button label (e.g., `collapse_text="Hide"`)

Example: `[read_more_button text="Read Full Article" lines="8" collapse_text="Hide"][/read_more_button]`

= Does this work with custom post types? =

Yes! The plugin automatically detects all public custom post types and includes them in the post type selection options.

= Will this affect my site's performance? =

No, the plugin is lightweight and only loads its scripts and styles on pages where the Read More functionality is enabled. It has no impact on pages where it's not being used.

= Can I change how many lines are shown before the button appears? =

Yes, you can set the number of lines in the settings page. The default is 14 lines, but you can adjust this from 1 to 50 lines based on your content needs.

= How does the line counting work? =

The plugin uses character counting (approximately 90 characters per line) to determine when to show the button. The actual visual lines may vary based on your content length, font size, screen width, and theme styling.

= Is this plugin translation ready? =

Yes, the plugin is fully prepared for translation and follows WordPress internationalization standards.

= Does the plugin work with caching plugins? =

Yes, the plugin is compatible with all major caching plugins as it doesn't use any server-side processing for the Read More functionality.

== Screenshots ==

1. Click to Read More Button Plugin settings page with all customization options
2. Read More button appearance on frontend

== Changelog ==
= 1.0.8 =
* Show Less button now appears at the same position as the Read More button, so users can collapse content without scrolling to the bottom of a long post.
* Fixed shortcode output (forms, galleries, etc.) disappearing when the Read More button is clicked. The previous implementation placed the same content in the DOM twice - once visible and once hidden. Shortcode JavaScript (e.g. contact form plugins) would initialise against the visible copy on page load, leaving the hidden copy empty or broken. Content is now placed in the DOM exactly once and visually clipped by CSS max-height, so shortcodes initialise correctly and full content is always revealed on click.
* Backward compatible with pages cached before this update - the new JavaScript handles both the old HTML structure and the new one.

= 1.0.7 =
* Fixed page jumping to the "Show Less" button when clicking "Read More" - the viewport now stays at the user's reading position after content expands.
* Fixed "Show Less" button appearing automatically for existing users who had not yet enabled that option - it now only defaults to enabled for new installs.

= 1.0.6 =
* Added collapse / Show Less button - users can now fold expanded content back after clicking Read More. Button label is configurable from Settings > Read More Button.
* Added `[read_more_button]` shortcode for manual control over which content is truncated. Supports `text`, `lines`, and `collapse_text` attributes.
* Improved keyboard accessibility - buttons respond to Enter/Space keys and focus is moved correctly after expand/collapse interactions.
* Added `aria-expanded` attributes to Read More and Show Less buttons for screen reader support.

= 1.0.5 =
* Implemented completely revamped admin page.
* Included comprehensive Support enhanced user troubleshooting

= 1.0.4 =
* Added option to select the icon for the read more button
* Added troubleshooting and support cards to settings page

= 1.0.0 =
* Initial release
* Customizable button colors and text
* Post type selection functionality
* Line count configuration
* Exclude specific pages/posts functionality
* Support for static homepage and blog pages
* Auto-detection of public custom post types
* Proper WordPress security and coding standards compliance
* Admin notices for activation and settings saved
* Settings page with version display
* Comprehensive documentation

== Upgrade Notice ==

= 1.0.0 =
Initial release of Read More Button plugin. Provides a complete solution for adding customizable read more buttons to your WordPress content.

== Developer Information ==

**Technical Details:**
* Uses WordPress coding standards and security practices
* All data properly sanitized and escaped
* Follows WordPress plugin guidelines
* Uses proper enqueue methods for scripts and styles
* Implements WordPress hooks and filters correctly
* Translation ready with proper text domain

**Shortcode:**

`[read_more_button text="Read More" lines="14" collapse_text="Show Less"]Content here[/read_more_button]`

* `text` (optional) - Read More button label. Defaults to the value set in Settings.
* `lines` (optional) - Number of lines before truncation. Defaults to the value set in Settings.
* `collapse_text` (optional) - Show Less button label. Defaults to the value set in Settings.

**Hooks and Filters:**
* `click_to_read_more_button_content_filter` - Filter the content before applying read more functionality
* `click_to_read_more_button_button_text` - Filter the button text
* `click_to_read_more_button_should_show` - Filter to control where the button should appear (receives `$show` bool and `$post_id`)

**CSS Customisation:**
The fade gradient on truncated content uses the CSS variable `--ctrmb-bg` (default: `#fff`) so it blends with any background colour. If your theme uses a non-white background, add this to your theme's stylesheet:

`body { --ctrmb-bg: #your-background-colour; }`

**Translation:**
Translation-ready `.pot` file located at `languages/click-to-read-more-button.pot`. Place translated `.po`/`.mo` files in the `languages/` folder using the naming convention `click-to-read-more-button-{locale}.po`.

**Support:**
For support and feature requests, please contact the plugin author or submit issues through the WordPress.org support forums.

**Donate:**
[Donate Here](https://superwebshare.com/read-more-plugin-donate)