Changeset 3835792
- Timestamp:
- 11/30/2026 05:49:36 PM (less than one hour ago)
- Location:
- depictronix-rapiditem
- Files:
-
- 4 added
- 22 edited
- 1 copied
-
tags/1.10.1 (copied) (copied from depictronix-rapiditem/trunk )
-
tags/1.10.1/assets/campaign-settings.js (added)
-
tags/1.10.1/assets/campaigns.css (added)
-
tags/1.10.1/assets/campaigns.js (modified) (4 diffs)
-
tags/1.10.1/blocks/product-card/block.json (modified) (2 diffs)
-
tags/1.10.1/blocks/product-card/editor.asset.php (modified) (1 diff)
-
tags/1.10.1/blocks/product-card/editor.js (modified) (4 diffs)
-
tags/1.10.1/blocks/product-card/style.css (modified) (10 diffs)
-
tags/1.10.1/depictronix-rapiditem.php (modified) (2 diffs)
-
tags/1.10.1/includes/class-campaign-admin.php (modified) (4 diffs)
-
tags/1.10.1/includes/class-campaigns.php (modified) (6 diffs)
-
tags/1.10.1/includes/class-renderer.php (modified) (6 diffs)
-
tags/1.10.1/includes/trait-settings-admin.php (modified) (3 diffs)
-
tags/1.10.1/readme.txt (modified) (3 diffs)
-
trunk/assets/campaign-settings.js (added)
-
trunk/assets/campaigns.css (added)
-
trunk/assets/campaigns.js (modified) (4 diffs)
-
trunk/blocks/product-card/block.json (modified) (2 diffs)
-
trunk/blocks/product-card/editor.asset.php (modified) (1 diff)
-
trunk/blocks/product-card/editor.js (modified) (4 diffs)
-
trunk/blocks/product-card/style.css (modified) (10 diffs)
-
trunk/depictronix-rapiditem.php (modified) (2 diffs)
-
trunk/includes/class-campaign-admin.php (modified) (4 diffs)
-
trunk/includes/class-campaigns.php (modified) (6 diffs)
-
trunk/includes/class-renderer.php (modified) (6 diffs)
-
trunk/includes/trait-settings-admin.php (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
depictronix-rapiditem/tags/1.10.1/assets/campaigns.js
r3834137 r3835792 1 1 ( function () { 2 2 'use strict'; 3 // Holding release: never render notices, including when an old page loads this URL. 4 var displayEnabled = false; 5 if ( ! displayEnabled ) { 6 var clearNotices = function () { 7 document.querySelectorAll( '.rapiditem-card .rapiditem-card__store-offer' ).forEach( function ( wrapper ) { 8 var button = wrapper.querySelector( 'a.rapiditem-card__button' ); 9 if ( button ) { wrapper.replaceWith( button ); } 10 } ); 11 document.querySelectorAll( '.rapiditem-card .rapiditem-card__campaign' ).forEach( function ( notice ) { notice.remove(); } ); 12 document.querySelectorAll( '.rapiditem-card .rapiditem-card__buttons--campaigns' ).forEach( function ( group ) { group.classList.remove( 'rapiditem-card__buttons--campaigns' ); } ); 13 }; 14 if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', clearNotices ); } else { clearNotices(); } 15 return; 16 } 3 17 var config = window.rapiditemCampaigns; 4 18 if ( ! config || ! window.fetch ) { return; } … … 27 41 }; 28 42 var current = function ( store ) { 43 // Also reject old cached Amazon facts while this feature is withdrawn. 44 if ( store === 'amazon' ) { return null; } 29 45 var record = snapshot && snapshot.stores && snapshot.stores[ store ]; 30 46 if ( ! record || ! Number.isFinite( record.valid_until ) || record.valid_until <= now() || ! Array.isArray( record.events ) ) { return null; } … … 33 49 typeof event.title === 'string' && event.title.length <= 150 && typeof event.until === 'string' && allowed( store, event.url ); 34 50 } ) || null; 51 }; 52 var appearance = function () { 53 var value = ( snapshot && snapshot.appearance ) || config.appearance || {}; 54 return { 55 style: value.style === 'text' ? 'text' : 'label', 56 size: { small: '.75em', normal: '.8em', large: '.9em' }[ value.size ] || '.8em', 57 accent: /^#[0-9a-f]{6}$/i.test( value.accent ) ? value.accent : '#B45309' 58 }; 35 59 }; 36 60 var sync = function () { … … 51 75 wrapper.appendChild( button ); 52 76 } 53 var signature = JSON.stringify( [ event.title, event.until, event.url, event.start, event.end ] ); 77 var visual = appearance(); 78 var signature = JSON.stringify( [ event.title, event.until, event.url, event.start, event.end, visual ] ); 54 79 if ( wrapper.dataset.campaignSignature === signature ) { return; } 55 80 var old = wrapper.querySelector( '.rapiditem-card__campaign' ); 56 81 if ( old ) { old.remove(); } 57 82 var notice = document.createElement( 'a' ); 58 notice.className = 'rapiditem-card__campaign'; 83 notice.className = 'rapiditem-card__campaign rapiditem-card__campaign--' + visual.style; 84 notice.style.setProperty( '--rapiditem-campaign-font-size', visual.size ); 85 notice.style.setProperty( '--rapiditem-campaign-accent', visual.accent ); 59 86 notice.href = event.url; 60 87 notice.target = '_blank'; -
depictronix-rapiditem/tags/1.10.1/blocks/product-card/block.json
r3834137 r3835792 3 3 "apiVersion": 3, 4 4 "name": "rapiditem/product-card", 5 "version": "1.10. 0",5 "version": "1.10.1", 6 6 "title": "Rapidアイテム", 7 7 "category": "widgets", … … 24 24 "headingLevel": { 25 25 "type": "string", 26 "default": " h3"26 "default": "div" 27 27 }, 28 28 "hiddenStores": { -
depictronix-rapiditem/tags/1.10.1/blocks/product-card/editor.asset.php
r3834137 r3835792 11 11 'wp-hooks', 12 12 ), 13 'version' => '1.10. 0',13 'version' => '1.10.1', 14 14 ); -
depictronix-rapiditem/tags/1.10.1/blocks/product-card/editor.js
r3834115 r3835792 204 204 var productLimit = 2; 205 205 var layout = 'columns'; 206 var headingLevel = [ ' h2', 'h3', 'h4', 'h5', 'h6' ].indexOf( props.attributes.headingLevel ) !== -1 ? props.attributes.headingLevel : 'h3';206 var headingLevel = [ 'div', 'h2', 'h3', 'h4', 'h5', 'h6' ].indexOf( props.attributes.headingLevel ) !== -1 ? props.attributes.headingLevel : 'div'; 207 207 var pickerRef = useRef( props.picker ); 208 208 pickerRef.current = props.picker; … … 613 613 overrides: entry.overrides || {}, 614 614 hiddenStores: disabledStores || [], 615 headingLevel: selectedHeadingLevel || ' h3'615 headingLevel: selectedHeadingLevel || 'div' 616 616 }, 617 617 signal: controller ? controller.signal : undefined … … 1627 1627 value: headingLevel, 1628 1628 options: [ 1629 { label: __( '見出しなし(標準)', 'depictronix-rapiditem' ), value: 'div' }, 1629 1630 { label: 'H2', value: 'h2' }, 1630 1631 { label: 'H3', value: 'h3' }, … … 1633 1634 { label: 'H6', value: 'h6' } 1634 1635 ], 1635 help: __( ' 記事内の見出し構造に合わせて選択します。既存ブロックはH3のままです。', 'depictronix-rapiditem' ),1636 help: __( '標準では商品名を記事の見出しに含めません。見出しとして使う場合だけH2〜H6を選択してください。', 'depictronix-rapiditem' ), 1636 1637 onChange: function ( value ) { props.setAttributes( { headingLevel: value } ); }, 1637 1638 __next40pxDefaultSize: true -
depictronix-rapiditem/tags/1.10.1/blocks/product-card/style.css
r3834137 r3835792 81 81 border-radius: 14px !important; 82 82 box-shadow: none !important; 83 /* Use the browser text size, independent of a theme's root rem scale. */ 84 font-size: medium; 83 85 font-style: normal; 84 86 letter-spacing: normal; … … 282 284 border: 0 !important; 283 285 color: var(--rapiditem-text) !important; 284 font-size: 1.15 rem !important;286 font-size: 1.15em !important; 285 287 font-family: inherit !important; 286 288 font-style: normal !important; … … 357 359 box-shadow: none; 358 360 font-family: inherit; 359 font-size: .82 rem;361 font-size: .82em; 360 362 font-style: normal; 361 363 letter-spacing: normal; … … 374 376 box-shadow: none; 375 377 font-family: inherit; 376 font-size: .84 rem;378 font-size: .84em; 377 379 font-style: normal; 378 380 letter-spacing: normal; … … 391 393 box-shadow: none; 392 394 font-family: inherit; 393 font-size: 1rem;395 font-size: calc(1em / .84); 394 396 font-style: normal; 395 397 font-weight: 700; … … 482 484 box-shadow: none; 483 485 font-family: inherit; 484 font-size: .78rem;486 font-size: calc(.78em / .84); 485 487 font-style: normal; 486 488 letter-spacing: normal; … … 504 506 background: transparent !important; 505 507 box-shadow: none !important; 506 }507 508 .rapiditem-card .rapiditem-card__buttons--campaigns {509 align-items: end;510 }511 512 .rapiditem-card .rapiditem-card__store-offer {513 display: flex;514 flex-direction: column;515 align-items: center;516 min-width: 0;517 width: 100%;518 gap: 8px;519 }520 521 .rapiditem-card .rapiditem-card__store-offer > .rapiditem-card__button {522 width: 100%;523 }524 525 .rapiditem-card .rapiditem-card__campaign {526 display: flex;527 flex-direction: column;528 align-items: center;529 box-sizing: border-box;530 max-width: 100%;531 gap: 3px;532 padding: 6px 4px;533 color: var(--rapiditem-text, #1f2937);534 font-size: .8rem;535 line-height: 1.5;536 text-align: center;537 text-decoration: none;538 overflow-wrap: anywhere;539 }540 541 .rapiditem-card .rapiditem-card__campaign small {542 font-size: .7rem;543 text-decoration: underline;544 text-underline-offset: 2px;545 }546 547 .rapiditem-card .rapiditem-card__campaign:focus-visible {548 outline: 2px solid currentColor;549 outline-offset: 2px;550 508 } 551 509 … … 572 530 box-shadow: none; 573 531 font-family: inherit; 574 font-size: 1 rem;532 font-size: 1em; 575 533 font-style: normal; 576 534 font-weight: 700; … … 631 589 min-height: 40px; 632 590 padding: 7px 11px; 633 font-size: .9 rem;591 font-size: .9em; 634 592 } 635 593 … … 637 595 min-height: 34px; 638 596 padding: 5px 9px; 639 font-size: .82 rem;597 font-size: .82em; 640 598 } 641 599 -
depictronix-rapiditem/tags/1.10.1/depictronix-rapiditem.php
r3834137 r3835792 3 3 * Plugin Name: Depictronix Rapidアイテム 4 4 * Description: Create reusable product cards for Amazon Japan, Rakuten and Yahoo! Shopping Japan. 5 * Version: 1.10. 05 * Version: 1.10.1 6 6 * Requires at least: 6.6 7 7 * Requires PHP: 8.1 … … 32 32 return 'rapiditem' === $slug ? 'depictronix-rapiditem' : $slug; 33 33 } ); 34 define( 'RAPIDITEM_VERSION', '1.10. 0' );34 define( 'RAPIDITEM_VERSION', '1.10.1' ); 35 35 define( 'RAPIDITEM_FILE', __FILE__ ); 36 36 define( 'RAPIDITEM_DIR', plugin_dir_path( __FILE__ ) ); -
depictronix-rapiditem/tags/1.10.1/includes/class-campaign-admin.php
r3834137 r3835792 5 5 6 6 final class Campaign_Admin { 7 public static function register(): void {8 add_submenu_page( 'edit.php?post_type=' . Post_Type::TYPE, __( 'セール情報', 'depictronix-rapiditem' ), __( 'セール情報', 'depictronix-rapiditem' ), 'manage_rapiditem_settings', 'rapiditem-campaigns', array( __CLASS__, 'render' ) );9 }10 11 7 private static function url(): string { 12 return admin_url( 'edit.php?post_type=' . Post_Type::TYPE . '&page=rapiditem-campaigns' );8 return Settings::page_url( 'campaigns' ); 13 9 } 14 10 … … 21 17 $input = isset( $_POST['stores'] ) && is_array( $_POST['stores'] ) ? wp_unslash( $_POST['stores'] ) : array(); 22 18 $stores = array(); 23 foreach ( Data::STORES as $store ) { $stores[ $store ] = '1' === ( $input[ $store ] ?? '' ); }24 19 $current = Campaigns::settings(); 25 if ( ( $current['stores'] ?? array() ) !== $stores ) { 26 $value = array( 'stores' => $stores, 'revision' => wp_generate_uuid4() ); 20 foreach ( Data::STORES as $store ) { 21 $stores[ $store ] = Campaigns::available( $store ) 22 ? '1' === ( $input[ $store ] ?? '' ) 23 : true === ( $current['stores'][ $store ] ?? false ); 24 } 25 $stores_changed = ( $current['stores'] ?? array() ) !== $stores; 26 $appearance = Campaigns::sanitize_appearance( isset( $_POST['appearance'] ) && is_array( $_POST['appearance'] ) ? map_deep( wp_unslash( $_POST['appearance'] ), 'sanitize_text_field' ) : Campaigns::appearance() ); 27 if ( $stores_changed || Campaigns::appearance() !== $appearance ) { 28 $value = array( 'stores' => $stores, 'revision' => $stores_changed ? wp_generate_uuid4() : (string) ( $current['revision'] ?? '' ), 'appearance' => $appearance ); 27 29 update_option( Campaigns::OPTION, $value, false ); 28 30 if ( Campaigns::settings() !== $value ) { wp_die( esc_html__( '設定を保存できませんでした。もう一度お試しください。', 'depictronix-rapiditem' ) ); } 29 31 } 30 Campaigns::queue();32 if ( $stores_changed ) { Campaigns::queue(); } 31 33 } elseif ( 'refresh' === $operation ) { 32 34 Campaigns::queue(); … … 44 46 $settings = Campaigns::settings(); 45 47 ?> 46 <div class="wrap"> 47 <h1><?php esc_html_e( 'セール情報の自動取得', 'depictronix-rapiditem' ); ?></h1> 48 <p><?php esc_html_e( '公式ページで開催日時を確認できたセール・キャンペーンを、商品カードの店舗ボタンの上に表示します。商品自体が割引やポイント還元の対象であることを保証する表示ではありません。', 'depictronix-rapiditem' ); ?></p> 48 <div class="rapiditem-campaign-settings"> 49 <h2><?php esc_html_e( 'セール情報の自動取得', 'depictronix-rapiditem' ); ?></h2> 50 <p class="notice notice-info" style="padding:12px"><?php esc_html_e( '表示は次のパッチで公開されます', 'depictronix-rapiditem' ); ?></p> 51 <p><?php esc_html_e( 'Amazon・楽天市場・Yahoo!ショッピングすべてのセール表示を一時停止しています。有効にした店舗の情報は内部で引き続き取得します。通常の商品カード・購入リンク・価格表示は引き続き利用できます。', 'depictronix-rapiditem' ); ?></p> 49 52 <?php // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display-only confirmation after the nonce-protected POST. ?> 50 <?php if ( isset( $_GET['updated'] ) ) : ?><div class="notice notice-success"><p><?php esc_html_e( '設定を反映し 、有効な店舗の取得を予約しました。短時間の再取得は5分間隔に制限されます。', 'depictronix-rapiditem' ); ?></p></div><?php endif; ?>53 <?php if ( isset( $_GET['updated'] ) ) : ?><div class="notice notice-success"><p><?php esc_html_e( '設定を反映しました。取得する店舗を変更した場合は、取得を予約しています。', 'depictronix-rapiditem' ); ?></p></div><?php endif; ?> 51 54 <h2><?php esc_html_e( '取得する店舗', 'depictronix-rapiditem' ); ?></h2> 52 55 <p><?php esc_html_e( '有効にした店舗の公式ページへ、WordPressサーバーから原則1時間ごとに接続します。接続先にはサーバーのIPアドレスとプラグイン名・バージョン等のHTTP情報が伝わります。APIキー、アフィリエイトID、記事内容、訪問者情報は送信しません。', 'depictronix-rapiditem' ); ?></p> 53 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" >56 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" data-rapiditem-campaign-settings> 54 57 <input type="hidden" name="action" value="rapiditem_campaigns"> 55 58 <input type="hidden" name="operation" value="save"> 56 59 <?php wp_nonce_field( 'rapiditem_campaigns' ); ?> 57 60 <?php foreach ( Data::STORES as $store ) : ?> 58 <p><label><input type="checkbox" name="stores[<?php echo esc_attr( $store ); ?>]" value="1" <?php checked( Campaigns::enabled( $store ) ); ?>> <?php echo esc_html( sprintf( /* translators: %s: shop name. */ __( '%sの公式ページへの接続とセール表示を有効にする', 'depictronix-rapiditem' ), Data::store_label( $store ) ) ); ?></label></p> 61 <?php if ( ! Campaigns::available( $store ) ) { continue; } ?> 62 <p><label><input type="checkbox" name="stores[<?php echo esc_attr( $store ); ?>]" value="1" <?php checked( Campaigns::enabled( $store ) ); ?>> <?php echo esc_html( sprintf( /* translators: %s: shop name. */ __( '%sの公式ページからセール情報を取得する', 'depictronix-rapiditem' ), Data::store_label( $store ) ) ); ?></label></p> 59 63 <?php endforeach; ?> 60 64 <p class="submit" style="text-align:center"><?php submit_button( __( '設定を保存', 'depictronix-rapiditem' ), 'primary', 'submit', false ); ?></p> … … 81 85 <?php endforeach; ?> 82 86 </tbody></table> 83 <p><?php esc_html_e( ' 表示は店舗ごとに1件です。終了した情報は自動で非表示になります。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は表示されない場合があります。ページキャッシュを利用している場合は、有効化後にキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>87 <p><?php esc_html_e( '取得状況は管理画面だけで確認できます。記事内のセール表示はすべて停止中です。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は取得できない場合があります。更新後も古いセール表示が残る場合は、サイトのページキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p> 84 88 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> 85 89 <input type="hidden" name="action" value="rapiditem_campaigns"><input type="hidden" name="operation" value="refresh"> -
depictronix-rapiditem/tags/1.10.1/includes/class-campaigns.php
r3834137 r3835792 21 21 add_action( self::HOOK, array( __CLASS__, 'refresh' ) ); 22 22 add_action( 'rest_api_init', array( __CLASS__, 'register_rest' ) ); 23 add_action( 'admin_menu', array( Campaign_Admin::class, 'register' ) );24 23 add_action( 'admin_post_rapiditem_campaigns', array( Campaign_Admin::class, 'save' ) ); 25 24 } … … 31 30 32 31 public static function enabled( string $store ): bool { 33 return in_array( $store, self::STORES, true ) && true === ( self::settings()['stores'][ $store ] ?? false ); 32 return self::available( $store ) && true === ( self::settings()['stores'][ $store ] ?? false ); 33 } 34 35 public static function available( string $store ): bool { 36 return in_array( $store, self::STORES, true ); 37 } 38 39 public static function display_enabled(): bool { 40 // Collection continues with existing consent; public display awaits the next patch. 41 return false; 42 } 43 44 public static function sanitize_appearance( mixed $input ): array { 45 $input = is_array( $input ) ? $input : array(); 46 $accent = is_string( $input['accent'] ?? null ) ? sanitize_hex_color( $input['accent'] ) : null; 47 return array( 48 'style' => in_array( $input['style'] ?? '', array( 'label', 'text' ), true ) ? $input['style'] : 'label', 49 'size' => in_array( $input['size'] ?? '', array( 'small', 'normal', 'large' ), true ) ? $input['size'] : 'normal', 50 'accent' => $accent ? strtoupper( $accent ) : '#B45309', 51 ); 52 } 53 54 public static function appearance(): array { 55 return self::sanitize_appearance( self::settings()['appearance'] ?? array() ); 34 56 } 35 57 … … 68 90 69 91 public static function register_assets(): void { 92 if ( ! self::display_enabled() ) { return; } 70 93 if ( ! array_filter( self::STORES, array( __CLASS__, 'enabled' ) ) ) { return; } 94 // Pro replaces the card stylesheet source. Keep campaign layout in its shared dependency. 95 wp_register_style( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.css', array(), RAPIDITEM_VERSION ); 96 $style = wp_styles()->registered['rapiditem-card'] ?? null; 97 if ( $style && ! in_array( 'rapiditem-campaigns', $style->deps, true ) ) { 98 $style->deps[] = 'rapiditem-campaigns'; 99 } 71 100 wp_register_script( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.js', array(), RAPIDITEM_VERSION, true ); 72 101 $card = wp_scripts()->registered['rapiditem-card'] ?? null; … … 76 105 wp_localize_script( 'rapiditem-campaigns', 'rapiditemCampaigns', array( 77 106 'url' => rest_url( 'rapiditem/v1/campaigns' ), 78 'conditions' => __( '対象・参加条件は公式ページで確認', 'depictronix-rapiditem' ), 107 'conditions' => __( '対象・参加条件を確認', 'depictronix-rapiditem' ), 108 'appearance' => self::appearance(), 79 109 ) ); 80 110 } … … 89 119 90 120 public static function response(): \WP_REST_Response { 91 return new \WP_REST_Response( self::snapshot( time() ), 200, array( 121 // Old cached clients must also receive no events while display is suspended. 122 $data = self::display_enabled() ? self::snapshot( time() ) : array( 'now' => time(), 'stores' => array() ); 123 $data['display_enabled'] = self::display_enabled(); 124 return new \WP_REST_Response( $data, 200, array( 92 125 'Cache-Control' => 'no-store, private, max-age=0', 93 126 'Pragma' => 'no-cache', … … 97 130 98 131 public static function snapshot( int $now ): array { 99 $result = array( 'now' => $now, 'stores' => array() );132 $result = array( 'now' => $now, 'stores' => array(), 'appearance' => self::appearance() ); 100 133 $revision = (string) ( self::settings()['revision'] ?? '' ); 101 134 foreach ( self::STORES as $store ) { -
depictronix-rapiditem/tags/1.10.1/includes/class-renderer.php
r3834115 r3835792 98 98 </figure> 99 99 <div class="rapiditem-card__body"> 100 < h3 class="rapiditem-card__title"><span><?php esc_html_e( 'サンプル商品', 'depictronix-rapiditem' ); ?></span></h3>100 <div class="rapiditem-card__title"><span><?php esc_html_e( 'サンプル商品', 'depictronix-rapiditem' ); ?></span></div> 101 101 <p class="rapiditem-card__note"><?php esc_html_e( '商品説明のサンプルです。実際の商品では取得情報または手動設定した説明を表示します。', 'depictronix-rapiditem' ); ?></p> 102 102 <div class="rapiditem-card__price"> … … 158 158 $content_post_id = absint( $block->context['postId'] ?? ( function_exists( 'get_the_ID' ) ? get_the_ID() : 0 ) ); 159 159 $hidden_stores = self::sanitize_hidden_stores( $attributes['hiddenStores'] ?? array() ); 160 $heading_level = self::sanitize_heading_level( $attributes['headingLevel'] ?? ' h3' );160 $heading_level = self::sanitize_heading_level( $attributes['headingLevel'] ?? 'div' ); 161 161 $allow_editor_preview = defined( 'REST_REQUEST' ) 162 162 && REST_REQUEST … … 381 381 382 382 public static function shortcode( array|string $atts ): string { 383 $atts = shortcode_atts( array( 'id' => 0, 'migration' => '' ), is_array( $atts ) ? $atts : array(), 'rapiditem' );383 $atts = shortcode_atts( array( 'id' => 0, 'migration' => '', 'heading' => 'div' ), is_array( $atts ) ? $atts : array(), 'rapiditem' ); 384 384 $id = absint( $atts['id'] ); 385 385 $overrides = array(); … … 397 397 $hidden = self::sanitize_hidden_stores( (array) ( $config['hiddenStores'] ?? array() ) ); 398 398 } 399 $card = static::card( $id, false, $overrides, $hidden, 'h3', function_exists( 'get_the_ID' ) ? absint( get_the_ID() ) : 0 );399 $card = static::card( $id, false, $overrides, $hidden, self::sanitize_heading_level( $atts['heading'] ), function_exists( 'get_the_ID' ) ? absint( get_the_ID() ) : 0 ); 400 400 return '' === $card ? '' : '<div class="rapiditem-card-slot">' . wp_kses( $card, self::comparison_allowed_html() ) . '</div>'; 401 401 } … … 542 542 } 543 543 544 public static function card( int $post_id, bool $allow_non_public = false, array $overrides = array(), array $hidden_stores = array(), string $heading_level = ' h3', int $content_post_id = 0 ): string {544 public static function card( int $post_id, bool $allow_non_public = false, array $overrides = array(), array $hidden_stores = array(), string $heading_level = 'div', int $content_post_id = 0 ): string { 545 545 $post = get_post( $post_id ); 546 546 if ( ! $post || Post_Type::TYPE !== $post->post_type ) { … … 1242 1242 protected static function sanitize_heading_level( mixed $level ): string { 1243 1243 $level = is_scalar( $level ) ? strtolower( (string) $level ) : ''; 1244 return in_array( $level, array( ' h2', 'h3', 'h4', 'h5', 'h6' ), true ) ? $level : 'h3';1244 return in_array( $level, array( 'div', 'h2', 'h3', 'h4', 'h5', 'h6' ), true ) ? $level : 'div'; 1245 1245 } 1246 1246 -
depictronix-rapiditem/tags/1.10.1/includes/trait-settings-admin.php
r3834115 r3835792 67 67 public static function page_url( string $tab = 'basic', string $affiliate_tab = '' ): string { 68 68 $tab = 'important' === $tab ? 'affiliate' : $tab; 69 if ( ! in_array( $tab, array( 'basic', 'affiliate', 'visual', 'refresh', ' data', 'migration' ), true ) ) {69 if ( ! in_array( $tab, array( 'basic', 'affiliate', 'visual', 'refresh', 'campaigns', 'data', 'migration' ), true ) ) { 70 70 $tab = 'basic'; 71 71 } … … 91 91 'visual' => __( 'ビジュアル設定', 'depictronix-rapiditem' ), 92 92 'refresh' => __( '情報更新設定', 'depictronix-rapiditem' ), 93 'campaigns' => __( 'セール情報', 'depictronix-rapiditem' ), 93 94 'data' => __( 'データ設定', 'depictronix-rapiditem' ), 94 95 'migration' => __( '移行', 'depictronix-rapiditem' ), … … 122 123 <?php if ( 'migration' === $active_tab ) : ?> 123 124 <?php Migration::render_page_contents(); ?> 125 <?php elseif ( 'campaigns' === $active_tab ) : ?> 126 <?php Campaign_Admin::render(); ?> 124 127 <?php else : ?> 125 128 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> -
depictronix-rapiditem/tags/1.10.1/readme.txt
r3834137 r3835792 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.10. 07 Stable tag: 1.10.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 28 28 = Optional official campaign collection = 29 29 30 Disabled by default. In Rapidアイテム → セール情報, administrators can opt in separately for Amazon, Rakuten and Yahoo!. WordPress then checks the enabled providers' public official pages approximately hourly using WP-Cron. Requests disclose the server IP address and an HTTP user agent containing the plugin name/version; no API keys, affiliate identifiers, post content or visitor information are sent. Visitors' browsers request cached campaign facts from their own site's REST API. Following a campaign link connects to its official source.30 Disabled by default. In Rapidアイテム → 設定 → セール情報, administrators can opt in separately for Amazon, Rakuten and Yahoo!. WordPress then checks the enabled providers' public official pages approximately hourly using WP-Cron. Requests disclose the server IP address and an HTTP user agent containing the plugin name/version; no API keys, affiliate identifiers, post content or visitor information are sent. In 1.10.1, public notices for ALL providers are suspended while internal collection continues with existing consent. The settings page says display will be released in the next patch. The public REST endpoint returns no campaign events during this suspension. 31 31 32 32 Sources: About Amazon Japan's retail and Amazon Prime announcements at www.aboutamazon.jp/news/; Rakuten Super SALE, shopping marathon, Black Friday, point days and Wonderful Day pages at event.rakuten.co.jp; dated promotions linked from shopping.yahoo.co.jp/promotion/campaign/cpnlist/. These pages are not a campaign API. Dates must be explicitly verifiable. Coverage is not exhaustive; page changes, missing dates and network failures can prevent display. The plugin never substitutes recurring date guesses. It does not copy source images, HTML or scripts into cards. Data older than two hours and ended campaigns are hidden. Purchase links and product prices are unchanged; campaign eligibility is determined by each provider. 33 33 34 PHP DOM , browser JavaScript and the site's REST API are required. WP-Cron timing depends on site traffic. Purge page caches after enabling this feature. Each store displays at most one active campaign. The browser checks its local REST endpoint at page load and while visible, so already cached cards can stop showing expired campaigns.34 PHP DOM is required for collection. WP-Cron timing depends on site traffic. Purge page caches after updating if an old notice remains. Campaign status can be checked by administrators in Settings; product prices and purchase links continue normally. 35 35 36 36 * Amazon official source: https://www.aboutamazon.jp/news/retail — Terms: https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=GLSBYFE9MGKKQXXM — Privacy: https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=GX7NJQ4ZB8MHFRNJ … … 89 89 == Changelog == 90 90 91 = 1.10.1 = 92 * Use non-heading product titles by default, with an explicit no-heading option and preserved H2-H6 choices. Shortcodes also default to non-heading titles. 93 * Suspend all public campaign notices while retaining opted-in internal collection. Move campaign information into Settings and announce display for the next patch. 94 * Keep card typography independent of the theme root font size. Update Pro to 1.6.6 if installed. 95 91 96 = 1.10.0 = 92 97 * Add optional scheduled collection of dated official Amazon, Rakuten and Yahoo! campaigns, with per-store consent, expiry checks and cache-aware card notices. -
depictronix-rapiditem/trunk/assets/campaigns.js
r3834137 r3835792 1 1 ( function () { 2 2 'use strict'; 3 // Holding release: never render notices, including when an old page loads this URL. 4 var displayEnabled = false; 5 if ( ! displayEnabled ) { 6 var clearNotices = function () { 7 document.querySelectorAll( '.rapiditem-card .rapiditem-card__store-offer' ).forEach( function ( wrapper ) { 8 var button = wrapper.querySelector( 'a.rapiditem-card__button' ); 9 if ( button ) { wrapper.replaceWith( button ); } 10 } ); 11 document.querySelectorAll( '.rapiditem-card .rapiditem-card__campaign' ).forEach( function ( notice ) { notice.remove(); } ); 12 document.querySelectorAll( '.rapiditem-card .rapiditem-card__buttons--campaigns' ).forEach( function ( group ) { group.classList.remove( 'rapiditem-card__buttons--campaigns' ); } ); 13 }; 14 if ( document.readyState === 'loading' ) { document.addEventListener( 'DOMContentLoaded', clearNotices ); } else { clearNotices(); } 15 return; 16 } 3 17 var config = window.rapiditemCampaigns; 4 18 if ( ! config || ! window.fetch ) { return; } … … 27 41 }; 28 42 var current = function ( store ) { 43 // Also reject old cached Amazon facts while this feature is withdrawn. 44 if ( store === 'amazon' ) { return null; } 29 45 var record = snapshot && snapshot.stores && snapshot.stores[ store ]; 30 46 if ( ! record || ! Number.isFinite( record.valid_until ) || record.valid_until <= now() || ! Array.isArray( record.events ) ) { return null; } … … 33 49 typeof event.title === 'string' && event.title.length <= 150 && typeof event.until === 'string' && allowed( store, event.url ); 34 50 } ) || null; 51 }; 52 var appearance = function () { 53 var value = ( snapshot && snapshot.appearance ) || config.appearance || {}; 54 return { 55 style: value.style === 'text' ? 'text' : 'label', 56 size: { small: '.75em', normal: '.8em', large: '.9em' }[ value.size ] || '.8em', 57 accent: /^#[0-9a-f]{6}$/i.test( value.accent ) ? value.accent : '#B45309' 58 }; 35 59 }; 36 60 var sync = function () { … … 51 75 wrapper.appendChild( button ); 52 76 } 53 var signature = JSON.stringify( [ event.title, event.until, event.url, event.start, event.end ] ); 77 var visual = appearance(); 78 var signature = JSON.stringify( [ event.title, event.until, event.url, event.start, event.end, visual ] ); 54 79 if ( wrapper.dataset.campaignSignature === signature ) { return; } 55 80 var old = wrapper.querySelector( '.rapiditem-card__campaign' ); 56 81 if ( old ) { old.remove(); } 57 82 var notice = document.createElement( 'a' ); 58 notice.className = 'rapiditem-card__campaign'; 83 notice.className = 'rapiditem-card__campaign rapiditem-card__campaign--' + visual.style; 84 notice.style.setProperty( '--rapiditem-campaign-font-size', visual.size ); 85 notice.style.setProperty( '--rapiditem-campaign-accent', visual.accent ); 59 86 notice.href = event.url; 60 87 notice.target = '_blank'; -
depictronix-rapiditem/trunk/blocks/product-card/block.json
r3834137 r3835792 3 3 "apiVersion": 3, 4 4 "name": "rapiditem/product-card", 5 "version": "1.10. 0",5 "version": "1.10.1", 6 6 "title": "Rapidアイテム", 7 7 "category": "widgets", … … 24 24 "headingLevel": { 25 25 "type": "string", 26 "default": " h3"26 "default": "div" 27 27 }, 28 28 "hiddenStores": { -
depictronix-rapiditem/trunk/blocks/product-card/editor.asset.php
r3834137 r3835792 11 11 'wp-hooks', 12 12 ), 13 'version' => '1.10. 0',13 'version' => '1.10.1', 14 14 ); -
depictronix-rapiditem/trunk/blocks/product-card/editor.js
r3834115 r3835792 204 204 var productLimit = 2; 205 205 var layout = 'columns'; 206 var headingLevel = [ ' h2', 'h3', 'h4', 'h5', 'h6' ].indexOf( props.attributes.headingLevel ) !== -1 ? props.attributes.headingLevel : 'h3';206 var headingLevel = [ 'div', 'h2', 'h3', 'h4', 'h5', 'h6' ].indexOf( props.attributes.headingLevel ) !== -1 ? props.attributes.headingLevel : 'div'; 207 207 var pickerRef = useRef( props.picker ); 208 208 pickerRef.current = props.picker; … … 613 613 overrides: entry.overrides || {}, 614 614 hiddenStores: disabledStores || [], 615 headingLevel: selectedHeadingLevel || ' h3'615 headingLevel: selectedHeadingLevel || 'div' 616 616 }, 617 617 signal: controller ? controller.signal : undefined … … 1627 1627 value: headingLevel, 1628 1628 options: [ 1629 { label: __( '見出しなし(標準)', 'depictronix-rapiditem' ), value: 'div' }, 1629 1630 { label: 'H2', value: 'h2' }, 1630 1631 { label: 'H3', value: 'h3' }, … … 1633 1634 { label: 'H6', value: 'h6' } 1634 1635 ], 1635 help: __( ' 記事内の見出し構造に合わせて選択します。既存ブロックはH3のままです。', 'depictronix-rapiditem' ),1636 help: __( '標準では商品名を記事の見出しに含めません。見出しとして使う場合だけH2〜H6を選択してください。', 'depictronix-rapiditem' ), 1636 1637 onChange: function ( value ) { props.setAttributes( { headingLevel: value } ); }, 1637 1638 __next40pxDefaultSize: true -
depictronix-rapiditem/trunk/blocks/product-card/style.css
r3834137 r3835792 81 81 border-radius: 14px !important; 82 82 box-shadow: none !important; 83 /* Use the browser text size, independent of a theme's root rem scale. */ 84 font-size: medium; 83 85 font-style: normal; 84 86 letter-spacing: normal; … … 282 284 border: 0 !important; 283 285 color: var(--rapiditem-text) !important; 284 font-size: 1.15 rem !important;286 font-size: 1.15em !important; 285 287 font-family: inherit !important; 286 288 font-style: normal !important; … … 357 359 box-shadow: none; 358 360 font-family: inherit; 359 font-size: .82 rem;361 font-size: .82em; 360 362 font-style: normal; 361 363 letter-spacing: normal; … … 374 376 box-shadow: none; 375 377 font-family: inherit; 376 font-size: .84 rem;378 font-size: .84em; 377 379 font-style: normal; 378 380 letter-spacing: normal; … … 391 393 box-shadow: none; 392 394 font-family: inherit; 393 font-size: 1rem;395 font-size: calc(1em / .84); 394 396 font-style: normal; 395 397 font-weight: 700; … … 482 484 box-shadow: none; 483 485 font-family: inherit; 484 font-size: .78rem;486 font-size: calc(.78em / .84); 485 487 font-style: normal; 486 488 letter-spacing: normal; … … 504 506 background: transparent !important; 505 507 box-shadow: none !important; 506 }507 508 .rapiditem-card .rapiditem-card__buttons--campaigns {509 align-items: end;510 }511 512 .rapiditem-card .rapiditem-card__store-offer {513 display: flex;514 flex-direction: column;515 align-items: center;516 min-width: 0;517 width: 100%;518 gap: 8px;519 }520 521 .rapiditem-card .rapiditem-card__store-offer > .rapiditem-card__button {522 width: 100%;523 }524 525 .rapiditem-card .rapiditem-card__campaign {526 display: flex;527 flex-direction: column;528 align-items: center;529 box-sizing: border-box;530 max-width: 100%;531 gap: 3px;532 padding: 6px 4px;533 color: var(--rapiditem-text, #1f2937);534 font-size: .8rem;535 line-height: 1.5;536 text-align: center;537 text-decoration: none;538 overflow-wrap: anywhere;539 }540 541 .rapiditem-card .rapiditem-card__campaign small {542 font-size: .7rem;543 text-decoration: underline;544 text-underline-offset: 2px;545 }546 547 .rapiditem-card .rapiditem-card__campaign:focus-visible {548 outline: 2px solid currentColor;549 outline-offset: 2px;550 508 } 551 509 … … 572 530 box-shadow: none; 573 531 font-family: inherit; 574 font-size: 1 rem;532 font-size: 1em; 575 533 font-style: normal; 576 534 font-weight: 700; … … 631 589 min-height: 40px; 632 590 padding: 7px 11px; 633 font-size: .9 rem;591 font-size: .9em; 634 592 } 635 593 … … 637 595 min-height: 34px; 638 596 padding: 5px 9px; 639 font-size: .82 rem;597 font-size: .82em; 640 598 } 641 599 -
depictronix-rapiditem/trunk/depictronix-rapiditem.php
r3834137 r3835792 3 3 * Plugin Name: Depictronix Rapidアイテム 4 4 * Description: Create reusable product cards for Amazon Japan, Rakuten and Yahoo! Shopping Japan. 5 * Version: 1.10. 05 * Version: 1.10.1 6 6 * Requires at least: 6.6 7 7 * Requires PHP: 8.1 … … 32 32 return 'rapiditem' === $slug ? 'depictronix-rapiditem' : $slug; 33 33 } ); 34 define( 'RAPIDITEM_VERSION', '1.10. 0' );34 define( 'RAPIDITEM_VERSION', '1.10.1' ); 35 35 define( 'RAPIDITEM_FILE', __FILE__ ); 36 36 define( 'RAPIDITEM_DIR', plugin_dir_path( __FILE__ ) ); -
depictronix-rapiditem/trunk/includes/class-campaign-admin.php
r3834137 r3835792 5 5 6 6 final class Campaign_Admin { 7 public static function register(): void {8 add_submenu_page( 'edit.php?post_type=' . Post_Type::TYPE, __( 'セール情報', 'depictronix-rapiditem' ), __( 'セール情報', 'depictronix-rapiditem' ), 'manage_rapiditem_settings', 'rapiditem-campaigns', array( __CLASS__, 'render' ) );9 }10 11 7 private static function url(): string { 12 return admin_url( 'edit.php?post_type=' . Post_Type::TYPE . '&page=rapiditem-campaigns' );8 return Settings::page_url( 'campaigns' ); 13 9 } 14 10 … … 21 17 $input = isset( $_POST['stores'] ) && is_array( $_POST['stores'] ) ? wp_unslash( $_POST['stores'] ) : array(); 22 18 $stores = array(); 23 foreach ( Data::STORES as $store ) { $stores[ $store ] = '1' === ( $input[ $store ] ?? '' ); }24 19 $current = Campaigns::settings(); 25 if ( ( $current['stores'] ?? array() ) !== $stores ) { 26 $value = array( 'stores' => $stores, 'revision' => wp_generate_uuid4() ); 20 foreach ( Data::STORES as $store ) { 21 $stores[ $store ] = Campaigns::available( $store ) 22 ? '1' === ( $input[ $store ] ?? '' ) 23 : true === ( $current['stores'][ $store ] ?? false ); 24 } 25 $stores_changed = ( $current['stores'] ?? array() ) !== $stores; 26 $appearance = Campaigns::sanitize_appearance( isset( $_POST['appearance'] ) && is_array( $_POST['appearance'] ) ? map_deep( wp_unslash( $_POST['appearance'] ), 'sanitize_text_field' ) : Campaigns::appearance() ); 27 if ( $stores_changed || Campaigns::appearance() !== $appearance ) { 28 $value = array( 'stores' => $stores, 'revision' => $stores_changed ? wp_generate_uuid4() : (string) ( $current['revision'] ?? '' ), 'appearance' => $appearance ); 27 29 update_option( Campaigns::OPTION, $value, false ); 28 30 if ( Campaigns::settings() !== $value ) { wp_die( esc_html__( '設定を保存できませんでした。もう一度お試しください。', 'depictronix-rapiditem' ) ); } 29 31 } 30 Campaigns::queue();32 if ( $stores_changed ) { Campaigns::queue(); } 31 33 } elseif ( 'refresh' === $operation ) { 32 34 Campaigns::queue(); … … 44 46 $settings = Campaigns::settings(); 45 47 ?> 46 <div class="wrap"> 47 <h1><?php esc_html_e( 'セール情報の自動取得', 'depictronix-rapiditem' ); ?></h1> 48 <p><?php esc_html_e( '公式ページで開催日時を確認できたセール・キャンペーンを、商品カードの店舗ボタンの上に表示します。商品自体が割引やポイント還元の対象であることを保証する表示ではありません。', 'depictronix-rapiditem' ); ?></p> 48 <div class="rapiditem-campaign-settings"> 49 <h2><?php esc_html_e( 'セール情報の自動取得', 'depictronix-rapiditem' ); ?></h2> 50 <p class="notice notice-info" style="padding:12px"><?php esc_html_e( '表示は次のパッチで公開されます', 'depictronix-rapiditem' ); ?></p> 51 <p><?php esc_html_e( 'Amazon・楽天市場・Yahoo!ショッピングすべてのセール表示を一時停止しています。有効にした店舗の情報は内部で引き続き取得します。通常の商品カード・購入リンク・価格表示は引き続き利用できます。', 'depictronix-rapiditem' ); ?></p> 49 52 <?php // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Display-only confirmation after the nonce-protected POST. ?> 50 <?php if ( isset( $_GET['updated'] ) ) : ?><div class="notice notice-success"><p><?php esc_html_e( '設定を反映し 、有効な店舗の取得を予約しました。短時間の再取得は5分間隔に制限されます。', 'depictronix-rapiditem' ); ?></p></div><?php endif; ?>53 <?php if ( isset( $_GET['updated'] ) ) : ?><div class="notice notice-success"><p><?php esc_html_e( '設定を反映しました。取得する店舗を変更した場合は、取得を予約しています。', 'depictronix-rapiditem' ); ?></p></div><?php endif; ?> 51 54 <h2><?php esc_html_e( '取得する店舗', 'depictronix-rapiditem' ); ?></h2> 52 55 <p><?php esc_html_e( '有効にした店舗の公式ページへ、WordPressサーバーから原則1時間ごとに接続します。接続先にはサーバーのIPアドレスとプラグイン名・バージョン等のHTTP情報が伝わります。APIキー、アフィリエイトID、記事内容、訪問者情報は送信しません。', 'depictronix-rapiditem' ); ?></p> 53 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" >56 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" data-rapiditem-campaign-settings> 54 57 <input type="hidden" name="action" value="rapiditem_campaigns"> 55 58 <input type="hidden" name="operation" value="save"> 56 59 <?php wp_nonce_field( 'rapiditem_campaigns' ); ?> 57 60 <?php foreach ( Data::STORES as $store ) : ?> 58 <p><label><input type="checkbox" name="stores[<?php echo esc_attr( $store ); ?>]" value="1" <?php checked( Campaigns::enabled( $store ) ); ?>> <?php echo esc_html( sprintf( /* translators: %s: shop name. */ __( '%sの公式ページへの接続とセール表示を有効にする', 'depictronix-rapiditem' ), Data::store_label( $store ) ) ); ?></label></p> 61 <?php if ( ! Campaigns::available( $store ) ) { continue; } ?> 62 <p><label><input type="checkbox" name="stores[<?php echo esc_attr( $store ); ?>]" value="1" <?php checked( Campaigns::enabled( $store ) ); ?>> <?php echo esc_html( sprintf( /* translators: %s: shop name. */ __( '%sの公式ページからセール情報を取得する', 'depictronix-rapiditem' ), Data::store_label( $store ) ) ); ?></label></p> 59 63 <?php endforeach; ?> 60 64 <p class="submit" style="text-align:center"><?php submit_button( __( '設定を保存', 'depictronix-rapiditem' ), 'primary', 'submit', false ); ?></p> … … 81 85 <?php endforeach; ?> 82 86 </tbody></table> 83 <p><?php esc_html_e( ' 表示は店舗ごとに1件です。終了した情報は自動で非表示になります。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は表示されない場合があります。ページキャッシュを利用している場合は、有効化後にキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>87 <p><?php esc_html_e( '取得状況は管理画面だけで確認できます。記事内のセール表示はすべて停止中です。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は取得できない場合があります。更新後も古いセール表示が残る場合は、サイトのページキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p> 84 88 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> 85 89 <input type="hidden" name="action" value="rapiditem_campaigns"><input type="hidden" name="operation" value="refresh"> -
depictronix-rapiditem/trunk/includes/class-campaigns.php
r3834137 r3835792 21 21 add_action( self::HOOK, array( __CLASS__, 'refresh' ) ); 22 22 add_action( 'rest_api_init', array( __CLASS__, 'register_rest' ) ); 23 add_action( 'admin_menu', array( Campaign_Admin::class, 'register' ) );24 23 add_action( 'admin_post_rapiditem_campaigns', array( Campaign_Admin::class, 'save' ) ); 25 24 } … … 31 30 32 31 public static function enabled( string $store ): bool { 33 return in_array( $store, self::STORES, true ) && true === ( self::settings()['stores'][ $store ] ?? false ); 32 return self::available( $store ) && true === ( self::settings()['stores'][ $store ] ?? false ); 33 } 34 35 public static function available( string $store ): bool { 36 return in_array( $store, self::STORES, true ); 37 } 38 39 public static function display_enabled(): bool { 40 // Collection continues with existing consent; public display awaits the next patch. 41 return false; 42 } 43 44 public static function sanitize_appearance( mixed $input ): array { 45 $input = is_array( $input ) ? $input : array(); 46 $accent = is_string( $input['accent'] ?? null ) ? sanitize_hex_color( $input['accent'] ) : null; 47 return array( 48 'style' => in_array( $input['style'] ?? '', array( 'label', 'text' ), true ) ? $input['style'] : 'label', 49 'size' => in_array( $input['size'] ?? '', array( 'small', 'normal', 'large' ), true ) ? $input['size'] : 'normal', 50 'accent' => $accent ? strtoupper( $accent ) : '#B45309', 51 ); 52 } 53 54 public static function appearance(): array { 55 return self::sanitize_appearance( self::settings()['appearance'] ?? array() ); 34 56 } 35 57 … … 68 90 69 91 public static function register_assets(): void { 92 if ( ! self::display_enabled() ) { return; } 70 93 if ( ! array_filter( self::STORES, array( __CLASS__, 'enabled' ) ) ) { return; } 94 // Pro replaces the card stylesheet source. Keep campaign layout in its shared dependency. 95 wp_register_style( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.css', array(), RAPIDITEM_VERSION ); 96 $style = wp_styles()->registered['rapiditem-card'] ?? null; 97 if ( $style && ! in_array( 'rapiditem-campaigns', $style->deps, true ) ) { 98 $style->deps[] = 'rapiditem-campaigns'; 99 } 71 100 wp_register_script( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.js', array(), RAPIDITEM_VERSION, true ); 72 101 $card = wp_scripts()->registered['rapiditem-card'] ?? null; … … 76 105 wp_localize_script( 'rapiditem-campaigns', 'rapiditemCampaigns', array( 77 106 'url' => rest_url( 'rapiditem/v1/campaigns' ), 78 'conditions' => __( '対象・参加条件は公式ページで確認', 'depictronix-rapiditem' ), 107 'conditions' => __( '対象・参加条件を確認', 'depictronix-rapiditem' ), 108 'appearance' => self::appearance(), 79 109 ) ); 80 110 } … … 89 119 90 120 public static function response(): \WP_REST_Response { 91 return new \WP_REST_Response( self::snapshot( time() ), 200, array( 121 // Old cached clients must also receive no events while display is suspended. 122 $data = self::display_enabled() ? self::snapshot( time() ) : array( 'now' => time(), 'stores' => array() ); 123 $data['display_enabled'] = self::display_enabled(); 124 return new \WP_REST_Response( $data, 200, array( 92 125 'Cache-Control' => 'no-store, private, max-age=0', 93 126 'Pragma' => 'no-cache', … … 97 130 98 131 public static function snapshot( int $now ): array { 99 $result = array( 'now' => $now, 'stores' => array() );132 $result = array( 'now' => $now, 'stores' => array(), 'appearance' => self::appearance() ); 100 133 $revision = (string) ( self::settings()['revision'] ?? '' ); 101 134 foreach ( self::STORES as $store ) { -
depictronix-rapiditem/trunk/includes/class-renderer.php
r3834115 r3835792 98 98 </figure> 99 99 <div class="rapiditem-card__body"> 100 < h3 class="rapiditem-card__title"><span><?php esc_html_e( 'サンプル商品', 'depictronix-rapiditem' ); ?></span></h3>100 <div class="rapiditem-card__title"><span><?php esc_html_e( 'サンプル商品', 'depictronix-rapiditem' ); ?></span></div> 101 101 <p class="rapiditem-card__note"><?php esc_html_e( '商品説明のサンプルです。実際の商品では取得情報または手動設定した説明を表示します。', 'depictronix-rapiditem' ); ?></p> 102 102 <div class="rapiditem-card__price"> … … 158 158 $content_post_id = absint( $block->context['postId'] ?? ( function_exists( 'get_the_ID' ) ? get_the_ID() : 0 ) ); 159 159 $hidden_stores = self::sanitize_hidden_stores( $attributes['hiddenStores'] ?? array() ); 160 $heading_level = self::sanitize_heading_level( $attributes['headingLevel'] ?? ' h3' );160 $heading_level = self::sanitize_heading_level( $attributes['headingLevel'] ?? 'div' ); 161 161 $allow_editor_preview = defined( 'REST_REQUEST' ) 162 162 && REST_REQUEST … … 381 381 382 382 public static function shortcode( array|string $atts ): string { 383 $atts = shortcode_atts( array( 'id' => 0, 'migration' => '' ), is_array( $atts ) ? $atts : array(), 'rapiditem' );383 $atts = shortcode_atts( array( 'id' => 0, 'migration' => '', 'heading' => 'div' ), is_array( $atts ) ? $atts : array(), 'rapiditem' ); 384 384 $id = absint( $atts['id'] ); 385 385 $overrides = array(); … … 397 397 $hidden = self::sanitize_hidden_stores( (array) ( $config['hiddenStores'] ?? array() ) ); 398 398 } 399 $card = static::card( $id, false, $overrides, $hidden, 'h3', function_exists( 'get_the_ID' ) ? absint( get_the_ID() ) : 0 );399 $card = static::card( $id, false, $overrides, $hidden, self::sanitize_heading_level( $atts['heading'] ), function_exists( 'get_the_ID' ) ? absint( get_the_ID() ) : 0 ); 400 400 return '' === $card ? '' : '<div class="rapiditem-card-slot">' . wp_kses( $card, self::comparison_allowed_html() ) . '</div>'; 401 401 } … … 542 542 } 543 543 544 public static function card( int $post_id, bool $allow_non_public = false, array $overrides = array(), array $hidden_stores = array(), string $heading_level = ' h3', int $content_post_id = 0 ): string {544 public static function card( int $post_id, bool $allow_non_public = false, array $overrides = array(), array $hidden_stores = array(), string $heading_level = 'div', int $content_post_id = 0 ): string { 545 545 $post = get_post( $post_id ); 546 546 if ( ! $post || Post_Type::TYPE !== $post->post_type ) { … … 1242 1242 protected static function sanitize_heading_level( mixed $level ): string { 1243 1243 $level = is_scalar( $level ) ? strtolower( (string) $level ) : ''; 1244 return in_array( $level, array( ' h2', 'h3', 'h4', 'h5', 'h6' ), true ) ? $level : 'h3';1244 return in_array( $level, array( 'div', 'h2', 'h3', 'h4', 'h5', 'h6' ), true ) ? $level : 'div'; 1245 1245 } 1246 1246 -
depictronix-rapiditem/trunk/includes/trait-settings-admin.php
r3834115 r3835792 67 67 public static function page_url( string $tab = 'basic', string $affiliate_tab = '' ): string { 68 68 $tab = 'important' === $tab ? 'affiliate' : $tab; 69 if ( ! in_array( $tab, array( 'basic', 'affiliate', 'visual', 'refresh', ' data', 'migration' ), true ) ) {69 if ( ! in_array( $tab, array( 'basic', 'affiliate', 'visual', 'refresh', 'campaigns', 'data', 'migration' ), true ) ) { 70 70 $tab = 'basic'; 71 71 } … … 91 91 'visual' => __( 'ビジュアル設定', 'depictronix-rapiditem' ), 92 92 'refresh' => __( '情報更新設定', 'depictronix-rapiditem' ), 93 'campaigns' => __( 'セール情報', 'depictronix-rapiditem' ), 93 94 'data' => __( 'データ設定', 'depictronix-rapiditem' ), 94 95 'migration' => __( '移行', 'depictronix-rapiditem' ), … … 122 123 <?php if ( 'migration' === $active_tab ) : ?> 123 124 <?php Migration::render_page_contents(); ?> 125 <?php elseif ( 'campaigns' === $active_tab ) : ?> 126 <?php Campaign_Admin::render(); ?> 124 127 <?php else : ?> 125 128 <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>"> -
depictronix-rapiditem/trunk/readme.txt
r3834137 r3835792 5 5 Tested up to: 7.1 6 6 Requires PHP: 8.1 7 Stable tag: 1.10. 07 Stable tag: 1.10.1 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 28 28 = Optional official campaign collection = 29 29 30 Disabled by default. In Rapidアイテム → セール情報, administrators can opt in separately for Amazon, Rakuten and Yahoo!. WordPress then checks the enabled providers' public official pages approximately hourly using WP-Cron. Requests disclose the server IP address and an HTTP user agent containing the plugin name/version; no API keys, affiliate identifiers, post content or visitor information are sent. Visitors' browsers request cached campaign facts from their own site's REST API. Following a campaign link connects to its official source.30 Disabled by default. In Rapidアイテム → 設定 → セール情報, administrators can opt in separately for Amazon, Rakuten and Yahoo!. WordPress then checks the enabled providers' public official pages approximately hourly using WP-Cron. Requests disclose the server IP address and an HTTP user agent containing the plugin name/version; no API keys, affiliate identifiers, post content or visitor information are sent. In 1.10.1, public notices for ALL providers are suspended while internal collection continues with existing consent. The settings page says display will be released in the next patch. The public REST endpoint returns no campaign events during this suspension. 31 31 32 32 Sources: About Amazon Japan's retail and Amazon Prime announcements at www.aboutamazon.jp/news/; Rakuten Super SALE, shopping marathon, Black Friday, point days and Wonderful Day pages at event.rakuten.co.jp; dated promotions linked from shopping.yahoo.co.jp/promotion/campaign/cpnlist/. These pages are not a campaign API. Dates must be explicitly verifiable. Coverage is not exhaustive; page changes, missing dates and network failures can prevent display. The plugin never substitutes recurring date guesses. It does not copy source images, HTML or scripts into cards. Data older than two hours and ended campaigns are hidden. Purchase links and product prices are unchanged; campaign eligibility is determined by each provider. 33 33 34 PHP DOM , browser JavaScript and the site's REST API are required. WP-Cron timing depends on site traffic. Purge page caches after enabling this feature. Each store displays at most one active campaign. The browser checks its local REST endpoint at page load and while visible, so already cached cards can stop showing expired campaigns.34 PHP DOM is required for collection. WP-Cron timing depends on site traffic. Purge page caches after updating if an old notice remains. Campaign status can be checked by administrators in Settings; product prices and purchase links continue normally. 35 35 36 36 * Amazon official source: https://www.aboutamazon.jp/news/retail — Terms: https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=GLSBYFE9MGKKQXXM — Privacy: https://www.amazon.co.jp/gp/help/customer/display.html?nodeId=GX7NJQ4ZB8MHFRNJ … … 89 89 == Changelog == 90 90 91 = 1.10.1 = 92 * Use non-heading product titles by default, with an explicit no-heading option and preserved H2-H6 choices. Shortcodes also default to non-heading titles. 93 * Suspend all public campaign notices while retaining opted-in internal collection. Move campaign information into Settings and announce display for the next patch. 94 * Keep card typography independent of the theme root font size. Update Pro to 1.6.6 if installed. 95 91 96 = 1.10.0 = 92 97 * Add optional scheduled collection of dated official Amazon, Rakuten and Yahoo! campaigns, with per-store consent, expiry checks and cache-aware card notices.
Note:
See TracChangeset
for help on using the changeset viewer.