| 1 |
<?php |
| 2 |
/** |
| 3 |
* Filter for Email Notification |
| 4 |
* |
| 5 |
* @package Give |
| 6 |
* @subpackage Classes/Emails |
| 7 |
* @copyright Copyright (c) 2016, GiveWP |
| 8 |
* @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 |
* @since 2.0 |
| 10 |
*/ |
| 11 |
|
| 12 |
/** |
| 13 |
* Add extra row actions to email notification table. |
| 14 |
* |
| 15 |
* @since 2.0 |
| 16 |
* |
| 17 |
* @param array $row_actions |
| 18 |
* @param Give_Email_Notification $email |
| 19 |
* |
| 20 |
* @return array |
| 21 |
*/ |
| 22 |
function give_email_notification_row_actions_callback( $row_actions, $email ) { |
| 23 |
if ( Give_Email_Notification_Util::is_email_preview( $email ) ) { |
| 24 |
$preview_link = sprintf( |
| 25 |
'<a href="%1$s" target="_blank">%2$s</a>', |
| 26 |
esc_url( |
| 27 |
wp_nonce_url( |
| 28 |
add_query_arg( |
| 29 |
array( |
| 30 |
'give_action' => 'preview_email', |
| 31 |
'email_type' => $email->config['id'], |
| 32 |
), |
| 33 |
home_url() |
| 34 |
), |
| 35 |
'give-preview-email' |
| 36 |
) |
| 37 |
), |
| 38 |
__( 'Preview', 'give' ) |
| 39 |
); |
| 40 |
|
| 41 |
$send_preview_email_link = give()->tooltips->render_link( [ |
| 42 |
'tag_content' => esc_html__( 'Send test email', 'give' ), |
| 43 |
'label' => sprintf( |
| 44 |
esc_html__( 'Click this link to send a test email to yourself at %s', 'give' ), |
| 45 |
wp_get_current_user()->user_email |
| 46 |
), |
| 47 |
'link' => esc_url_raw(wp_nonce_url( |
| 48 |
add_query_arg( |
| 49 |
array( |
| 50 |
'give_action' => 'send_preview_email', |
| 51 |
'email_type' => $email->config['id'], |
| 52 |
'give-messages[]' => 'sent-test-email', |
| 53 |
) |
| 54 |
), |
| 55 |
'give-send-preview-email' |
| 56 |
)) |
| 57 |
] ); |
| 58 |
|
| 59 |
$row_actions['email_preview'] = $preview_link; |
| 60 |
$row_actions['send_preview_email'] = $send_preview_email_link; |
| 61 |
} |
| 62 |
|
| 63 |
return $row_actions; |
| 64 |
} |
| 65 |
add_filter( 'give_email_notification_row_actions', 'give_email_notification_row_actions_callback', 10, 2 ); |
| 66 |
|
| 67 |
/** |
| 68 |
* This help to decode all email template tags. |
| 69 |
* |
| 70 |
* @since 2.0 |
| 71 |
* |
| 72 |
* @param string $message |
| 73 |
* @param Give_Emails $email_obj |
| 74 |
* |
| 75 |
* @return string |
| 76 |
*/ |
| 77 |
function give_decode_email_tags( $message, $email_obj ) { |
| 78 |
if ( ! empty( $email_obj->tag_args ) ) { |
| 79 |
$message = give_do_email_tags( $message, $email_obj->tag_args ); |
| 80 |
} |
| 81 |
|
| 82 |
return $message; |
| 83 |
} |
| 84 |
|
| 85 |
add_filter( 'give_email_message', 'give_decode_email_tags', 10, 2 ); |
| 86 |
|