Skip to content

Commit

Permalink
Merge branch 'release/1.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Jun 13, 2024
2 parents 75035b8 + 9185213 commit 58998bc
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 11 deletions.
67 changes: 64 additions & 3 deletions dokan-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
* Plugin Name: Dokan - WPML Integration
* Plugin URI: https://wedevs.com/
* Description: WPML and Dokan compatible package
* Version: 1.1.2
* Version: 1.1.3
* Author: weDevs
* Author URI: https://wedevs.com/
* Text Domain: dokan-wpml
* WC requires at least: 5.5.0
* WC tested up to: 8.7.0
* WC tested up to: 8.9.3
* Domain Path: /languages/
* License: GPL2
*/
Expand Down Expand Up @@ -157,6 +157,8 @@ public function plugins_loaded() {
add_filter( 'dokan_pro_rma_reason', [ $this, 'get_translated_rma_reason' ] );

add_filter( 'wp', [ $this, 'set_translated_query_var_to_default_query_var' ], 11 );
add_filter( 'dokan_set_store_categories', [ $this, 'set_translated_category' ] );
add_filter( 'dokan_get_store_categories_in_vendor', [ $this, 'get_translated_category' ] );
}

/**
Expand Down Expand Up @@ -637,6 +639,64 @@ public function dokan_get_translated_page_id( $page_id ) {
return wpml_object_id_filter( $page_id, 'page', true, ICL_LANGUAGE_CODE );
}

/**
* Set store categories with default language to store.
*
* @since 1.1.3
*
* @param array $categories Store Categories.
*
* @return array
*/
public function set_translated_category( $categories ) {
if ( ! function_exists( 'wpml_object_id_filter' ) || ! function_exists( 'wpml_get_active_languages' ) ) {
return $categories;
}

$all_categories = [];
$languages = wpml_get_active_languages();

foreach ( $categories as $store_cat_id ) {
foreach ( $languages as $code => $language ) {
$translated_cat_id = wpml_object_id_filter( $store_cat_id, 'store_category', true, $code );
$all_categories[] = $translated_cat_id;
}
}

return array_unique( $all_categories );
}

/**
* Get store categories with current translation to store.
*
* @since 1.1.3
*
* @param WP_Term[] $categories Store Categories.
*
* @return array
*/
public function get_translated_category( $categories ) {
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
return $categories;
}

$category_ids = array_unique(
array_map(
function ( $store_cat ) {
return wpml_object_id_filter( $store_cat->term_id, 'store_category', true, null );
},
$categories
)
);

return array_map(
function ( $category_id ) {
return get_term( $category_id, 'store_category' );
},
$category_ids
);
}

/**
* Set Vendor Subscription product count query on based language.
*
Expand Down Expand Up @@ -686,6 +746,7 @@ public function set_subscription_pack_id_in_base_language( $meta_value, $meta_ke

return $this->get_product_id_in_base_language( absint( $meta_value ) );
}

/**
* Dokan get base product id from translated product id.
*
Expand Down Expand Up @@ -899,7 +960,7 @@ public function fix_store_category_query_arg() {
if (
! function_exists( 'dokan_is_store_categories_feature_on' ) ||
! dokan_is_store_categories_feature_on() ||
! dokan_pro()->store_category ) {
! empty( dokan_pro()->store_category ) ) {
return;
}

Expand Down
8 changes: 4 additions & 4 deletions languages/dokan-wpml.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# This file is distributed under the GPL2.
msgid ""
msgstr ""
"Project-Id-Version: Dokan - WPML Integration 1.1.2\n"
"Project-Id-Version: Dokan - WPML Integration 1.1.3\n"
"Report-Msgid-Bugs-To: http://wedevs.com/support/\n"
"POT-Creation-Date: 2024-04-01 09:02:11+00:00\n"
"POT-Creation-Date: 2024-06-13 09:36:34+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
Expand All @@ -13,14 +13,14 @@ msgstr ""
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
"X-Generator: grunt-wp-i18n 1.0.3\n"

#: dokan-wpml.php:204
#: dokan-wpml.php:206
#. translators: %1$s: opening anchor tag, %2$s: closing anchor tag
msgid ""
"<b>Dokan - WPML Integration</b> requires %1$s Dokan plugin %2$s to be "
"installed & activated!"
msgstr ""

#: dokan-wpml.php:210
#: dokan-wpml.php:212
#. translators: %1$s: opening anchor tag, %2$s: closing anchor tag
msgid ""
"<b>Dokan - WPML Integration</b> requires %1$s WPML Multilingual CMS %2$s to "
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dokan-wpml",
"version": "1.1.2",
"version": "1.1.3",
"description": "WPML compatibility for dokan plugin",
"author": "weDevs",
"license": "GPL",
Expand Down
11 changes: 8 additions & 3 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Contributors: wedevs
Tags: WPML, i18n, l10n, Translation, Dokan
Donate link: https://tareq.co/donate
Requires at least: 5.6
Tested up to: 6.4.3
Tested up to: 6.5.4
WC requires at least: 5.5.0
WC tested up to: 8.7.0
WC tested up to: 8.9.3
Requires PHP: 7.4
Stable tag: 1.1.2
Stable tag: 1.1.3
License: GPL v2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -52,6 +52,11 @@ nothing here

== Changelog ==

v1.1.3 -> Jun 13, 2024
---------------------------
- **update:** Dokan Product meta-key set to copy in WPML
- **fix:** Store category counts sync for multiple language

v1.1.2 -> Apr 01, 2024
---------------------------
- **update:** Vendor Subscription remaining product count WPML Support
Expand Down
19 changes: 19 additions & 0 deletions wpml-config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,24 @@
<custom-field action="copy">dokan_subscription_trial_period_types</custom-field>
<custom-field action="copy">_dokan_advertisement_slot_count</custom-field>
<custom-field action="copy">_dokan_advertisement_validity</custom-field>
<custom-field action="copy">_lot_discount_quantity</custom-field>
<custom-field action="copy">_lot_discount_amount</custom-field>
<custom-field action="copy">_is_lot_discount</custom-field>
<custom-field action="copy">dokan_geo_latitude</custom-field>
<custom-field action="copy">dokan_geo_longitude</custom-field>
<custom-field action="copy">dokan_geo_public</custom-field>
<custom-field action="copy">dokan_geo_address</custom-field>
<custom-field action="copy">_dokan_rma_override_product</custom-field>
<custom-field action="copy">_dokan_rma_settings</custom-field>
<custom-field action="copy">_dokan_wholesale_meta</custom-field>
<custom-field action="copy">_dokan_min_max_meta</custom-field>
<custom-field action="copy">_dokan_geolocation_use_store_settings</custom-field>
<custom-field action="copy">_dokan_new_product_email_sent</custom-field>
<custom-field action="copy">dokan_product_quantity_discount</custom-field>
<custom-field action="copy">_product_addons_exclude_global</custom-field>
<custom-field action="copy">_product_addons</custom-field>
</custom-fields>
<taxonomies>
<taxonomy translate="2">store_category</taxonomy>
</taxonomies>
</wpml-config>

0 comments on commit 58998bc

Please sign in to comment.