Plugin Directory

Changeset 3400152


Ignore:
Timestamp:
11/21/2025 03:20:06 AM (3 weeks ago)
Author:
naibabiji
Message:

update 1.0.12

Location:
naibabiji-b2b-product-showcase
Files:
38 added
11 edited

Legend:

Unmodified
Added
Removed
  • naibabiji-b2b-product-showcase/readme-zh_CN.txt

    r3392923 r3400152  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.9
     7Stable tag: 1.0.12
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080详细参数请在设置页面查看使用说明。
    8181
     82= 侧边栏小工具支持吗? =
     83
     84完全支持!插件提供专用的侧边栏小工具,支持以下功能:
     85
     86**功能特点:**
     87* **智能样式加载** - 自动检测侧边栏中的短代码,只在需要时加载CSS样式
     88* **灵活配置** - 支持显示产品数量、列数、分类筛选等参数设置
     89* **响应式设计** - 在移动设备上自动调整为单列显示
     90* **主题兼容** - 与主流WordPress主题完美兼容
     91
     92**使用步骤:**
     931. 进入WordPress后台 `外观 → 小工具`
     942. 找到"内巴比基B2B产品展示"小工具
     953. 拖拽到目标侧边栏区域
     964. 配置显示参数(产品数量、列数、是否显示分类等)
     975. 保存设置
     98
     99**推荐配置:**
     100* 侧边栏显示:`[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]`
     101* 这种配置适合侧边栏空间,显示3个产品,单列布局,不显示分类和摘要
     102
     103= 为什么侧边栏中的产品样式不生效? =
     104
     105v1.0.12版本已修复此问题。如果仍遇到样式问题,请尝试:
     106
     1071. **清除缓存** - 如果使用缓存插件,请清除所有缓存
     1082. **刷新页面** - 使用Ctrl+F5强制刷新浏览器
     1093. **检查小工具配置** - 确保小工具已正确保存
     1104. **主题兼容性** - 某些主题可能需要额外的CSS调整
     111
     112如果问题依然存在,请联系技术支持并提供主题名称以便进一步排查。
     113
    82114== 更新日志 ==
     115
     116= 1.0.12 =
     117* 优化CSS加载逻辑,新增侧边栏小工具短代码检测功能
     118* 修复侧边栏小工具中产品展示CSS样式不生效的问题
     119* 智能检测页面中的短代码内容,只在需要时加载CSS资源
     120* 完善响应式设计,优化产品卡片在小屏幕设备上的显示效果
     121
     122= 1.0.11 =
     123* SEO内容区域添加elementor短代码支持
     124* 统一函数和变量前缀以符合WordPress插件最佳开发实践
     125
     126=1.0.10=
     127* 添加切换以启用/禁用产品元信息显示
     128* 改进翻译和更新本地化文件
    83129
    84130= 1.0.9 =
  • naibabiji-b2b-product-showcase/readme.txt

    r3392923 r3400152  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.9
     7Stable tag: 1.0.12
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080For detailed parameters, please check the usage instructions on the settings page.
    8181
     82= Does the plugin support sidebar widgets? =
     83
     84Yes! The plugin provides dedicated sidebar widgets with the following features:
     85
     86**Key Features:**
     87* **Smart Style Loading** - Automatically detects shortcodes in sidebar and loads CSS styles only when needed
     88* **Flexible Configuration** - Supports product count, column layout, category filtering and other parameter settings
     89* **Responsive Design** - Automatically adjusts to single column display on mobile devices
     90* **Theme Compatibility** - Perfectly compatible with popular WordPress themes
     91
     92**Usage Steps:**
     931. Go to WordPress admin `Appearance → Widgets`
     942. Find the "Naibabiji B2B Product Showcase" widget
     953. Drag to the target sidebar area
     964. Configure display parameters (product count, columns, show categories, etc.)
     975. Save settings
     98
     99**Recommended Configuration:**
     100* Sidebar display: `[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]`
     101* This configuration is suitable for sidebar space, showing 3 products in single column layout without categories and excerpts
     102
     103= Why don't product styles work in the sidebar? =
     104
     105This issue has been fixed in v1.0.12. If you still encounter style problems, please try:
     106
     1071. **Clear Cache** - If using a cache plugin, clear all caches
     1082. **Refresh Page** - Use Ctrl+F5 to force refresh the browser
     1093. **Check Widget Configuration** - Ensure the widget is properly saved
     1104. **Theme Compatibility** - Some themes may require additional CSS adjustments
     111
     112If the problem persists, please contact technical support and provide the theme name for further troubleshooting.
     113
    82114== Changelog ==
     115
     116= 1.0.12 =
     117* Enhanced CSS loading logic with sidebar widget shortcode detection
     118* Fixed CSS styles not working in sidebar widgets
     119* Smart detection of shortcode content on pages, loading CSS resources only when needed
     120* Improved responsive design for better product card display on mobile devices
     121
     122= 1.0.11 =
     123* Added Elementor shortcode support in SEO content area
     124* Standardized function and variable prefixes to comply with WordPress plugin best development practices
     125
     126= 1.0.10 =
     127* Added toggle to enable/disable product meta information display
     128* Improved translations and updated localization files
    83129
    84130= 1.0.9 =
  • naibabiji-b2b-product-showcase/trunk/assets/css/frontend.css

    r3350010 r3400152  
    2525
    2626.naibabiji-b2b-taxonomy-title {
    27     font-size: 32px;
     27    font-size: 20px;
    2828    color: #333333;
    2929    margin-bottom: 15px;
     
    187187    flex-direction: column;
    188188    height: 100%;
    189     padding: 20px;
     189    padding: 16px;
     190    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    190191}
    191192
    192193.naibabiji-b2b-product-card:hover {
    193     transform: translateY(-5px);
    194     box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
     194    transform: translateY(-3px);
     195    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
     196    border-color: #0066cc;
    195197}
    196198
     
    198200    position: relative;
    199201    overflow: hidden;
     202    margin: -16px -16px 12px -16px;
     203    border-radius: 8px 8px 0 0;
    200204}
    201205
     
    204208    height: auto;
    205209    display: block;
    206     object-fit: contain;
    207 }
    208 
    209 .naibabiji-b2b-product-summary {
    210     padding: 20px;
     210    object-fit: cover;
     211    transition: transform 0.3s ease;
     212}
     213
     214.naibabiji-b2b-product-thumbnail:hover img {
     215    transform: scale(1.05);
     216}
     217
     218.naibabiji-b2b-product-info {
    211219    display: flex;
    212220    flex-direction: column;
    213221    flex-grow: 1;
    214     justify-content: flex-start;
    215 }
    216 
     222    padding: 20px;
     223    text-align: center;
     224}
     225
     226/* H6标题样式 - 更适合侧边栏 */
    217227.naibabiji-b2b-product-title {
    218     font-size: 18px;
    219     margin: 0 0 10px;
    220     line-height: 1.4;
     228    font-size: 15px;
     229    font-weight: 600;
     230    margin: 0 0 10px 0;
     231    line-height: 1.3;
     232    color: #333333;
     233    display: -webkit-box;
     234    -webkit-line-clamp: 2;
     235    -webkit-box-orient: vertical;
     236    overflow: hidden;
    221237}
    222238
    223239.naibabiji-b2b-product-title a {
    224     color: #333333;
     240    color: inherit;
    225241    text-decoration: none;
     242    transition: color 0.3s ease;
    226243}
    227244
     
    232249.naibabiji-b2b-product-excerpt {
    233250    color: #666666;
    234     font-size: 14px;
    235     line-height: 1.6;
    236     margin-bottom: 15px;
     251    font-size: 13px;
     252    line-height: 1.5;
     253    margin-bottom: 12px;
     254    display: -webkit-box;
     255    -webkit-line-clamp: 2;
     256    -webkit-box-orient: vertical;
     257    overflow: hidden;
    237258}
    238259
    239260.naibabiji-b2b-product-meta {
    240     font-size: 13px;
     261    font-size: 12px;
    241262    color: #888888;
    242     margin-bottom: 0;
    243     margin-top: auto;
     263    margin-bottom: 12px;
     264    padding-bottom: 8px;
     265    border-bottom: 1px solid #f0f0f0;
     266}
     267
     268.naibabiji-b2b-product-category {
     269    display: flex;
     270    align-items: center;
     271}
     272
     273.naibabiji-b2b-product-category::before {
     274    content: "🏷️";
     275    margin-right: 4px;
    244276}
    245277
     
    248280    text-decoration: none;
    249281    transition: color 0.3s ease;
     282    font-weight: 500;
    250283}
    251284
     
    256289
    257290.naibabiji-b2b-product-actions {
     291    margin-top: auto;
     292}
     293
     294.naibabiji-b2b-button-group {
    258295    display: flex;
    259     margin-top: auto;
     296    flex-direction: column;
     297    gap: 8px;
     298}
     299
     300.naibabiji-b2b-view-details-button,
     301.naibabiji-b2b-inquiry-button {
     302    display: inline-flex;
     303    align-items: center;
     304    justify-content: center;
     305    padding: 8px 12px;
     306    text-decoration: none;
     307    border-radius: 6px;
     308    font-size: 13px;
     309    font-weight: 500;
     310    transition: all 0.3s ease;
     311    text-align: center;
     312    border: none;
     313    cursor: pointer;
    260314}
    261315
    262316.naibabiji-b2b-view-details-button {
    263     display: inline-block;
    264     padding: 8px 20px;
    265     background-color: #0066cc;
     317    background: linear-gradient(135deg, #0066cc, #0052a3);
    266318    color: #ffffff;
    267     text-decoration: none;
    268     border-radius: 4px;
    269     font-size: 14px;
    270     transition: background-color 0.3s ease;
    271319}
    272320
    273321.naibabiji-b2b-view-details-button:hover {
    274     background-color: #0052a3;
     322    background: linear-gradient(135deg, #0052a3, #003d7a);
     323    transform: translateY(-1px);
     324    box-shadow: 0 3px 8px rgba(0, 102, 204, 0.3);
     325}
     326
     327.naibabiji-b2b-inquiry-button {
     328    background: linear-gradient(135deg, #28a745, #1e7e34);
    275329    color: #ffffff;
    276330}
    277331
    278 /* Pagination Navigation */
     332.naibabiji-b2b-inquiry-button:hover {
     333    background: linear-gradient(135deg, #1e7e34, #155724);
     334    transform: translateY(-1px);
     335    box-shadow: 0 3px 8px rgba(40, 167, 69, 0.3);
     336}
     337
     338.naibabiji-b2b-button-icon {
     339     margin-right: 6px;
     340     font-size: 12px;
     341 }
     342 
     343/* 响应式样式 - 侧边栏优化 */
     344@media screen and (max-width: 768px) {
     345    .naibabiji-b2b-product-card {
     346        padding: 12px;
     347    }
     348   
     349    .naibabiji-b2b-product-thumbnail {
     350        margin: -12px -12px 10px -12px;
     351    }
     352   
     353    .naibabiji-b2b-product-title {
     354        font-size: 14px;
     355        -webkit-line-clamp: 1;
     356    }
     357   
     358    .naibabiji-b2b-product-excerpt {
     359        font-size: 12px;
     360        -webkit-line-clamp: 1;
     361    }
     362   
     363    .naibabiji-b2b-button-group {
     364        gap: 6px;
     365    }
     366   
     367    .naibabiji-b2b-view-details-button,
     368    .naibabiji-b2b-inquiry-button {
     369        padding: 6px 10px;
     370        font-size: 12px;
     371    }
     372}
     373
     374@media screen and (max-width: 480px) {
     375    .naibabiji-b2b-product-card {
     376        padding: 10px;
     377        border-radius: 6px;
     378    }
     379   
     380    .naibabiji-b2b-product-thumbnail {
     381        margin: -10px -10px 8px -10px;
     382        border-radius: 6px 6px 0 0;
     383    }
     384   
     385    .naibabiji-b2b-product-title {
     386        font-size: 13px;
     387        margin-bottom: 8px;
     388    }
     389   
     390    .naibabiji-b2b-product-excerpt {
     391        font-size: 11px;
     392        margin-bottom: 8px;
     393    }
     394   
     395    .naibabiji-b2b-product-meta {
     396        font-size: 11px;
     397        margin-bottom: 8px;
     398    }
     399   
     400    .naibabiji-b2b-view-details-button,
     401    .naibabiji-b2b-inquiry-button {
     402        padding: 5px 8px;
     403        font-size: 11px;
     404    }
     405   
     406    .naibabiji-b2b-button-icon {
     407        margin-right: 4px;
     408        font-size: 10px;
     409    }
     410}
     411
     412/* 小容器优化 - 特别适合侧边栏 */
     413@media (max-width: 300px) {
     414    .naibabiji-b2b-product-card {
     415        padding: 8px;
     416    }
     417   
     418    .naibabiji-b2b-product-thumbnail {
     419        margin: -8px -8px 6px -8px;
     420    }
     421   
     422    .naibabiji-b2b-product-title {
     423        font-size: 12px;
     424        line-height: 1.2;
     425        -webkit-line-clamp: 1;
     426    }
     427   
     428    .naibabiji-b2b-product-excerpt,
     429    .naibabiji-b2b-product-meta {
     430        display: none; /* 在超小容器中隐藏摘要和元信息 */
     431    }
     432   
     433    .naibabiji-b2b-view-details-button,
     434    .naibabiji-b2b-inquiry-button {
     435        padding: 4px 6px;
     436        font-size: 10px;
     437    }
     438}
     439
     440/* 产品网格响应式列数 */
     441.naibabiji-b2b-columns-1 {
     442    grid-template-columns: 1fr;
     443}
     444
     445.naibabiji-b2b-columns-2 {
     446    grid-template-columns: repeat(2, 1fr);
     447}
     448
     449.naibabiji-b2b-columns-3 {
     450    grid-template-columns: repeat(3, 1fr);
     451}
     452
     453.naibabiji-b2b-columns-4 {
     454    grid-template-columns: repeat(4, 1fr);
     455}
     456
     457.naibabiji-b2b-columns-5 {
     458    grid-template-columns: repeat(5, 1fr);
     459}
     460
     461.naibabiji-b2b-columns-6 {
     462    grid-template-columns: repeat(6, 1fr);
     463}
     464
     465/* 响应式网格调整 */
     466@media screen and (max-width: 1200px) {
     467    .naibabiji-b2b-columns-6 {
     468        grid-template-columns: repeat(4, 1fr);
     469    }
     470   
     471    .naibabiji-b2b-columns-5 {
     472        grid-template-columns: repeat(3, 1fr);
     473    }
     474}
     475
     476@media screen and (max-width: 768px) {
     477    .naibabiji-b2b-products-grid {
     478        grid-template-columns: repeat(2, 1fr);
     479        gap: 20px;
     480    }
     481   
     482    .naibabiji-b2b-columns-4,
     483    .naibabiji-b2b-columns-5,
     484    .naibabiji-b2b-columns-6 {
     485        grid-template-columns: repeat(2, 1fr);
     486    }
     487}
     488
     489@media screen and (max-width: 480px) {
     490    .naibabiji-b2b-products-grid {
     491        grid-template-columns: 1fr;
     492        gap: 15px;
     493    }
     494   
     495    .naibabiji-b2b-columns-2,
     496    .naibabiji-b2b-columns-3,
     497    .naibabiji-b2b-columns-4,
     498    .naibabiji-b2b-columns-5,
     499    .naibabiji-b2b-columns-6 {
     500        grid-template-columns: 1fr;
     501    }
     502}
     503 
     504 /* Pagination Navigation */
    279505.navigation.pagination {
    280506    margin-top: 40px;
     
    555781
    556782.naibabiji-b2b-product-title {
    557     font-size: 32px;
     783    font-size: 20px;
    558784    font-weight: 600;
    559785    color: #333;
  • naibabiji-b2b-product-showcase/trunk/includes/class-admin-settings.php

    r3393419 r3400152  
    224224                    <li><strong><?php echo esc_html__('Shortcode', 'naibabiji-b2b-product-showcase'); ?>:</strong> <?php echo esc_html__('Use', 'naibabiji-b2b-product-showcase'); ?> <code>[naibabiji_b2b_products]</code> <?php echo esc_html__('to display product grid on any page', 'naibabiji-b2b-product-showcase'); ?></li>
    225225                    <li><strong><?php echo esc_html__('Shortcode Parameters', 'naibabiji-b2b-product-showcase'); ?>:</strong>
    226                         <ul>
    227                             <li><code>limit</code> - <?php echo esc_html__('Number of products to display', 'naibabiji-b2b-product-showcase'); ?> (<?php echo esc_html__('Default', 'naibabiji-b2b-product-showcase'); ?>: 8)</li>
    228                             <li><code>columns</code> - <?php echo esc_html__('Number of columns', 'naibabiji-b2b-product-showcase'); ?> (<?php echo esc_html__('Default', 'naibabiji-b2b-product-showcase'); ?>: 3)</li>
    229                             <li><code>category</code> - <?php echo esc_html__('Specify category slug', 'naibabiji-b2b-product-showcase'); ?></li>
    230                         </ul>
     226                        <table class="naibabiji-b2b-params-table" style="width: 100%; border-collapse: collapse; margin-top: 10px;">
     227                            <thead>
     228                                <tr style="background: #fff;">
     229                                    <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 20%;"><strong><?php echo esc_html__('参数', 'naibabiji-b2b-product-showcase'); ?></strong></th>
     230                                    <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 40%;"><strong><?php echo esc_html__('说明', 'naibabiji-b2b-product-showcase'); ?></strong></th>
     231                                    <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 20%;"><strong><?php echo esc_html__('默认值', 'naibabiji-b2b-product-showcase'); ?></strong></th>
     232                                    <th style="border: 1px solid #ddd; padding: 8px; text-align: left; width: 20%;"><strong><?php echo esc_html__('可选值', 'naibabiji-b2b-product-showcase'); ?></strong></th>
     233                                </tr>
     234                            </thead>
     235                            <tbody>
     236                                <tr>
     237                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>limit</code></td>
     238                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('显示产品数量', 'naibabiji-b2b-product-showcase'); ?></td>
     239                                    <td style="border: 1px solid #ddd; padding: 8px;">8</td>
     240                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('任意正整数', 'naibabiji-b2b-product-showcase'); ?></td>
     241                                </tr>
     242                                <tr style="background: #f9f9f9;">
     243                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>columns</code></td>
     244                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('显示列数', 'naibabiji-b2b-product-showcase'); ?></td>
     245                                    <td style="border: 1px solid #ddd; padding: 8px;">3</td>
     246                                    <td style="border: 1px solid #ddd; padding: 8px;">1-6</td>
     247                                </tr>
     248                                <tr>
     249                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>show_excerpt</code></td>
     250                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('是否显示摘要', 'naibabiji-b2b-product-showcase'); ?></td>
     251                                    <td style="border: 1px solid #ddd; padding: 8px;">true</td>
     252                                    <td style="border: 1px solid #ddd; padding: 8px;">true/false</td>
     253                                </tr>
     254                                <tr style="background: #f9f9f9;">
     255                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>show_category</code></td>
     256                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('是否显示分类', 'naibabiji-b2b-product-showcase'); ?></td>
     257                                    <td style="border: 1px solid #ddd; padding: 8px;">true</td>
     258                                    <td style="border: 1px solid #ddd; padding: 8px;">true/false</td>
     259                                </tr>
     260                                <tr>
     261                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>show_view_details</code></td>
     262                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('是否显示"View Details"按钮', 'naibabiji-b2b-product-showcase'); ?></td>
     263                                    <td style="border: 1px solid #ddd; padding: 8px;">true</td>
     264                                    <td style="border: 1px solid #ddd; padding: 8px;">true/false</td>
     265                                </tr>
     266                                <tr style="background: #f9f9f9;">
     267                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>show_inquiry</code></td>
     268                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('是否显示"Get Quote"按钮', 'naibabiji-b2b-product-showcase'); ?></td>
     269                                    <td style="border: 1px solid #ddd; padding: 8px;">true</td>
     270                                    <td style="border: 1px solid #ddd; padding: 8px;">true/false</td>
     271                                </tr>
     272                                <tr>
     273                                    <td style="border: 1px solid #ddd; padding: 8px;"><code>category</code></td>
     274                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('指定产品分类(使用分类别名)', 'naibabiji-b2b-product-showcase'); ?></td>
     275                                    <td style="border: 1px solid #ddd; padding: 8px;">-</td>
     276                                    <td style="border: 1px solid #ddd; padding: 8px;"><?php echo esc_html__('分类别名', 'naibabiji-b2b-product-showcase'); ?></td>
     277                                </tr>
     278                            </tbody>
     279                        </table>
    231280                    </li>
    232281                    <li><strong><?php echo esc_html__('Example', 'naibabiji-b2b-product-showcase'); ?>:</strong> <code>[naibabiji_b2b_products limit="6" columns="4" category="electronics"]</code></li>
  • naibabiji-b2b-product-showcase/trunk/includes/class-frontend-display.php

    r3392914 r3400152  
    309309            'category' => '',
    310310            'show_excerpt' => true,
     311            'show_category' => true,
     312            'show_view_details' => true,
     313            'show_inquiry' => true,
    311314            'orderby' => 'date',
    312315            'order' => 'DESC',
     
    324327       
    325328        if (!empty($args['category'])) {
     329            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Necessary for category filtering
    326330            $query_args['tax_query'] = array(
    327331                array(
     
    342346       
    343347        // 通过模板渲染产品卡片,避免重复HTML实现
    344         $naibabiji_b2b_show_excerpt = (bool) $args['show_excerpt'];
     348        // 修复变量名不匹配问题,传递正确的变量名
     349        $show_excerpt = (bool) $args['show_excerpt'];
     350        $show_category = (bool) $args['show_category'];
     351        $show_view_details = (bool) $args['show_view_details'];
     352        $show_inquiry = (bool) $args['show_inquiry'];
     353       
    345354        while ($products->have_posts()) {
    346355            $products->the_post();
  • naibabiji-b2b-product-showcase/trunk/includes/class-shortcodes.php

    r3392914 r3400152  
    4444     * [naibabiji_b2b_products limit="6" columns="2"]
    4545     * [naibabiji_b2b_products category="electronics" limit="8" columns="4"]
     46     * [naibabiji_b2b_products show_excerpt="true" show_category="true" show_view_details="true" show_inquiry="true"]
    4647     */
    4748    public function products_shortcode($atts, $content = null) {
     
    5152            'category' => '',
    5253            'show_excerpt' => 'true',
     54            'show_category' => 'true',
     55            'show_view_details' => 'true',
     56            'show_inquiry' => 'true',
    5357            'orderby' => 'date',
    5458            'order' => 'DESC',
     
    5761        // 转换字符串为布尔值
    5862        $show_excerpt = filter_var($atts['show_excerpt'], FILTER_VALIDATE_BOOLEAN);
     63        $show_category = filter_var($atts['show_category'], FILTER_VALIDATE_BOOLEAN);
     64        $show_view_details = filter_var($atts['show_view_details'], FILTER_VALIDATE_BOOLEAN);
     65        $show_inquiry = filter_var($atts['show_inquiry'], FILTER_VALIDATE_BOOLEAN);
    5966       
    6067        // 验证和清理参数
     
    6875            'category' => sanitize_text_field($atts['category']),
    6976            'show_excerpt' => $show_excerpt,
     77            'show_category' => $show_category,
     78            'show_view_details' => $show_view_details,
     79            'show_inquiry' => $show_inquiry,
    7080            'orderby' => sanitize_text_field($atts['orderby']),
    7181            'order' => sanitize_text_field($atts['order']),
  • naibabiji-b2b-product-showcase/trunk/naibabiji-b2b-product-showcase.php

    r3393729 r3400152  
    44 * Plugin URI: https://blog.naibabiji.com
    55 * Description: Lightweight B2B product showcase plugin designed for corporate websites, without shopping cart functionality, focusing on product display and inquiry.
    6  * Version: 1.0.11
     6 * Version: 1.0.12
    77 * Author: Naibabiji
    88 * Text Domain: naibabiji-b2b-product-showcase
     
    2525 * 定义插件常量
    2626 */
    27 define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_VERSION', '1.0.11' );
     27define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_VERSION', '1.0.12' );
    2828define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_AUTHOR', 'Naibabiji' );
    2929define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_URI', 'https://blog.naibabiji.com' );
     
    295295        }
    296296
     297        // 检查侧边栏小工具中是否包含短代码
     298        if ( $this->is_shortcode_in_widgets( array( 'naibabiji_b2b_products', 'naibabiji_b2b_product_categories' ) ) ) {
     299            return true;
     300        }
     301
    297302        /**
    298303         * Filters whether the frontend assets should be enqueued.
     
    302307         */
    303308        return (bool) apply_filters( 'naibabiji_b2b_should_enqueue_frontend_assets', false );
     309    }
     310   
     311    /**
     312     * Check if shortcode exists in widgets
     313     *
     314     * @since 1.1.1
     315     * @param array $shortcodes Shortcodes to search for
     316     * @return bool
     317     */
     318    private function is_shortcode_in_widgets( $shortcodes ) {
     319        // 获取所有已注册的侧边栏
     320        // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited -- Safe to use for reading sidebar widgets
     321        global $wp_registered_sidebars;
     322        $sidebars_widgets = get_option( 'sidebars_widgets', array() );
     323       
     324        if ( empty( $sidebars_widgets ) ) {
     325            return false;
     326        }
     327
     328        // 遍历每个侧边栏
     329        foreach ( $sidebars_widgets as $sidebar_id => $widget_ids ) {
     330            if ( 'wp_inactive_widgets' === $sidebar_id || empty( $widget_ids ) ) {
     331                continue;
     332            }
     333
     334            // 遍历该侧边栏中的每个小工具
     335            foreach ( $widget_ids as $widget_id ) {
     336                // 解析小工具类型和实例ID
     337                if ( preg_match( '/^(.+?)-(\d+)$/', $widget_id, $matches ) ) {
     338                    $widget_type = $matches[1];
     339                    $widget_instance_id = $matches[2];
     340                   
     341                    // 获取该类型小工具的所有实例
     342                    $widget_instances = get_option( 'widget_' . $widget_type, array() );
     343                   
     344                    if ( ! isset( $widget_instances[ $widget_instance_id ] ) ) {
     345                        continue;
     346                    }
     347                   
     348                    $widget_data = $widget_instances[ $widget_instance_id ];
     349                   
     350                    if ( ! is_array( $widget_data ) ) {
     351                        continue;
     352                    }
     353
     354                    // 检查文本小工具的text字段
     355                    if ( isset( $widget_data['text'] ) && is_string( $widget_data['text'] ) ) {
     356                        foreach ( $shortcodes as $shortcode ) {
     357                            if ( has_shortcode( $widget_data['text'], $shortcode ) ) {
     358                                return true;
     359                            }
     360                        }
     361                    }
     362
     363                    // 检查HTML小工具的content字段
     364                    if ( isset( $widget_data['content'] ) && is_string( $widget_data['content'] ) ) {
     365                        foreach ( $shortcodes as $shortcode ) {
     366                            if ( has_shortcode( $widget_data['content'], $shortcode ) ) {
     367                                return true;
     368                            }
     369                        }
     370                    }
     371
     372                    // 检查其他可能包含短代码的字段
     373                    foreach ( $widget_data as $field_value ) {
     374                        if ( is_string( $field_value ) ) {
     375                            foreach ( $shortcodes as $shortcode ) {
     376                                if ( has_shortcode( $field_value, $shortcode ) ) {
     377                                    return true;
     378                                }
     379                            }
     380                        }
     381                    }
     382                }
     383            }
     384        }
     385
     386        return false;
    304387    }
    305388   
  • naibabiji-b2b-product-showcase/trunk/readme-zh_CN.txt

    r3393729 r3400152  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.11
     7Stable tag: 1.0.12
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080详细参数请在设置页面查看使用说明。
    8181
     82= 侧边栏小工具支持吗? =
     83
     84完全支持!插件提供专用的侧边栏小工具,支持以下功能:
     85
     86**功能特点:**
     87* **智能样式加载** - 自动检测侧边栏中的短代码,只在需要时加载CSS样式
     88* **灵活配置** - 支持显示产品数量、列数、分类筛选等参数设置
     89* **响应式设计** - 在移动设备上自动调整为单列显示
     90* **主题兼容** - 与主流WordPress主题完美兼容
     91
     92**使用步骤:**
     931. 进入WordPress后台 `外观 → 小工具`
     942. 找到"内巴比基B2B产品展示"小工具
     953. 拖拽到目标侧边栏区域
     964. 配置显示参数(产品数量、列数、是否显示分类等)
     975. 保存设置
     98
     99**推荐配置:**
     100* 侧边栏显示:`[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]`
     101* 这种配置适合侧边栏空间,显示3个产品,单列布局,不显示分类和摘要
     102
     103= 为什么侧边栏中的产品样式不生效? =
     104
     105v1.0.12版本已修复此问题。如果仍遇到样式问题,请尝试:
     106
     1071. **清除缓存** - 如果使用缓存插件,请清除所有缓存
     1082. **刷新页面** - 使用Ctrl+F5强制刷新浏览器
     1093. **检查小工具配置** - 确保小工具已正确保存
     1104. **主题兼容性** - 某些主题可能需要额外的CSS调整
     111
     112如果问题依然存在,请联系技术支持并提供主题名称以便进一步排查。
     113
    82114== 更新日志 ==
     115
     116= 1.0.12 =
     117* 优化CSS加载逻辑,新增侧边栏小工具短代码检测功能
     118* 修复侧边栏小工具中产品展示CSS样式不生效的问题
     119* 智能检测页面中的短代码内容,只在需要时加载CSS资源
     120* 完善响应式设计,优化产品卡片在小屏幕设备上的显示效果
    83121
    84122= 1.0.11 =
  • naibabiji-b2b-product-showcase/trunk/readme.txt

    r3393729 r3400152  
    55Tested up to: 6.8
    66Requires PHP: 7.4
    7 Stable tag: 1.0.11
     7Stable tag: 1.0.12
    88License: GPL v2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    8080For detailed parameters, please check the usage instructions on the settings page.
    8181
     82= Does the plugin support sidebar widgets? =
     83
     84Yes! The plugin provides dedicated sidebar widgets with the following features:
     85
     86**Key Features:**
     87* **Smart Style Loading** - Automatically detects shortcodes in sidebar and loads CSS styles only when needed
     88* **Flexible Configuration** - Supports product count, column layout, category filtering and other parameter settings
     89* **Responsive Design** - Automatically adjusts to single column display on mobile devices
     90* **Theme Compatibility** - Perfectly compatible with popular WordPress themes
     91
     92**Usage Steps:**
     931. Go to WordPress admin `Appearance → Widgets`
     942. Find the "Naibabiji B2B Product Showcase" widget
     953. Drag to the target sidebar area
     964. Configure display parameters (product count, columns, show categories, etc.)
     975. Save settings
     98
     99**Recommended Configuration:**
     100* Sidebar display: `[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]`
     101* This configuration is suitable for sidebar space, showing 3 products in single column layout without categories and excerpts
     102
     103= Why don't product styles work in the sidebar? =
     104
     105This issue has been fixed in v1.0.12. If you still encounter style problems, please try:
     106
     1071. **Clear Cache** - If using a cache plugin, clear all caches
     1082. **Refresh Page** - Use Ctrl+F5 to force refresh the browser
     1093. **Check Widget Configuration** - Ensure the widget is properly saved
     1104. **Theme Compatibility** - Some themes may require additional CSS adjustments
     111
     112If the problem persists, please contact technical support and provide the theme name for further troubleshooting.
     113
    82114== Changelog ==
     115
     116= 1.0.12 =
     117* Enhanced CSS loading logic with sidebar widget shortcode detection
     118* Fixed CSS styles not working in sidebar widgets
     119* Smart detection of shortcode content on pages, loading CSS resources only when needed
     120* Improved responsive design for better product card display on mobile devices
    83121
    84122= 1.0.11 =
  • naibabiji-b2b-product-showcase/trunk/templates/content-product-card.php

    r3393729 r3400152  
    1111
    1212$naibabiji_b2b_product_id = get_the_ID();
    13 $naibabiji_b2b_show_excerpt = isset($naibabiji_b2b_show_excerpt) ? (bool) $naibabiji_b2b_show_excerpt : true;
     13
     14// 确保变量存在,提供默认值
     15$naibabiji_b2b_show_excerpt = isset($show_excerpt) ? (bool) $show_excerpt : true;
     16$naibabiji_b2b_show_category = isset($show_category) ? (bool) $show_category : true;
     17$naibabiji_b2b_show_view_details = isset($show_view_details) ? (bool) $show_view_details : true;
     18$naibabiji_b2b_show_inquiry = isset($show_inquiry) ? (bool) $show_inquiry : true;
    1419?>
    1520
     
    2429   
    2530    <div class="naibabiji-b2b-product-info">
    26         <h2 class="naibabiji-b2b-product-title">
     31        <h6 class="naibabiji-b2b-product-title">
    2732            <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    28         </h2>
     33        </h6>
    2934       
    30         <?php if ($show_excerpt && has_excerpt()) : ?>
     35        <?php if ($naibabiji_b2b_show_excerpt && has_excerpt()) : ?>
    3136            <div class="naibabiji-b2b-product-excerpt">
    3237                <?php
     
    3843        <?php endif; ?>
    3944       
     45        <?php if ($naibabiji_b2b_show_category) : ?>
    4046        <?php
    4147        // Display product categories
     
    4450            $naibabiji_b2b_primary_category = $naibabiji_b2b_product_categories[0];
    4551            $naibabiji_b2b_primary_category_link = get_term_link($naibabiji_b2b_primary_category, 'naibb2pr_product_category');
    46             if (!is_wp_error($primary_category_link)) :
     52            if (!is_wp_error($naibabiji_b2b_primary_category_link)) :
    4753        ?>
    4854            <div class="naibabiji-b2b-product-meta">
     
    5864        endif;
    5965        ?>
     66        <?php endif; ?>
    6067       
    6168        <div class="naibabiji-b2b-product-actions">
    6269            <div class="naibabiji-b2b-button-group">
     70                <?php if ($naibabiji_b2b_show_view_details) : ?>
    6371                <a href="<?php the_permalink(); ?>" class="naibabiji-b2b-view-details-button">
    6472                    <span class="naibabiji-b2b-button-icon">→</span><?php echo esc_html__('View Details', 'naibabiji-b2b-product-showcase'); ?>
    6573                </a>
     74                <?php endif; ?>
    6675               
    6776                <?php
    6877                // Display inquiry button (if enabled)
    6978                $naibabiji_b2b_enable_inquiry = get_option('naibabiji_b2b_product_enable_inquiry_button', 1);
    70                 if ($naibabiji_b2b_enable_inquiry) :
     79                if ($naibabiji_b2b_show_inquiry && $naibabiji_b2b_enable_inquiry) :
    7180                    $naibabiji_b2b_inquiry_text = get_post_meta($naibabiji_b2b_product_id, '_naibabiji_b2b_product_inquiry_text', true);
    7281                    if (empty($naibabiji_b2b_inquiry_text)) {
  • naibabiji-b2b-product-showcase/trunk/templates/single-naibb2pr_products.php

    r3393729 r3400152  
    169169        <?php
    170170        // Display related products
    171 $naibabiji_b2b_related_products = get_posts(array(
    172     'post_type' => 'naibb2pr_products',
     171        $naibabiji_b2b_category_ids = wp_get_post_terms(get_the_ID(), 'naibb2pr_product_category', array('fields' => 'ids'));
     172       
     173        $naibabiji_b2b_related_args = array(
     174            'post_type' => 'naibb2pr_products',
    173175            'posts_per_page' => 4,
    174             'post__not_in' => array(get_the_ID()),
    175             'tax_query' => array(
     176            'orderby' => 'rand',
     177        );
     178       
     179        // Only add tax_query if categories exist
     180        if (!empty($naibabiji_b2b_category_ids) && !is_wp_error($naibabiji_b2b_category_ids)) {
     181            // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Necessary for related products by category
     182            $naibabiji_b2b_related_args['tax_query'] = array(
    176183                array(
    177184                    'taxonomy' => 'naibb2pr_product_category',
    178185                    'field' => 'term_id',
    179                     'terms' => wp_get_post_terms(get_the_ID(), 'naibb2pr_product_category', array('fields' => 'ids')),
     186                    'terms' => $naibabiji_b2b_category_ids,
    180187                ),
    181             ),
    182         ));
    183        
    184         if ($naibabiji_b2b_related_products) :
     188            );
     189        }
     190       
     191        $naibabiji_b2b_related_products = get_posts($naibabiji_b2b_related_args);
     192       
     193        // Exclude current product
     194        $naibabiji_b2b_filtered_products = array();
     195        foreach ($naibabiji_b2b_related_products as $naibabiji_b2b_product) {
     196            if ($naibabiji_b2b_product->ID !== get_the_ID()) {
     197                $naibabiji_b2b_filtered_products[] = $naibabiji_b2b_product;
     198                if (count($naibabiji_b2b_filtered_products) >= 4) {
     199                    break;
     200                }
     201            }
     202        }
     203       
     204        if ($naibabiji_b2b_filtered_products) :
    185205        ?>
    186206            <section class="naibabiji-b2b-related-products">
    187207                <h2><?php echo esc_html__('Related Products', 'naibabiji-b2b-product-showcase'); ?></h2>
    188208                <div class="naibabiji-b2b-products-grid naibabiji-b2b-columns-4">
    189                     <?php foreach ($naibabiji_b2b_related_products as $naibabiji_b2b_related_product) : ?>
     209                    <?php foreach ($naibabiji_b2b_filtered_products as $naibabiji_b2b_related_product) : ?>
    190210                        <?php
    191211                        $post = $naibabiji_b2b_related_product;
Note: See TracChangeset for help on using the changeset viewer.