← All changes
|
includes/admin/emails/class-email-notification-util.php
+16
-11
2.3.1
→
4.17.0
View file →
| @@ -24,9 +24,9 @@ | ||
| 24 | 24 | * @since 2.0 |
| 25 | 25 | * @access static |
| 26 | 26 | * @var |
| 27 | 27 | */ |
| 28 | - static private $instance; | |
| 28 | + private static $instance; | |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | 31 | * Singleton pattern. |
| 32 | 32 | * |
| @@ -149,9 +149,9 @@ | ||
| 149 | 149 | * @param Give_Email_Notification $email |
| 150 | 150 | * |
| 151 | 151 | * @return bool |
| 152 | 152 | */ |
| 153 | - public static function is_show_on_emails_setting_page( Give_Email_Notification $email ){ | |
| 153 | + public static function is_show_on_emails_setting_page( Give_Email_Notification $email ) { | |
| 154 | 154 | return $email->config['show_on_emails_setting_page']; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | /** |
| @@ -160,13 +160,13 @@ | ||
| 160 | 160 | * @since 2.0 |
| 161 | 161 | * @access public |
| 162 | 162 | * |
| 163 | 163 | * @param Give_Email_Notification $email |
| 164 | - * @param int $form_id | |
| 164 | + * @param int $form_id | |
| 165 | 165 | * |
| 166 | 166 | * @return bool |
| 167 | 167 | */ |
| 168 | - public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ){ | |
| 168 | + public static function can_use_form_email_options( Give_Email_Notification $email, $form_id = null ) { | |
| 169 | 169 | return give_is_setting_enabled( give_get_meta( $form_id, '_give_email_options', true ) ); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | /** |
| @@ -175,9 +175,9 @@ | ||
| 175 | 175 | * @since 2.0 |
| 176 | 176 | * @access public |
| 177 | 177 | * |
| 178 | 178 | * @param Give_Email_Notification $email |
| 179 | - * @param int $form_id | |
| 179 | + * @param int $form_id | |
| 180 | 180 | * |
| 181 | 181 | * @return string |
| 182 | 182 | */ |
| 183 | 183 | public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
| @@ -182,9 +182,8 @@ | ||
| 182 | 182 | */ |
| 183 | 183 | public static function is_email_notification_active( Give_Email_Notification $email, $form_id = null ) { |
| 184 | 184 | $notification_status = $email->get_notification_status( $form_id ); |
| 185 | 185 | |
| 186 | - | |
| 187 | 186 | $notification_status = empty( $form_id ) |
| 188 | 187 | ? give_is_setting_enabled( $notification_status ) |
| 189 | 188 | : give_is_setting_enabled( give_get_option( "{$email->config['id']}_notification", $email->config['notification_status'] ) ) && give_is_setting_enabled( $notification_status, array( 'enabled', 'global' ) ); |
| 190 | 189 | // To check if email notification is active or not on a per-form basis, email notification must be globally active—otherwise it will be considered disabled. |
| @@ -272,11 +271,11 @@ | ||
| 272 | 271 | * @since 2.0 |
| 273 | 272 | * @access public |
| 274 | 273 | * |
| 275 | 274 | * @param Give_Email_Notification $email |
| 276 | - * @param string $option_name | |
| 277 | - * @param int $form_id | |
| 278 | - * @param mixed $default | |
| 275 | + * @param string $option_name | |
| 276 | + * @param int $form_id | |
| 277 | + * @param mixed $default | |
| 279 | 278 | * |
| 280 | 279 | * @return mixed |
| 281 | 280 | */ |
| 282 | 281 | public static function get_value( Give_Email_Notification $email, $option_name, $form_id = null, $default = false ) { |
| @@ -284,10 +283,16 @@ | ||
| 284 | 283 | // So make sure you are using correct option name. |
| 285 | 284 | $global_option_name = ( 0 === strpos( $option_name, '_give_' ) |
| 286 | 285 | ? str_replace( '_give_', '', $option_name ) |
| 287 | 286 | : $option_name ); |
| 288 | - $option_value = give_get_option( $global_option_name, $default ); | |
| 287 | + $option_value = give_get_option( $global_option_name, $default ); | |
| 289 | 288 | |
| 289 | + // Ensure that emails sent to donors can be translated using WPML | |
| 290 | + // Registering only the emails sent to the donors. | |
| 291 | + if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! is_array( $option_value ) ) { | |
| 292 | + $option_value = apply_filters( 'wpml_translate_single_string', $option_value, 'admin_texts_give_settings', '[give_settings]' . $global_option_name ); | |
| 293 | + } | |
| 294 | + | |
| 290 | 295 | if ( |
| 291 | 296 | ! empty( $form_id ) |
| 292 | 297 | && give_is_setting_enabled( |
| 293 | 298 | give_get_meta( |
| @@ -300,9 +305,9 @@ | ||
| 300 | 305 | ) { |
| 301 | 306 | $option_value = get_post_meta( $form_id, $option_name, true ); |
| 302 | 307 | |
| 303 | 308 | // Get only email field value from recipients setting. |
| 304 | - if( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { | |
| 309 | + if ( Give_Email_Setting_Field::get_prefix( $email, $form_id ) . 'recipient' === $option_name ) { | |
| 305 | 310 | $option_value = wp_list_pluck( $option_value, 'email' ); |
| 306 | 311 | } |
| 307 | 312 | } |
| 308 | 313 | |