Submit
Path:
~
/
home
/
getwphos
/
www
/
techniquetechs
/
wp-content
/
plugins
/
woocommerce
/
src
/
Internal
/
Admin
/
Notes
/
File Content:
MerchantEmailNotifications.php
<?php /** * Handles merchant email notifications */ namespace Automattic\WooCommerce\Internal\Admin\Notes; use Automattic\WooCommerce\Admin\Notes\Note; use Automattic\WooCommerce\Admin\Notes\Notes; defined( 'ABSPATH' ) || exit; /** * Merchant email notifications. * This gets all non-sent notes type `email` and sends them. */ class MerchantEmailNotifications { /** * Initialize the merchant email notifications. */ public static function init() { add_action( 'admin_init', array( __CLASS__, 'trigger_notification_action' ) ); } /** * Trigger the note action. */ public static function trigger_notification_action() { /* phpcs:disable WordPress.Security.NonceVerification */ if ( ! isset( $_GET['external_redirect'] ) || 1 !== intval( $_GET['external_redirect'] ) || ! isset( $_GET['user'] ) || ! isset( $_GET['note'] ) || ! isset( $_GET['action'] ) ) { return; } $note_id = intval( $_GET['note'] ); $action_id = intval( $_GET['action'] ); $user_id = intval( $_GET['user'] ); /* phpcs:enable */ $note = Notes::get_note( $note_id ); if ( ! $note || Note::E_WC_ADMIN_NOTE_EMAIL !== $note->get_type() ) { return; } $triggered_action = Notes::get_action_by_id( $note, $action_id ); if ( ! $triggered_action ) { return; } Notes::trigger_note_action( $note, $triggered_action ); $url = $triggered_action->query; // We will use "wp_safe_redirect" when it's an internal redirect. if ( strpos( $url, 'http' ) === false ) { wp_safe_redirect( $url ); } else { header( 'Location: ' . $url ); } exit(); } /** * Send all the notifications type `email`. */ public static function run() { $data_store = Notes::load_data_store(); $notes = $data_store->get_notes( array( 'type' => array( Note::E_WC_ADMIN_NOTE_EMAIL ), 'status' => array( 'unactioned' ), ) ); foreach ( $notes as $note ) { $note = Notes::get_note( $note->note_id ); if ( $note ) { self::send_merchant_notification( $note ); $note->set_status( 'sent' ); $note->save(); } } } /** * Send the notification to the merchant. * * @param object $note The note to send. */ public static function send_merchant_notification( $note ) { \WC_Emails::instance(); $users = self::get_notification_recipients( $note ); $email = new EmailNotification( $note ); foreach ( $users as $user ) { if ( is_email( $user->user_email ) ) { $name = self::get_merchant_preferred_name( $user ); $email->trigger( $user->user_email, $user->ID, $name ); } } } /** * Get the preferred name for user. First choice is * the user's first name, and then display_name. * * @param WP_User $user Recipient to send the note to. * @return string User's name. */ public static function get_merchant_preferred_name( $user ) { $first_name = get_user_meta( $user->ID, 'first_name', true ); if ( $first_name ) { return $first_name; } if ( $user->display_name ) { return $user->display_name; } return ''; } /** * Get users by role to notify. * * @param object $note The note to send. * @return array Users to notify */ public static function get_notification_recipients( $note ) { $content_data = $note->get_content_data(); $role = 'administrator'; if ( isset( $content_data->role ) ) { $role = $content_data->role; } $args = array( 'role' => $role ); return get_users( $args ); } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
AddFirstProduct.php
2914 bytes
0644
CustomizeStoreWithBlocks.php
2403 bytes
0644
CustomizingProductCatalog.php
2250 bytes
0644
EUVATNumber.php
1674 bytes
0644
EditProductsOnTheMove.php
1716 bytes
0644
EmailNotification.php
5288 bytes
0644
FirstProduct.php
2234 bytes
0644
GivingFeedbackNotes.php
1538 bytes
0644
InstallJPAndWCSPlugins.php
4690 bytes
0644
LaunchChecklist.php
1720 bytes
0644
MagentoMigration.php
2508 bytes
0644
ManageOrdersOnTheGo.php
1577 bytes
0644
MarketingJetpack.php
3765 bytes
0644
MerchantEmailNotifications.php
3457 bytes
0644
MigrateFromShopify.php
2264 bytes
0644
MobileApp.php
1421 bytes
0644
NewSalesRecord.php
5380 bytes
0644
OnboardingPayments.php
1780 bytes
0644
OnlineClothingStore.php
2745 bytes
0644
OrderMilestones.php
9366 bytes
0644
PaymentsMoreInfoNeeded.php
2059 bytes
0644
PaymentsRemindMeLater.php
1985 bytes
0644
PerformanceOnMobile.php
1677 bytes
0644
PersonalizeStore.php
1958 bytes
0644
RealTimeOrderAlerts.php
1546 bytes
0644
SellingOnlineCourses.php
2432 bytes
0644
TrackingOptIn.php
3251 bytes
0644
UnsecuredReportFiles.php
2174 bytes
0644
WooCommercePayments.php
6400 bytes
0644
WooCommerceSubscriptions.php
1922 bytes
0644
WooSubscriptionsNotes.php
13421 bytes
0644
N4ST4R_ID | Naxtarrr