Skip to content

Commit 8b85f54

Browse files
committed
Merge branch 'release/1.0.3'
2 parents 38cbfc8 + e9f22fe commit 8b85f54

File tree

5 files changed

+134
-55
lines changed

5 files changed

+134
-55
lines changed

changelog.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v1.0.3 -> December 03, 2020
2+
---------------------------
3+
- [fix] Vendor dashboard page all links coming 404 error fixed
4+
- [fix] Vendor dashboard all url slug missing on url issue fixed
5+
- [fix] Fatal error when dokan plugin deactivated
6+
- [fix] Improve coding structure
7+
18
v1.0.2 -> November 23, 2019
29
---------------------------
310
- [Fix] Color customizer and order page is not loading

dokan-wpml.php

Lines changed: 109 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
Plugin Name: Dokan - WPML Integration
44
Plugin URI: https://wedevs.com/
55
Description: WPML and Dokan compitable package
6-
Version: 1.0.2
6+
Version: 1.0.3
77
Author: weDevs
88
Author URI: https://wedevs.com/
99
Text Domain: dokan-wpml
1010
WC requires at least: 3.0
11-
WC tested up to: 3.8.0
11+
WC tested up to: 4.7.1
1212
Domain Path: /languages/
1313
License: GPL2
1414
*/
@@ -48,6 +48,13 @@
4848
*/
4949
class Dokan_WPML {
5050

51+
/*
52+
* WordPress Endpoints text domain
53+
*
54+
* @var string
55+
*/
56+
public $wp_endpoints = 'WP Endpoints';
57+
5158
/**
5259
* Constructor for the Dokan_WPML class
5360
*
@@ -60,24 +67,26 @@ class Dokan_WPML {
6067
* @uses add_action()
6168
*/
6269
public function __construct() {
63-
register_activation_hook( __FILE__, array( $this, 'dependency_missing_notice' ) );
70+
register_activation_hook( __FILE__, [ $this, 'dependency_missing_notice' ] );
6471

6572
// Localize our plugin
66-
add_action( 'init', array( $this, 'localization_setup' ) );
73+
add_action( 'init', [ $this, 'localization_setup' ] );
6774

6875
// Load all actions hook
69-
add_filter( 'dokan_forced_load_scripts', array( $this, 'load_scripts_and_style') );
70-
add_filter( 'dokan_force_load_extra_args', array( $this, 'load_scripts_and_style') );
71-
add_filter( 'dokan_seller_setup_wizard_url', array( $this, 'render_wmpl_home_url' ), 70 );
72-
add_filter( 'dokan_get_page_url', array( $this, 'reflect_page_url' ), 10, 3 );
73-
add_filter( 'dokan_get_terms_condition_url', array( $this, 'get_terms_condition_url' ), 10, 2 );
74-
add_filter( 'dokan_redirect_login', array( $this, 'redirect_if_not_login' ), 90 );
75-
add_filter( 'dokan_force_page_redirect', array( $this, 'force_redirect_page' ), 90, 2 );
76+
add_filter( 'dokan_forced_load_scripts', [ $this, 'load_scripts_and_style' ] );
77+
add_filter( 'dokan_force_load_extra_args', [ $this, 'load_scripts_and_style' ] );
78+
add_filter( 'dokan_seller_setup_wizard_url', [ $this, 'render_wmpl_home_url' ], 70 );
79+
add_filter( 'dokan_get_page_url', [ $this, 'reflect_page_url' ], 10, 3 );
80+
add_filter( 'dokan_get_terms_condition_url', [ $this, 'get_terms_condition_url' ], 10, 2 );
81+
add_filter( 'dokan_redirect_login', [ $this, 'redirect_if_not_login' ], 90 );
82+
add_filter( 'dokan_force_page_redirect', [ $this, 'force_redirect_page' ], 90, 2 );
7683

7784
// Load all filters hook
78-
add_filter( 'dokan_get_navigation_url', array( $this, 'load_translated_url' ), 10 ,2 );
79-
add_filter( 'body_class', array( $this, 'add_dashboard_template_class_if_wpml' ), 99 );
85+
add_filter( 'dokan_get_navigation_url', [ $this, 'load_translated_url' ], 10 ,2 );
86+
add_filter( 'body_class', [ $this, 'add_dashboard_template_class_if_wpml' ], 99 );
8087
add_filter( 'dokan_get_current_page_id', [ $this, 'dokan_set_current_page_id' ] );
88+
add_filter( 'dokan_get_dashboard_nav', [ $this, 'replace_dokan_dashboard_nav_key' ] );
89+
add_action( 'wp_head', [ $this, 'dokan_wpml_remove_fix_fallback_links' ] );
8190
}
8291

8392
/**
@@ -129,12 +138,12 @@ public function localization_setup() {
129138
}
130139

131140
/**
132-
* Redirect seller setup wizerd into translated url
133-
*
134-
* @since 1.0.0
135-
*
136-
* @return void
137-
**/
141+
* Redirect seller setup wizerd into translated url
142+
*
143+
* @since 1.0.0
144+
*
145+
* @return void
146+
*/
138147
public function render_wmpl_home_url( $url ) {
139148
$translated_url = apply_filters( 'wpml_home_url', $url );
140149
return add_query_arg( array( 'page' => 'dokan-seller-setup' ), $translated_url );
@@ -151,12 +160,27 @@ public function render_wmpl_home_url( $url ) {
151160
* @return string
152161
*/
153162
function load_translated_url( $url, $name ) {
163+
$current_lang = apply_filters( 'wpml_current_language', NULL );
164+
154165
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
155166
return $url;
156167
}
157168

158169
if ( ! empty( $name ) ) {
170+
171+
if ( $current_lang ) {
172+
$name_arr = explode( '/', $name );
173+
174+
if ( isset( $name_arr[1] ) ) {
175+
$name = apply_filters( 'wpml_translate_single_string', $name_arr[0], $this->wp_endpoints, $name_arr[0], $current_lang ).'/'.$name_arr[1];
176+
} else {
177+
$get_name = ( ! empty( $name_arr[0] ) ) ? $name_arr[0] : $name;
178+
$name = apply_filters( 'wpml_translate_single_string', $get_name, $this->wp_endpoints, $get_name, $current_lang );
179+
}
180+
}
181+
159182
$url = $this->get_dokan_url_for_language( ICL_LANGUAGE_CODE ).$name.'/';
183+
160184
} else {
161185
$url = $this->get_dokan_url_for_language( ICL_LANGUAGE_CODE );
162186
}
@@ -165,12 +189,36 @@ function load_translated_url( $url, $name ) {
165189
}
166190

167191
/**
168-
* Reflect page url
169-
*
170-
* @since 1.0.1
171-
*
172-
* @return void
173-
**/
192+
* Replace dashboard key language wise
193+
*
194+
* @param array $urls
195+
*
196+
* @since 2.4
197+
*
198+
* @return array $urls
199+
*/
200+
public function replace_dokan_dashboard_nav_key( $urls ) {
201+
$current_lang = apply_filters( 'wpml_current_language', NULL );
202+
$new_urls = $urls;
203+
204+
foreach ( $urls as $get_key => $item ) {
205+
$new_key = apply_filters( 'wpml_translate_single_string', $get_key, $this->wp_endpoints, $get_key, $current_lang );
206+
if ( $get_key != $new_key ) {
207+
$new_urls[$new_key] = $new_urls[$get_key];
208+
unset($new_urls[$get_key]);
209+
}
210+
}
211+
212+
return $new_urls;
213+
}
214+
215+
/**
216+
* Reflect page url
217+
*
218+
* @since 1.0.1
219+
*
220+
* @return void
221+
*/
174222
public function reflect_page_url( $url, $page_id, $context ) {
175223
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
176224
return $url;
@@ -182,12 +230,12 @@ public function reflect_page_url( $url, $page_id, $context ) {
182230
}
183231

184232
/**
185-
* Get terms and condition page url
186-
*
187-
* @since 1.0.1
188-
*
189-
* @return url
190-
**/
233+
* Get terms and condition page url
234+
*
235+
* @since 1.0.1
236+
*
237+
* @return url
238+
*/
191239
public function get_terms_condition_url( $url, $page_id ) {
192240
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
193241
return $url;
@@ -199,12 +247,12 @@ public function get_terms_condition_url( $url, $page_id ) {
199247
}
200248

201249
/**
202-
* Redirect if not login
203-
*
204-
* @since 1.0.1
205-
*
206-
* @return void
207-
**/
250+
* Redirect if not login
251+
*
252+
* @since 1.0.1
253+
*
254+
* @return void
255+
*/
208256
public function redirect_if_not_login( $url ) {
209257
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
210258
return $url;
@@ -217,12 +265,12 @@ public function redirect_if_not_login( $url ) {
217265
}
218266

219267
/**
220-
* undocumented function
221-
*
222-
* @since 1.0.1
223-
*
224-
* @return void
225-
**/
268+
* Undocumented function
269+
*
270+
* @since 1.0.1
271+
*
272+
* @return void
273+
*/
226274
public function force_redirect_page( $flag, $page_id ) {
227275
if ( ! function_exists( 'wpml_object_id_filter' ) ) {
228276
return false;
@@ -339,7 +387,7 @@ public function dokan_set_current_page_id( $page_id ) {
339387
/**
340388
* Get raw value from database
341389
*
342-
* @since DOKAN_WPML_SINCE
390+
* @since 1.0.3
343391
*
344392
* @param string $option
345393
* @param string $section
@@ -360,6 +408,23 @@ public function get_raw_option( $option, $section, $default = '' ) {
360408
return isset( $options[ $option ] ) ? $options[ $option ] : $default;
361409
}
362410

411+
/**
412+
* Remove callback links with WPML on vendor dashboard
413+
*
414+
* @since 1.0.3
415+
*/
416+
public function dokan_wpml_remove_fix_fallback_links() {
417+
if ( function_exists( 'dokan_is_seller_dashboard' ) && ! dokan_is_seller_dashboard() ) {
418+
return;
419+
}
420+
421+
if ( ! class_exists( 'WPML_Fix_Links_In_Display_As_Translated_Content' ) || ! function_exists( 'dokan_remove_hook_for_anonymous_class' ) ) {
422+
return;
423+
}
424+
425+
dokan_remove_hook_for_anonymous_class( 'the_content', 'WPML_Fix_Links_In_Display_As_Translated_Content', 'fix_fallback_links', 99 );
426+
}
427+
363428
} // Dokan_WPML
364429

365430
function dokan_load_wpml() {

languages/dokan-wpml.pot

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
1-
# Copyright (C) 2019 weDevs
1+
# Copyright (C) 2020 weDevs
22
# This file is distributed under the GPL2.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Dokan - WPML Integration 1.0.2\n"
5+
"Project-Id-Version: Dokan - WPML Integration 1.0.3\n"
66
"Report-Msgid-Bugs-To: http://wedevs.com/support/\n"
7-
"POT-Creation-Date: 2019-11-23 09:12:29+00:00\n"
7+
"POT-Creation-Date: 2020-12-03 09:37:59+00:00\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=utf-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
11-
"PO-Revision-Date: 2019-MO-DA HO:MI+ZONE\n"
11+
"PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
1212
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1313
"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
1414
"X-Generator: grunt-wp-i18n 0.4.9\n"
1515

16-
#: dokan-wpml.php:110
16+
#: dokan-wpml.php:119
1717
msgid ""
1818
"<b>Dokan - WPML Integration</b> requires %sDokan plugin%s to be installed & "
1919
"activated!"
2020
msgstr ""
2121

22-
#: dokan-wpml.php:116
22+
#: dokan-wpml.php:125
2323
msgid ""
2424
"<b>Dokan - WPML Integration</b> requires %sWPML Multilingual CMS%s to be "
2525
"installed & activated!"

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dokan-wpml",
3-
"version": "1.0.2",
3+
"version": "1.0.3",
44
"description": "WPML compatibility for dokan plugin",
55
"author": "weDevs",
66
"license": "GPL",

readme.txt

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
=== Dokan WPML ===
2-
Contributors: wedevs, sabbir1991, rafsuntaskin,
2+
Contributors: wedevs, sabbir1991, rafsuntaskin, alamgircsebd
33
Tags: WPML, i18n, l10n, Translation, Dokan
44
Donate link: https://tareq.co/donate
55
Requires at least: 4.7
6-
Tested up to: 5.3.0
6+
Tested up to: 5.5.3
77
WC requires at least: 3.0
8-
WC tested up to: 3.8.0
8+
WC tested up to: 4.7.1
99
Requires PHP: 5.6
10-
Stable tag: trunk
10+
Stable tag: 1.0.3
1111
License: GPL v2
1212
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1313

@@ -52,6 +52,13 @@ nothing here
5252

5353
== Changelog ==
5454

55+
v1.0.3 -> December 03, 2020
56+
---------------------------
57+
- [fix] Vendor dashboard page all links coming 404 error fixed
58+
- [fix] Vendor dashboard all url slug missing on url issue fixed
59+
- [fix] Fatal error when dokan plugin deactivated
60+
- [fix] Improve coding structure
61+
5562
v1.0.2 -> November 23, 2019
5663
---------------------------
5764
- [Fix] Color customizer and order page is not loading

0 commit comments

Comments
 (0)