' . esc_html($label) . '');
return $links;
}
/**
* Until it is connected, one line on the dashboard and the plugins page leads to the button. Its X hides it
* for good for that admin (WordPress review 26.10.2026, guideline 11: notices limited and dismissible).
*/
public static function notice() {
if (Adly_Shop_Settings::connected() || Adly_Shop_Settings::keys_connected() || !current_user_can('manage_woocommerce')) {
return;
}
if (get_user_meta(get_current_user_id(), self::DISMISSED, true)) {
return;
}
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
if (!$screen || !in_array($screen->id, array('dashboard', 'plugins'), true)) {
return;
}
printf(
'
',
esc_html(adly_shop_t('ADLY Shop מותקן. נשאר רק לחבר את החנות.', 'ADLY Shop is installed. One step left: connect your store.')),
esc_url(Adly_Shop_Connect::page_url()),
esc_html(adly_shop_t('לחיבור', 'Connect'))
);
// WordPress adds the X; a click on it tells the server, so the notice stays closed after a reload
wp_print_inline_script_tag(sprintf(
"document.addEventListener('click',function(e){if(!e.target.closest||!e.target.closest('#adly-shop-connect-notice .notice-dismiss')){return;}var d=new FormData();d.append('action','adly_shop_dismiss_notice');d.append('_ajax_nonce',%s);fetch(%s,{method:'POST',body:d,credentials:'same-origin'});});",
wp_json_encode(wp_create_nonce('adly_shop_dismiss_notice')),
wp_json_encode(admin_url('admin-ajax.php'))
));
}
public static function dismiss_notice() {
check_ajax_referer('adly_shop_dismiss_notice');
if (!current_user_can('manage_woocommerce')) {
wp_send_json_error(null, 403);
}
update_user_meta(get_current_user_id(), self::DISMISSED, 1);
wp_send_json_success();
}
private static function button($action, $label, $class = 'button') {
printf('', esc_attr($class), esc_html($label));
}
// The notices only read which message to show after our own redirects; nothing is changed by them.
// phpcs:disable WordPress.Security.NonceVerification.Recommended
private static function messages() {
$errors = array(
'https' => adly_shop_t('האתר צריך לרוץ ב-https כדי להתחבר.', 'Your site must run on https to connect.'),
'state' => adly_shop_t('החיבור לא הושלם (פג תוקף או נפתח מחשבון אחר). לחצו שוב "חיבור ל-ADLY".', 'The connection did not finish (it expired or came back to another account). Press "Connect to ADLY" again.'),
'expired' => adly_shop_t('קוד החיבור פג. לחצו שוב "חיבור ל-ADLY".', 'The connection code expired. Press "Connect to ADLY" again.'),
'exchange' => adly_shop_t('לא הצלחנו לקבל את המפתחות מ-ADLY. נסו שוב בעוד דקה.', 'We could not get the keys from ADLY. Try again in a minute.'),
);
if (!empty($_GET['adly_error'])) {
$k = sanitize_key(wp_unslash($_GET['adly_error']));
$s = Adly_Shop_Settings::get();
$detail = !empty($s['last_error']) && $k === 'exchange' ? ' (' . $s['last_error'] . ')' : '';
printf('', esc_html((isset($errors[$k]) ? $errors[$k] : $errors['exchange']) . $detail));
}
if (!empty($_GET['adly_disconnected'])) {
printf('', esc_html(adly_shop_t('החנות נותקה מ-ADLY.', 'Your store was disconnected from ADLY.')));
}
if (isset($_GET['adly_products'])) {
$ok = sanitize_key(wp_unslash($_GET['adly_products'])) === '1';
printf('', esc_attr($ok ? 'success' : 'error'),
esc_html($ok ? adly_shop_t('המוצרים נשלחו.', 'Products sent.') : adly_shop_t('שליחת המוצרים נכשלה. נסו שוב.', 'Sending the products failed. Try again.')));
}
}
// phpcs:enable WordPress.Security.NonceVerification.Recommended
public static function page() {
if (!current_user_can('manage_woocommerce')) {
return;
}
$s = Adly_Shop_Settings::get();
echo '';
echo '
ADLY Shop
';
self::messages();
// Already connected from ADLY's site with WooCommerce keys: nothing to connect, and a second connection
// would turn the store into another kind of ADLY store, so there is no button here
if (Adly_Shop_Settings::keys_connected()) {
echo '
';
printf('
%s
', esc_html(adly_shop_t('החנות כבר מחוברת ל-ADLY', 'Your store is already connected to ADLY')));
printf('
%s
', esc_html(adly_shop_t(
'החנות מחוברת ל-ADLY דרך מפתחות WooCommerce, וההזמנות והקודים של היוצרות כבר עובדים. התוסף מוסיף דבר אחד: קונה שמגיע מהקישור של יוצרת מקבל את הקוד שלה בעגלה לבד.',
'Your store is connected to ADLY with WooCommerce keys, and orders and creators\' codes already work. The plugin adds one thing: a buyer who arrives through a creator\'s link gets her code on the cart by itself.'
)));
printf('
%s
', esc_html(adly_shop_t('אין צורך ללחוץ על שום דבר נוסף.', 'There is nothing else to do.')));
echo '
';
return;
}
if (!Adly_Shop_Settings::connected()) {
echo '';
printf('
%s
', esc_html(adly_shop_t('יוצרות תוכן מוכרות את המוצרים שלכם', 'Creators sell your products')));
printf('
%s
', esc_html(adly_shop_t(
'כל יוצרת מקבלת קוד הנחה אישי. כשקונים איתו, ההזמנה נרשמת ב-ADLY והעמלה מחושבת לבד. התוסף רק שולח ל-ADLY את ההזמנות ובודק את הקודים בקופה. ADLY לא נכנסת לאתר שלכם ולא מקבלת סיסמה.',
'Each creator gets a personal discount code. When a buyer uses it, ADLY records the order and works out the commission. The plugin only reports your orders to ADLY and checks the codes at checkout. ADLY never logs in to your site and gets no password.'
)));
printf('
%s
', esc_html(adly_shop_t(
'לחיצה על הכפתור פותחת את ADLY. מאשרים שם (בחשבון המותג) וחוזרים לכאן מחוברים.',
'The button opens ADLY. Approve there (in your brand account) and you come back here connected.'
)));
self::button('adly_shop_connect', adly_shop_t('חיבור ל-ADLY', 'Connect to ADLY'), 'button button-primary button-hero');
echo '
';
return;
}
$test = isset($s['test']) && is_array($s['test']) ? $s['test'] : array();
$steps = isset($test['steps']) ? $test['steps'] : array();
$names = array(
'validate' => adly_shop_t('בדיקת קוד בקופה', 'Code check at checkout'),
'order' => adly_shop_t('דיווח הזמנה', 'Order report'),
'beacon' => adly_shop_t('עמוד התודה', 'Thank-you page'),
'refund' => adly_shop_t('דיווח החזר', 'Refund report'),
);
echo '';
printf('
%s
', esc_html(adly_shop_t('החנות מחוברת ל-ADLY', 'Your store is connected to ADLY')));
echo '
';
$row = function ($k, $v) {
printf('| %s | %s |
', esc_html($k), wp_kses($v, array('span' => array('style' => array()))));
};
$row(adly_shop_t('חנות', 'Store'), esc_html(!empty($s['store_name']) ? $s['store_name'] : home_url()));
if (!empty($s['brand_name'])) {
$row(adly_shop_t('חשבון ב-ADLY', 'ADLY account'), esc_html($s['brand_name']));
}
$row(adly_shop_t('מטבע', 'Currency'), esc_html(!empty($s['currency']) ? $s['currency'] : get_woocommerce_currency()));
foreach ($names as $k => $label) {
$ok = !empty($steps[$k]);
$row($label, $ok ? '✓ ' . esc_html(adly_shop_t('עבר', 'Passed')) . ''
: '✗ ' . esc_html(adly_shop_t('לא עבר', 'Not yet')) . '');
}
$row(adly_shop_t('אישור ADLY', 'ADLY approval'), !empty($s['approved'])
? '✓ ' . esc_html(adly_shop_t('מאושרת', 'Approved')) . ''
: esc_html(adly_shop_t('ממתינה לבדיקה שעוברת', 'Waiting for a passing test')));
$row(adly_shop_t('מוצרים ב-ADLY', 'Products at ADLY'), esc_html(isset($s['products_count']) ? (string) (int) $s['products_count'] : '0')
. (!empty($s['products_at']) ? ' · ' . esc_html(wp_date(get_option('date_format') . ' H:i', (int) $s['products_at'])) : ''));
echo '
';
if (!empty($test['error'])) {
printf('
%s %s
', esc_html(adly_shop_t('מה ADLY ענתה:', 'What ADLY said:')), esc_html($test['error']));
}
if (!empty($s['approved'])) {
printf('
%s %s
',
esc_html(adly_shop_t('השלב הבא ב-ADLY: לקבוע את העמלה וההנחה לקונים, ויוצרות יוכלו להצטרף.', 'Next, at ADLY: set the commission and the buyers\' discount, and creators can join.')),
esc_html(adly_shop_t('להגדרת התוכנית', 'Set up the program')));
}
echo '
';
self::button('adly_shop_retest', adly_shop_t('בדיקה חוזרת', 'Check again'), 'button button-primary');
self::button('adly_shop_products', adly_shop_t('שליחת המוצרים מחדש', 'Send products again'));
echo '
';
echo '
';
printf('
%s
', esc_html(adly_shop_t(
'ניתוק עוצר את הקודים של היוצרות בחנות. הזמנות שכבר נרשמו נשארות ב-ADLY.',
'Disconnecting stops the creators\' codes in your store. Orders already recorded stay at ADLY.'
)));
self::button('adly_shop_disconnect', adly_shop_t('ניתוק מ-ADLY', 'Disconnect from ADLY'), 'button button-link-delete');
echo '
';
}
}