Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: vendor vacation, biography dokan-pro support #91

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 72 additions & 7 deletions dokan-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ public function plugins_loaded() {
add_filter( 'dokan_force_page_redirect', [ $this, 'force_redirect_page' ], 90, 2 );

// Load all filters hook
add_filter('sanitize_user_meta_product_package_id', [ $this, 'set_subscription_pack_id_in_base_language' ], 10, 3 );
add_filter('dokan_vendor_subscription_package_title', [ $this, 'vendor_subscription_pack_title_translation' ], 10, 2 );
add_filter('dokan_vendor_subscription_package_id', [ $this, 'get_product_id_in_base_language' ] );
add_filter( 'sanitize_user_meta_product_package_id', [ $this, 'set_subscription_pack_id_in_base_language' ], 10, 3 );
add_filter( 'dokan_vendor_subscription_package_title', [ $this, 'vendor_subscription_pack_title_translation' ], 10, 2 );
add_filter( 'dokan_vendor_subscription_package_id', [ $this, 'get_product_id_in_base_language' ] );
add_filter( 'dokan_get_navigation_url', [ $this, 'load_translated_url' ], 10, 2 );
add_filter( 'body_class', [ $this, 'add_dashboard_template_class_if_wpml' ], 99 );
add_filter( 'dokan_get_current_page_id', [ $this, 'dokan_set_current_page_id' ] );
Expand All @@ -141,8 +141,8 @@ public function plugins_loaded() {
add_filter( 'dokan_dashboard_nav_menu_key', [ $this, 'filter_dashboard_settings_key' ] );
add_filter( 'dokan_dashboard_nav_submenu_key', [ $this, 'filter_dashboard_settings_key' ] );
add_filter( 'wcml_vendor_addon_configuration', [ $this, 'add_vendor_capability' ] );
add_filter('icl_lang_sel_copy_parameters', [ $this, 'set_language_switcher_copy_param' ] );
add_filter( 'dokan_vendor_subscription_product_count_query', [ $this, 'set_vendor_subscription_product_count_query' ],10 ,3 );
add_filter( 'icl_lang_sel_copy_parameters', [ $this, 'set_language_switcher_copy_param' ] );
add_filter( 'dokan_vendor_subscription_product_count_query', [ $this, 'set_vendor_subscription_product_count_query' ], 10, 3 );

add_action( 'init', [ $this, 'fix_store_category_query_arg' ], 10 );
add_action( 'init', [ $this, 'load_wpml_admin_post_actions' ], 10 );
Expand All @@ -157,8 +157,8 @@ public function plugins_loaded() {
add_filter( 'dokan_pro_abuse_report_reason', [ $this, 'get_translated_abuse_report_reason' ] );
add_filter( 'dokan_pro_subscription_allowed_categories', [ $this, 'get_translated_allowed_categories' ] );
add_filter( 'dokan_pro_rma_reason', [ $this, 'get_translated_rma_reason' ] );
add_action( 'dokan_pro_vendor_verification_method_created', [ $this, 'register_vendor_verification_method'] );
add_action( 'dokan_pro_vendor_verification_method_updated', [ $this, 'register_vendor_verification_method'] );
add_action( 'dokan_pro_vendor_verification_method_created', [ $this, 'register_vendor_verification_method' ] );
add_action( 'dokan_pro_vendor_verification_method_updated', [ $this, 'register_vendor_verification_method' ] );
add_filter( 'dokan_pro_vendor_verification_method_title', [ $this, 'get_translated_verification_method_title' ] );
add_filter( 'dokan_pro_vendor_verification_method_help_text', [ $this, 'get_translated_verification_method_help_text' ] );

Expand All @@ -169,6 +169,13 @@ public function plugins_loaded() {
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' ] );

add_action( 'dokan_vendor_vacation_message_updated', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
add_action( 'dokan_vendor_vacation_message_schedule_after_update', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
add_filter( 'dokan_get_vendor_vacation_message', [ $this, 'get_translated_dokan_vendor_vacation_message' ], 10, 2 );
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Mismatch in action parameters.
The action 'dokan_vendor_vacation_message_updated' is hooked with 10, 3 arguments, but dokan_vendor_vacation_message_updated($text, $name) only accepts 2 parameters. This may cause inconsistencies or notices in production.

-add_action( 'dokan_vendor_vacation_message_updated', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
-add_action( 'dokan_vendor_vacation_message_schedule_after_update', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
+add_action( 'dokan_vendor_vacation_message_updated', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 2 );
+add_action( 'dokan_vendor_vacation_message_schedule_after_update', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 2 );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
add_action( 'dokan_vendor_vacation_message_updated', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
add_action( 'dokan_vendor_vacation_message_schedule_after_update', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 3 );
add_filter( 'dokan_get_vendor_vacation_message', [ $this, 'get_translated_dokan_vendor_vacation_message' ], 10, 2 );
add_action( 'dokan_vendor_vacation_message_updated', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 2 );
add_action( 'dokan_vendor_vacation_message_schedule_after_update', [ $this, 'dokan_vendor_vacation_message_updated' ], 10, 2 );
add_filter( 'dokan_get_vendor_vacation_message', [ $this, 'get_translated_dokan_vendor_vacation_message' ], 10, 2 );


add_action( 'dokan_vendor_biography_after_update', [ $this, 'dokan_vendor_biography_updated' ], 10, 3 );
add_filter( 'dokan_get_vendor_biography_text', [ $this, 'get_translated_dokan_vendor_biography_text' ], 10, 2 );
kzamanbd marked this conversation as resolved.
Show resolved Hide resolved
}

/**
Expand Down Expand Up @@ -1316,6 +1323,64 @@ public function get_translated_verification_method_title( $title ) {
public function get_translated_verification_method_help_text( $help_text ) {
return $this->get_translated_single_string( $help_text, 'dokan', 'Dokan Vendor Verification Method Help Text: ' . substr( $help_text, 0, 116 ) );
}

/**
* Translate Vendor Vacation Message
*
* @param $text
* @param $name
*
* @return void
*/
public function dokan_vendor_vacation_message_updated($text, $name) {
$this->register_single_string(
'dokan',
'Vendor Vacation Message: ' . $name,
$text
);
}

/**
* Translated Vendor Vacation Message
*
* @param string $text
* @param $name
*
* @return string
*/
public function get_translated_dokan_vendor_vacation_message(string $text , $name) {
return $this->get_translated_single_string( $text, 'dokan', 'Vendor Vacation Message: '.$name );
}
kzamanbd marked this conversation as resolved.
Show resolved Hide resolved


/**
* Translate Vendor Biography Text
*
* @param $store_info array
* @param $name string
*
* @return void
*/
public function dokan_vendor_biography_updated($store_info, $name) {
$this->register_single_string(
'dokan',
'Vendor Biography Text: ' . $name,
$store_info['vendor_biography']
);
}

/**
* Translated Vendor Biography Text
*
* @param string $text
* @param $name
*
* @return string
*/
public function get_translated_dokan_vendor_biography_text(string $text , $name) {
return $this->get_translated_single_string( $text, 'dokan', 'Vendor Biography Text: '.$name );
}

} // Dokan_WPML

function dokan_load_wpml() { // phpcs:ignore
Expand Down