Plugin Directory

Changeset 3811481


Ignore:
Timestamp:
11/19/2026 12:16:34 PM (15 hours ago)
Author:
paapiplugin
Message:

Version 2.54.1

  • Fix: The "publish a post with your box" notice and the Home setup step now see boxes placed through widgets, theme templates, synced patterns and page builders, not only boxes pasted into a post.
Location:
paapi-product-search-for-amazon/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • paapi-product-search-for-amazon/trunk/README.txt

    r3811371 r3811481  
    44Requires at least: 5.8
    55Tested up to: 7.1
    6 Stable tag: 2.54.0
     6Stable tag: 2.54.1
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    7878* **Button and display customization** - buy button color and size, custom button text, hide Amazon icon
    7979* **Settings import and export** - copy settings between sites, also with WP-CLI
    80 * **AI assistant tools** - search Amazon and get box shortcodes in Claude or ChatGPT with a one-time code (Managed API). The free MCP Adapter plugin adds tables and drafts (WP 6.9+)
     80* **AI assistant tools** - connect Claude or ChatGPT without a code for Amazon product box shortcodes in the chat (Managed API). The free MCP Adapter plugin adds tables and drafts (WP 6.9+)
    8181* **More Managed API capacity** - 1,200 searches and product lookups a month per site (Agency: 3,600 shared across all your sites)
    8282
    … …  
    190190= Can an AI assistant build product boxes and comparison tables for me? =
    191191
    192 Yes, on Premium, in two ways. On the Managed API, connect Claude or ChatGPT with a one-time code from the Amazon connection page. Then ask in the chat for Amazon products and it gives you product box shortcodes to paste into a post. On WordPress 6.9 or later, you can also install the free MCP Adapter plugin, create a WordPress application password, and connect an AI app that supports MCP, like Claude Desktop. Ask it to compare three air fryers and it finds the products, makes the table and saves a draft post with the shortcode already in it. It never publishes anything. You review the draft and publish it yourself. Each WordPress user can make 30 lookups an hour this way. Either way, PaapiPlugin gives the assistant product names, brands and images but never a price to put in your post, and each lookup counts the same as one from your site. Setup steps are in the AI assistant documentation: https://paapiplugin.com/ai-assistant-documentation/
     192Yes, on Premium, in two ways. On the Managed API, click Connect Claude on the Amazon connection page and approve it on your own site, or add the connector URL shown there in ChatGPT and enter your site's address when it asks. Then ask in the chat for Amazon products and it gives you product box shortcodes to paste into a post. On WordPress 6.9 or later, you can also install the free MCP Adapter plugin, create a WordPress application password, and connect an AI app that supports MCP, like Claude Desktop. Ask it to compare three air fryers and it finds the products, makes the table and saves a draft post with the shortcode already in it. It never publishes anything. You review the draft and publish it yourself. Each WordPress user can make 30 lookups an hour this way. Either way, PaapiPlugin gives the assistant product names, brands and images but never a price to put in your post, and each lookup counts the same as one from your site. Setup steps are in the AI assistant documentation: https://paapiplugin.com/ai-assistant-documentation/
    193193
    194194= Is there a Gutenberg block? =
    … …  
    24324312. Home: whether the plugin is connected, your setup progress, and the product boxes and comparison tables you made recently. Free.
    24424413. The Appearance page: set the color and size of product titles, brands, prices and deal badges, and watch a real product box change beside the controls. Premium.
     24514. The Amazon connection page: click Connect Claude to add PaapiPlugin to Claude, or copy the connector URL for ChatGPT. No code to copy. Premium, on the Managed API.
     24615. Claude asks your site for access, and you approve it in your own WordPress admin. Only a site admin can approve it. Premium.
     24716. Then ask Claude for an Amazon product. It searches through your site's connection and gives you a product box shortcode to paste into a post. Premium, on the Managed API.
    245248
    246249== Changelog ==
     250
     251= 2.54.1 =
     252* Fix: The "publish a post with your box" notice and the Home setup step now see boxes placed through widgets, theme templates, synced patterns and page builders, not only boxes pasted into a post.
    247253
    248254= 2.54.0 =
  • paapi-product-search-for-amazon/trunk/paapi-product-search-for-amazon.php

    r3811371 r3811481  
    55 * Plugin URI: https://paapiplugin.com/
    66 * Description: Amazon affiliate plugin: product boxes, comparison tables and live search, free to start, no Amazon API credentials needed yet. Your Associate tag on every link.
    7  * Version: 2.54.0
     7 * Version: 2.54.1
    88 * Author: PaapiPlugin
    99 * Author URI: https://paapiplugin.com
    … …  
    9393    psfa_fs()->add_action( 'after_uninstall', 'psfa_product_store_uninstall' );
    9494
     95    // The last time a plugin shortcode rendered for the public goes too. The
     96    // callback lives in src/core/shared/live-placement-cache.php, which the
     97    // entry file loads at file scope below.
     98    psfa_fs()->add_action( 'after_uninstall', 'psfa_live_placement_uninstall' );
     99
    95100    do_action('psfa_fs_loaded');
    96101}
    … …  
    99104define('PSFA_PLUGIN_DIR', plugin_dir_path(__FILE__));
    100105define('PSFA_PLUGIN_URL', plugin_dir_url(__FILE__));
    101 define('PSFA_VERSION', '2.54.0');
     106define('PSFA_VERSION', '2.54.1');
    102107
    103108/**
    … …  
    167172// src/core/shared/live-placement-cache.php. Every post change drops both.
    168173// File scope, because posts also change through REST, wp-cron and WP-CLI,
    169 // where is_admin() is false.
     174// where is_admin() is false. The do_shortcode_tag filter keeps the time a
     175// plugin shortcode last rendered for the public, which no post change drops.
    170176require_once PSFA_PLUGIN_DIR . 'src/core/shared/live-placement-cache.php';
    171177add_action('transition_post_status', 'psfa_live_placement_flush', 10, 0);
    … …  
    173179add_action('deleted_post', 'psfa_live_placement_flush', 10, 0);
    174180add_action('trashed_post', 'psfa_live_placement_flush', 10, 0);
     181add_filter('do_shortcode_tag', 'psfa_live_placement_note_render', 10, 2);
    175182
    176183// ── Top-products background pre-generation (stale-while-revalidate, 2026-05-28) ──
  • paapi-product-search-for-amazon/trunk/src/core/admin/go-live-notice.php

    r3801546 r3811481  
    11<?php
    22/**
    3  * Go-live courtesy notice: PaapiPlugin is connected, but no published post
    4  * holds it yet.
     3 * Go-live courtesy notice: PaapiPlugin is connected, but the site does not
     4 * show it yet. Live is psfa_live_placement_state(): a published post holds
     5 * it, or one of its shortcodes rendered for a logged-out visitor lately.
    56 *
    67 * A slim card on the WordPress Dashboard and the Posts and Pages lists, and
    … …  
    1112 *   draft waiting  a draft or pending post holds PaapiPlugin
    1213 *   no box yet     no saved product box
    13  *   not published  a saved box, but no published post holds PaapiPlugin
     14 *   not published  a saved box, but nothing shows PaapiPlugin publicly
    1415 *
    1516 * The X is the existing courtesy dismiss: psfa_notification_read stamps the
    … …  
    1819 * on that id hides it for good. Per user, like every courtesy dismiss.
    1920 *
    20  * Once a post is live the notice stops, with nothing to clean up. The posts
    21  * queries run only after the capability, the connection and the dismiss
    22  * checks pass, at most once per request, and not at all while the live
    23  * answer is kept (src/core/shared/live-placement-cache.php). The feed builds
     21 * Once the site is live the notice stops, with nothing to clean up. The
     22 * posts queries run only after the capability, the connection and the
     23 * dismiss checks pass, at most once per request, and not at all while the
     24 * live answer is kept or a public render is recent
     25 * (src/core/shared/live-placement-cache.php). The feed builds
    2426 * the item only where the card can print, on the plugin's own pages and in
    2527 * AJAX requests; never on the Plugins screen.
  • paapi-product-search-for-amazon/trunk/src/core/admin/setup-checklist.php

    r3806998 r3811481  
    9696
    9797/**
    98  * Whether PaapiPlugin is on the public site, read from the posts themselves.
    99  *
    100  * live is true when a published post of a public post type other than
    101  * attachment holds the literal [psfa_ (the opening of every shortcode the
    102  * plugin registers) in post_content or in the _elementor_data meta, where
    103  * Elementor keeps its widgets. Drafts, pending, scheduled, private and
    104  * trashed posts, auto-drafts and revisions are not live.
     98 * Whether PaapiPlugin is on the public site, read from the posts and from
     99 * the plugin's own shortcodes rendering for the public.
     100 *
     101 * live is true when either holds:
     102 *   - a published post of a public post type other than attachment holds
     103 *     the literal [psfa_ (the opening of every shortcode the plugin
     104 *     registers) in post_content or in the _elementor_data meta, where
     105 *     Elementor keeps its widgets. Drafts, pending, scheduled, private and
     106 *     trashed posts, auto-drafts and revisions are not live;
     107 *   - a shortcode whose tag starts with psfa_ rendered for a logged-out
     108 *     visitor on a public front-end view within
     109 *     PSFA_LIVE_PLACEMENT_SEEN_WINDOW, as psfa_live_placement_note_render()
     110 *     keeps it. This sees boxes no post holds: theme files run through a
     111 *     wrapper shortcode, widgets, synced patterns, block theme templates and
     112 *     other builders' meta. It can only say live, never not live.
    105113 *
    106114 * draftEditUrl is the raw edit link of the most recently modified draft or
    … …  
    118126 * notices.php docblock records. See src/core/shared/live-placement-cache.php.
    119127 * At most two prepared LIMIT 1 queries per request, none while the live
    120  * answer is kept. Nothing leaves the site.
     128 * answer is kept or a public render is recent. Nothing leaves the site.
    121129 *
    122130 * @since 2.45.0
    … …  
    136144
    137145/**
    138  * The placement as the kept live answer or the posts show it.
     146 * The placement as the kept live answer, a recent public render or the
     147 * posts show it, in that order.
    139148 *
    140149 * @since 2.45.0
    … …  
    148157
    149158        if ( '1' === get_transient( PSFA_LIVE_PLACEMENT_CACHE ) ) {
     159                return $live;
     160        }
     161
     162        if ( psfa_live_placement_seen_recently( time() ) ) {
    150163                return $live;
    151164        }
  • paapi-product-search-for-amazon/trunk/src/core/frontend/ssr/skeleton.php

    r3811371 r3811481  
    88 * initial content while React hydrates on the client.
    99 *
    10  * Generated: 2026-11-19T08:13:49.462Z
     10 * Generated: 2026-11-19T12:12:10.699Z
    1111 */
    1212
  • paapi-product-search-for-amazon/trunk/src/core/shared/live-placement-cache.php

    r3801546 r3811481  
    44 * src/core/admin/setup-checklist.php) keeps between reads.
    55 *
    6  * Two layers:
     6 * Layers:
    77 *   - a request-local read, so the checklist, the notifications feed and the
    88 *     go-live card share one set of posts queries per request;
    99 *   - a positive answer only: once a published post holds PaapiPlugin, "live"
    1010 *     is kept in the psfa_live_placement_live transient for 12 hours. A
    11  *     not-live answer and the draft link are never stored.
     11 *     not-live answer and the draft link are never stored;
     12 *   - the last time a plugin shortcode rendered for the public, in the
     13 *     psfa_live_placement_seen option. That catches boxes no post holds:
     14 *     theme files run through a wrapper shortcode, widgets, synced patterns,
     15 *     block theme templates and builders that keep their layout elsewhere.
     16 *
     17 * A render counts only when its tag starts with psfa_, the request is a
     18 * front-end page view (not wp-admin, AJAX, wp-cron, REST or WP-CLI), the
     19 * visitor is logged out, the view is not a post preview or the customizer,
     20 * and a singular view shows a published post. Logged-in views are left out
     21 * so a builder preview, the box builder's preview frame or an editor's own
     22 * look at a draft never reads as live. The time is written at most once per
     23 * request and only when the kept one is missing, unreadable, from the future
     24 * or older than PSFA_LIVE_PLACEMENT_SEEN_REFRESH. A render inside the last
     25 * PSFA_LIVE_PLACEMENT_SEEN_WINDOW reads as live.
    1226 *
    1327 * Why a positive answer may be kept when the notices.php docblock records
    … …  
    1529 * "live" can only hide a courtesy card or tick a Home step early. It can
    1630 * never show a banner that should be gone, which is the failure that
    17  * docblock warns about. And every change to a post clears it.
     31 * docblock warns about. Every change to a post clears the transient. The
     32 * render time is not tied to a post, so a post change leaves it; it ages out
     33 * of the window instead.
    1834 *
    1935 * Loaded on every request, not only in wp-admin, because posts are also
    2036 * published, edited and trashed through REST (the block editor), wp-cron
    21  * (scheduled posts) and WP-CLI. Elementor saves its data and then calls
    22  * wp_update_post(), so its saves reach save_post too.
     37 * (scheduled posts) and WP-CLI, and because shortcodes render on the front
     38 * end. Elementor saves its data and then calls wp_update_post(), so its
     39 * saves reach save_post too.
    2340 *
    2441 * @package PSFA
    … …  
    3249if ( ! defined( 'PSFA_LIVE_PLACEMENT_CACHE' ) ) {
    3350        define( 'PSFA_LIVE_PLACEMENT_CACHE', 'psfa_live_placement_live' );
     51}
     52
     53if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN' ) ) {
     54        define( 'PSFA_LIVE_PLACEMENT_SEEN', 'psfa_live_placement_seen' );
     55}
     56
     57if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN_REFRESH' ) ) {
     58        define( 'PSFA_LIVE_PLACEMENT_SEEN_REFRESH', DAY_IN_SECONDS );
     59}
     60
     61if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN_WINDOW' ) ) {
     62        define( 'PSFA_LIVE_PLACEMENT_SEEN_WINDOW', 30 * DAY_IN_SECONDS );
    3463}
    3564
    … …  
    6291function psfa_live_placement_reset_request(): void {
    6392        psfa_live_placement_memo( null, true );
     93        psfa_live_placement_render_noted( false );
    6494}
    6595
    … …  
    75105        psfa_live_placement_reset_request();
    76106}
     107
     108/**
     109 * Whether this request already handled a public render: sets the flag when
     110 * given one, else reads it.
     111 *
     112 * @since 2.54.1
     113 * @param bool|null $noted Flag to keep for this request, or null to read.
     114 * @return bool
     115 */
     116function psfa_live_placement_render_noted( ?bool $noted = null ): bool {
     117        static $kept = false;
     118
     119        if ( null !== $noted ) {
     120                $kept = $noted;
     121        }
     122
     123        return $kept;
     124}
     125
     126/**
     127 * The kept render time as a unix time, or null when it is missing or is not
     128 * a whole non-negative number (an int, or digits as the database returns it).
     129 *
     130 * @since 2.54.1
     131 * @return int|null
     132 */
     133function psfa_live_placement_seen_at(): ?int {
     134        $seen = get_option( PSFA_LIVE_PLACEMENT_SEEN, null );
     135
     136        if ( is_int( $seen ) ) {
     137                return $seen >= 0 ? $seen : null;
     138        }
     139
     140        if ( is_string( $seen ) && '' !== $seen && ctype_digit( $seen ) ) {
     141                return (int) $seen;
     142        }
     143
     144        return null;
     145}
     146
     147/**
     148 * Whether a plugin shortcode rendered for the public within
     149 * PSFA_LIVE_PLACEMENT_SEEN_WINDOW of $now. A time after $now does not count.
     150 *
     151 * @since 2.54.1
     152 * @param int $now Unix time.
     153 * @return bool
     154 */
     155function psfa_live_placement_seen_recently( int $now ): bool {
     156        $seen = psfa_live_placement_seen_at();
     157
     158        return null !== $seen && $seen <= $now && $now - $seen < PSFA_LIVE_PLACEMENT_SEEN_WINDOW;
     159}
     160
     161/**
     162 * Whether a render of $tag in this request is the public seeing PaapiPlugin.
     163 * See the file docblock for the rule. Fail-closed: a missing context
     164 * function means not public.
     165 *
     166 * @since 2.54.1
     167 * @param mixed $tag Shortcode tag.
     168 * @return bool
     169 */
     170function psfa_live_placement_render_is_public( $tag ): bool {
     171        if ( ! is_string( $tag ) || 0 !== strpos( $tag, 'psfa_' ) ) {
     172                return false;
     173        }
     174
     175        if ( is_admin() || wp_doing_ajax() || wp_doing_cron() ) {
     176                return false;
     177        }
     178
     179        if ( ( defined( 'REST_REQUEST' ) && REST_REQUEST ) || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
     180                return false;
     181        }
     182
     183        foreach ( array( 'is_user_logged_in', 'is_preview', 'is_customize_preview', 'is_singular', 'get_queried_object' ) as $function ) {
     184                if ( ! function_exists( $function ) ) {
     185                        return false;
     186                }
     187        }
     188
     189        if ( is_user_logged_in() || is_preview() || is_customize_preview() ) {
     190                return false;
     191        }
     192
     193        if ( is_singular() ) {
     194                $post = get_queried_object();
     195                if ( ! $post instanceof WP_Post || 'publish' !== $post->post_status ) {
     196                        return false;
     197                }
     198        }
     199
     200        return true;
     201}
     202
     203/**
     204 * Do_shortcode_tag callback: keeps the time a plugin shortcode rendered for
     205 * the public, then returns the output unchanged.
     206 *
     207 * @since 2.54.1
     208 * @param mixed $output Shortcode output.
     209 * @param mixed $tag    Shortcode tag.
     210 * @return mixed The output, unchanged.
     211 */
     212function psfa_live_placement_note_render( $output, $tag = null ) {
     213        if ( psfa_live_placement_render_noted() || ! psfa_live_placement_render_is_public( $tag ) ) {
     214                return $output;
     215        }
     216
     217        psfa_live_placement_render_noted( true );
     218
     219        $now  = time();
     220        $seen = psfa_live_placement_seen_at();
     221        if ( null !== $seen && $seen <= $now && $now - $seen < PSFA_LIVE_PLACEMENT_SEEN_REFRESH ) {
     222                return $output;
     223        }
     224
     225        update_option( PSFA_LIVE_PLACEMENT_SEEN, $now, true );
     226
     227        return $output;
     228}
     229
     230/**
     231 * Uninstall cleanup: drop the kept render time.
     232 *
     233 * @since 2.54.1
     234 * @return void
     235 */
     236function psfa_live_placement_uninstall(): void {
     237        delete_option( PSFA_LIVE_PLACEMENT_SEEN );
     238}
Note: See TracChangeset for help on using the changeset viewer.