Changeset 3400152
- Timestamp:
- 11/21/2025 03:20:06 AM (3 weeks ago)
- Location:
- naibabiji-b2b-product-showcase
- Files:
-
- 38 added
- 11 edited
-
readme-zh_CN.txt (modified) (2 diffs)
-
readme.txt (modified) (2 diffs)
-
tags/1.0.12 (added)
-
tags/1.0.12/assets (added)
-
tags/1.0.12/assets/css (added)
-
tags/1.0.12/assets/css/admin.css (added)
-
tags/1.0.12/assets/css/frontend.css (added)
-
tags/1.0.12/assets/js (added)
-
tags/1.0.12/assets/js/admin.js (added)
-
tags/1.0.12/assets/js/frontend.js (added)
-
tags/1.0.12/composer.json (added)
-
tags/1.0.12/includes (added)
-
tags/1.0.12/includes/class-admin-settings.php (added)
-
tags/1.0.12/includes/class-ajax-handlers.php (added)
-
tags/1.0.12/includes/class-frontend-display.php (added)
-
tags/1.0.12/includes/class-hooks.php (added)
-
tags/1.0.12/includes/class-meta-fields.php (added)
-
tags/1.0.12/includes/class-security.php (added)
-
tags/1.0.12/includes/class-shortcodes.php (added)
-
tags/1.0.12/includes/class-taxonomy-fields.php (added)
-
tags/1.0.12/includes/class-template-loader.php (added)
-
tags/1.0.12/includes/class-upgrader.php (added)
-
tags/1.0.12/includes/post-types.php (added)
-
tags/1.0.12/languages (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-en_US.l10n.php (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-en_US.mo (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-en_US.po (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-zh_CN.l10n.php (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-zh_CN.mo (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase-zh_CN.po (added)
-
tags/1.0.12/languages/naibabiji-b2b-product-showcase.pot (added)
-
tags/1.0.12/naibabiji-b2b-product-showcase.php (added)
-
tags/1.0.12/readme-zh_CN.txt (added)
-
tags/1.0.12/readme.txt (added)
-
tags/1.0.12/templates (added)
-
tags/1.0.12/templates/archive-naibb2pr_products.php (added)
-
tags/1.0.12/templates/content-product-card.php (added)
-
tags/1.0.12/templates/single-naibb2pr_products.php (added)
-
tags/1.0.12/templates/taxonomy-naibb2pr_product_category.php (added)
-
tags/1.0.12/templates/taxonomy-naibb2pr_product_tag.php (added)
-
trunk/assets/css/frontend.css (modified) (8 diffs)
-
trunk/includes/class-admin-settings.php (modified) (1 diff)
-
trunk/includes/class-frontend-display.php (modified) (3 diffs)
-
trunk/includes/class-shortcodes.php (modified) (4 diffs)
-
trunk/naibabiji-b2b-product-showcase.php (modified) (4 diffs)
-
trunk/readme-zh_CN.txt (modified) (2 diffs)
-
trunk/readme.txt (modified) (2 diffs)
-
trunk/templates/content-product-card.php (modified) (5 diffs)
-
trunk/templates/single-naibb2pr_products.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
naibabiji-b2b-product-showcase/readme-zh_CN.txt
r3392923 r3400152 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 97 Stable tag: 1.0.12 8 8 License: GPL v2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 80 80 详细参数请在设置页面查看使用说明。 81 81 82 = 侧边栏小工具支持吗? = 83 84 完全支持!插件提供专用的侧边栏小工具,支持以下功能: 85 86 **功能特点:** 87 * **智能样式加载** - 自动检测侧边栏中的短代码,只在需要时加载CSS样式 88 * **灵活配置** - 支持显示产品数量、列数、分类筛选等参数设置 89 * **响应式设计** - 在移动设备上自动调整为单列显示 90 * **主题兼容** - 与主流WordPress主题完美兼容 91 92 **使用步骤:** 93 1. 进入WordPress后台 `外观 → 小工具` 94 2. 找到"内巴比基B2B产品展示"小工具 95 3. 拖拽到目标侧边栏区域 96 4. 配置显示参数(产品数量、列数、是否显示分类等) 97 5. 保存设置 98 99 **推荐配置:** 100 * 侧边栏显示:`[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]` 101 * 这种配置适合侧边栏空间,显示3个产品,单列布局,不显示分类和摘要 102 103 = 为什么侧边栏中的产品样式不生效? = 104 105 v1.0.12版本已修复此问题。如果仍遇到样式问题,请尝试: 106 107 1. **清除缓存** - 如果使用缓存插件,请清除所有缓存 108 2. **刷新页面** - 使用Ctrl+F5强制刷新浏览器 109 3. **检查小工具配置** - 确保小工具已正确保存 110 4. **主题兼容性** - 某些主题可能需要额外的CSS调整 111 112 如果问题依然存在,请联系技术支持并提供主题名称以便进一步排查。 113 82 114 == 更新日志 == 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 * 改进翻译和更新本地化文件 83 129 84 130 = 1.0.9 = -
naibabiji-b2b-product-showcase/readme.txt
r3392923 r3400152 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.0. 97 Stable tag: 1.0.12 8 8 License: GPL v2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 80 80 For detailed parameters, please check the usage instructions on the settings page. 81 81 82 = Does the plugin support sidebar widgets? = 83 84 Yes! 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:** 93 1. Go to WordPress admin `Appearance → Widgets` 94 2. Find the "Naibabiji B2B Product Showcase" widget 95 3. Drag to the target sidebar area 96 4. Configure display parameters (product count, columns, show categories, etc.) 97 5. 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 105 This issue has been fixed in v1.0.12. If you still encounter style problems, please try: 106 107 1. **Clear Cache** - If using a cache plugin, clear all caches 108 2. **Refresh Page** - Use Ctrl+F5 to force refresh the browser 109 3. **Check Widget Configuration** - Ensure the widget is properly saved 110 4. **Theme Compatibility** - Some themes may require additional CSS adjustments 111 112 If the problem persists, please contact technical support and provide the theme name for further troubleshooting. 113 82 114 == 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 83 129 84 130 = 1.0.9 = -
naibabiji-b2b-product-showcase/trunk/assets/css/frontend.css
r3350010 r3400152 25 25 26 26 .naibabiji-b2b-taxonomy-title { 27 font-size: 32px;27 font-size: 20px; 28 28 color: #333333; 29 29 margin-bottom: 15px; … … 187 187 flex-direction: column; 188 188 height: 100%; 189 padding: 20px; 189 padding: 16px; 190 box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); 190 191 } 191 192 192 193 .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; 195 197 } 196 198 … … 198 200 position: relative; 199 201 overflow: hidden; 202 margin: -16px -16px 12px -16px; 203 border-radius: 8px 8px 0 0; 200 204 } 201 205 … … 204 208 height: auto; 205 209 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 { 211 219 display: flex; 212 220 flex-direction: column; 213 221 flex-grow: 1; 214 justify-content: flex-start; 215 } 216 222 padding: 20px; 223 text-align: center; 224 } 225 226 /* H6标题样式 - 更适合侧边栏 */ 217 227 .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; 221 237 } 222 238 223 239 .naibabiji-b2b-product-title a { 224 color: #333333;240 color: inherit; 225 241 text-decoration: none; 242 transition: color 0.3s ease; 226 243 } 227 244 … … 232 249 .naibabiji-b2b-product-excerpt { 233 250 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; 237 258 } 238 259 239 260 .naibabiji-b2b-product-meta { 240 font-size: 1 3px;261 font-size: 12px; 241 262 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; 244 276 } 245 277 … … 248 280 text-decoration: none; 249 281 transition: color 0.3s ease; 282 font-weight: 500; 250 283 } 251 284 … … 256 289 257 290 .naibabiji-b2b-product-actions { 291 margin-top: auto; 292 } 293 294 .naibabiji-b2b-button-group { 258 295 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; 260 314 } 261 315 262 316 .naibabiji-b2b-view-details-button { 263 display: inline-block; 264 padding: 8px 20px; 265 background-color: #0066cc; 317 background: linear-gradient(135deg, #0066cc, #0052a3); 266 318 color: #ffffff; 267 text-decoration: none;268 border-radius: 4px;269 font-size: 14px;270 transition: background-color 0.3s ease;271 319 } 272 320 273 321 .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); 275 329 color: #ffffff; 276 330 } 277 331 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 */ 279 505 .navigation.pagination { 280 506 margin-top: 40px; … … 555 781 556 782 .naibabiji-b2b-product-title { 557 font-size: 32px;783 font-size: 20px; 558 784 font-weight: 600; 559 785 color: #333; -
naibabiji-b2b-product-showcase/trunk/includes/class-admin-settings.php
r3393419 r3400152 224 224 <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> 225 225 <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> 231 280 </li> 232 281 <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 309 309 'category' => '', 310 310 'show_excerpt' => true, 311 'show_category' => true, 312 'show_view_details' => true, 313 'show_inquiry' => true, 311 314 'orderby' => 'date', 312 315 'order' => 'DESC', … … 324 327 325 328 if (!empty($args['category'])) { 329 // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query -- Necessary for category filtering 326 330 $query_args['tax_query'] = array( 327 331 array( … … 342 346 343 347 // 通过模板渲染产品卡片,避免重复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 345 354 while ($products->have_posts()) { 346 355 $products->the_post(); -
naibabiji-b2b-product-showcase/trunk/includes/class-shortcodes.php
r3392914 r3400152 44 44 * [naibabiji_b2b_products limit="6" columns="2"] 45 45 * [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"] 46 47 */ 47 48 public function products_shortcode($atts, $content = null) { … … 51 52 'category' => '', 52 53 'show_excerpt' => 'true', 54 'show_category' => 'true', 55 'show_view_details' => 'true', 56 'show_inquiry' => 'true', 53 57 'orderby' => 'date', 54 58 'order' => 'DESC', … … 57 61 // 转换字符串为布尔值 58 62 $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); 59 66 60 67 // 验证和清理参数 … … 68 75 'category' => sanitize_text_field($atts['category']), 69 76 'show_excerpt' => $show_excerpt, 77 'show_category' => $show_category, 78 'show_view_details' => $show_view_details, 79 'show_inquiry' => $show_inquiry, 70 80 'orderby' => sanitize_text_field($atts['orderby']), 71 81 'order' => sanitize_text_field($atts['order']), -
naibabiji-b2b-product-showcase/trunk/naibabiji-b2b-product-showcase.php
r3393729 r3400152 4 4 * Plugin URI: https://blog.naibabiji.com 5 5 * Description: Lightweight B2B product showcase plugin designed for corporate websites, without shopping cart functionality, focusing on product display and inquiry. 6 * Version: 1.0.1 16 * Version: 1.0.12 7 7 * Author: Naibabiji 8 8 * Text Domain: naibabiji-b2b-product-showcase … … 25 25 * 定义插件常量 26 26 */ 27 define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_VERSION', '1.0.1 1' );27 define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_VERSION', '1.0.12' ); 28 28 define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_AUTHOR', 'Naibabiji' ); 29 29 define( 'NAIBABIJI_B2B_PRODUCT_SHOWCASE_URI', 'https://blog.naibabiji.com' ); … … 295 295 } 296 296 297 // 检查侧边栏小工具中是否包含短代码 298 if ( $this->is_shortcode_in_widgets( array( 'naibabiji_b2b_products', 'naibabiji_b2b_product_categories' ) ) ) { 299 return true; 300 } 301 297 302 /** 298 303 * Filters whether the frontend assets should be enqueued. … … 302 307 */ 303 308 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; 304 387 } 305 388 -
naibabiji-b2b-product-showcase/trunk/readme-zh_CN.txt
r3393729 r3400152 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.0.1 17 Stable tag: 1.0.12 8 8 License: GPL v2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 80 80 详细参数请在设置页面查看使用说明。 81 81 82 = 侧边栏小工具支持吗? = 83 84 完全支持!插件提供专用的侧边栏小工具,支持以下功能: 85 86 **功能特点:** 87 * **智能样式加载** - 自动检测侧边栏中的短代码,只在需要时加载CSS样式 88 * **灵活配置** - 支持显示产品数量、列数、分类筛选等参数设置 89 * **响应式设计** - 在移动设备上自动调整为单列显示 90 * **主题兼容** - 与主流WordPress主题完美兼容 91 92 **使用步骤:** 93 1. 进入WordPress后台 `外观 → 小工具` 94 2. 找到"内巴比基B2B产品展示"小工具 95 3. 拖拽到目标侧边栏区域 96 4. 配置显示参数(产品数量、列数、是否显示分类等) 97 5. 保存设置 98 99 **推荐配置:** 100 * 侧边栏显示:`[naibabiji_b2b_products limit="3" columns="1" show_category="false" show_excerpt="false"]` 101 * 这种配置适合侧边栏空间,显示3个产品,单列布局,不显示分类和摘要 102 103 = 为什么侧边栏中的产品样式不生效? = 104 105 v1.0.12版本已修复此问题。如果仍遇到样式问题,请尝试: 106 107 1. **清除缓存** - 如果使用缓存插件,请清除所有缓存 108 2. **刷新页面** - 使用Ctrl+F5强制刷新浏览器 109 3. **检查小工具配置** - 确保小工具已正确保存 110 4. **主题兼容性** - 某些主题可能需要额外的CSS调整 111 112 如果问题依然存在,请联系技术支持并提供主题名称以便进一步排查。 113 82 114 == 更新日志 == 115 116 = 1.0.12 = 117 * 优化CSS加载逻辑,新增侧边栏小工具短代码检测功能 118 * 修复侧边栏小工具中产品展示CSS样式不生效的问题 119 * 智能检测页面中的短代码内容,只在需要时加载CSS资源 120 * 完善响应式设计,优化产品卡片在小屏幕设备上的显示效果 83 121 84 122 = 1.0.11 = -
naibabiji-b2b-product-showcase/trunk/readme.txt
r3393729 r3400152 5 5 Tested up to: 6.8 6 6 Requires PHP: 7.4 7 Stable tag: 1.0.1 17 Stable tag: 1.0.12 8 8 License: GPL v2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 80 80 For detailed parameters, please check the usage instructions on the settings page. 81 81 82 = Does the plugin support sidebar widgets? = 83 84 Yes! 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:** 93 1. Go to WordPress admin `Appearance → Widgets` 94 2. Find the "Naibabiji B2B Product Showcase" widget 95 3. Drag to the target sidebar area 96 4. Configure display parameters (product count, columns, show categories, etc.) 97 5. 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 105 This issue has been fixed in v1.0.12. If you still encounter style problems, please try: 106 107 1. **Clear Cache** - If using a cache plugin, clear all caches 108 2. **Refresh Page** - Use Ctrl+F5 to force refresh the browser 109 3. **Check Widget Configuration** - Ensure the widget is properly saved 110 4. **Theme Compatibility** - Some themes may require additional CSS adjustments 111 112 If the problem persists, please contact technical support and provide the theme name for further troubleshooting. 113 82 114 == 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 83 121 84 122 = 1.0.11 = -
naibabiji-b2b-product-showcase/trunk/templates/content-product-card.php
r3393729 r3400152 11 11 12 12 $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; 14 19 ?> 15 20 … … 24 29 25 30 <div class="naibabiji-b2b-product-info"> 26 <h 2class="naibabiji-b2b-product-title">31 <h6 class="naibabiji-b2b-product-title"> 27 32 <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> 28 </h 2>33 </h6> 29 34 30 <?php if ($ show_excerpt && has_excerpt()) : ?>35 <?php if ($naibabiji_b2b_show_excerpt && has_excerpt()) : ?> 31 36 <div class="naibabiji-b2b-product-excerpt"> 32 37 <?php … … 38 43 <?php endif; ?> 39 44 45 <?php if ($naibabiji_b2b_show_category) : ?> 40 46 <?php 41 47 // Display product categories … … 44 50 $naibabiji_b2b_primary_category = $naibabiji_b2b_product_categories[0]; 45 51 $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)) : 47 53 ?> 48 54 <div class="naibabiji-b2b-product-meta"> … … 58 64 endif; 59 65 ?> 66 <?php endif; ?> 60 67 61 68 <div class="naibabiji-b2b-product-actions"> 62 69 <div class="naibabiji-b2b-button-group"> 70 <?php if ($naibabiji_b2b_show_view_details) : ?> 63 71 <a href="<?php the_permalink(); ?>" class="naibabiji-b2b-view-details-button"> 64 72 <span class="naibabiji-b2b-button-icon">→</span><?php echo esc_html__('View Details', 'naibabiji-b2b-product-showcase'); ?> 65 73 </a> 74 <?php endif; ?> 66 75 67 76 <?php 68 77 // Display inquiry button (if enabled) 69 78 $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) : 71 80 $naibabiji_b2b_inquiry_text = get_post_meta($naibabiji_b2b_product_id, '_naibabiji_b2b_product_inquiry_text', true); 72 81 if (empty($naibabiji_b2b_inquiry_text)) { -
naibabiji-b2b-product-showcase/trunk/templates/single-naibb2pr_products.php
r3393729 r3400152 169 169 <?php 170 170 // 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', 173 175 '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( 176 183 array( 177 184 'taxonomy' => 'naibb2pr_product_category', 178 185 'field' => 'term_id', 179 'terms' => wp_get_post_terms(get_the_ID(), 'naibb2pr_product_category', array('fields' => 'ids')),186 'terms' => $naibabiji_b2b_category_ids, 180 187 ), 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) : 185 205 ?> 186 206 <section class="naibabiji-b2b-related-products"> 187 207 <h2><?php echo esc_html__('Related Products', 'naibabiji-b2b-product-showcase'); ?></h2> 188 208 <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) : ?> 190 210 <?php 191 211 $post = $naibabiji_b2b_related_product;
Note: See TracChangeset
for help on using the changeset viewer.