From bc4eadd3430d7548f232062eedcfdbf51ab76c26 Mon Sep 17 00:00:00 2001 From: nithinjohn22 Date: Wed, 20 Mar 2024 12:10:51 +0000 Subject: [PATCH] IMPROVE: Code formatting based on phpcs --- admin/class-awsm-job-openings-settings.php | 94 +++++++++---------- admin/templates/notification.php | 8 +- inc/class-awsm-job-openings-form.php | 46 ++++----- ...lass-awsm-job-openings-mail-customizer.php | 2 +- wp-job-openings.php | 76 +++++++-------- 5 files changed, 113 insertions(+), 113 deletions(-) diff --git a/admin/class-awsm-job-openings-settings.php b/admin/class-awsm-job-openings-settings.php index a40cadc6..9bc90e06 100644 --- a/admin/class-awsm-job-openings-settings.php +++ b/admin/class-awsm-job-openings-settings.php @@ -425,14 +425,14 @@ private function settings() { public static function get_default_settings( $option_name = '' ) { $options = array( - 'awsm_permalink_slug' => 'jobs', - 'awsm_default_msg' => esc_html__( 'We currently have no job openings', 'wp-job-openings' ), - 'awsm_jobs_listing_view' => 'list-view', - 'awsm_jobs_list_per_page' => 10, - 'awsm_jobs_number_of_columns' => 3, - 'awsm_current_appearance_subtab' => 'awsm-job-listing-nav-subtab', - 'awsm_jobs_details_page_layout' => 'single', - 'awsm_jobs_filter' => array( + 'awsm_permalink_slug' => 'jobs', + 'awsm_default_msg' => esc_html__( 'We currently have no job openings', 'wp-job-openings' ), + 'awsm_jobs_listing_view' => 'list-view', + 'awsm_jobs_list_per_page' => 10, + 'awsm_jobs_number_of_columns' => 3, + 'awsm_current_appearance_subtab' => 'awsm-job-listing-nav-subtab', + 'awsm_jobs_details_page_layout' => 'single', + 'awsm_jobs_filter' => array( array( 'taxonomy' => 'job-category', 'filter' => esc_html__( 'Job Category', 'wp-job-openings' ), @@ -447,21 +447,21 @@ public static function get_default_settings( $option_name = '' ) { 'filter' => esc_html__( 'Job Location', 'wp-job-openings' ), ), ), - 'awsm_enable_job_filter_listing' => 'enabled', - 'awsm_jobs_listing_available_filters' => array( 'job-category', 'job-type', 'job-location' ), - 'awsm_jobs_listing_specs' => array( 'job-category', 'job-location' ), - 'awsm_jobs_admin_upload_file_ext' => array( 'pdf', 'doc', 'docx' ), - 'awsm_enable_gdpr_cb' => 'true', - 'awsm_gdpr_cb_text' => esc_html__( 'By using this form you agree with the storage and handling of your data by this website.', 'wp-job-openings' ), - 'awsm_jobs_acknowledgement' => 'acknowledgement', - 'awsm_jobs_notification_subject' => 'Thanks for submitting your application for a job at {company}', - 'awsm_jobs_notification_content' => "Dear {applicant},\n\nThis is to let you know that we have received your application.We appreciate your interest in {company} and the position of {job-title} for which you applied. If you are selected for an interview, you can expect a phone call from our Human Resources staff shortly.\n\n Thank you, again, for your interest in our company. We do appreciate the time that you invested in this application.\n\nSincerely\n\nHR Manager\n{company}", - 'awsm_jobs_enable_admin_notification' => 'enable', - 'awsm_jobs_admin_notification_subject' => 'New application received for the position {job-title} [{job-id}]', - 'awsm_jobs_admin_notification_content' => "Job Opening: {job-title} [{job-id}]\nName: {applicant}\nEmail: {applicant-email}\nPhone: {applicant-phone}\nResume: {applicant-resume}\nCover letter: {applicant-cover}\n\nPowered by WP Job Openings Plugin", - 'awsm_jobs_enable_expiry_notification' => 'enable', - 'awsm_jobs_author_notification_subject' => 'Job Listing Expired', - 'awsm_jobs_author_notification_content' => "This email is to notify you that your job listing for [{job-title}] has just expired. As a result, applicants will no longer be able to apply for this position.\n\nIf you would like to extend the expiration date or remove the listing, please log in to the dashboard and take the necessary steps.\n\nPowered by WP Job Openings Plugin", + 'awsm_enable_job_filter_listing' => 'enabled', + 'awsm_jobs_listing_available_filters' => array( 'job-category', 'job-type', 'job-location' ), + 'awsm_jobs_listing_specs' => array( 'job-category', 'job-location' ), + 'awsm_jobs_admin_upload_file_ext' => array( 'pdf', 'doc', 'docx' ), + 'awsm_enable_gdpr_cb' => 'true', + 'awsm_gdpr_cb_text' => esc_html__( 'By using this form you agree with the storage and handling of your data by this website.', 'wp-job-openings' ), + 'awsm_jobs_acknowledgement' => 'acknowledgement', + 'awsm_jobs_notification_subject' => 'Thanks for submitting your application for a job at {company}', + 'awsm_jobs_notification_content' => "Dear {applicant},\n\nThis is to let you know that we have received your application.We appreciate your interest in {company} and the position of {job-title} for which you applied. If you are selected for an interview, you can expect a phone call from our Human Resources staff shortly.\n\n Thank you, again, for your interest in our company. We do appreciate the time that you invested in this application.\n\nSincerely\n\nHR Manager\n{company}", + 'awsm_jobs_enable_admin_notification' => 'enable', + 'awsm_jobs_admin_notification_subject' => 'New application received for the position {job-title} [{job-id}]', + 'awsm_jobs_admin_notification_content' => "Job Opening: {job-title} [{job-id}]\nName: {applicant}\nEmail: {applicant-email}\nPhone: {applicant-phone}\nResume: {applicant-resume}\nCover letter: {applicant-cover}\n\nPowered by WP Job Openings Plugin", + 'awsm_jobs_enable_expiry_notification' => 'enable', + 'awsm_jobs_author_notification_subject' => 'Job Listing Expired', + 'awsm_jobs_author_notification_content' => "This email is to notify you that your job listing for [{job-title}] has just expired. As a result, applicants will no longer be able to apply for this position.\n\nIf you would like to extend the expiration date or remove the listing, please log in to the dashboard and take the necessary steps.\n\nPowered by WP Job Openings Plugin", ); if ( ! empty( $option_name ) ) { if ( isset( $options[ $option_name ] ) ) { @@ -584,7 +584,7 @@ public function validate_from_email_id( $email ) { if ( preg_match( '/^[0-9.]+$/', $site_domain ) ) { return $email; } - + if ( trim( $email ) === '{default-from-email}' ) { return $email; } @@ -608,9 +608,9 @@ public function validate_from_email_id( $email ) { public function sanitize_from_email_id( $email ) { if ( empty( $email ) ) { - $email = $this->awsm_from_email(true); + $email = $this->awsm_from_email( true ); } - return sanitize_text_field($email); + return sanitize_text_field( $email ); } public function sanitize_list_per_page( $input ) { @@ -985,7 +985,7 @@ public function display_settings_fields( $settings_fields, $container = 'table', 'span' => array(), 'strong' => array(), 'small' => array(), - 'p'=> array('class'=> true), + 'p' => array( 'class' => true ), ); foreach ( $settings_fields as $field_details ) { if ( isset( $field_details['visible'] ) && $field_details['visible'] === false ) { @@ -1261,23 +1261,23 @@ public function get_template_tags() { $template_tags = apply_filters( 'awsm_job_template_tags', array( - '{applicant}' => __( 'Applicant Name:', 'wp-job-openings' ), - '{application-id}' => __( 'Application ID:', 'wp-job-openings' ), - '{applicant-email}' => __( 'Applicant Email:', 'wp-job-openings' ), - '{applicant-phone}' => __( 'Applicant Phone:', 'wp-job-openings' ), - '{applicant-resume}' => __( 'Applicant Resume:', 'wp-job-openings' ), - '{applicant-cover}' => __( 'Cover letter:', 'wp-job-openings' ), - '{job-title}' => __( 'Job Title:', 'wp-job-openings' ), - '{job-id}' => __( 'Job ID:', 'wp-job-openings' ), - '{job-expiry}' => __( 'Job Expiry Date:', 'wp-job-openings' ), - '{site-title}' => __( 'Site Title:', 'wp-job-openings' ), - '{site-tagline}' => __( 'Site Tagline:', 'wp-job-openings' ), - '{site-url}' => __( 'Site URL:', 'wp-job-openings' ), - '{admin-email}' => __( 'Site admin email:', 'wp-job-openings' ), - '{hr-email}' => __( 'HR Email:', 'wp-job-openings' ), - '{company}' => __( 'Company Name:', 'wp-job-openings' ), - '{author-email}' => __( 'Author Email:', 'wp-job-openings' ), - '{default-from-email}' => __( 'Default from email:', 'wp-job-openings' ), + '{applicant}' => __( 'Applicant Name:', 'wp-job-openings' ), + '{application-id}' => __( 'Application ID:', 'wp-job-openings' ), + '{applicant-email}' => __( 'Applicant Email:', 'wp-job-openings' ), + '{applicant-phone}' => __( 'Applicant Phone:', 'wp-job-openings' ), + '{applicant-resume}' => __( 'Applicant Resume:', 'wp-job-openings' ), + '{applicant-cover}' => __( 'Cover letter:', 'wp-job-openings' ), + '{job-title}' => __( 'Job Title:', 'wp-job-openings' ), + '{job-id}' => __( 'Job ID:', 'wp-job-openings' ), + '{job-expiry}' => __( 'Job Expiry Date:', 'wp-job-openings' ), + '{site-title}' => __( 'Site Title:', 'wp-job-openings' ), + '{site-tagline}' => __( 'Site Tagline:', 'wp-job-openings' ), + '{site-url}' => __( 'Site URL:', 'wp-job-openings' ), + '{admin-email}' => __( 'Site admin email:', 'wp-job-openings' ), + '{hr-email}' => __( 'HR Email:', 'wp-job-openings' ), + '{company}' => __( 'Company Name:', 'wp-job-openings' ), + '{author-email}' => __( 'Author Email:', 'wp-job-openings' ), + '{default-from-email}' => __( 'Default from email:', 'wp-job-openings' ), ) ); @@ -1296,11 +1296,11 @@ public static function awsm_from_email( $set_as_empty = false ) { $sitename = substr( $sitename, 4 ); } $from_email = 'noreply@' . $sitename; - if(! $set_as_empty) { + if ( ! $set_as_empty ) { $get_default_from_email = get_option( 'awsm_jobs_notification_customizer' ); - + $from_email = isset( $get_default_from_email['from_email'] ) ? $get_default_from_email['from_email'] : ''; - + if ( $from_email ) { return $from_email; } diff --git a/admin/templates/notification.php b/admin/templates/notification.php index 89023373..257d1c0c 100644 --- a/admin/templates/notification.php +++ b/admin/templates/notification.php @@ -192,9 +192,9 @@ validate_from_email_id( $customizer_settings['from_email'] ) === false ) { - $validation_msg = $from_email_error_msg; - } + if ( $this->validate_from_email_id( $customizer_settings['from_email'] ) === false ) { + $validation_msg = $from_email_error_msg; + } /** * Filters the notification customizer fields. * @@ -223,7 +223,7 @@ 'type' => 'email', 'label' => __( 'Default "From" Email Address: ', 'wp-job-openings' ), 'value' => $customizer_settings['from_email'], - 'description' => $validation_msg ? '

'. $validation_msg.'

' : '', + 'description' => $validation_msg ? '

' . $validation_msg . '

' : '', ), array( 'id' => 'awsm_jobs_notification_customizer_base_color', diff --git a/inc/class-awsm-job-openings-form.php b/inc/class-awsm-job-openings-form.php index c631434a..e9fc20a5 100644 --- a/inc/class-awsm-job-openings-form.php +++ b/inc/class-awsm-job-openings-form.php @@ -707,16 +707,16 @@ public static function get_expired_notification_content() { * @return array */ public static function get_notification_options( $type ) { - $options = array(); - $admin_email = get_option( 'admin_email' ); - $hr_email = get_option( 'awsm_hr_email_address' ); - $expired_options = self::get_expired_notification_content(); + $options = array(); + $admin_email = get_option( 'admin_email' ); + $hr_email = get_option( 'awsm_hr_email_address' ); + $expired_options = self::get_expired_notification_content(); $default_from_email = AWSM_Job_Openings_Settings::awsm_from_email(); if ( $type === 'applicant' ) { $options = array( 'acknowledgement' => get_option( 'awsm_jobs_acknowledgement' ), - 'from' => get_option( 'awsm_jobs_from_email_notification', '{default-from-email}' ), + 'from' => get_option( 'awsm_jobs_from_email_notification', '{default-from-email}' ), 'reply_to' => get_option( 'awsm_jobs_reply_to_notification' ), 'cc' => get_option( 'awsm_jobs_hr_notification', $hr_email ), 'subject' => get_option( 'awsm_jobs_notification_subject', '' ), @@ -726,7 +726,7 @@ public static function get_notification_options( $type ) { } elseif ( $type === 'admin' ) { $options = array( 'enable' => get_option( 'awsm_jobs_enable_admin_notification' ), - 'from' => get_option( 'awsm_jobs_admin_from_email_notification', '{default-from-email}' ), + 'from' => get_option( 'awsm_jobs_admin_from_email_notification', '{default-from-email}' ), 'reply_to' => get_option( 'awsm_jobs_admin_reply_to_notification', '{applicant-email}' ), 'to' => get_option( 'awsm_jobs_admin_to_notification', $hr_email ), 'cc' => get_option( 'awsm_jobs_admin_hr_notification' ), @@ -737,8 +737,8 @@ public static function get_notification_options( $type ) { } elseif ( $type === 'author' ) { $options = array( 'enable' => get_option( 'awsm_jobs_enable_expiry_notification', $expired_options['enable'] ), - 'from' => get_option( 'awsm_jobs_author_from_email_notification', '{default-from-email}' ), - 'reply_to' => get_option( 'awsm_jobs_author_reply_to_notification', get_option( 'awsm_jobs_reply_to_notification') ), + 'from' => get_option( 'awsm_jobs_author_from_email_notification', '{default-from-email}' ), + 'reply_to' => get_option( 'awsm_jobs_author_reply_to_notification', get_option( 'awsm_jobs_reply_to_notification' ) ), 'to' => get_option( 'awsm_jobs_author_to_notification', '{author-email}' ), 'cc' => get_option( 'awsm_jobs_author_hr_notification' ), 'subject' => get_option( 'awsm_jobs_author_notification_subject', $expired_options['subject'] ), @@ -788,34 +788,34 @@ protected function notification_email( $applicant_details, $data = array() ) { } if ( $enable ) { - $admin_email = get_option( 'admin_email' ); - $hr_mail = get_option( 'awsm_hr_email_address' ); - $applicant_email = $applicant_details['awsm_applicant_email']; - $company_name = get_option( 'awsm_job_company_name' ); - $from = ( ! empty( $company_name ) ) ? $company_name : get_option( 'blogname' ); - $author_id = get_post_field( 'post_author', $applicant_details['awsm_job_id'] ); - $author_email = get_the_author_meta( 'user_email', intval( $author_id ) ); + $admin_email = get_option( 'admin_email' ); + $hr_mail = get_option( 'awsm_hr_email_address' ); + $applicant_email = $applicant_details['awsm_applicant_email']; + $company_name = get_option( 'awsm_job_company_name' ); + $from = ( ! empty( $company_name ) ) ? $company_name : get_option( 'blogname' ); + $author_id = get_post_field( 'post_author', $applicant_details['awsm_job_id'] ); + $author_email = get_the_author_meta( 'user_email', intval( $author_id ) ); $default_from_email = AWSM_Job_Openings_Settings::awsm_from_email(); $tags = $this->get_mail_template_tags( $applicant_details, array( - 'admin_email' => $admin_email, - 'hr_email' => $hr_mail, - 'company_name' => $company_name, + 'admin_email' => $admin_email, + 'hr_email' => $hr_mail, + 'company_name' => $company_name, 'default_from_email' => $default_from_email, ) ); $tag_names = array_keys( $tags ); $tag_values = array_values( $tags ); $email_tag_names = array( '{admin-email}', '{hr-email}', '{applicant-email}', '{author-email}', '{default-from-email}' ); - $email_tag_values = array( $admin_email, $hr_mail, $applicant_email, $author_email, $default_from_email ); + $email_tag_values = array( $admin_email, $hr_mail, $applicant_email, $author_email, $default_from_email ); if ( ! empty( $options['subject'] ) && ! empty( $options['content'] ) ) { - $subject = str_replace( $tag_names, $tag_values, $options['subject'] ); - $from_email = str_replace( $tag_names, $tag_values, $options['from'] ); - $reply_to = str_replace( $email_tag_names, $email_tag_values, $options['reply_to'] ); - $cc = str_replace( $email_tag_names, $email_tag_values, $options['cc'] ); + $subject = str_replace( $tag_names, $tag_values, $options['subject'] ); + $from_email = str_replace( $tag_names, $tag_values, $options['from'] ); + $reply_to = str_replace( $email_tag_names, $email_tag_values, $options['reply_to'] ); + $cc = str_replace( $email_tag_names, $email_tag_values, $options['cc'] ); /** * Filters the applicant or admin notification mail headers. diff --git a/inc/class-awsm-job-openings-mail-customizer.php b/inc/class-awsm-job-openings-mail-customizer.php index 69fb2691..19414e90 100644 --- a/inc/class-awsm-job-openings-mail-customizer.php +++ b/inc/class-awsm-job-openings-mail-customizer.php @@ -51,7 +51,7 @@ public static function sanitize_content( $content ) { } public static function get_settings() { - $default_from_email = AWSM_Job_Openings_Settings::awsm_from_email(true); + $default_from_email = AWSM_Job_Openings_Settings::awsm_from_email( true ); /** * Filters the notification customizer default values. * diff --git a/wp-job-openings.php b/wp-job-openings.php index 8863e989..a9b1ea76 100644 --- a/wp-job-openings.php +++ b/wp-job-openings.php @@ -693,9 +693,9 @@ public function send_email_digest() { if ( ! empty( $mail_content ) ) { $tags = self::get_mail_generic_template_tags( array( - 'admin_email' => $admin_email, - 'hr_email' => $to, - 'company_name' => $company_name, + 'admin_email' => $admin_email, + 'hr_email' => $to, + 'company_name' => $company_name, 'default_from_email' => $default_from_email, ) ); @@ -736,18 +736,18 @@ public function send_email_digest() { } public static function get_mail_generic_template_tags( $options = array() ) { - $company_name = isset( $options['company_name'] ) ? $options['company_name'] : get_option( 'awsm_job_company_name' ); - $admin_email = isset( $options['admin_email'] ) ? $options['admin_email'] : get_option( 'admin_email' ); - $hr_email = isset( $options['hr_email'] ) ? $options['hr_email'] : get_option( 'awsm_hr_email_address', '' ); - $default_from_email = isset( $options['default_from_email'] ) ? $options['default_from_email'] : get_option( 'awsm_jobs_from_email_notification', '' ); + $company_name = isset( $options['company_name'] ) ? $options['company_name'] : get_option( 'awsm_job_company_name' ); + $admin_email = isset( $options['admin_email'] ) ? $options['admin_email'] : get_option( 'admin_email' ); + $hr_email = isset( $options['hr_email'] ) ? $options['hr_email'] : get_option( 'awsm_hr_email_address', '' ); + $default_from_email = isset( $options['default_from_email'] ) ? $options['default_from_email'] : get_option( 'awsm_jobs_from_email_notification', '' ); $tags = array( - '{site-title}' => esc_html( get_bloginfo( 'name' ) ), - '{site-tagline}' => esc_html( get_bloginfo( 'description' ) ), - '{site-url}' => esc_url( site_url( '/' ) ), - '{company}' => esc_html( $company_name ), - '{admin-email}' => esc_html( $admin_email ), - '{hr-email}' => esc_html( $hr_email ), + '{site-title}' => esc_html( get_bloginfo( 'name' ) ), + '{site-tagline}' => esc_html( get_bloginfo( 'description' ) ), + '{site-url}' => esc_url( site_url( '/' ) ), + '{company}' => esc_html( $company_name ), + '{admin-email}' => esc_html( $admin_email ), + '{hr-email}' => esc_html( $hr_email ), '{default-from-email}' => $default_from_email, ); @@ -1865,29 +1865,29 @@ public function expiry_notification_handler( $new_status, $old_status, $post ) { if ( $new_status !== 'publish' && $new_status !== $old_status && $post->post_type === 'awsm_job_openings' ) { if ( $new_status === 'expired' ) { if ( $enable_expiry === 'enable' ) { - $job_id = $post->ID; - $admin_email = get_option( 'admin_email' ); - $hr_mail = get_option( 'awsm_hr_email_address' ); - $company_name = get_option( 'awsm_job_company_name' ); - $from = ( ! empty( $company_name ) ) ? $company_name : get_option( 'blogname' ); + $job_id = $post->ID; + $admin_email = get_option( 'admin_email' ); + $hr_mail = get_option( 'awsm_hr_email_address' ); + $company_name = get_option( 'awsm_job_company_name' ); + $from = ( ! empty( $company_name ) ) ? $company_name : get_option( 'blogname' ); $default_from_email = AWSM_Job_Openings_Settings::awsm_from_email(); - $from_email = get_option( 'awsm_jobs_author_from_email_notification', $default_from_email ); - $to = get_option( 'awsm_jobs_author_to_notification' ); - $reply_to = get_option( 'awsm_jobs_author_reply_to_notification', get_option( 'awsm_jobs_reply_to_notification') ); - $cc = get_option( 'awsm_jobs_author_hr_notification' ); - $subject = get_option( 'awsm_jobs_author_notification_subject', $expiry_default_options['subject'] ); - $content = get_option( 'awsm_jobs_author_notification_content', $expiry_default_options['content'] ); - $html_template = get_option( 'awsm_jobs_notification_author_mail_template' ); - $author_id = get_post_field( 'post_author', $job_id ); - $author_email = get_the_author_meta( 'user_email', $author_id ); - $job_expiry = get_post_meta( $job_id, 'awsm_job_expiry', true ); + $from_email = get_option( 'awsm_jobs_author_from_email_notification', $default_from_email ); + $to = get_option( 'awsm_jobs_author_to_notification' ); + $reply_to = get_option( 'awsm_jobs_author_reply_to_notification', get_option( 'awsm_jobs_reply_to_notification' ) ); + $cc = get_option( 'awsm_jobs_author_hr_notification' ); + $subject = get_option( 'awsm_jobs_author_notification_subject', $expiry_default_options['subject'] ); + $content = get_option( 'awsm_jobs_author_notification_content', $expiry_default_options['content'] ); + $html_template = get_option( 'awsm_jobs_notification_author_mail_template' ); + $author_id = get_post_field( 'post_author', $job_id ); + $author_email = get_the_author_meta( 'user_email', $author_id ); + $job_expiry = get_post_meta( $job_id, 'awsm_job_expiry', true ); $tags = $this->get_mail_generic_template_tags( array( - 'admin_email' => $admin_email, - 'hr_email' => $hr_mail, - 'company_name' => $company_name, - 'job_id' => $job_id, + 'admin_email' => $admin_email, + 'hr_email' => $hr_mail, + 'company_name' => $company_name, + 'job_id' => $job_id, 'default_from_email' => $default_from_email, ) ); @@ -1917,12 +1917,12 @@ public function expiry_notification_handler( $new_status, $old_status, $post ) { $email_tag_values = array( $admin_email, $hr_mail, $author_email, $job_id, $job_expiry, $job_title, $default_from_email ); if ( ! empty( $subject ) && ! empty( $content ) ) { - $subject = str_replace( $tag_names, $tag_values, $subject ); - $from_email = str_replace( $tag_names, $tag_values, $from_email ); - $reply_to = str_replace( $email_tag_names, $email_tag_values, $reply_to ); - $cc = str_replace( $email_tag_names, $email_tag_values, $cc ); - $subject = str_replace( $email_tag_names, $email_tag_values, $subject ); - $content = str_replace( $email_tag_names, $email_tag_values, $content ); + $subject = str_replace( $tag_names, $tag_values, $subject ); + $from_email = str_replace( $tag_names, $tag_values, $from_email ); + $reply_to = str_replace( $email_tag_names, $email_tag_values, $reply_to ); + $cc = str_replace( $email_tag_names, $email_tag_values, $cc ); + $subject = str_replace( $email_tag_names, $email_tag_values, $subject ); + $content = str_replace( $email_tag_names, $email_tag_values, $content ); /** * Filters the author notification mail headers.