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

Update feature/stats branch #2764

Merged
merged 6 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 2 additions & 0 deletions assets/js/datepicker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* global job_manager_datepicker */
jQuery(document).ready( function() {
var $date_today = new Date();
var datePickerOptions = {
altFormat : 'yy-mm-dd',
minDate : $date_today,
};

if ( typeof job_manager_datepicker !== 'undefined' ) {
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# WP Job Manager

## 2.2.2 - 2024-02-15
* Fix issue with rich e-mails on some e-mail providers (#2753)
* Fix: 'featured_first' argument now works when 'show_filters' is set to false.
* Improve checkbox and radio inputs for styled forms

## 2.2.1 - 2024-01-31
* Fix PHP 7.x error for mixed returned type (#2726)

Expand Down
92 changes: 32 additions & 60 deletions includes/class-wp-job-manager-email-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ final class WP_Job_Manager_Email_Notifications {
const EMAIL_SETTING_PREFIX = 'job_manager_email_';
const EMAIL_SETTING_ENABLED = 'enabled';
const EMAIL_SETTING_PLAIN_TEXT = 'plain_text';
const MULTIPART_BOUNDARY = 'jm-boundary';

/**
* Notifications to be scheduled.
Expand Down Expand Up @@ -767,7 +766,7 @@ private static function is_email_notification_valid( $email_class ) {
* @return bool
*/
private static function send_email( $email_notification_key, WP_Job_Manager_Email $email ) {
add_filter( 'wp_mail_content_type', [ __CLASS__, 'mail_content_type' ] );

global $job_manager_doing_email;
$job_manager_doing_email = true;

Expand Down Expand Up @@ -804,10 +803,11 @@ private static function send_email( $email_notification_key, WP_Job_Manager_Emai
$is_plain_text_only = self::send_as_plain_text( $email_notification_key, $args );

$content_plain = self::get_email_content( $email_notification_key, $args, true );
$content_html = null;

if ( ! $is_plain_text_only ) {
$content_html = self::get_email_content( $email_notification_key, $args, false );
if ( $is_plain_text_only ) {
$body = $content_plain;
} else {
$body = self::get_email_content( $email_notification_key, $args, false );
}

/**
Expand All @@ -829,8 +829,6 @@ private static function send_email( $email_notification_key, WP_Job_Manager_Emai
$headers[] = 'CC: ' . $args['cc'];
}

$multipart_body = self::get_multipart_body( $content_html, $content_plain );

/**
* Allows for short-circuiting the actual sending of email notifications.
*
Expand All @@ -842,34 +840,45 @@ private static function send_email( $email_notification_key, WP_Job_Manager_Emai
* @param string $content Email content.
* @param array $headers Email headers.
*/
if ( ! apply_filters( 'job_manager_email_do_send_notification', true, $email, $args, $multipart_body, $headers ) ) {
if ( ! apply_filters( 'job_manager_email_do_send_notification', true, $email, $args, $body, $headers ) ) {
continue;
}

if ( wp_mail( $to_email, $args['subject'], $multipart_body, $headers, $args['attachments'] ) ) {
$set_alt_body = function( $mailer ) use ( $content_plain ) {
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$mailer->AltBody = $content_plain;

return $mailer;
};

$set_content_type = fn() => 'multipart/alternative';

if ( ! $is_plain_text_only ) {
add_filter( 'wp_mail_content_type', $set_content_type );
add_filter( 'phpmailer_init', $set_alt_body );
}

if ( wp_mail( $to_email, $args['subject'], $body, $headers, $args['attachments'] ) ) {
$sent_count++;
}

remove_filter( 'wp_mail_content_type', $set_content_type );
remove_filter( 'phpmailer_init', $set_alt_body );

// Make sure AltBody is not sticking around for a different email.
global $phpmailer;

if ( $phpmailer instanceof \PHPMailer\PHPMailer\PHPMailer ) {
// phpcs:ignore WordPress.NamingConventions.ValidVariableName.UsedPropertyNotSnakeCase
$phpmailer->AltBody = '';
}
}

remove_filter( 'wp_mail_content_type', [ __CLASS__, 'mail_content_type' ] );
$job_manager_doing_email = false;

return $sent_count > 0;
}

/**
* Set the "Content Type" header of the e-mail to multipart/alternative.
*
* @access private
*
* @since 2.2.0
*
* @return string
*/
public static function mail_content_type() {
return 'multipart/alternative; boundary="' . self::MULTIPART_BOUNDARY . '"';
}

/**
* Generates the content for an email.
*
Expand Down Expand Up @@ -965,41 +974,4 @@ private static function get_styles() {
return ob_get_clean();
}

/**
* Assemble multipart e-mail body.
*
* @param string $content_html
* @param string $content_plain
*
* @return string
*/
private static function get_multipart_body( string $content_html, string $content_plain ): string {
$multipart_body = '';

if ( ! empty( $content_plain ) ) {

$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '
Content-Type: text/plain; charset="utf-8"

' . $content_plain;
}

if ( ! empty( $content_html ) ) {
$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '
Content-Type: text/html; charset="utf-8"

' . $content_html;
}

if ( ! empty( $multipart_body ) ) {
$multipart_body .= '
--' . self::MULTIPART_BOUNDARY . '--
';
}

return $multipart_body;
}

}
9 changes: 3 additions & 6 deletions includes/class-wp-job-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,14 @@ public function __construct() {
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-wp-job-manager-data-exporter.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-wp-job-manager-com-api.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/promoted-jobs/class-wp-job-manager-promoted-jobs.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-access-token.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-guest-user.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-guest-session.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/class-stats.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-ui.php';
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-ui-settings.php';

if ( is_admin() ) {
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/admin/class-wp-job-manager-admin.php';
}

\WP_Job_Manager\UI\UI::instance();
\WP_Job_Manager\UI\UI_Settings::instance();

// Load 3rd party customizations.
include_once JOB_MANAGER_PLUGIN_DIR . '/includes/3rd-party/3rd-party.php';

Expand Down
4 changes: 1 addition & 3 deletions includes/ui/class-ui-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
* @internal
*/
class UISettings {
class UI_Settings {

use Singleton;

Expand Down Expand Up @@ -333,5 +333,3 @@ public function preview_ui_elements() {

}
}

UISettings::instance();
7 changes: 0 additions & 7 deletions includes/ui/class-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@
exit; // Exit if accessed directly.
}

require_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-ui-elements.php';
require_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-notice.php';
require_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-modal-dialog.php';
require_once JOB_MANAGER_PLUGIN_DIR . '/includes/ui/class-redirect-message.php';

/**
* Frontend UI elements of Job Manager.
*
Expand Down Expand Up @@ -103,5 +98,3 @@ private function generate_inline_css() {
return $css;
}
}

UI::instance();
Loading
Loading