Skip to content
This repository was archived by the owner on Mar 17, 2022. It is now read-only.

Commit c7eb1f7

Browse files
committed
Fix #317
1 parent e3a8db6 commit c7eb1f7

File tree

2 files changed

+40
-17
lines changed

2 files changed

+40
-17
lines changed

src/Hyyan/WPI/Product/Variable.php

+22-11
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __construct()
3030
// Handle variations duplication
3131
add_action('save_post', array($this, 'duplicateVariations'), 10, 3);
3232
add_action('save_post', array($this, 'syncDefaultAttributes'), 10, 3);
33-
33+
3434
// Remove variations
3535
add_action('wp_ajax_woocommerce_remove_variations', array($this, 'removeVariations'), 9);
3636

@@ -75,7 +75,7 @@ public function duplicateVariations($ID, \WP_Post $post, $update)
7575
if ($product->get_parent_id()) {
7676
$product = wc_get_product($product->get_parent_id());
7777
}
78-
78+
7979
$from = null;
8080

8181
if (pll_get_post_language($product->get_id()) == pll_default_language()) {
@@ -87,11 +87,13 @@ public function duplicateVariations($ID, \WP_Post $post, $update)
8787
* created for brand new products which are not saved yet by user
8888
*/
8989
$from = Utilities::getProductTranslationByID(
90-
esc_attr($_GET['from_post']), pll_default_language()
90+
esc_attr($_GET['from_post']),
91+
pll_default_language()
9192
);
9293
} else {
9394
$from = Utilities::getProductTranslationByObject(
94-
$product, pll_default_language()
95+
$product,
96+
pll_default_language()
9597
);
9698
}
9799
}
@@ -104,12 +106,13 @@ public function duplicateVariations($ID, \WP_Post $post, $update)
104106
foreach ($langs as $lang) {
105107
remove_action('save_post', array($this, __FUNCTION__), 10);
106108
$variation = new Variation(
107-
$from, Utilities::getProductTranslationByObject($product, $lang)
109+
$from,
110+
Utilities::getProductTranslationByObject($product, $lang)
108111
);
109112
$variation->duplicate();
110113
add_action('save_post', array($this, __FUNCTION__), 10, 3);
111114
}
112-
115+
113116
/*
114117
remove_action('save_post', array($this, __FUNCTION__), 10);
115118
$translations = Utilities::getProductTranslationsArrayByObject($from, true);
@@ -121,7 +124,7 @@ public function duplicateVariations($ID, \WP_Post $post, $update)
121124
*
122125
*/
123126
}
124-
127+
125128
/**
126129
* Prevents plugins (like Polylang) from overwriting default attribute meta sync.
127130
* TODO: split and correct: this function is now covering multiple concepts, not just skipping default attributes
@@ -169,7 +172,7 @@ public function skipDefaultAttributesMeta($check, $object_id, $meta_key, $meta_v
169172
if ($term && pll_is_translated_taxonomy($term->taxonomy)) {
170173
if ($translated_term_id = pll_get_term($term->term_id, $lang)) {
171174
$translated_term = get_term_by('id', $translated_term_id, $term->taxonomy);
172-
175+
173176
// If meta is taxonomy managed by Polylang and is in the
174177
// correct language continue, otherwise return false to
175178
// stop execution
@@ -335,7 +338,10 @@ public function handleVariableLimitation()
335338
.' title : "%s" ,'
336339
.' content : "%s" ,'
337340
.' defaultLang : "%s"'
338-
.'};', __('Wrong Language For Variable Product', 'woo-poly-integration'), __("Variable product must be created in the default language first or things will get messy. <br> <a href='https://github.com/hyyan/woo-poly-integration/tree/master#what-you-need-to-know-about-this-plugin' target='_blank'>Read more , to know why</a>", 'woo-poly-integration'), pll_default_language()
341+
.'};',
342+
__('Wrong Language For Variable Product', 'woo-poly-integration'),
343+
__("Variable product must be created in the default language first or things will get messy. <br> <a href='https://github.com/hyyan/woo-poly-integration/tree/master#what-you-need-to-know-about-this-plugin' target='_blank'>Read more , to know why</a>", 'woo-poly-integration'),
344+
pll_default_language()
339345
);
340346

341347
Utilities::jsScriptWrapper($jsID, $code, false);
@@ -347,7 +353,11 @@ public function handleVariableLimitation()
347353
wp_enqueue_script('jquery-effects-core');
348354
wp_enqueue_script('jquery-ui-dialog');
349355
wp_enqueue_script(
350-
'woo-poly-variables', plugins_url('public/js/Variables' . $suffix . '.js', Hyyan_WPI_DIR), array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'), \Hyyan\WPI\Plugin::getVersion(), true
356+
'woo-poly-variables',
357+
plugins_url('public/js/Variables' . $suffix . '.js', Hyyan_WPI_DIR),
358+
array('jquery', 'jquery-ui-core', 'jquery-ui-dialog'),
359+
\Hyyan\WPI\Plugin::getVersion(),
360+
true
351361
);
352362
}, 100);
353363
}
@@ -379,7 +389,8 @@ public function shouldDisableLangSwitcher()
379389
.'});'
380390
.' $("#options-lang").prepend('
381391
.' "<p class=\'update-nag\'>%s</p>"'
382-
.');', __('You can not change the default language ,Becuase you are using variable products', 'woo-poly-integration')
392+
.');',
393+
__('You can not change the default language because you are using variable products', 'woo-poly-integration')
383394
);
384395
Utilities::jsScriptWrapper($jsID, $code);
385396
}, 100);

src/Hyyan/WPI/Taxonomies/Attributes.php

+18-6
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ public function __construct()
2626
{
2727
/* Manage attributes label translation */
2828
add_action(
29-
'init', array($this, 'manageAttrLablesTranslation'), 11, 2
29+
'init',
30+
array($this, 'manageAttrLablesTranslation'),
31+
11,
32+
2
3033
);
3134
add_filter(
32-
'woocommerce_attribute_label', array($this, 'translateAttrLable')
35+
'woocommerce_attribute_label',
36+
array($this, 'translateAttrLable')
3337
);
3438
add_action(
35-
'admin_print_scripts', array($this, 'addAttrsTranslateLinks'), 100
39+
'admin_print_scripts',
40+
array($this, 'addAttrsTranslateLinks'),
41+
100
3642
);
3743
}
3844

@@ -56,7 +62,9 @@ public function manageAttrLablesTranslation()
5662
$section = __('Woocommerce Attributes', 'woo-poly-integration');
5763
foreach ($attrs as $attr) {
5864
pll_register_string(
59-
$attr->attribute_label, $attr->attribute_label, $section
65+
$attr->attribute_label,
66+
$attr->attribute_label,
67+
$section
6068
);
6169
}
6270
}
@@ -105,7 +113,9 @@ public function addAttrsTranslateLinks()
105113
$buttonID = 'attrs-label-translation-button';
106114
$buttonCode = sprintf(
107115
'$("<a href=\'%s\' class=\'button button-primary button-large\'>%s</a><br><br>")'
108-
.' .insertBefore(".attributes-table");', $stringTranslationURL, __('Translate Attributes Lables', 'woo-poly-integration')
116+
.' .insertBefore(".attributes-table");',
117+
$stringTranslationURL,
118+
__('Translate Attributes Labels', 'woo-poly-integration')
109119
);
110120

111121
/* Add attribute translate search link */
@@ -121,7 +131,9 @@ public function addAttrsTranslateLinks()
121131
.' + "<a href=\'"+attrTranslateUrl+"\'>%s</a>"'
122132
.' + "</span>";'
123133
.' $this.append(attrTranslateHref);'
124-
."\n});\n", $stringTranslationURL, __('Translate', 'woo-poly-integration')
134+
."\n});\n",
135+
$stringTranslationURL,
136+
__('Translate', 'woo-poly-integration')
125137
);
126138

127139
/* Output code */

0 commit comments

Comments
 (0)