diff options
Diffstat (limited to 'Postman/Postman-Configuration')
-rw-r--r-- | Postman/Postman-Configuration/PostmanConfigurationController.php | 69 | ||||
-rw-r--r-- | Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php | 92 |
2 files changed, 31 insertions, 130 deletions
diff --git a/Postman/Postman-Configuration/PostmanConfigurationController.php b/Postman/Postman-Configuration/PostmanConfigurationController.php index 59fbdb8..c63d6a9 100644 --- a/Postman/Postman-Configuration/PostmanConfigurationController.php +++ b/Postman/Postman-Configuration/PostmanConfigurationController.php @@ -201,13 +201,21 @@ class PostmanConfigurationController { print '<div class="wrap">'; PostmanViewController::outputChildPageHeader( __( 'Settings', 'post-smtp' ), 'advanced_config' ); + + $config_tabs = apply_filters( 'post_smtp_admin_tabs', array( + 'account_config' => __( 'Account', 'post-smtp' ), + 'fallback' => __( 'Fallback', 'post-smtp' ), + 'message_config' => __( 'Message', 'post-smtp' ), + 'logging_config' => __( 'Logging', 'post-smtp' ), + 'advanced_options_config' => __( 'Advanced', 'post-smtp' ), + ) ); + print '<div id="config_tabs"><ul>'; - print sprintf( '<li><a href="#account_config">%s</a></li>', __( 'Account', 'post-smtp' ) ); - print sprintf( '<li><a href="#fallback">%s</a></li>', __( 'Fallback', 'post-smtp' ) ); - print sprintf( '<li><a href="#message_config">%s</a></li>', __( 'Message', 'post-smtp' ) ); - print sprintf( '<li><a href="#logging_config">%s</a></li>', __( 'Logging', 'post-smtp' ) ); - print sprintf( '<li><a href="#advanced_options_config">%s</a></li>', __( 'Advanced', 'post-smtp' ) ); - print sprintf( '<li><a href="#notifications">%s</a></li>', __( 'Notifications', 'post-smtp' ) ); + + foreach ( $config_tabs as $slug => $tab ) : + printf( '<li><a href="#%s">%s</a></li>', $slug, $tab ); + endforeach; + print '</ul>'; print '<form method="post" action="options.php">'; @@ -294,9 +302,9 @@ class PostmanConfigurationController { <th scope="row"><?php _e('Security', 'post-smtp' ); ?></th> <?php $security_options = array( - 'none' => __( 'None', 'post-smtp' ), - 'ssl' => __( 'SSL', 'post-smtp' ), - 'tls' => __( 'TLS', 'post-smtp' ), + 'none' => __( 'None', 'post-smtp' ), + 'ssl' => __( 'SSL', 'post-smtp' ), + 'tls' => __( 'TLS', 'post-smtp' ), ); ?> <td> @@ -313,17 +321,17 @@ class PostmanConfigurationController { </td> </tr> - <tr> - <th scope="row"><?php _e('From Email', 'post-smtp' ); ?></th> - <td> - <input type="email" id="fallback-smtp-from-email" - value="<?php echo $this->options->getFallbackFromEmail(); ?>" - name="postman_options[<?php echo PostmanOptions::FALLBACK_FROM_EMAIL; ?>]" - > - <br> - <small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.", 'post-smtp' ); ?></small> - </td> - </tr> + <tr> + <th scope="row"><?php _e('From Email', 'post-smtp' ); ?></th> + <td> + <input type="email" id="fallback-smtp-from-email" + value="<?php echo $this->options->getFallbackFromEmail(); ?>" + name="postman_options[<?php echo PostmanOptions::FALLBACK_FROM_EMAIL; ?>]" + > + <br> + <small><?php _e( "Use allowed email, for example: If you are using Gmail, type your Gmail adress.", 'post-smtp' ); ?></small> + </td> + </tr> <tr valign=""> <th scope="row"><?php _e( 'Use SMTP Authentication?', 'post-smtp' ); ?></th> @@ -387,24 +395,7 @@ class PostmanConfigurationController { do_settings_sections( PostmanAdminController::ADVANCED_OPTIONS ); print '</section>'; - print '<section id="notifications">'; - do_settings_sections( PostmanAdminController::NOTIFICATIONS_OPTIONS ); - - $currentKey = $this->options->getNotificationService(); - $pushover = $currentKey == 'pushover' ? 'block' : 'none'; - $slack = $currentKey == 'slack' ? 'block' : 'none'; - - echo '<div id="pushover_cred" style="display: ' . $pushover . ';">'; - do_settings_sections( PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED ); - echo '</div>'; - - echo '<div id="slack_cred" style="display: ' . $slack . ';">'; - do_settings_sections( PostmanAdminController::NOTIFICATIONS_SLACK_CRED ); - echo '</div>'; - - do_action( 'post_smtp_notification_settings' ); - - print '</section>'; + do_action( 'post_smtp_settings_menu' ); submit_button(); print '</form>'; @@ -762,7 +753,7 @@ class PostmanManageConfigurationAjaxHandler extends PostmanAbstractAjaxHandler { wp_send_json_success( $response ); } else { /* translators: where %s is the URL to the Connectivity Test page */ - $configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', 'post-smtp' ), PostmanViewController::getPageUrl( PostmanViewController::PORT_TEST_SLUG ) ); + $configuration ['message'] = sprintf( __( 'Postman can\'t find any way to send mail on your system. Run a <a href="%s">connectivity test</a>.', 'post-smtp' ), PostmanViewController::getPageUrl( PostmanConnectivityTestController::PORT_TEST_SLUG ) ); $response ['configuration'] = $configuration; if ( $this->logger->isTrace() ) { $this->logger->trace( 'configuration:' ); diff --git a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php index 705ef23..9c0170b 100644 --- a/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php +++ b/Postman/Postman-Configuration/PostmanRegisterConfigurationSettings.php @@ -186,55 +186,7 @@ class PostmanSettingsRegistry { 'temporaryDirectoryCallback', ), PostmanAdminController::ADVANCED_OPTIONS, PostmanAdminController::ADVANCED_SECTION ); - // Notifications - add_settings_section( PostmanAdminController::NOTIFICATIONS_SECTION, _x( 'Notifications Settings', 'Configuration Section Title', 'post-smtp' ), array( - $this, - 'printNotificationsSectionInfo', - ), PostmanAdminController::NOTIFICATIONS_OPTIONS ); - - add_settings_field( PostmanOptions::NOTIFICATION_SERVICE, _x( 'Notification Service', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'notification_service_callback', - ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); - - // Pushover - add_settings_section( 'pushover_credentials', _x( 'Pushover Credentials', 'Configuration Section Title', 'post-smtp' ), array( - $this, - 'printNotificationsSectionInfo', - ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED ); - - add_settings_field( PostmanOptions::PUSHOVER_USER, _x( 'Pushover User Key', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'pushover_user_callback', - ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' ); - - add_settings_field( PostmanOptions::PUSHOVER_TOKEN, _x( 'Pushover App Token', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'pushover_token_callback', - ), PostmanAdminController::NOTIFICATIONS_PUSHOVER_CRED, 'pushover_credentials' ); - - // Slack - add_settings_section( 'slack_credentials', _x( 'Slack Credentials', 'Configuration Section Title', 'post-smtp' ), array( - $this, - 'printNotificationsSectionInfo', - ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED ); - - add_settings_field( PostmanOptions::SLACK_TOKEN, _x( 'Slack Webhook', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'slack_token_callback', - ), PostmanAdminController::NOTIFICATIONS_SLACK_CRED, 'slack_credentials' ); - - add_settings_field( PostmanOptions::NOTIFICATION_USE_CHROME, _x( 'Push to chrome extension', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'notification_use_chrome_callback', - ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); - - add_settings_field( PostmanOptions::NOTIFICATION_CHROME_UID, _x( 'Chrome Extension UID', 'Configuration Input Field', 'post-smtp' ), array( - $this, - 'notification_chrome_uid_callback', - ), PostmanAdminController::NOTIFICATIONS_OPTIONS, PostmanAdminController::NOTIFICATIONS_SECTION ); - - do_action( 'post_smtp_settings' ); + do_action( 'post_smtp_settings_fields' ); } } @@ -442,48 +394,6 @@ class PostmanSettingsRegistry { printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); } - public function notification_service_callback() { - $inputDescription = __( 'Select the notification service you want to recieve alerts about failed emails.' ); - - $options = apply_filters('post_smtp_notification_service', array( - 'default' => __( 'WP Admin Email', 'post-smtp' ), - 'pushover' => __( 'Pushover', 'post-smtp' ), - 'slack' => __( 'Slack', 'post-smtp' ), - )); - - printf( '<select id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]">', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_SERVICE ); - $currentKey = $this->options->getNotificationService(); - - foreach ( $options as $key => $label ) { - $this->printSelectOption( $label, $key, $currentKey ); - } - - printf( '</select><br/><span class="postman_input_description">%s</span>', $inputDescription ); - } - - public function notification_use_chrome_callback() { - $value = $this->options->useChromeExtension(); - printf( '<input type="checkbox" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" %3$s />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_USE_CHROME, $value ? 'checked="checked"' : '' ); - } - - public function notification_chrome_uid_callback() { - printf( '<input type="password" id="input_%2$s" class="input_%2$s" name="%1$s[%2$s]" value="%3$s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::NOTIFICATION_CHROME_UID, PostmanUtils::obfuscatePassword( $this->options->getNotificationChromeUid() ) ); - } - - public function pushover_user_callback() { - printf( '<input type="password" id="pushover_user" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_USER, $this->options->getPushoverUser() ); - } - - public function pushover_token_callback() { - printf( '<input type="password" id="pushover_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::PUSHOVER_TOKEN, $this->options->getPushoverToken() ); - } - - public function slack_token_callback() { - printf( '<input type="password" id="slack_token" name="%s[%s]" value="%s" />', PostmanOptions::POSTMAN_OPTIONS, PostmanOptions::SLACK_TOKEN, $this->options->getSlackToken() ); - echo '<a target="_blank" href="https://slack.postmansmtp.com/">' . __( 'Get your webhook URL here', 'post-smtp' ) . '</a>'; - - } - private function printSelectOption( $label, $optionKey, $currentKey ) { $optionPattern = '<option value="%1$s" %2$s>%3$s</option>'; printf( $optionPattern, $optionKey, $optionKey == $currentKey ? 'selected="selected"' : '', $label ); |