35
35
* **********************************************************************
36
36
*/
37
37
38
- // don't call the file directly
39
- if ( !defined ( 'ABSPATH ' ) ) exit ;
38
+ defined ( 'ABSPATH ' ) || exit;
40
39
41
40
/**
42
41
* Dokan_WPML class
@@ -57,7 +56,7 @@ class Dokan_WPML {
57
56
* @uses add_action()
58
57
*/
59
58
public function __construct () {
60
- add_action ( ' init ' , array ( $ this , 'is_dependency_installed ' ) );
59
+ register_activation_hook ( __FILE__ , array ( $ this , 'dependency_missing_notice ' ) );
61
60
62
61
// Localize our plugin
63
62
add_action ( 'init ' , array ( $ this , 'localization_setup ' ) );
@@ -67,6 +66,7 @@ public function __construct() {
67
66
add_filter ( 'dokan_force_load_extra_args ' , array ( $ this , 'load_scripts_and_style ' ) );
68
67
add_filter ( 'dokan_seller_setup_wizard_url ' , array ( $ this , 'render_wmpl_home_url ' ), 70 );
69
68
add_filter ( 'dokan_get_page_url ' , array ( $ this , 'reflect_page_url ' ), 10 , 3 );
69
+ add_filter ( 'dokan_get_terms_condition_url ' , array ( $ this , 'get_terms_condition_url ' ), 10 , 2 );
70
70
add_filter ( 'dokan_redirect_login ' , array ( $ this , 'redirect_if_not_login ' ), 90 );
71
71
add_filter ( 'dokan_force_page_redirect ' , array ( $ this , 'force_redirect_page ' ), 90 , 2 );
72
72
@@ -91,26 +91,27 @@ public static function init() {
91
91
return $ instance ;
92
92
}
93
93
94
-
95
- function is_dependency_installed (){
96
- if ( !class_exists ( 'WeDevs_Dokan ' )){
97
- add_action ( 'admin_notices ' , array ( $ this , 'need_dependency ' ) );
98
- }
99
- }
100
-
101
94
/**
102
95
* Print error notice if dependency not active
103
96
*
104
- * @since 1.0.0
97
+ * @since 1.0.1
98
+ *
99
+ * @return void
105
100
*/
106
- function need_dependency (){
107
- $ error = sprintf ( __ ( '<b>Dokan - WPML Integration</b> requires %sDokan plugin%s to be installed & activated! ' , 'dokan-wpml ' ), '<a target="_blank" href="https://wedevs.com/products/plugins/dokan/"> ' , '</a> ' );
108
-
109
- $ message = '<div class="error"><p> ' . $ error . '</p></div> ' ;
101
+ public function dependency_missing_notice () {
102
+ deactivate_plugins ( plugin_basename ( __FILE__ ) );
110
103
111
- echo $ message ;
104
+ if ( ! class_exists ( 'WeDevs_Dokan ' ) ) {
105
+ $ error = sprintf ( __ ( '<b>Dokan - WPML Integration</b> requires %sDokan plugin%s to be installed & activated! ' , 'dokan-wpml ' ), '<a target="_blank" href="https://wedevs.com/products/plugins/dokan/"> ' , '</a> ' );
106
+ $ message = '<div class="error"><p> ' . $ error . '</p></div> ' ;
107
+ wp_die ( $ message );
108
+ }
112
109
113
- deactivate_plugins ( plugin_basename ( __FILE__ ) );
110
+ if ( ! class_exists ( 'SitePress ' ) ) {
111
+ $ error = sprintf ( __ ( '<b>Dokan - WPML Integration</b> requires %sWPML Multilingual CMS%s to be installed & activated! ' , 'dokan-wpml ' ), '<a target="_blank" href="https://wpml.org/"> ' , '</a> ' );
112
+ $ message = '<div class="error"><p> ' . $ error . '</p></div> ' ;
113
+ wp_die ( $ message );
114
+ }
114
115
}
115
116
116
117
/**
@@ -166,19 +167,32 @@ function load_translated_url( $url, $name ) {
166
167
*
167
168
* @return void
168
169
**/
169
- function reflect_page_url ( $ url , $ page_id , $ context ) {
170
+ public function reflect_page_url ( $ url , $ page_id , $ context ) {
170
171
$ lang_post_id = wpml_object_id_filter ( $ page_id , 'page ' , true , ICL_LANGUAGE_CODE );
171
172
return get_permalink ( $ lang_post_id );
172
173
}
173
174
175
+ /**
176
+ * Get terms and condition page url
177
+ *
178
+ * @since 1.0.1
179
+ *
180
+ * @return url
181
+ **/
182
+ public function get_terms_condition_url ( $ url , $ page_id ) {
183
+ $ page_id = wpml_object_id_filter ( $ page_id , 'page ' , true , ICL_LANGUAGE_CODE );
184
+
185
+ return get_permalink ( $ page_id );
186
+ }
187
+
174
188
/**
175
189
* Redirect if not login
176
190
*
177
191
* @since 1.0.1
178
192
*
179
193
* @return void
180
194
**/
181
- function redirect_if_not_login ( $ url ) {
195
+ public function redirect_if_not_login ( $ url ) {
182
196
$ page_id = wc_get_page_id ( 'myaccount ' );
183
197
$ lang_post_id = wpml_object_id_filter ( $ page_id , 'page ' , true , ICL_LANGUAGE_CODE );
184
198
return get_permalink ( $ lang_post_id );
@@ -191,7 +205,7 @@ function redirect_if_not_login( $url ) {
191
205
*
192
206
* @return void
193
207
**/
194
- function force_redirect_page ( $ flag , $ page_id ) {
208
+ public function force_redirect_page ( $ flag , $ page_id ) {
195
209
$ lang_post_id = wpml_object_id_filter ( $ page_id , 'page ' , true , ICL_LANGUAGE_CODE );
196
210
197
211
if ( is_page ( $ lang_post_id ) ) {
@@ -210,7 +224,7 @@ function force_redirect_page( $flag, $page_id ) {
210
224
*
211
225
* @return string [$url]
212
226
*/
213
- function get_dokan_url_for_language ( $ language ) {
227
+ public function get_dokan_url_for_language ( $ language ) {
214
228
$ post_id = dokan_get_option ( 'dashboard ' , 'dokan_pages ' );
215
229
$ lang_post_id = wpml_object_id_filter ( $ post_id , 'page ' , true , $ language );
216
230
@@ -232,7 +246,7 @@ function get_dokan_url_for_language( $language ) {
232
246
*
233
247
* @param array $classes
234
248
*/
235
- function add_dashboard_template_class_if_wpml ( $ classes ) {
249
+ public function add_dashboard_template_class_if_wpml ( $ classes ) {
236
250
if ( function_exists ('wpml_object_id_filter ' ) ) {
237
251
global $ post ;
238
252
@@ -259,17 +273,17 @@ function add_dashboard_template_class_if_wpml( $classes ) {
259
273
*
260
274
* @return void
261
275
*/
262
- function load_scripts_and_style () {
276
+ public function load_scripts_and_style () {
263
277
if ( function_exists ('wpml_object_id_filter ' ) ) {
264
278
global $ post ;
265
279
266
280
if ( !$ post ) {
267
281
return false ;
268
282
}
269
283
270
- $ default_lang = apply_filters ('wpml_default_language ' , NULL );
284
+ $ default_lang = apply_filters ('wpml_default_language ' , NULL );
271
285
$ current_page_id = wpml_object_id_filter ( $ post ->ID ,'page ' ,false , $ default_lang );
272
- $ page_id = dokan_get_option ( 'dashboard ' , 'dokan_pages ' );
286
+ $ page_id = dokan_get_option ( 'dashboard ' , 'dokan_pages ' );
273
287
274
288
if ( ( $ current_page_id == $ page_id ) || ( get_query_var ( 'edit ' ) && is_singular ( 'product ' ) ) ) {
275
289
return true ;
@@ -281,8 +295,8 @@ function load_scripts_and_style() {
281
295
282
296
} // Dokan_WPML
283
297
284
- add_action ( 'dokan_loaded ' , 'dokan_load_wpml ' , 15 );
285
-
286
298
function dokan_load_wpml () {
287
299
$ dokan_wpml = Dokan_WPML::init ();
288
- }
300
+ }
301
+
302
+ dokan_load_wpml ();
0 commit comments