Changeset 3811481
- Timestamp:
- 11/19/2026 12:16:34 PM (15 hours ago)
- Location:
- paapi-product-search-for-amazon/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (4 diffs)
-
paapi-product-search-for-amazon.php (modified) (5 diffs)
-
src/core/admin/go-live-notice.php (modified) (3 diffs)
-
src/core/admin/setup-checklist.php (modified) (4 diffs)
-
src/core/frontend/ssr/skeleton.php (modified) (1 diff)
-
src/core/shared/live-placement-cache.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
paapi-product-search-for-amazon/trunk/README.txt
r3811371 r3811481 4 4 Requires at least: 5.8 5 5 Tested up to: 7.1 6 Stable tag: 2.54. 06 Stable tag: 2.54.1 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 78 78 * **Button and display customization** - buy button color and size, custom button text, hide Amazon icon 79 79 * **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+) 81 81 * **More Managed API capacity** - 1,200 searches and product lookups a month per site (Agency: 3,600 shared across all your sites) 82 82 … … 190 190 = Can an AI assistant build product boxes and comparison tables for me? = 191 191 192 Yes, on Premium, in two ways. On the Managed API, c onnect 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/192 Yes, 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/ 193 193 194 194 = Is there a Gutenberg block? = … … 243 243 12. Home: whether the plugin is connected, your setup progress, and the product boxes and comparison tables you made recently. Free. 244 244 13. 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. 245 14. 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. 246 15. Claude asks your site for access, and you approve it in your own WordPress admin. Only a site admin can approve it. Premium. 247 16. 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. 245 248 246 249 == 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. 247 253 248 254 = 2.54.0 = -
paapi-product-search-for-amazon/trunk/paapi-product-search-for-amazon.php
r3811371 r3811481 5 5 * Plugin URI: https://paapiplugin.com/ 6 6 * 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. 07 * Version: 2.54.1 8 8 * Author: PaapiPlugin 9 9 * Author URI: https://paapiplugin.com … … 93 93 psfa_fs()->add_action( 'after_uninstall', 'psfa_product_store_uninstall' ); 94 94 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 95 100 do_action('psfa_fs_loaded'); 96 101 } … … 99 104 define('PSFA_PLUGIN_DIR', plugin_dir_path(__FILE__)); 100 105 define('PSFA_PLUGIN_URL', plugin_dir_url(__FILE__)); 101 define('PSFA_VERSION', '2.54. 0');106 define('PSFA_VERSION', '2.54.1'); 102 107 103 108 /** … … 167 172 // src/core/shared/live-placement-cache.php. Every post change drops both. 168 173 // 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. 170 176 require_once PSFA_PLUGIN_DIR . 'src/core/shared/live-placement-cache.php'; 171 177 add_action('transition_post_status', 'psfa_live_placement_flush', 10, 0); … … 173 179 add_action('deleted_post', 'psfa_live_placement_flush', 10, 0); 174 180 add_action('trashed_post', 'psfa_live_placement_flush', 10, 0); 181 add_filter('do_shortcode_tag', 'psfa_live_placement_note_render', 10, 2); 175 182 176 183 // ── 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 1 1 <?php 2 2 /** 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. 5 6 * 6 7 * A slim card on the WordPress Dashboard and the Posts and Pages lists, and … … 11 12 * draft waiting a draft or pending post holds PaapiPlugin 12 13 * no box yet no saved product box 13 * not published a saved box, but no published post holds PaapiPlugin14 * not published a saved box, but nothing shows PaapiPlugin publicly 14 15 * 15 16 * The X is the existing courtesy dismiss: psfa_notification_read stamps the … … 18 19 * on that id hides it for good. Per user, like every courtesy dismiss. 19 20 * 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 24 26 * the item only where the card can print, on the plugin's own pages and in 25 27 * AJAX requests; never on the Plugins screen. -
paapi-product-search-for-amazon/trunk/src/core/admin/setup-checklist.php
r3806998 r3811481 96 96 97 97 /** 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. 105 113 * 106 114 * draftEditUrl is the raw edit link of the most recently modified draft or … … 118 126 * notices.php docblock records. See src/core/shared/live-placement-cache.php. 119 127 * 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. 121 129 * 122 130 * @since 2.45.0 … … 136 144 137 145 /** 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. 139 148 * 140 149 * @since 2.45.0 … … 148 157 149 158 if ( '1' === get_transient( PSFA_LIVE_PLACEMENT_CACHE ) ) { 159 return $live; 160 } 161 162 if ( psfa_live_placement_seen_recently( time() ) ) { 150 163 return $live; 151 164 } -
paapi-product-search-for-amazon/trunk/src/core/frontend/ssr/skeleton.php
r3811371 r3811481 8 8 * initial content while React hydrates on the client. 9 9 * 10 * Generated: 2026-11-19T 08:13:49.462Z10 * Generated: 2026-11-19T12:12:10.699Z 11 11 */ 12 12 -
paapi-product-search-for-amazon/trunk/src/core/shared/live-placement-cache.php
r3801546 r3811481 4 4 * src/core/admin/setup-checklist.php) keeps between reads. 5 5 * 6 * Two layers:6 * Layers: 7 7 * - a request-local read, so the checklist, the notifications feed and the 8 8 * go-live card share one set of posts queries per request; 9 9 * - a positive answer only: once a published post holds PaapiPlugin, "live" 10 10 * 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. 12 26 * 13 27 * Why a positive answer may be kept when the notices.php docblock records … … 15 29 * "live" can only hide a courtesy card or tick a Home step early. It can 16 30 * 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. 18 34 * 19 35 * Loaded on every request, not only in wp-admin, because posts are also 20 36 * 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. 23 40 * 24 41 * @package PSFA … … 32 49 if ( ! defined( 'PSFA_LIVE_PLACEMENT_CACHE' ) ) { 33 50 define( 'PSFA_LIVE_PLACEMENT_CACHE', 'psfa_live_placement_live' ); 51 } 52 53 if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN' ) ) { 54 define( 'PSFA_LIVE_PLACEMENT_SEEN', 'psfa_live_placement_seen' ); 55 } 56 57 if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN_REFRESH' ) ) { 58 define( 'PSFA_LIVE_PLACEMENT_SEEN_REFRESH', DAY_IN_SECONDS ); 59 } 60 61 if ( ! defined( 'PSFA_LIVE_PLACEMENT_SEEN_WINDOW' ) ) { 62 define( 'PSFA_LIVE_PLACEMENT_SEEN_WINDOW', 30 * DAY_IN_SECONDS ); 34 63 } 35 64 … … 62 91 function psfa_live_placement_reset_request(): void { 63 92 psfa_live_placement_memo( null, true ); 93 psfa_live_placement_render_noted( false ); 64 94 } 65 95 … … 75 105 psfa_live_placement_reset_request(); 76 106 } 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 */ 116 function 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 */ 133 function 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 */ 155 function 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 */ 170 function 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 */ 212 function 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 */ 236 function psfa_live_placement_uninstall(): void { 237 delete_option( PSFA_LIVE_PLACEMENT_SEEN ); 238 }
Note:
See TracChangeset
for help on using the changeset viewer.