Plugin Directory

Changeset 3835792


Ignore:
Timestamp:
11/30/2026 05:49:36 PM (less than one hour ago)
Author:
depictronix
Message:

Release 1.10.1: suspend all public campaign notices while retaining opted-in internal collection; move campaign status into Settings. Use non-heading product titles by default and correct theme-relative typography.

Location:
depictronix-rapiditem
Files:
4 added
22 edited
1 copied

Legend:

Unmodified
Added
Removed
  • depictronix-rapiditem/tags/1.10.1/assets/campaigns.js

    r3834137 r3835792  
    11( function () {
    22        '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        }
    317        var config = window.rapiditemCampaigns;
    418        if ( ! config || ! window.fetch ) { return; }
    … …  
    2741        };
    2842        var current = function ( store ) {
     43                // Also reject old cached Amazon facts while this feature is withdrawn.
     44                if ( store === 'amazon' ) { return null; }
    2945                var record = snapshot && snapshot.stores && snapshot.stores[ store ];
    3046                if ( ! record || ! Number.isFinite( record.valid_until ) || record.valid_until <= now() || ! Array.isArray( record.events ) ) { return null; }
    … …  
    3349                                typeof event.title === 'string' && event.title.length <= 150 && typeof event.until === 'string' && allowed( store, event.url );
    3450                } ) || 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                };
    3559        };
    3660        var sync = function () {
    … …  
    5175                                wrapper.appendChild( button );
    5276                        }
    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 ] );
    5479                        if ( wrapper.dataset.campaignSignature === signature ) { return; }
    5580                        var old = wrapper.querySelector( '.rapiditem-card__campaign' );
    5681                        if ( old ) { old.remove(); }
    5782                        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 );
    5986                        notice.href = event.url;
    6087                        notice.target = '_blank';
  • depictronix-rapiditem/tags/1.10.1/blocks/product-card/block.json

    r3834137 r3835792  
    33  "apiVersion": 3,
    44  "name": "rapiditem/product-card",
    5   "version": "1.10.0",
     5  "version": "1.10.1",
    66  "title": "Rapidアイテム",
    77  "category": "widgets",
    … …  
    2424    "headingLevel": {
    2525      "type": "string",
    26       "default": "h3"
     26      "default": "div"
    2727    },
    2828    "hiddenStores": {
  • depictronix-rapiditem/tags/1.10.1/blocks/product-card/editor.asset.php

    r3834137 r3835792  
    1111                'wp-hooks',
    1212        ),
    13         'version' => '1.10.0',
     13        'version' => '1.10.1',
    1414);
  • depictronix-rapiditem/tags/1.10.1/blocks/product-card/editor.js

    r3834115 r3835792  
    204204                        var productLimit = 2;
    205205                        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';
    207207                        var pickerRef = useRef( props.picker );
    208208                        pickerRef.current = props.picker;
    … …  
    613613                                                        overrides: entry.overrides || {},
    614614                                                        hiddenStores: disabledStores || [],
    615                                                         headingLevel: selectedHeadingLevel || 'h3'
     615                                                        headingLevel: selectedHeadingLevel || 'div'
    616616                                                },
    617617                                                signal: controller ? controller.signal : undefined
    … …  
    16271627                                                value: headingLevel,
    16281628                                                options: [
     1629                                                        { label: __( '見出しなし(標準)', 'depictronix-rapiditem' ), value: 'div' },
    16291630                                                        { label: 'H2', value: 'h2' },
    16301631                                                        { label: 'H3', value: 'h3' },
    … …  
    16331634                                                        { label: 'H6', value: 'h6' }
    16341635                                                ],
    1635                                                 help: __( '記事内の見出し構造に合わせて選択します。既存ブロックはH3のままです。', 'depictronix-rapiditem' ),
     1636                                                help: __( '標準では商品名を記事の見出しに含めません。見出しとして使う場合だけH2〜H6を選択してください。', 'depictronix-rapiditem' ),
    16361637                                                onChange: function ( value ) { props.setAttributes( { headingLevel: value } ); },
    16371638                                                __next40pxDefaultSize: true
  • depictronix-rapiditem/tags/1.10.1/blocks/product-card/style.css

    r3834137 r3835792  
    8181        border-radius: 14px !important;
    8282        box-shadow: none !important;
     83        /* Use the browser text size, independent of a theme's root rem scale. */
     84        font-size: medium;
    8385        font-style: normal;
    8486        letter-spacing: normal;
    … …  
    282284        border: 0 !important;
    283285        color: var(--rapiditem-text) !important;
    284         font-size: 1.15rem !important;
     286        font-size: 1.15em !important;
    285287        font-family: inherit !important;
    286288        font-style: normal !important;
    … …  
    357359        box-shadow: none;
    358360        font-family: inherit;
    359         font-size: .82rem;
     361        font-size: .82em;
    360362        font-style: normal;
    361363        letter-spacing: normal;
    … …  
    374376        box-shadow: none;
    375377        font-family: inherit;
    376         font-size: .84rem;
     378        font-size: .84em;
    377379        font-style: normal;
    378380        letter-spacing: normal;
    … …  
    391393        box-shadow: none;
    392394        font-family: inherit;
    393         font-size: 1rem;
     395        font-size: calc(1em / .84);
    394396        font-style: normal;
    395397        font-weight: 700;
    … …  
    482484        box-shadow: none;
    483485        font-family: inherit;
    484         font-size: .78rem;
     486        font-size: calc(.78em / .84);
    485487        font-style: normal;
    486488        letter-spacing: normal;
    … …  
    504506        background: transparent !important;
    505507        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;
    550508}
    551509
    … …  
    572530        box-shadow: none;
    573531        font-family: inherit;
    574         font-size: 1rem;
     532        font-size: 1em;
    575533        font-style: normal;
    576534        font-weight: 700;
    … …  
    631589        min-height: 40px;
    632590        padding: 7px 11px;
    633         font-size: .9rem;
     591        font-size: .9em;
    634592}
    635593
    … …  
    637595        min-height: 34px;
    638596        padding: 5px 9px;
    639         font-size: .82rem;
     597        font-size: .82em;
    640598}
    641599
  • depictronix-rapiditem/tags/1.10.1/depictronix-rapiditem.php

    r3834137 r3835792  
    33 * Plugin Name: Depictronix Rapidアイテム
    44 * Description: Create reusable product cards for Amazon Japan, Rakuten and Yahoo! Shopping Japan.
    5  * Version:     1.10.0
     5 * Version:     1.10.1
    66 * Requires at least: 6.6
    77 * Requires PHP: 8.1
    … …  
    3232        return 'rapiditem' === $slug ? 'depictronix-rapiditem' : $slug;
    3333} );
    34 define( 'RAPIDITEM_VERSION', '1.10.0' );
     34define( 'RAPIDITEM_VERSION', '1.10.1' );
    3535define( 'RAPIDITEM_FILE', __FILE__ );
    3636define( 'RAPIDITEM_DIR', plugin_dir_path( __FILE__ ) );
  • depictronix-rapiditem/tags/1.10.1/includes/class-campaign-admin.php

    r3834137 r3835792  
    55
    66final 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 
    117        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' );
    139        }
    1410
    … …  
    2117                        $input = isset( $_POST['stores'] ) && is_array( $_POST['stores'] ) ? wp_unslash( $_POST['stores'] ) : array();
    2218                        $stores = array();
    23                         foreach ( Data::STORES as $store ) { $stores[ $store ] = '1' === ( $input[ $store ] ?? '' ); }
    2419                        $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 );
    2729                                update_option( Campaigns::OPTION, $value, false );
    2830                                if ( Campaigns::settings() !== $value ) { wp_die( esc_html__( '設定を保存できませんでした。もう一度お試しください。', 'depictronix-rapiditem' ) ); }
    2931                        }
    30                         Campaigns::queue();
     32                        if ( $stores_changed ) { Campaigns::queue(); }
    3133                } elseif ( 'refresh' === $operation ) {
    3234                        Campaigns::queue();
    … …  
    4446                $settings = Campaigns::settings();
    4547                ?>
    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>
    4952                        <?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; ?>
    5154                        <h2><?php esc_html_e( '取得する店舗', 'depictronix-rapiditem' ); ?></h2>
    5255                        <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>
    5457                                <input type="hidden" name="action" value="rapiditem_campaigns">
    5558                                <input type="hidden" name="operation" value="save">
    5659                                <?php wp_nonce_field( 'rapiditem_campaigns' ); ?>
    5760                                <?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>
    5963                                <?php endforeach; ?>
    6064                                <p class="submit" style="text-align:center"><?php submit_button( __( '設定を保存', 'depictronix-rapiditem' ), 'primary', 'submit', false ); ?></p>
    … …  
    8185                        <?php endforeach; ?>
    8286                        </tbody></table>
    83                         <p><?php esc_html_e( '表示は店舗ごとに1件です。終了した情報は自動で非表示になります。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は表示されない場合があります。ページキャッシュを利用している場合は、有効化後にキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>
     87                        <p><?php esc_html_e( '取得状況は管理画面だけで確認できます。記事内のセール表示はすべて停止中です。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は取得できない場合があります。更新後も古いセール表示が残る場合は、サイトのページキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>
    8488                        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
    8589                                <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  
    2121                add_action( self::HOOK, array( __CLASS__, 'refresh' ) );
    2222                add_action( 'rest_api_init', array( __CLASS__, 'register_rest' ) );
    23                 add_action( 'admin_menu', array( Campaign_Admin::class, 'register' ) );
    2423                add_action( 'admin_post_rapiditem_campaigns', array( Campaign_Admin::class, 'save' ) );
    2524        }
    … …  
    3130
    3231        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() );
    3456        }
    3557
    … …  
    6890
    6991        public static function register_assets(): void {
     92                if ( ! self::display_enabled() ) { return; }
    7093                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                }
    71100                wp_register_script( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.js', array(), RAPIDITEM_VERSION, true );
    72101                $card = wp_scripts()->registered['rapiditem-card'] ?? null;
    … …  
    76105                wp_localize_script( 'rapiditem-campaigns', 'rapiditemCampaigns', array(
    77106                        'url' => rest_url( 'rapiditem/v1/campaigns' ),
    78                         'conditions' => __( '対象・参加条件は公式ページで確認', 'depictronix-rapiditem' ),
     107                        'conditions' => __( '対象・参加条件を確認', 'depictronix-rapiditem' ),
     108                        'appearance' => self::appearance(),
    79109                ) );
    80110        }
    … …  
    89119
    90120        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(
    92125                        'Cache-Control' => 'no-store, private, max-age=0',
    93126                        'Pragma' => 'no-cache',
    … …  
    97130
    98131        public static function snapshot( int $now ): array {
    99                 $result = array( 'now' => $now, 'stores' => array() );
     132                $result = array( 'now' => $now, 'stores' => array(), 'appearance' => self::appearance() );
    100133                $revision = (string) ( self::settings()['revision'] ?? '' );
    101134                foreach ( self::STORES as $store ) {
  • depictronix-rapiditem/tags/1.10.1/includes/class-renderer.php

    r3834115 r3835792  
    9898                                </figure>
    9999                                <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>
    101101                                        <p class="rapiditem-card__note"><?php esc_html_e( '商品説明のサンプルです。実際の商品では取得情報または手動設定した説明を表示します。', 'depictronix-rapiditem' ); ?></p>
    102102                                        <div class="rapiditem-card__price">
    … …  
    158158                $content_post_id = absint( $block->context['postId'] ?? ( function_exists( 'get_the_ID' ) ? get_the_ID() : 0 ) );
    159159                $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' );
    161161                $allow_editor_preview = defined( 'REST_REQUEST' )
    162162                        && REST_REQUEST
    … …  
    381381
    382382        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' );
    384384                $id = absint( $atts['id'] );
    385385                $overrides = array();
    … …  
    397397                        $hidden = self::sanitize_hidden_stores( (array) ( $config['hiddenStores'] ?? array() ) );
    398398                }
    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 );
    400400                return '' === $card ? '' : '<div class="rapiditem-card-slot">' . wp_kses( $card, self::comparison_allowed_html() ) . '</div>';
    401401        }
    … …  
    542542        }
    543543
    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 {
    545545                $post = get_post( $post_id );
    546546                if ( ! $post || Post_Type::TYPE !== $post->post_type ) {
    … …  
    12421242        protected static function sanitize_heading_level( mixed $level ): string {
    12431243                $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';
    12451245        }
    12461246
  • depictronix-rapiditem/tags/1.10.1/includes/trait-settings-admin.php

    r3834115 r3835792  
    6767        public static function page_url( string $tab = 'basic', string $affiliate_tab = '' ): string {
    6868                $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 ) ) {
    7070                        $tab = 'basic';
    7171                }
    … …  
    9191                        'visual'    => __( 'ビジュアル設定', 'depictronix-rapiditem' ),
    9292                        'refresh'   => __( '情報更新設定', 'depictronix-rapiditem' ),
     93                        'campaigns' => __( 'セール情報', 'depictronix-rapiditem' ),
    9394                        'data'      => __( 'データ設定', 'depictronix-rapiditem' ),
    9495                        'migration' => __( '移行', 'depictronix-rapiditem' ),
    … …  
    122123                        <?php if ( 'migration' === $active_tab ) : ?>
    123124                                <?php Migration::render_page_contents(); ?>
     125                        <?php elseif ( 'campaigns' === $active_tab ) : ?>
     126                                <?php Campaign_Admin::render(); ?>
    124127                        <?php else : ?>
    125128                        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
  • depictronix-rapiditem/tags/1.10.1/readme.txt

    r3834137 r3835792  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2828= Optional official campaign collection =
    2929
    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.
     30Disabled 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.
    3131
    3232Sources: 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.
    3333
    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.
     34PHP 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.
    3535
    3636* 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
    … …  
    8989== Changelog ==
    9090
     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
    9196= 1.10.0 =
    9297* 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  
    11( function () {
    22        '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        }
    317        var config = window.rapiditemCampaigns;
    418        if ( ! config || ! window.fetch ) { return; }
    … …  
    2741        };
    2842        var current = function ( store ) {
     43                // Also reject old cached Amazon facts while this feature is withdrawn.
     44                if ( store === 'amazon' ) { return null; }
    2945                var record = snapshot && snapshot.stores && snapshot.stores[ store ];
    3046                if ( ! record || ! Number.isFinite( record.valid_until ) || record.valid_until <= now() || ! Array.isArray( record.events ) ) { return null; }
    … …  
    3349                                typeof event.title === 'string' && event.title.length <= 150 && typeof event.until === 'string' && allowed( store, event.url );
    3450                } ) || 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                };
    3559        };
    3660        var sync = function () {
    … …  
    5175                                wrapper.appendChild( button );
    5276                        }
    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 ] );
    5479                        if ( wrapper.dataset.campaignSignature === signature ) { return; }
    5580                        var old = wrapper.querySelector( '.rapiditem-card__campaign' );
    5681                        if ( old ) { old.remove(); }
    5782                        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 );
    5986                        notice.href = event.url;
    6087                        notice.target = '_blank';
  • depictronix-rapiditem/trunk/blocks/product-card/block.json

    r3834137 r3835792  
    33  "apiVersion": 3,
    44  "name": "rapiditem/product-card",
    5   "version": "1.10.0",
     5  "version": "1.10.1",
    66  "title": "Rapidアイテム",
    77  "category": "widgets",
    … …  
    2424    "headingLevel": {
    2525      "type": "string",
    26       "default": "h3"
     26      "default": "div"
    2727    },
    2828    "hiddenStores": {
  • depictronix-rapiditem/trunk/blocks/product-card/editor.asset.php

    r3834137 r3835792  
    1111                'wp-hooks',
    1212        ),
    13         'version' => '1.10.0',
     13        'version' => '1.10.1',
    1414);
  • depictronix-rapiditem/trunk/blocks/product-card/editor.js

    r3834115 r3835792  
    204204                        var productLimit = 2;
    205205                        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';
    207207                        var pickerRef = useRef( props.picker );
    208208                        pickerRef.current = props.picker;
    … …  
    613613                                                        overrides: entry.overrides || {},
    614614                                                        hiddenStores: disabledStores || [],
    615                                                         headingLevel: selectedHeadingLevel || 'h3'
     615                                                        headingLevel: selectedHeadingLevel || 'div'
    616616                                                },
    617617                                                signal: controller ? controller.signal : undefined
    … …  
    16271627                                                value: headingLevel,
    16281628                                                options: [
     1629                                                        { label: __( '見出しなし(標準)', 'depictronix-rapiditem' ), value: 'div' },
    16291630                                                        { label: 'H2', value: 'h2' },
    16301631                                                        { label: 'H3', value: 'h3' },
    … …  
    16331634                                                        { label: 'H6', value: 'h6' }
    16341635                                                ],
    1635                                                 help: __( '記事内の見出し構造に合わせて選択します。既存ブロックはH3のままです。', 'depictronix-rapiditem' ),
     1636                                                help: __( '標準では商品名を記事の見出しに含めません。見出しとして使う場合だけH2〜H6を選択してください。', 'depictronix-rapiditem' ),
    16361637                                                onChange: function ( value ) { props.setAttributes( { headingLevel: value } ); },
    16371638                                                __next40pxDefaultSize: true
  • depictronix-rapiditem/trunk/blocks/product-card/style.css

    r3834137 r3835792  
    8181        border-radius: 14px !important;
    8282        box-shadow: none !important;
     83        /* Use the browser text size, independent of a theme's root rem scale. */
     84        font-size: medium;
    8385        font-style: normal;
    8486        letter-spacing: normal;
    … …  
    282284        border: 0 !important;
    283285        color: var(--rapiditem-text) !important;
    284         font-size: 1.15rem !important;
     286        font-size: 1.15em !important;
    285287        font-family: inherit !important;
    286288        font-style: normal !important;
    … …  
    357359        box-shadow: none;
    358360        font-family: inherit;
    359         font-size: .82rem;
     361        font-size: .82em;
    360362        font-style: normal;
    361363        letter-spacing: normal;
    … …  
    374376        box-shadow: none;
    375377        font-family: inherit;
    376         font-size: .84rem;
     378        font-size: .84em;
    377379        font-style: normal;
    378380        letter-spacing: normal;
    … …  
    391393        box-shadow: none;
    392394        font-family: inherit;
    393         font-size: 1rem;
     395        font-size: calc(1em / .84);
    394396        font-style: normal;
    395397        font-weight: 700;
    … …  
    482484        box-shadow: none;
    483485        font-family: inherit;
    484         font-size: .78rem;
     486        font-size: calc(.78em / .84);
    485487        font-style: normal;
    486488        letter-spacing: normal;
    … …  
    504506        background: transparent !important;
    505507        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;
    550508}
    551509
    … …  
    572530        box-shadow: none;
    573531        font-family: inherit;
    574         font-size: 1rem;
     532        font-size: 1em;
    575533        font-style: normal;
    576534        font-weight: 700;
    … …  
    631589        min-height: 40px;
    632590        padding: 7px 11px;
    633         font-size: .9rem;
     591        font-size: .9em;
    634592}
    635593
    … …  
    637595        min-height: 34px;
    638596        padding: 5px 9px;
    639         font-size: .82rem;
     597        font-size: .82em;
    640598}
    641599
  • depictronix-rapiditem/trunk/depictronix-rapiditem.php

    r3834137 r3835792  
    33 * Plugin Name: Depictronix Rapidアイテム
    44 * Description: Create reusable product cards for Amazon Japan, Rakuten and Yahoo! Shopping Japan.
    5  * Version:     1.10.0
     5 * Version:     1.10.1
    66 * Requires at least: 6.6
    77 * Requires PHP: 8.1
    … …  
    3232        return 'rapiditem' === $slug ? 'depictronix-rapiditem' : $slug;
    3333} );
    34 define( 'RAPIDITEM_VERSION', '1.10.0' );
     34define( 'RAPIDITEM_VERSION', '1.10.1' );
    3535define( 'RAPIDITEM_FILE', __FILE__ );
    3636define( 'RAPIDITEM_DIR', plugin_dir_path( __FILE__ ) );
  • depictronix-rapiditem/trunk/includes/class-campaign-admin.php

    r3834137 r3835792  
    55
    66final 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 
    117        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' );
    139        }
    1410
    … …  
    2117                        $input = isset( $_POST['stores'] ) && is_array( $_POST['stores'] ) ? wp_unslash( $_POST['stores'] ) : array();
    2218                        $stores = array();
    23                         foreach ( Data::STORES as $store ) { $stores[ $store ] = '1' === ( $input[ $store ] ?? '' ); }
    2419                        $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 );
    2729                                update_option( Campaigns::OPTION, $value, false );
    2830                                if ( Campaigns::settings() !== $value ) { wp_die( esc_html__( '設定を保存できませんでした。もう一度お試しください。', 'depictronix-rapiditem' ) ); }
    2931                        }
    30                         Campaigns::queue();
     32                        if ( $stores_changed ) { Campaigns::queue(); }
    3133                } elseif ( 'refresh' === $operation ) {
    3234                        Campaigns::queue();
    … …  
    4446                $settings = Campaigns::settings();
    4547                ?>
    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>
    4952                        <?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; ?>
    5154                        <h2><?php esc_html_e( '取得する店舗', 'depictronix-rapiditem' ); ?></h2>
    5255                        <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>
    5457                                <input type="hidden" name="action" value="rapiditem_campaigns">
    5558                                <input type="hidden" name="operation" value="save">
    5659                                <?php wp_nonce_field( 'rapiditem_campaigns' ); ?>
    5760                                <?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>
    5963                                <?php endforeach; ?>
    6064                                <p class="submit" style="text-align:center"><?php submit_button( __( '設定を保存', 'depictronix-rapiditem' ), 'primary', 'submit', false ); ?></p>
    … …  
    8185                        <?php endforeach; ?>
    8286                        </tbody></table>
    83                         <p><?php esc_html_e( '表示は店舗ごとに1件です。終了した情報は自動で非表示になります。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は表示されない場合があります。ページキャッシュを利用している場合は、有効化後にキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>
     87                        <p><?php esc_html_e( '取得状況は管理画面だけで確認できます。記事内のセール表示はすべて停止中です。WordPressの定期処理はアクセス状況により遅れることがあります。ページ形式の変更、日時の未掲載、接続エラー時は取得できない場合があります。更新後も古いセール表示が残る場合は、サイトのページキャッシュを更新してください。', 'depictronix-rapiditem' ); ?></p>
    8488                        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
    8589                                <input type="hidden" name="action" value="rapiditem_campaigns"><input type="hidden" name="operation" value="refresh">
  • depictronix-rapiditem/trunk/includes/class-campaigns.php

    r3834137 r3835792  
    2121                add_action( self::HOOK, array( __CLASS__, 'refresh' ) );
    2222                add_action( 'rest_api_init', array( __CLASS__, 'register_rest' ) );
    23                 add_action( 'admin_menu', array( Campaign_Admin::class, 'register' ) );
    2423                add_action( 'admin_post_rapiditem_campaigns', array( Campaign_Admin::class, 'save' ) );
    2524        }
    … …  
    3130
    3231        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() );
    3456        }
    3557
    … …  
    6890
    6991        public static function register_assets(): void {
     92                if ( ! self::display_enabled() ) { return; }
    7093                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                }
    71100                wp_register_script( 'rapiditem-campaigns', RAPIDITEM_URL . 'assets/campaigns.js', array(), RAPIDITEM_VERSION, true );
    72101                $card = wp_scripts()->registered['rapiditem-card'] ?? null;
    … …  
    76105                wp_localize_script( 'rapiditem-campaigns', 'rapiditemCampaigns', array(
    77106                        'url' => rest_url( 'rapiditem/v1/campaigns' ),
    78                         'conditions' => __( '対象・参加条件は公式ページで確認', 'depictronix-rapiditem' ),
     107                        'conditions' => __( '対象・参加条件を確認', 'depictronix-rapiditem' ),
     108                        'appearance' => self::appearance(),
    79109                ) );
    80110        }
    … …  
    89119
    90120        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(
    92125                        'Cache-Control' => 'no-store, private, max-age=0',
    93126                        'Pragma' => 'no-cache',
    … …  
    97130
    98131        public static function snapshot( int $now ): array {
    99                 $result = array( 'now' => $now, 'stores' => array() );
     132                $result = array( 'now' => $now, 'stores' => array(), 'appearance' => self::appearance() );
    100133                $revision = (string) ( self::settings()['revision'] ?? '' );
    101134                foreach ( self::STORES as $store ) {
  • depictronix-rapiditem/trunk/includes/class-renderer.php

    r3834115 r3835792  
    9898                                </figure>
    9999                                <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>
    101101                                        <p class="rapiditem-card__note"><?php esc_html_e( '商品説明のサンプルです。実際の商品では取得情報または手動設定した説明を表示します。', 'depictronix-rapiditem' ); ?></p>
    102102                                        <div class="rapiditem-card__price">
    … …  
    158158                $content_post_id = absint( $block->context['postId'] ?? ( function_exists( 'get_the_ID' ) ? get_the_ID() : 0 ) );
    159159                $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' );
    161161                $allow_editor_preview = defined( 'REST_REQUEST' )
    162162                        && REST_REQUEST
    … …  
    381381
    382382        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' );
    384384                $id = absint( $atts['id'] );
    385385                $overrides = array();
    … …  
    397397                        $hidden = self::sanitize_hidden_stores( (array) ( $config['hiddenStores'] ?? array() ) );
    398398                }
    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 );
    400400                return '' === $card ? '' : '<div class="rapiditem-card-slot">' . wp_kses( $card, self::comparison_allowed_html() ) . '</div>';
    401401        }
    … …  
    542542        }
    543543
    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 {
    545545                $post = get_post( $post_id );
    546546                if ( ! $post || Post_Type::TYPE !== $post->post_type ) {
    … …  
    12421242        protected static function sanitize_heading_level( mixed $level ): string {
    12431243                $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';
    12451245        }
    12461246
  • depictronix-rapiditem/trunk/includes/trait-settings-admin.php

    r3834115 r3835792  
    6767        public static function page_url( string $tab = 'basic', string $affiliate_tab = '' ): string {
    6868                $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 ) ) {
    7070                        $tab = 'basic';
    7171                }
    … …  
    9191                        'visual'    => __( 'ビジュアル設定', 'depictronix-rapiditem' ),
    9292                        'refresh'   => __( '情報更新設定', 'depictronix-rapiditem' ),
     93                        'campaigns' => __( 'セール情報', 'depictronix-rapiditem' ),
    9394                        'data'      => __( 'データ設定', 'depictronix-rapiditem' ),
    9495                        'migration' => __( '移行', 'depictronix-rapiditem' ),
    … …  
    122123                        <?php if ( 'migration' === $active_tab ) : ?>
    123124                                <?php Migration::render_page_contents(); ?>
     125                        <?php elseif ( 'campaigns' === $active_tab ) : ?>
     126                                <?php Campaign_Admin::render(); ?>
    124127                        <?php else : ?>
    125128                        <form method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>">
  • depictronix-rapiditem/trunk/readme.txt

    r3834137 r3835792  
    55Tested up to: 7.1
    66Requires PHP: 8.1
    7 Stable tag: 1.10.0
     7Stable tag: 1.10.1
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    … …  
    2828= Optional official campaign collection =
    2929
    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.
     30Disabled 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.
    3131
    3232Sources: 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.
    3333
    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.
     34PHP 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.
    3535
    3636* 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
    … …  
    8989== Changelog ==
    9090
     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
    9196= 1.10.0 =
    9297* 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.