Changeset 3350324
- Timestamp:
- 08/26/2025 10:44:02 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
naibabiji-b2b-product-showcase/tags/1.0.7/includes/class-meta-fields.php
r3350288 r3350324 350 350 351 351 /** 352 * 添加产品编辑页面的自定义样式 和设置模态框352 * 添加产品编辑页面的自定义样式 353 353 * 354 354 * @since 1.0.0 … … 357 357 global $post_type, $pagenow; 358 358 if ( 'naibb2pr_products' === $post_type && in_array( $pagenow, array( 'post.php', 'post-new.php' ), true ) ) { 359 $default_inquiry_url = get_option( 'naibabiji_b2b_product_default_inquiry_url', '' );360 $default_inquiry_text = get_option( 'naibabiji_b2b_product_inquiry_button_text', esc_html__( 'Get Quote', 'naibabiji-b2b-product-showcase' ) );361 362 359 // 添加内联样式 363 360 wp_add_inline_style( … … 369 366 width: 100%; 370 367 min-height: 80px; 371 }372 373 /* 设置模态框样式 */374 .naibabiji-b2b-settings-modal {375 display: none;376 position: fixed;377 z-index: 100000;378 left: 0;379 top: 0;380 width: 100%;381 height: 100%;382 background-color: rgba(0,0,0,0.5);383 }384 .naibabiji-b2b-settings-modal-content {385 background-color: #fefefe;386 margin: 5% auto;387 padding: 20px;388 border: 1px solid #888;389 width: 80%;390 max-width: 600px;391 border-radius: 5px;392 }393 .naibabiji-b2b-settings-close {394 color: #aaa;395 float: right;396 font-size: 28px;397 font-weight: bold;398 cursor: pointer;399 }400 .naibabiji-b2b-settings-close:hover {401 color: black;402 368 }' 403 369 ); 404 405 $save_success_msg = esc_js( __( 'Settings saved successfully! The page will refresh to show new settings.', 'naibabiji-b2b-product-showcase' ) );406 $save_failed_msg = esc_js( __( 'Save failed:', 'naibabiji-b2b-product-showcase' ) );407 $unknown_error_msg = esc_js( __( 'Unknown error', 'naibabiji-b2b-product-showcase' ) );408 409 // 添加内联脚本410 wp_add_inline_script(411 'naibabiji-b2b-product-showcase-admin-script',412 'function openSettingsModal() {413 document.getElementById("naibabijiB2bSettingsModal").style.display = "block";414 }415 416 function closeSettingsModal() {417 document.getElementById("naibabijiB2bSettingsModal").style.display = "none";418 }419 420 function saveSettings() {421 var form = document.getElementById("naibabijiB2bSettingsForm");422 var formData = new FormData(form);423 formData.append("action", "naibabiji_b2b_save_settings");424 425 fetch(ajaxurl, {426 method: "POST",427 body: formData428 })429 .then(function(response) {430 return response.json();431 })432 .then(function(data) {433 if (data.success) {434 alert("' . $save_success_msg . '");435 location.reload();436 } else {437 alert("' . $save_failed_msg . ' " + (data.data || "' . $unknown_error_msg . '"));438 }439 })440 .catch(function(error) {441 alert("' . $save_failed_msg . ' " + error.message);442 });443 }444 445 // 点击模态框外部关闭446 window.onclick = function(event) {447 var modal = document.getElementById("naibabijiB2bSettingsModal");448 if (event.target == modal) {449 closeSettingsModal();450 }451 }'452 );453 ?>454 <!-- 设置模态框 -->455 <div id="naibabijiB2bSettingsModal" class="naibabiji-b2b-settings-modal">456 <div class="naibabiji-b2b-settings-modal-content">457 <span class="naibabiji-b2b-settings-close" onclick="closeSettingsModal()">×</span>458 <h2><?php esc_html_e( 'B2B Product Showcase - Global Settings', 'naibabiji-b2b-product-showcase' ); ?></h2>459 <form id="naibabijiB2bSettingsForm">460 <table class="form-table">461 <tr>462 <th scope="row">463 <label for="naibabiji_b2b_product_default_inquiry_url"><?php esc_html_e( 'Default Inquiry Page URL:', 'naibabiji-b2b-product-showcase' ); ?></label>464 </th>465 <td>466 <input type="url" id="naibabiji_b2b_product_default_inquiry_url" name="naibabiji_b2b_product_default_inquiry_url"467 value="<?php echo esc_attr( $default_inquiry_url ); ?>" class="regular-text">468 </td>469 </tr>470 <tr>471 <th scope="row">472 <label for="naibabiji_b2b_product_inquiry_button_text"><?php esc_html_e( 'Default Inquiry Button Text:', 'naibabiji-b2b-product-showcase' ); ?></label>473 </th>474 <td>475 <input type="text" id="naibabiji_b2b_product_inquiry_button_text" name="naibabiji_b2b_product_inquiry_button_text"476 value="<?php echo esc_attr( $default_inquiry_text ); ?>" class="regular-text">477 </td>478 </tr>479 </table>480 <p class="submit">481 <button type="button" class="button button-primary" onclick="saveSettings()"><?php esc_html_e( 'Save Settings', 'naibabiji-b2b-product-showcase' ); ?></button>482 </p>483 </form>484 </div>485 </div>486 <?php487 370 } 488 371 }
Note: See TracChangeset
for help on using the changeset viewer.