From ae96b84d6eaa4b25558235508034bb32452f5748 Mon Sep 17 00:00:00 2001 From: Mikey Arce Date: Mon, 5 Feb 2024 14:33:54 -0800 Subject: [PATCH 1/5] Set minDate in jquery datepicker (#2737) --- assets/js/datepicker.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/assets/js/datepicker.js b/assets/js/datepicker.js index 891c62399..1d8e248a5 100644 --- a/assets/js/datepicker.js +++ b/assets/js/datepicker.js @@ -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' ) { From c5fe0425093f7fa9b0d87f82ebb72b265d6449f6 Mon Sep 17 00:00:00 2001 From: Peter Kiss Date: Wed, 14 Feb 2024 11:46:52 +0100 Subject: [PATCH 2/5] Use PHPMailer hook to set up multipart e-mails (#2757) --- ...ass-wp-job-manager-email-notifications.php | 92 +++++++------------ 1 file changed, 32 insertions(+), 60 deletions(-) diff --git a/includes/class-wp-job-manager-email-notifications.php b/includes/class-wp-job-manager-email-notifications.php index 16d2396ee..10d2404ea 100644 --- a/includes/class-wp-job-manager-email-notifications.php +++ b/includes/class-wp-job-manager-email-notifications.php @@ -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. @@ -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; @@ -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 ); } /** @@ -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. * @@ -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. * @@ -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; - } - } From 99d683365c3e6df23b81ee837085280435a870c3 Mon Sep 17 00:00:00 2001 From: Peter Kiss Date: Thu, 15 Feb 2024 14:09:22 +0100 Subject: [PATCH 3/5] Release WP Job Manager 2.2.2 (#2733) --- languages/wp-job-manager.pot | 78 +++++++++++++++++------------------- package-lock.json | 4 +- package.json | 2 +- readme.txt | 2 +- wp-job-manager.php | 4 +- 5 files changed, 42 insertions(+), 48 deletions(-) diff --git a/languages/wp-job-manager.pot b/languages/wp-job-manager.pot index dae947cae..a06e33c51 100644 --- a/languages/wp-job-manager.pot +++ b/languages/wp-job-manager.pot @@ -2,16 +2,16 @@ # This file is distributed under the GPL2+. msgid "" msgstr "" -"Project-Id-Version: WP Job Manager 2.2.1\n" +"Project-Id-Version: WP Job Manager 2.2.2\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wp-job-manager/\n" "Last-Translator: \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-01-31T09:07:35+00:00\n" +"POT-Creation-Date: 2024-02-02T12:24:53+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"X-Generator: WP-CLI 2.5.0\n" +"X-Generator: WP-CLI 2.7.1\n" "X-Domain: wp-job-manager\n" #. Plugin Name of the plugin @@ -381,7 +381,6 @@ msgstr "" msgid "%1$s updated. View" msgstr "" -#. translators: %1$s is the singular name of the job listing post type; %2$s is the URL to view the listing. #: includes/admin/class-wp-job-manager-cpt.php:457 msgid "Custom field updated." msgstr "" @@ -479,7 +478,6 @@ msgstr "" msgid "View" msgstr "" -#. translators: Placeholder %s is the singular label of the job listing post type. #: includes/admin/class-wp-job-manager-cpt.php:567 #: includes/class-wp-job-manager-post-types.php:464 #: includes/class-wp-job-manager-shortcodes.php:454 @@ -1504,7 +1502,6 @@ msgstr[1] "" msgid "You must be logged in to upload files using this method." msgstr "" -#. translators: Placeholder %s is the singular label of the job listing post type. #: includes/class-wp-job-manager-data-exporter.php:51 #: includes/class-wp-job-manager-post-types.php:481 msgid "Company Logo" @@ -1717,7 +1714,6 @@ msgstr "" msgid "Jobs" msgstr "" -#. translators: Placeholder %s is the plural label of the job listing post type. #: includes/class-wp-job-manager-post-types.php:461 msgid "Add New" msgstr "" @@ -1766,7 +1762,7 @@ msgid "This is where you can create and manage %s." msgstr "" #: includes/class-wp-job-manager-post-types.php:522 -#: wp-job-manager-functions.php:377 +#: wp-job-manager-functions.php:381 msgctxt "post status" msgid "Expired" msgstr "" @@ -1779,7 +1775,7 @@ msgstr[0] "" msgstr[1] "" #: includes/class-wp-job-manager-post-types.php:535 -#: wp-job-manager-functions.php:378 +#: wp-job-manager-functions.php:382 msgctxt "post status" msgid "Preview" msgstr "" @@ -1935,7 +1931,6 @@ msgstr "" msgid "Missing submission page." msgstr "" -#. translators: Placeholder %s is the plural label for the job listing post type. #: includes/class-wp-job-manager-shortcodes.php:405 #: includes/widgets/class-wp-job-manager-widget-featured-jobs.php:36 #: includes/widgets/class-wp-job-manager-widget-featured-jobs.php:52 @@ -1972,7 +1967,7 @@ msgid "Continue Submission" msgstr "" #: includes/class-wp-job-manager-shortcodes.php:715 -#: includes/class-wp-job-manager-shortcodes.php:754 +#: includes/class-wp-job-manager-shortcodes.php:755 msgid "Load more listings" msgstr "" @@ -2204,7 +2199,7 @@ msgstr "" #. translators: Placeholder %1$s is field label; %2$s is the file mime type; %3$s is the allowed mime-types. #. translators: %1$s is the file field label; %2$s is the file type; %3$s is the list of allowed file types. #: includes/forms/class-wp-job-manager-form-submit-job.php:500 -#: wp-job-manager-functions.php:1412 +#: wp-job-manager-functions.php:1416 msgid "\"%1$s\" (filetype %2$s) needs to be one of the following file types: %3$s" msgstr "" @@ -2688,12 +2683,12 @@ msgid "Maximum file size: %s." msgstr "" #: templates/form-fields/multiselect-field.php:20 -#: wp-job-manager-functions.php:1179 +#: wp-job-manager-functions.php:1183 msgid "No results match" msgstr "" #: templates/form-fields/multiselect-field.php:20 -#: wp-job-manager-functions.php:1180 +#: wp-job-manager-functions.php:1184 msgid "Select Some Options" msgstr "" @@ -2798,7 +2793,6 @@ msgstr "" msgid "%s submitted successfully. Your listing will be visible once approved." msgstr "" -#. translators: %1$s is the URL to view the listing; %2$s is #: templates/job-submitted.php:61 msgid " View your %2$s" msgstr "" @@ -2816,117 +2810,117 @@ msgstr "" msgid "Requires Attention" msgstr "" -#: wp-job-manager-functions.php:376 +#: wp-job-manager-functions.php:380 msgctxt "post status" msgid "Draft" msgstr "" -#: wp-job-manager-functions.php:379 +#: wp-job-manager-functions.php:383 msgctxt "post status" msgid "Pending approval" msgstr "" -#: wp-job-manager-functions.php:380 +#: wp-job-manager-functions.php:384 msgctxt "post status" msgid "Pending payment" msgstr "" -#: wp-job-manager-functions.php:381 +#: wp-job-manager-functions.php:385 msgctxt "post status" msgid "Active" msgstr "" -#: wp-job-manager-functions.php:382 +#: wp-job-manager-functions.php:386 msgctxt "post status" msgid "Scheduled" msgstr "" -#: wp-job-manager-functions.php:503 +#: wp-job-manager-functions.php:507 msgid "Reset" msgstr "" -#: wp-job-manager-functions.php:507 +#: wp-job-manager-functions.php:511 msgid "RSS" msgstr "" -#: wp-job-manager-functions.php:616 +#: wp-job-manager-functions.php:620 msgid "Invalid email address." msgstr "" -#: wp-job-manager-functions.php:624 +#: wp-job-manager-functions.php:628 msgid "Your email address isn’t correct." msgstr "" -#: wp-job-manager-functions.php:628 +#: wp-job-manager-functions.php:632 msgid "This email is already registered, please choose another one." msgstr "" -#: wp-job-manager-functions.php:939 +#: wp-job-manager-functions.php:943 msgid "Full Time" msgstr "" -#: wp-job-manager-functions.php:940 +#: wp-job-manager-functions.php:944 msgid "Part Time" msgstr "" -#: wp-job-manager-functions.php:941 +#: wp-job-manager-functions.php:945 msgid "Contractor" msgstr "" -#: wp-job-manager-functions.php:942 +#: wp-job-manager-functions.php:946 msgid "Temporary" msgstr "" -#: wp-job-manager-functions.php:943 +#: wp-job-manager-functions.php:947 msgid "Intern" msgstr "" -#: wp-job-manager-functions.php:944 +#: wp-job-manager-functions.php:948 msgid "Volunteer" msgstr "" -#: wp-job-manager-functions.php:945 +#: wp-job-manager-functions.php:949 msgid "Per Diem" msgstr "" -#: wp-job-manager-functions.php:946 +#: wp-job-manager-functions.php:950 msgid "Other" msgstr "" -#: wp-job-manager-functions.php:1013 +#: wp-job-manager-functions.php:1017 msgid "Passwords must be at least 8 characters long." msgstr "" -#: wp-job-manager-functions.php:1178 +#: wp-job-manager-functions.php:1182 msgid "Choose a category…" msgstr "" #. translators: %s is the list of allowed file types. -#: wp-job-manager-functions.php:1415 +#: wp-job-manager-functions.php:1419 msgid "Uploaded files need to be one of the following file types: %s" msgstr "" -#: wp-job-manager-functions.php:1711 +#: wp-job-manager-functions.php:1715 msgid "--" msgstr "" -#: wp-job-manager-functions.php:1712 +#: wp-job-manager-functions.php:1716 msgid "Year" msgstr "" -#: wp-job-manager-functions.php:1713 +#: wp-job-manager-functions.php:1717 msgid "Month" msgstr "" -#: wp-job-manager-functions.php:1714 +#: wp-job-manager-functions.php:1718 msgid "Week" msgstr "" -#: wp-job-manager-functions.php:1715 +#: wp-job-manager-functions.php:1719 msgid "Day" msgstr "" -#: wp-job-manager-functions.php:1716 +#: wp-job-manager-functions.php:1720 msgid "Hour" msgstr "" diff --git a/package-lock.json b/package-lock.json index b55e234b3..aa805bdf9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wp-job-manager", - "version": "2.2.1", + "version": "2.2.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "wp-job-manager", - "version": "2.2.1", + "version": "2.2.2", "license": "GPL-2.0-or-later", "dependencies": { "select2": "4.0.13" diff --git a/package.json b/package.json index 175e31815..41520fa58 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-job-manager", - "version": "2.2.1", + "version": "2.2.2", "description": "WP Job Manager", "author": "Automattic", "license": "GPL-2.0-or-later", diff --git a/readme.txt b/readme.txt index 49c945f64..1ca0fa729 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: job manager, job listing, job board, job management, job lists, job list, Requires at least: 6.2 Tested up to: 6.4 Requires PHP: 7.2 -Stable tag: 2.2.1 +Stable tag: 2.2.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html diff --git a/wp-job-manager.php b/wp-job-manager.php index 8f8539c9e..d4c88fd51 100644 --- a/wp-job-manager.php +++ b/wp-job-manager.php @@ -3,7 +3,7 @@ * Plugin Name: WP Job Manager * Plugin URI: https://wpjobmanager.com/ * Description: Manage job listings from the WordPress admin panel, and allow users to post jobs directly to your site. - * Version: 2.2.1 + * Version: 2.2.2 * Author: Automattic * Author URI: https://wpjobmanager.com/ * Requires at least: 6.2 @@ -21,7 +21,7 @@ } // Define constants. -define( 'JOB_MANAGER_VERSION', '2.2.1' ); +define( 'JOB_MANAGER_VERSION', '2.2.2' ); define( 'JOB_MANAGER_PLUGIN_DIR', untrailingslashit( plugin_dir_path( __FILE__ ) ) ); define( 'JOB_MANAGER_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); define( 'JOB_MANAGER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); From ad6eb6c7e3d5b3b9c35423fff18d1bc7da4799d0 Mon Sep 17 00:00:00 2001 From: WPJM Bot Date: Thu, 15 Feb 2024 13:10:02 +0000 Subject: [PATCH 4/5] Update changelog for 2.2.2 --- changelog.txt | 5 +++++ readme.txt | 19 +++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/changelog.txt b/changelog.txt index b1362b92f..849e17fa1 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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) diff --git a/readme.txt b/readme.txt index 1ca0fa729..c1325dd31 100644 --- a/readme.txt +++ b/readme.txt @@ -147,6 +147,11 @@ You can view (and contribute) translations via the [translate.wordpress.org](htt == Changelog == +### 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) @@ -182,17 +187,3 @@ Fixes: ### 2.1.0 - 2023-11-17 * Fix: Remove public update endpoint and add nonce check (#2642) -### 2.0.0 - 2023-11-17 -* Enhancement: Improve settings descriptions (#2639) -* Enhancement: Add directApply in Google job schema (#2635) -* Enhancement: Add 'Don't show this again' link to dismiss promote job modal in the editor (#2632) -* Enhancement: Add landing pages for Applications and Resumes extensions (#2621) -* Fix: Align actions in notices in the center (#2637) -* Fix: Safeguard array in WP_Job_Manager_Settings::input_capabilities (#2631) -* Fix: Escape menu titles and various admin labels (#2630) -* Fix: Incorrectly duplicated string in settings (#2628) -* Fix: Add array initialization to avoid warning (#2619) -* Fix: Do not check for plugin updates when there are no plugins (#2605) -* Change: Reorganize administration menu (#2621) -* Change: Update naming from Add-ons to Extensions, Marketplace (#2621) - From e042ce976d3bddd5ece48bb0b2650bd972a8e6e2 Mon Sep 17 00:00:00 2001 From: Peter Kiss Date: Mon, 19 Feb 2024 13:43:03 +0100 Subject: [PATCH 5/5] Add class autoloader (#2756) --- includes/class-wp-job-manager.php | 8 ++- includes/ui/class-ui-settings.php | 4 +- includes/ui/class-ui.php | 7 --- wp-job-manager-autoload.php | 86 +++++++++++++++++++++++++++++++ wp-job-manager.php | 4 ++ 5 files changed, 94 insertions(+), 15 deletions(-) create mode 100644 wp-job-manager-autoload.php diff --git a/includes/class-wp-job-manager.php b/includes/class-wp-job-manager.php index d25c92096..b996824a1 100644 --- a/includes/class-wp-job-manager.php +++ b/includes/class-wp-job-manager.php @@ -77,16 +77,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/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'; diff --git a/includes/ui/class-ui-settings.php b/includes/ui/class-ui-settings.php index 5d79f1ac5..0fed89303 100644 --- a/includes/ui/class-ui-settings.php +++ b/includes/ui/class-ui-settings.php @@ -21,7 +21,7 @@ * * @internal */ -class UISettings { +class UI_Settings { use Singleton; @@ -333,5 +333,3 @@ public function preview_ui_elements() { } } - -UISettings::instance(); diff --git a/includes/ui/class-ui.php b/includes/ui/class-ui.php index 84cb29c1c..a899223c8 100644 --- a/includes/ui/class-ui.php +++ b/includes/ui/class-ui.php @@ -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. * @@ -103,5 +98,3 @@ private function generate_inline_css() { return $css; } } - -UI::instance(); diff --git a/wp-job-manager-autoload.php b/wp-job-manager-autoload.php new file mode 100644 index 000000000..2de528282 --- /dev/null +++ b/wp-job-manager-autoload.php @@ -0,0 +1,86 @@ + directory mappings. + * + * @var array + */ + private static $autoload_map = []; + + /** + * Add the autoloader. + */ + public static function init() { + spl_autoload_register( [ self::class, 'autoload' ] ); + } + + /** + * Register a new plugin with a class prefix and directory to autoload. + * + * @param string $namespace Root namespace. Should start with WP_Job_Manager_. + * @param string $dir Directory to autoload. + */ + public static function register( $namespace, $dir ) { + self::$autoload_map[ $namespace ] = $dir; + } + + /** + * Autoload plugin classes. + * + * @access private + * + * @param string $class_name Class name. + */ + public static function autoload( $class_name ) { + + if ( ! str_starts_with( $class_name, 'WP_Job_Manager' ) || ! str_contains( $class_name, '\\' ) ) { + return; + } + + [ $namespace, $file_name ] = explode( '\\', $class_name, 2 ); + + if ( empty( $namespace ) || empty( $file_name ) || empty( self::$autoload_map[ $namespace ] ) ) { + return; + } + + $root_dir = self::$autoload_map[ $namespace ]; + + $file_name = strtolower( $file_name ); + $dirs = explode( '\\', $file_name ); + $file_name = array_pop( $dirs ); + $file_name = str_replace( '_', '-', $file_name ); + + $file_dir = implode( '/', [ $root_dir, ...$dirs ] ); + + $file_paths = [ + 'class-' . $file_name . '.php', + 'trait-' . $file_name . '.php', + ]; + + foreach ( $file_paths as $file_path ) { + $file_path = $file_dir . '/' . $file_path; + if ( file_exists( $file_path ) ) { + require $file_path; + return; + } + } + + } + +} diff --git a/wp-job-manager.php b/wp-job-manager.php index d4c88fd51..fbb25f095 100644 --- a/wp-job-manager.php +++ b/wp-job-manager.php @@ -26,6 +26,10 @@ define( 'JOB_MANAGER_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) ); define( 'JOB_MANAGER_PLUGIN_BASENAME', plugin_basename( __FILE__ ) ); +require_once dirname( __FILE__ ) . '/wp-job-manager-autoload.php'; +WP_Job_Manager_Autoload::init(); +WP_Job_Manager_Autoload::register( 'WP_Job_Manager', JOB_MANAGER_PLUGIN_DIR . '/includes' ); + require_once dirname( __FILE__ ) . '/includes/class-wp-job-manager-dependency-checker.php'; if ( ! WP_Job_Manager_Dependency_Checker::check_dependencies() ) { return;