=== MrSeokar Inline Related Products for WooCommerce ===
Contributors: inmoon
Tags: related products, woocommerce, affiliate, inline products, product recommendations
Requires at least: 5.2
Tested up to: 7.1
Requires PHP: 7.2
Stable tag: 2.0.1
License: GPLv3 or later
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Show related WooCommerce products inside your blog posts, between headings, paragraphs or images. For online stores and affiliate sites.

== Description ==

MrSeokar Inline Related Products for WooCommerce automatically shows **related products inside your blog posts**: between the headings, paragraphs or images of every article, exactly where readers are paying attention. No shortcodes, no snippets, no editing posts one by one.

Activate the plugin, pick a style, and every post starts recommending matching products. Want full control over an important article? Choose its products by hand from the post editor.

= Who is it for? =

* **Online stores with a blog** – show your products right inside your articles.
* **Affiliate sites** – list your affiliate offers as WooCommerce external/affiliate products and show them automatically in every review, guide and comparison post. The buy button can go straight to the affiliate link with `rel="sponsored nofollow"`.
* **Content sites** – add product recommendations to existing articles without editing them.

= Features =

* **Show related products in blog posts automatically** – before every heading (H2 to H6), paragraph or image, or every other one.
* **Smart product matching** – four methods: post title (priority on the last or first words), the focus keyword of Yoast SEO or Rank Math, or smart detection of a product category named in the post title.
* **Per-post control from one simple box** – search and pick products, choose a product category, or turn products off for a single post. No snippets needed, even with hundreds of posts.
* **Affiliate ready** – external/affiliate products link directly to the affiliate URL with the product's own button text.
* **Four responsive designs** – vertical card, horizontal row, text over image, image beside details.
* **Simple, variable, grouped and external products** – sale prices and price ranges use your WooCommerce currency and tax settings.
* **Fully customizable** – button text, label text ("You May Also Like"), colors, product name tag, new-tab links.
* **Skips unavailable products** – out-of-stock, hidden and zero-price products are not shown (optional).
* **Works with any theme and page builder** – Elementor, Elementor Pro theme builder, the block editor (Gutenberg), Classic Editor, WPBakery, Divi, Beaver Builder, Bricks, Oxygen and block themes. Your article markup is read with the WordPress HTML API and never rebuilt.
* **Built for speed** – the product boxes of each post are cached with the post, so after the first view the plugin adds **zero database queries**. The cache clears itself when products, prices, stock or settings change, and a "Clear cache" button is included.
* **SEO friendly** – product names use a paragraph tag by default, so they never pollute your heading structure or table of contents.
* **RTL and multilingual** – works in left-to-right and right-to-left languages; English and Persian included, translation ready.
* **Lightweight and private** – no tracking, no external requests, no ads in your dashboard.

= How related products are found =

1. Products or a category you chose for the post are used first.
2. Otherwise the selected automatic method finds matching products. If the focus keyword or the smart method finds nothing, the words of the post title are used.
3. Out-of-stock, hidden and zero-price products are skipped (unless you allow them).

= Privacy =

This plugin does not collect any data, does not set cookies and does not connect to any external service.

= For developers =

Filters: `mrseokar_ip_should_insert`, `mrseokar_ip_post_types`, `mrseokar_ip_product_ids`, `mrseokar_ip_keywords`, `mrseokar_ip_focus_keyword`, `mrseokar_ip_product_html`, `mrseokar_ip_cache_ttl`, `mrseokar_ip_content_priority`.

Example – never show products in the "news" category:

`add_filter( 'mrseokar_ip_should_insert', function ( $insert, $post_id ) { return has_category( 'news', $post_id ) ? false : $insert; }, 10, 2 );`

= Author =

Made by [Ebrahim Hanafi (MrSeokar)](https://ehm.ir/). Documentation: [Inline products in blog posts](https://ehm.ir/inline-products-in-blog/).

WooCommerce is a trademark of Automattic Inc. This plugin is not affiliated with or endorsed by Automattic.

== Installation ==

1. Make sure WooCommerce is installed and active.
2. Go to **Plugins → Add New**, search for "MrSeokar Inline Related Products", then install and activate it.
3. Go to **WooCommerce → Inline Products**, choose where products appear and how they look, and save.
4. Open any blog post – related products are already shown inside the content.

== Frequently Asked Questions ==

= How do I show related products in a WordPress blog post? =

Install the plugin and activate it. Related WooCommerce products are added inside every blog post automatically, before the headings of the article by default. You can change the position, the number of products and the design in **WooCommerce → Inline Products**.

= Can I use it for an affiliate site? =

Yes. Add your offers as WooCommerce "External/Affiliate" products. They are shown inside your articles like any other product, and the buy button can go straight to the affiliate link with `rel="sponsored nofollow"`.

= Can I choose the products of a single post? =

Yes. Edit the post and use the **Inline Products** box under the editor: search and pick products, choose a product category, or tick **Do not show products in this post**. There is no need to create snippets or shortcodes for each post.

= Does it work with Elementor? =

Yes. It works with posts built with Elementor and with single post templates made in Elementor Pro's theme builder (Post Content widget). Products are not added inside the Elementor editor, only on the live page.

= Does it slow down my site? =

No. Related products are searched only on the first view of a post. The finished boxes are stored with the post and reused without any extra database query until something changes (a product, its price or stock, a category, the post or the plugin settings) or the cache time you chose passes.

= No products appear in my post. Why? =

* The post type is selected in **Show products in** (Posts by default).
* The article contains the tag chosen in **Insert products before** (for example Heading 2). If your sections use Heading 3, choose Heading 3.
* Matching products exist. If the title words match no product, choose products or a category in the post's **Inline Products** box.
* The products are in stock and have a price, or **Out-of-stock products** is enabled.
* You just changed products outside WooCommerce: click **Clear cache**.

= Does it change my posts? =

No. Nothing is written into your post content. Products are added only when a post is displayed, so deactivating the plugin removes them everywhere.

= Products appear in my table of contents. =

Set **HTML tag of the product name** to "p" (the default). Heading tags make product names part of the article outline.

= Is it compatible with caching and SEO plugins? =

Yes. The output is normal HTML that page caches store like the rest of the article, and it works alongside Yoast SEO, Rank Math and table-of-contents plugins.

= Where can I get help? =

Use the support forum of the plugin on WordPress.org or visit [ehm.ir](https://ehm.ir/).

== Screenshots ==

1. Related products shown inside a blog post.
2. The four product box styles.
3. Settings page.
4. Choosing the products of a single post.

== Changelog ==

= 2.0.1 =
* Main plugin file renamed to mrseokar-inline-products.php (sites updating from 1.x are switched automatically).
* Readme clarified.

= 2.0.0 =
* Renamed to "MrSeokar Inline Related Products for WooCommerce" and prepared for WordPress.org.
* New: affiliate mode – external products link straight to the affiliate URL (rel="sponsored nofollow").
* New: per-post cache of the product boxes with automatic invalidation and a "Clear cache" button: no extra database queries after the first view.
* New: the content is read with the WordPress HTML API (WordPress 6.2+), with a built-in fallback for older versions.
* New: choose products with WooCommerce's product search in the post editor.
* New: turn products off for a single post.
* New: choose the post types where products appear.
* New: open products in a new tab (optional).
* New: right-to-left and left-to-right layouts.
* New: compatible with WooCommerce High-Performance Order Storage.
* Fixed: fatal error on large pages, for example posts built with Elementor.
* Fixed: an empty post could be displayed when the content could not be processed.
* Fixed: fatal error with variable products.
* Fixed: fatal error when WooCommerce is not active.
* Fixed: products were inserted inside links, lists and tables.
* Fixed: products were added to related-post widgets and page-builder templates.
* Fixed: "Every other" position setting skipped half of the products.
* Fixed: hiding out-of-stock products did not work.
* Fixed: the regular price was shown crossed out even when the product was not on sale.
* Fixed: color picker not loading.
* Improved: all settings stored in one option; every input sanitized and every output escaped.
* Removed: the bundled HTML parser library, remote images and the dashboard-wide notice.
* Settings of version 1.x are migrated automatically.

= 1.2 =
* Focus keyword and smart category detection methods.

== Upgrade Notice ==

= 2.0.1 =
Major update: affiliate mode, zero-query cache, Elementor compatibility and many bug fixes. Settings are migrated automatically.

= 2.0.0 =
Major update: affiliate mode, zero-query cache, Elementor compatibility and many bug fixes. Settings are migrated automatically.
