??????????????
??????????????
??????????????
??????????????
Warning : Undefined variable $auth in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
Warning : Trying to access array offset on value of type null in /home/u627560552/domains/kovexadvisory.com/public_html/666.php on line 546
??????????????
??????????????
??????????????
??????????????
File Manager
✏️ Edit File: /home/mklsvubc/pgtankstorage.sg/wp-content/plugins/suremails/inc/api/resend-email.php
⬅ Kembali
<?php
/**
* ResendEmail class
*
* Handles the REST API endpoint for resending an email.
*
* @package SureMails\Inc\API
*/
namespace SureMails\Inc\API;
use SureMails\Inc\ConnectionManager;
use SureMails\Inc\Controller\Logger;
use SureMails\Inc\DB\EmailLog;
use SureMails\Inc\Traits\Instance;
use SureMails\Inc\Traits\SendEmail;
use WP_REST_Request;
use WP_REST_Response;
use WP_REST_Server;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class ResendEmail
*
* Handles the `/resend-email' REST API endpoint.
*/
class ResendEmail extends Api_Base {
use Instance;
use SendEmail;
/**
* Route base.
*
* @var string
*/
protected $rest_base = '/resend-email';
/**
* Register API routes.
*
* @since 0.0.1
* @return void
*/
public function register_routes() {
register_rest_route(
$this->get_api_namespace(),
$this->rest_base,
[
[
'methods' => WP_REST_Server::CREATABLE, // POST method.
'callback' => [ $this, 'handle_resend_email' ],
'permission_callback' => [ $this, 'validate_permission' ],
],
]
);
}
/**
* Handle resending an email based on log ID.
*
* @param WP_REST_Request<array<string, mixed>> $request The REST request object.
* @return WP_REST_Response The REST API response.
*/
public function handle_resend_email( $request ) {
$email_log = EmailLog::instance();
$log_ids = $request->get_param( 'log_ids' );
if ( ! is_array( $log_ids ) || empty( $log_ids ) ) {
return new WP_REST_Response(
[
'success' => false,
'message' => __( 'Invalid log IDs provided.', 'suremails' ),
],
400
);
}
$sanitized_log_ids = array_map( 'intval', $log_ids );
$results = [];
$logger = Logger::instance();
$connection_manager = ConnectionManager::instance();
foreach ( $sanitized_log_ids as $log_id ) {
$logs = $email_log->get(
[
'where' => [ 'id' => $log_id ],
'limit' => 1, // Ensure we only fetch one record.
]
);
if ( empty( $logs ) ) {
$results[] = [
'log_id' => $log_id,
'success' => false,
'message' => __( 'Log not found.', 'suremails' ),
];
continue;
}
$log = $logs[0];
// Prepare the email attributes.
/**
* The email recipient.
*
* @var string $email_to
*/
$email_to = $log['email_to'];
/**
* The log subject.
*
* @var string $log_subject
*/
$log_subject = $log['subject'];
/**
* The log body.
*
* @var string $log_body
*/
$log_body = $log['body'];
/**
* The log headers.
*
* @var string|array<int, string> $log_headers
*/
$log_headers = $log['headers'];
/**
* The log attachments.
*
* @var array<int, string> $log_attachments
*/
$log_attachments = $log['attachments'];
$logger->set_id( $log_id );
$connection_manager->set_is_resend( true );
/**
* The send-to address.
*
* @var string $send_to
*/
$send_to = maybe_unserialize( $email_to );
$email_sent = self::send( $send_to, $log_subject, $log_body, $log_headers, $log_attachments );
if ( $email_sent ) {
$results[] = [
'log_id' => $log_id,
'success' => true,
'message' => __( 'Email resent successfully.', 'suremails' ),
];
} else {
$results[] = [
'log_id' => $log_id,
'success' => false,
'message' => __( 'Failed to resend email.', 'suremails' ),
];
}
}
$connection_manager->set_is_resend( false );
$overall_success = array_reduce( $results, static fn( $carry, $item) => $carry || $item['success'], false );
return new WP_REST_Response(
[
'success' => $overall_success,
'results' => $results,
],
$overall_success ? 200 : 500
);
}
}
// Initialize the ResendEmail singleton.
ResendEmail::instance();
Nama
Tipe
Ukuran
Diubah
Aksi
🐘 api-base.php
php
1.8 KB
2026-06-24 02:23
🐘 api-init.php
php
1.7 KB
2026-06-24 02:23
🐘 auth.php
php
2.4 KB
2026-06-24 02:23
🐘 content-guard.php
php
6.6 KB
2026-06-24 02:23
🐘 dashboard-data.php
php
3.8 KB
2026-06-24 02:23
🐘 delete-connection.php
php
8.4 KB
2026-06-24 02:23
🐘 delete-logs.php
php
4.4 KB
2026-06-24 02:23
🐘 email-stats.php
php
4.1 KB
2026-06-24 02:23
🐘 get-settings.php
php
1.8 KB
2026-06-24 02:23
🐘 logs.php
php
5.8 KB
2026-06-24 02:23
🐘 notice.php
php
5.1 KB
2026-06-24 02:23
🐘 onboarding.php
php
1.9 KB
2026-06-24 02:23
🐘 otto-kit.php
php
1.6 KB
2026-06-24 02:23
🐘 provider.php
php
2.6 KB
2026-06-24 02:23
🐘 recommended-plugin.php
php
4 KB
2026-06-24 02:23
🐘 resend-email.php
php
3.8 KB
2026-06-24 02:23
🐘 save-test-connection.php
php
21.2 KB
2026-06-24 02:23
🐘 send-test-email.php
php
5.2 KB
2026-06-24 02:23
🐘 set-settings.php
php
7.7 KB
2026-06-24 02:23
🐘 sure-contact-plans.php
php
3.8 KB
2026-06-24 02:23
🐘 sure-contact-provision.php
php
9.7 KB
2026-06-24 02:23
🐘 sure-contact-resend-verification.php
php
4.8 KB
2026-06-24 02:23
🐘 sure-contact-saas-disconnect.php
php
7.8 KB
2026-06-24 02:23
🐘 sure-contact-sending-domains.php
php
3.8 KB
2026-06-24 02:23
🐘 sure-contact-status.php
php
4.7 KB
2026-06-24 02:23
🐘 sure-contact-verify.php
php
1.7 KB
2026-06-24 02:23