Skip to content

Commit

Permalink
2.0.23
Browse files Browse the repository at this point in the history
* Fixed: WP_Scripts::localize called incorrectly message.
  • Loading branch information
smusman98 committed Jul 18, 2022
1 parent 63a97d9 commit 835ae5b
Show file tree
Hide file tree
Showing 19 changed files with 146 additions and 145 deletions.
29 changes: 29 additions & 0 deletions Postman/Localize.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php
$warning = __( 'Warning', 'post-smtp' );

return array(
/* translators: where %s is the name of the SMTP server */
'postman_smtp_mitm' => sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ),
/* translators: where %d is a port number */
'postman_wizard_bad_redirect_url' => __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', 'post-smtp' ),
'postman_input_sender_email' => '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL,
'postman_input_sender_name' => '#input_' . PostmanOptions::MESSAGE_SENDER_NAME,
'postman_port_element_name' => '#input_' . PostmanOptions::PORT,
'postman_hostname_element_name' => '#input_' . PostmanOptions::HOSTNAME,
'postman_enc_for_password_el' => '#input_enc_type_password',
'postman_input_basic_username' => '#input_' . PostmanOptions::BASIC_AUTH_USERNAME,
'postman_input_basic_password' => '#input_' . PostmanOptions::BASIC_AUTH_PASSWORD,
'postman_redirect_url_el' => '#input_oauth_redirect_url',
'postman_input_auth_type' => '#input_' . PostmanOptions::AUTHENTICATION_TYPE,
'postman_js_email_was_resent' => __( 'Email was successfully resent (but without attachments)', 'post-smtp' ),
/* Translators: Where %s is an error message */
'postman_js_email_not_resent' => __( 'Email could not be resent. Error: %s', 'post-smtp' ),
'postman_js_resend_label' => __( 'Resend', 'post-smtp' ),
'steps_current_step' => 'steps_current_step',
'steps_pagination' => 'steps_pagination',
'steps_finish' => _x( 'Finish', 'Press this button to Finish this task', 'post-smtp' ),
'steps_next' => _x( 'Next', 'Press this button to go to the next step', 'post-smtp' ),
'steps_previous' => _x( 'Previous', 'Press this button to go to the previous step', 'post-smtp' ),
'steps_loading' => 'steps_loading'
);

26 changes: 2 additions & 24 deletions Postman/Postman-Configuration/PostmanConfigurationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,28 +100,6 @@ private function registerStylesAndScripts() {
/**
*/
private function addLocalizeScriptsToPage() {
$warning = __( 'Warning', 'post-smtp' );
/* translators: where %s is the name of the SMTP server */
wp_localize_script( 'postman_wizard_script', 'postman_smtp_mitm', sprintf( '%s: %s', $warning, __( 'connected to %1$s instead of %2$s.', 'post-smtp' ) ) );
/* translators: where %d is a port number */
wp_localize_script( 'postman_wizard_script', 'postman_wizard_bad_redirect_url', __( 'You are about to configure OAuth 2.0 with an IP address instead of a domain name. This is not permitted. Either assign a real domain name to your site or add a fake one in your local host file.', 'post-smtp' ) );

// user input
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_email', '#input_' . PostmanOptions::MESSAGE_SENDER_EMAIL );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_sender_name', '#input_' . PostmanOptions::MESSAGE_SENDER_NAME );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_port_element_name', '#input_' . PostmanOptions::PORT );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME );

// the enc input
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_enc_for_password_el', '#input_enc_type_password' );
// these are the ids for the <option>s in the encryption <select>
// the password inputs
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_basic_username', '#input_' . PostmanOptions::BASIC_AUTH_USERNAME );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_basic_password', '#input_' . PostmanOptions::BASIC_AUTH_PASSWORD );

// the auth input
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_redirect_url_el', '#input_oauth_redirect_url' );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_input_auth_type', '#input_' . PostmanOptions::AUTHENTICATION_TYPE );

// the transport modules scripts
foreach ( PostmanTransportRegistry::getInstance()->getTransports() as $transport ) {
Expand Down Expand Up @@ -187,7 +165,7 @@ function enqueueWizardResources() {
wp_enqueue_style( 'jquery_steps_style' );
wp_enqueue_style( PostmanViewController::POSTMAN_STYLE );
wp_enqueue_script( 'postman_wizard_script' );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, '$jq', 'jQuery.noConflict(true)' );
//wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, '$jq', 'jQuery.noConflict(true)' );
$shortLocale = substr( get_locale(), 0, 2 );
if ( $shortLocale != 'en' ) {
$url = plugins_url( sprintf( 'script/jquery-validate/localization/messages_%s.js', $shortLocale ), $this->rootPluginFilenameAndPath );
Expand Down Expand Up @@ -601,7 +579,7 @@ public function outputWizardContent() {
Postman::getMailerTypeRecommend();

$in_wizard = true;
include_once POST_SMTP_PATH . '/Postman/extra/donation.php';
//include_once POST_SMTP_PATH . '/Postman/extra/donation.php';

print '</section>';
print '</fieldset>';
Expand Down
10 changes: 5 additions & 5 deletions Postman/Postman-Configuration/postman_manual_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jQuery(document).ready(
Hook.call( 'post_smtp_notification_change', selected );

});


// add an event on the authentication input field
// on user changing the auth type, determine whether to show
Expand All @@ -61,23 +61,23 @@ jQuery(document).ready(

// add an event on the hostname input field
// on keyup, start the countdown
jQuery(postman_hostname_element_name).keyup(function() {
jQuery(post_smtp_localize.postman_hostname_element_name).keyup(function() {
clearTimeout(typingTimer);
if (jQuery(postman_hostname_element_name).val) {
if (jQuery(post_smtp_localize.postman_hostname_element_name).val) {
typingTimer = setTimeout(doneTyping, doneTypingInterval);
}
});

// user is "finished typing," do something
function doneTyping() {
if (jQuery(postman_input_auth_type).val() == 'oauth2') {
if (jQuery(post_smtp_localize.postman_input_auth_type).val() == 'oauth2') {
reloadOauthSection();
}
}
});

function reloadOauthSection() {
var hostname = jQuery(postman_hostname_element_name).val();
var hostname = jQuery(post_smtp_localize.postman_hostname_element_name).val();
var transport = jQuery('#input_transport_type').val();
var authtype = jQuery('select#input_auth_type').val();
var security = jQuery('#security').val();
Expand Down
76 changes: 38 additions & 38 deletions Postman/Postman-Configuration/postman_wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ portTestInProgress = false;
* Functions to run on document load
*/
jQuery(document).ready(function() {
jQuery(postman_input_sender_email).focus();
jQuery(post_smtp_localize.postman_input_sender_email).focus();
initializeJQuerySteps();
// add an event on the plugin selection
jQuery('input[name="input_plugin"]').click(function() {
Expand Down Expand Up @@ -63,7 +63,7 @@ function checkEmail(goDaddyHostDetected, email) {
smtpDiscovery = response.data;
if (response.data.hostname != null
&& response.data.hostname) {
jQuery(postman_hostname_element_name).val(
jQuery(post_smtp_localize.postman_hostname_element_name).val(
response.data.hostname);
}
enableSmtpHostnameInput(goDaddyHostDetected);
Expand Down Expand Up @@ -108,20 +108,20 @@ function initializeJQuerySteps() {
autoFocus : true,
startIndex : parseInt(postman_setup_wizard.start_page),
labels : {
current : steps_current_step,
pagination : steps_pagination,
finish : steps_finish,
next : steps_next,
previous : steps_previous,
loading : steps_loading
current : post_smtp_localize.steps_current_step,
pagination : post_smtp_localize.steps_pagination,
finish : post_smtp_localize.steps_finish,
next : post_smtp_localize.steps_next,
previous : post_smtp_localize.steps_previous,
loading : post_smtp_localize.steps_loading
},
onStepChanging : function(event, currentIndex, newIndex) {
return handleStepChange(event, currentIndex, newIndex,
jQuery(this));

},
onInit : function() {
jQuery(postman_input_sender_email).focus();
jQuery(post_smtp_localize.postman_input_sender_email).focus();
},
onStepChanged : function(event, currentIndex, priorIndex) {
return postHandleStepChange(event, currentIndex,
Expand Down Expand Up @@ -191,7 +191,7 @@ function handleStepChange(event, currentIndex, newIndex, form) {
if (currentIndex === 1) {
// page 1 : look-up the email
// address for the smtp server
checkGoDaddyAndCheckEmail(jQuery(postman_input_sender_email).val());
checkGoDaddyAndCheckEmail(jQuery(post_smtp_localize.postman_input_sender_email).val());

} else if (currentIndex === 2) {

Expand All @@ -203,7 +203,7 @@ function handleStepChange(event, currentIndex, newIndex, form) {
portsToCheck = 0;
totalAvail = 0;

getHostsToCheck(jQuery(postman_hostname_element_name).val());
getHostsToCheck(jQuery(post_smtp_localize.postman_hostname_element_name).val());

} else if (currentIndex === 3) {

Expand All @@ -219,9 +219,9 @@ function handleStepChange(event, currentIndex, newIndex, form) {
if (!valid) {
return false;
}
var chosenPort = jQuery(postman_port_element_name).val();
var hostname = jQuery(postman_hostname_element_name).val();
var authType = jQuery(postman_input_auth_type).val()
var chosenPort = jQuery(post_smtp_localize.postman_port_element_name).val();
var hostname = jQuery(post_smtp_localize.postman_hostname_element_name).val();
var authType = jQuery(post_smtp_localize.postman_input_auth_type).val()

}

Expand All @@ -234,7 +234,7 @@ function postHandleStepChange(event, currentIndex, priorIndex, myself) {
// the user is old enough and wants
// to the previous step.
if (currentIndex === 2) {
jQuery(postman_hostname_element_name).focus();
jQuery(post_smtp_localize.postman_hostname_element_name).focus();
// this is the second place i disable the next button but Steps
// re-enables it after the screen slides
if (priorIndex === 1) {
Expand All @@ -253,7 +253,7 @@ function postHandleStepChange(event, currentIndex, priorIndex, myself) {
}
if (currentIndex === 4) {
if (redirectUrlWarning) {
alert(postman_wizard_bad_redirect_url);
alert(post_smtp_localize.postman_wizard_bad_redirect_url);
}
if (chosenPort == 'none') {
if (priorIndex === 5) {
Expand All @@ -269,7 +269,7 @@ function postHandleStepChange(event, currentIndex, priorIndex, myself) {

/**
* Asks the server for a List of sockets to perform port checks upon.
*
*
* @param hostname
*/
function getHostsToCheck(hostname) {
Expand Down Expand Up @@ -298,7 +298,7 @@ function getHostsToCheck(hostname) {

/**
* Handles the response from the server of the list of sockets to check.
*
*
* @param hostname
* @param response
*/
Expand All @@ -323,7 +323,7 @@ function handleHostsToCheckResponse(response) {

/**
* Asks the server to run a connectivity test on the given port
*
*
* @param hostname
* @param port
* @param data
Expand All @@ -342,7 +342,7 @@ function postThePortTest(hostname, port, data) {

/**
* Handles the result of the port test
*
*
* @param hostname
* @param port
* @param data
Expand All @@ -368,7 +368,7 @@ function handlePortTestResponse(hostname, port, data, response) {
}

/**
*
*
* @param message
*/
function updateStatus(message) {
Expand Down Expand Up @@ -502,7 +502,7 @@ function handleConfigurationResponse(response) {

jQuery('select#input_notification_service').change(function() {
var selected = jQuery( this ).val();

if ( selected == 'default' ) {
jQuery('#slack_cred').fadeOut('fast');
jQuery('#pushover_cred').fadeOut('fast');
Expand Down Expand Up @@ -554,7 +554,7 @@ function getConfiguration() {
var data = {
'action' : 'import_configuration',
'plugin' : plugin,
'_wpnonce' : jQuery('#_wpnonce').val(),
'security' : jQuery('#security').val(),
};
jQuery
.post(
Expand All @@ -564,36 +564,36 @@ function getConfiguration() {
if (response.success) {
jQuery('select#input_transport_type').val(
'smtp');
jQuery(postman_input_sender_email).val(
jQuery(post_smtp_localize.postman_input_sender_email).val(
response.sender_email);
jQuery(postman_input_sender_name).val(
jQuery(post_smtp_localize.postman_input_sender_name).val(
response.sender_name);
jQuery(postman_hostname_element_name).val(
jQuery(post_smtp_localize.postman_hostname_element_name).val(
response.hostname);
jQuery(postman_port_element_name).val(
jQuery(post_smtp_localize.postman_port_element_name).val(
response.port);
jQuery(postman_input_auth_type).val(
jQuery(post_smtp_localize.postman_input_auth_type).val(
response.auth_type);
jQuery('#input_enc_type')
.val(response.enc_type);
jQuery(postman_input_basic_username).val(
jQuery(post_smtp_localize.postman_input_basic_username).val(
response.basic_auth_username);
jQuery(postman_input_basic_password).val(
jQuery(post_smtp_localize.postman_input_basic_password).val(
response.basic_auth_password);
switchBetweenPasswordAndOAuth();
}
}).fail(function(response) {
ajaxFailed(response);
});
} else {
jQuery(postman_input_sender_email).val('');
jQuery(postman_input_sender_name).val('');
jQuery(postman_input_basic_username).val('');
jQuery(postman_input_basic_password).val('');
jQuery(postman_hostname_element_name).val('');
jQuery(postman_port_element_name).val('');
jQuery(postman_input_auth_type).val('none');
jQuery(postman_enc_for_password_el).val('none');
jQuery(post_smtp_localize.postman_input_sender_email).val('');
jQuery(post_smtp_localize.postman_input_sender_name).val('');
jQuery(post_smtp_localize.postman_input_basic_username).val('');
jQuery(post_smtp_localize.postman_input_basic_password).val('');
jQuery(post_smtp_localize.postman_hostname_element_name).val('');
jQuery(post_smtp_localize.postman_port_element_name).val('');
jQuery(post_smtp_localize.postman_input_auth_type).val('none');
jQuery(post_smtp_localize.postman_enc_for_password_el).val('none');
switchBetweenPasswordAndOAuth();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function enqueuePortTestResources() {
wp_enqueue_style( PostmanViewController::POSTMAN_STYLE );
wp_enqueue_script( 'postman_port_test_script' );
$warning = __( 'Warning', 'post-smtp' );
wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_hostname_element_name', '#input_' . PostmanOptions::HOSTNAME );

wp_localize_script( PostmanViewController::POSTMAN_SCRIPT, 'postman_email_test', array(
'recipient' => '#' . PostmanSendTestEmailController::RECIPIENT_EMAIL_FIELD_NAME,
'not_started' => _x( 'In Outbox', 'Email Test Status', 'post-smtp' ),
Expand Down
10 changes: 5 additions & 5 deletions Postman/Postman-Connectivity-Test/postman_port_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ postman_begin_test_button_id = 'input#begin-port-test';

jQuery(document).ready(function() {
var elHostname = jQuery(postman_begin_test_button_id);
jQuery(postman_hostname_element_name).focus();
jQuery(post_smtp_localize.postman_hostname_element_name).focus();
elHostname.click(function() {
valid = jQuery('#port_test_form_id').valid();
if (!valid) {
Expand All @@ -20,7 +20,7 @@ jQuery(document).ready(function() {
$elTestingTable.show();
show('.portquiz');

var hostname = jQuery(postman_hostname_element_name).val();
var hostname = jQuery(post_smtp_localize.postman_hostname_element_name).val();
var data = {
'action' : 'postman_get_hosts_to_test',
'hostname' : hostname,
Expand All @@ -45,7 +45,7 @@ jQuery(document).ready(function() {

/**
* Handles the response from the server of the list of sockets to check.
*
*
* @param hostname
* @param response
*/
Expand Down Expand Up @@ -262,7 +262,7 @@ function enableButtonCheck() {
if (totalPortsTested >= portsToBeTested) {
enable(postman_begin_test_button_id);
hideLoaderIcon();
jQuery(postman_hostname_element_name).focus();
jQuery(post_smtp_localize.postman_hostname_element_name).focus();
}
}
function inspectResponse(id, response, port) {
Expand Down Expand Up @@ -333,4 +333,4 @@ function addConclusion(message, success, isSecure) {
message = '&#10060; ' + secureIcon + message;
}
jQuery('ol.conclusion').append('<li>' + message + '</li>');
}
}
Loading

0 comments on commit 835ae5b

Please sign in to comment.