Skip to content

[WIP] Removing SendGrid UI #3615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions classes/email/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -50,7 +50,7 @@ class Caldera_Forms_Email_Settings {
'key' => false
),
'wp' => array(

),
'method' => 'wp'
);
Expand All @@ -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 );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@riverBanjo This filter is in the right place. A few concerns:

  1. Filter names should be prefeixed with caldera_forms_
  2. $arg1 and $arg2 are undefined. Please delete those.
  3. There are no inline docs

}

/**
Expand Down Expand Up @@ -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
Expand All @@ -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' ] ) ) {
Expand All @@ -159,7 +159,7 @@ public static function save(){
}

wp_send_json_error();

}


Expand All @@ -186,7 +186,7 @@ public static function maybe_add_hooks() {
}

}

}


Expand All @@ -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 ) {
Expand Down Expand Up @@ -261,7 +261,7 @@ public static function ui() {
include CFCORE_PATH . '/ui/emails/settings.php';

}



}
Expand Down Expand Up @@ -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 ] );
Expand All @@ -328,10 +328,10 @@ public static function sanitize_save( $values ){
$values[ $api ] = self::$defaults[ $api ];
}
}


return $values;

}

}
20 changes: 0 additions & 20 deletions ui/emails/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ class="button button-primary"
<option value="wp" <?php if ( 'wp' == Caldera_Forms_Email_Settings::get_method() ) : echo 'selected'; endif; ?> >
<?php esc_html_e( 'WordPress', 'caldera-forms' ); ?>
</option>
<option value="sendgrid" <?php if ( 'sendgrid' == Caldera_Forms_Email_Settings::get_method() ) : echo 'selected'; endif; ?> >
<?php esc_html_e( 'SendGrid', 'caldera-forms' ); ?>
</option>
<option value="caldera" <?php if ( 'caldera' == Caldera_Forms_Email_Settings::get_method() ) : echo 'selected'; endif; ?> disabled >
<?php esc_html_e( 'Caldera (coming soon)', 'caldera-forms' ); ?>
</option>
Expand All @@ -60,23 +57,6 @@ class="button button-primary"
<?php esc_html_e( 'By default Caldera Forms uses WordPress to send emails. You can choose to use another method to increase reliability of emails and reduce server load.', 'caldera-forms' ); ?>
</p>
</div>
<div class="cf-emails-field-group caldera-config-group" id="cf-emails-sendgrid-key-wrap">
<label for="cf-emails-sendgrid-key" id="cf-emails-sendgrid-key-label">
<?php esc_html_e( 'SendGrid API Key', 'caldera-forms' ); ?>
</label>
<div class="cf-emails-field-group">
<input type="text" class="cf-email-settings" id="cf-emails-sendgrid-key" name="cf-emails-sendgrid-key" value="<?php echo esc_attr( Caldera_Forms_Email_Settings::get_key( 'sendgrid' ) ); ?>">
</div>
<p class="description" id="cf-emails-sendgrid-key-desc" style="max-width: 440px; margin-bottom: 12px;">
<?php printf( '<span>%s</span> <span><a href="%s" target="_blank" rel="nofollow" title="%s">%s</a></span>',
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' )
);
?></p>

</div>
<?php echo Caldera_Forms_Email_Settings::nonce_field(); ?>
<br><br>
<div class="field-group">
Expand Down