From 226cb08b719ba679a0daaeda7732b56b765cc082 Mon Sep 17 00:00:00 2001
From: riverBanjo
Date: Wed, 26 Aug 2020 17:15:29 -0400
Subject: [PATCH] Removes SendGrid API Key setting from the Email Settings and
SendGrid Option from the Email System setting. Also, adds filter to allow
users to change email settings should they so choose to use SendGrid.
---
classes/email/settings.php | 36 ++++++++++++++++++------------------
ui/emails/settings.php | 20 --------------------
2 files changed, 18 insertions(+), 38 deletions(-)
diff --git a/classes/email/settings.php b/classes/email/settings.php
index 0dcf2d26b..1d86466e6 100755
--- a/classes/email/settings.php
+++ b/classes/email/settings.php
@@ -31,9 +31,9 @@ class Caldera_Forms_Email_Settings {
/**
* Nonce action for settings UI
- *
+ *
* @since 1.4.0
- *
+ *
* @var string
*/
protected static $nonce_action = 'cf-emails';
@@ -50,7 +50,7 @@ class Caldera_Forms_Email_Settings {
'key' => false
),
'wp' => array(
-
+
),
'method' => 'wp'
);
@@ -67,8 +67,8 @@ public static function get_settings() {
self::$settings = get_option( self::$option_key, array() );
self::$settings = wp_parse_args( self::$settings, self::$defaults );
}
-
- return self::$settings;
+
+ return apply_filters( 'change_email_settings', self::$settings, $arg1, $arg2 );
}
/**
@@ -114,9 +114,9 @@ public static function save_key( $api, $key, $save = true ) {
/**
* Check if is an allowed API
- *
+ *
* @since 1.4.0
- *
+ *
* @param string $api Name of API
*
* @return bool
@@ -128,16 +128,16 @@ public static function is_allowed_method( $api ){
/**
* Save email settings
- *
+ *
* @uses "wp_ajax_cf_email_save" action
- *
+ *
* @since 1.3.5
*/
public static function save(){
if( ! current_user_can( Caldera_Forms::get_manage_cap( 'admin' ) ) ) {
wp_die();
}
-
+
if( isset( $_POST[ 'nonce' ] ) && wp_verify_nonce( $_POST[ 'nonce' ], self::$nonce_action ) ){
if( isset( $_POST[ 'method' ] ) ){
if ( self::is_allowed_method( $_POST[ 'method' ] ) ) {
@@ -159,7 +159,7 @@ public static function save(){
}
wp_send_json_error();
-
+
}
@@ -186,7 +186,7 @@ public static function maybe_add_hooks() {
}
}
-
+
}
@@ -210,7 +210,7 @@ public static function nonce_field(){
* @since 1.4.0
*
* @param string $api API name
-
+
* @return bool
*/
protected static function valid( $api ) {
@@ -261,7 +261,7 @@ public static function ui() {
include CFCORE_PATH . '/ui/emails/settings.php';
}
-
+
}
@@ -306,7 +306,7 @@ public static function sanitize_save( $values ){
if( ! is_array( $values ) ){
return self::$defaults;
}
-
+
foreach ( $values as $key => $value ){
if( ! array_key_exists( $key, self::$defaults ) ){
unset( $values[ $key ] );
@@ -328,10 +328,10 @@ public static function sanitize_save( $values ){
$values[ $api ] = self::$defaults[ $api ];
}
}
-
-
+
+
return $values;
-
+
}
}
diff --git a/ui/emails/settings.php b/ui/emails/settings.php
index 5fdeb62c5..43bf2d9c1 100755
--- a/ui/emails/settings.php
+++ b/ui/emails/settings.php
@@ -48,9 +48,6 @@ class="button button-primary"
-
@@ -60,23 +57,6 @@ class="button button-primary"
-
-
-
-
-
-
- %s %s',
- esc_html__( 'SendGrid API Key', 'caldera-forms' ),
- 'https://CalderaWP.com/docs/configure-sendgrid',
- esc_attr__( 'Documentation for configuring SendGrid API', 'caldera-forms' ),
- esc_html__( 'Learn More', 'caldera-forms' )
- );
- ?>
-
-