155 lines
6.8 KiB
PHP
155 lines
6.8 KiB
PHP
<?php
|
|
/**
|
|
* دیالوگ راهنمای ثبت کالا در شبکه تأمین (قالب hesabix2)
|
|
*
|
|
* @package Hesabix2
|
|
*/
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* آیا در زمینهٔ کاتالوگ شبکه تأمین هستیم؟
|
|
*/
|
|
function hesabix2_shabake_tamin_supplier_dialog_context() {
|
|
if ( ! function_exists( 'hesabix2_shabake_tamin_active' ) || ! hesabix2_shabake_tamin_active() ) {
|
|
return false;
|
|
}
|
|
if ( ! class_exists( 'Shabake_Tamin_Public_Catalog', false ) ) {
|
|
return false;
|
|
}
|
|
return Shabake_Tamin_Public_Catalog::is_request() || Shabake_Tamin_Public_Catalog::is_product_request();
|
|
}
|
|
|
|
/**
|
|
* آدرس ورود به آرک برای CTA دیالوگ.
|
|
*/
|
|
function hesabix2_shabake_tamin_supplier_arc_url() {
|
|
$url = function_exists( 'hesabix2_fp_arc_url' ) ? hesabix2_fp_arc_url() : 'https://arc.hesabix.ir';
|
|
return (string) apply_filters( 'shabake_tamin_hesabix2_supplier_arc_url', $url );
|
|
}
|
|
|
|
/**
|
|
* بارگذاری CSS/JS دیالوگ.
|
|
*/
|
|
function hesabix2_shabake_tamin_supplier_dialog_assets() {
|
|
if ( ! hesabix2_shabake_tamin_supplier_dialog_context() ) {
|
|
return;
|
|
}
|
|
|
|
$theme_dir = get_template_directory();
|
|
$theme_uri = get_template_directory_uri();
|
|
$css = $theme_dir . '/assets/css/shabake-tamin-supplier-dialog.css';
|
|
$js = $theme_dir . '/assets/js/shabake-tamin-supplier-dialog.js';
|
|
|
|
wp_enqueue_style(
|
|
'hesabix2-st-supplier-dialog',
|
|
$theme_uri . '/assets/css/shabake-tamin-supplier-dialog.css',
|
|
array( 'hesabix2-style' ),
|
|
file_exists( $css ) ? (string) filemtime( $css ) : '1.0'
|
|
);
|
|
|
|
wp_enqueue_script(
|
|
'hesabix2-st-supplier-dialog',
|
|
$theme_uri . '/assets/js/shabake-tamin-supplier-dialog.js',
|
|
array(),
|
|
file_exists( $js ) ? (string) filemtime( $js ) : '1.0',
|
|
true
|
|
);
|
|
|
|
wp_localize_script(
|
|
'hesabix2-st-supplier-dialog',
|
|
'hesabixStSupplierDialog',
|
|
array(
|
|
'arcUrl' => hesabix2_shabake_tamin_supplier_arc_url(),
|
|
'i18n' => array(
|
|
'close' => __( 'بستن', 'hesabix2' ),
|
|
),
|
|
)
|
|
);
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'hesabix2_shabake_tamin_supplier_dialog_assets', 35 );
|
|
|
|
/**
|
|
* ویژگیهای دکمهٔ ورود به آرک (یکپارچه با دیالوگ ورود سایت).
|
|
*
|
|
* @return string
|
|
*/
|
|
function hesabix2_shabake_tamin_supplier_arc_link_attrs() {
|
|
if ( function_exists( 'hesabix2_entry_link_attrs' ) && function_exists( 'hesabix2_entry_dialog_enabled' ) && hesabix2_entry_dialog_enabled() ) {
|
|
return hesabix2_entry_link_attrs( 'arc', hesabix2_shabake_tamin_supplier_arc_url() );
|
|
}
|
|
return '';
|
|
}
|
|
|
|
/**
|
|
* HTML دیالوگ در فوتر.
|
|
*/
|
|
function hesabix2_render_shabake_tamin_supplier_dialog() {
|
|
if ( ! hesabix2_shabake_tamin_supplier_dialog_context() ) {
|
|
return;
|
|
}
|
|
|
|
$arc_attrs = hesabix2_shabake_tamin_supplier_arc_link_attrs();
|
|
$arc_href = esc_url( hesabix2_shabake_tamin_supplier_arc_url() );
|
|
?>
|
|
<div id="hx-st-supplier-dialog" class="hx-st-supplier-dialog" aria-hidden="true" role="dialog" aria-modal="true" aria-labelledby="hx-st-supplier-dialog-title">
|
|
<div class="hx-st-supplier-dialog__backdrop" data-hx-st-supplier-close tabindex="-1" aria-hidden="true"></div>
|
|
<div class="hx-st-supplier-dialog__panel" tabindex="-1">
|
|
<button type="button" class="hx-st-supplier-dialog__close" data-hx-st-supplier-close aria-label="<?php esc_attr_e( 'بستن', 'hesabix2' ); ?>">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/></svg>
|
|
</button>
|
|
|
|
<header class="hx-st-supplier-dialog__header">
|
|
<p class="hx-st-supplier-dialog__badge"><?php esc_html_e( 'راهنمای تأمینکنندگان', 'hesabix2' ); ?></p>
|
|
<h2 id="hx-st-supplier-dialog-title" class="hx-st-supplier-dialog__title">
|
|
<?php esc_html_e( 'چگونه کالای خود را در شبکه تأمین منتشر کنم؟', 'hesabix2' ); ?>
|
|
</h2>
|
|
<p class="hx-st-supplier-dialog__lead">
|
|
<?php esc_html_e( 'برای نمایش کالا در این صفحه نیازی به تماس با پشتیبانی نیست؛ همهچیز از داخل نسخهٔ آرک حسابیکس انجام میشود.', 'hesabix2' ); ?>
|
|
</p>
|
|
</header>
|
|
|
|
<ol class="hx-st-supplier-dialog__steps">
|
|
<li>
|
|
<strong><?php esc_html_e( 'ثبتنام در نسخهٔ آرک', 'hesabix2' ); ?></strong>
|
|
<span><?php esc_html_e( 'اگر هنوز حساب ندارید، در آرک (نسخهٔ جدید حسابیکس) ثبتنام رایگان کنید.', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li>
|
|
<strong><?php esc_html_e( 'ایجاد کسبوکار', 'hesabix2' ); ?></strong>
|
|
<span><?php esc_html_e( 'پس از ورود، یک کسبوکار جدید بسازید یا کسبوکار موجود را انتخاب کنید.', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li>
|
|
<strong><?php esc_html_e( 'افزودن یا ویرایش کالا', 'hesabix2' ); ?></strong>
|
|
<span><?php esc_html_e( 'از بخش کالاها، کالای جدید ثبت کنید یا کالای موجود را ویرایش کنید.', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li>
|
|
<strong><?php esc_html_e( 'فعالسازی انتشار در شبکه تأمین', 'hesabix2' ); ?></strong>
|
|
<span><?php esc_html_e( 'در فرم افزودن/ویرایش کالا، سوییچ «انتشار در شبکه تأمین کالا» را روشن کنید تا کالا در این کاتالوگ عمومی نمایش داده شود.', 'hesabix2' ); ?></span>
|
|
</li>
|
|
</ol>
|
|
|
|
<aside class="hx-st-supplier-dialog__note">
|
|
<p>
|
|
<?php esc_html_e( 'اطلاعات تماس (تلفن، موبایل، آدرس و …) از بخش تنظیمات کسبوکار در آرک قابل ویرایش است و همانها برای بازدیدکنندگان شبکه تأمین نمایش داده میشوند.', 'hesabix2' ); ?>
|
|
</p>
|
|
</aside>
|
|
|
|
<footer class="hx-st-supplier-dialog__footer">
|
|
<?php if ( $arc_attrs ) : ?>
|
|
<a href="<?php echo $arc_href; ?>" class="hx-st-supplier-dialog__btn hx-st-supplier-dialog__btn--primary" <?php echo $arc_attrs; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
|
|
<?php esc_html_e( 'ثبتنام / ورود به آرک', 'hesabix2' ); ?>
|
|
</a>
|
|
<?php else : ?>
|
|
<a href="<?php echo $arc_href; ?>" class="hx-st-supplier-dialog__btn hx-st-supplier-dialog__btn--primary" target="_blank" rel="noopener noreferrer">
|
|
<?php esc_html_e( 'ثبتنام / ورود به آرک', 'hesabix2' ); ?>
|
|
</a>
|
|
<?php endif; ?>
|
|
<button type="button" class="hx-st-supplier-dialog__btn hx-st-supplier-dialog__btn--ghost" data-hx-st-supplier-close>
|
|
<?php esc_html_e( 'بستن', 'hesabix2' ); ?>
|
|
</button>
|
|
</footer>
|
|
</div>
|
|
</div>
|
|
<?php
|
|
}
|
|
add_action( 'wp_footer', 'hesabix2_render_shabake_tamin_supplier_dialog', 14 );
|