Plugin Directory

Changeset 1334054


Ignore:
Timestamp:
01/22/2016 10:37:55 PM (10 years ago)
Author:
ryuheixys
Message:

Added check for valid email settings, and sent back appropriate response.

Location:
reach-seo/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • reach-seo/trunk/classes/rest-api.php

    r1334005 r1334054  
    136136            $settings = $settings[ 'basic' ];
    137137
     138            // 0. Check that the user has valid email settings
     139            if ( !isset($settings[ 'reachseo-email-host' ]) ||
     140                 !isset($settings[ 'reachseo-email-port' ]) ||
     141                 !isset($settings[ 'reachseo-email-username' ]) ||
     142                 !isset($settings[ 'reachseo-email-password' ]) ) {
     143                return new WP_JSON_Response( array(
     144                    'error' => 'You must add your email settings before sending outreach emails!',
     145                    'code' => 400
     146                ));
     147            }
     148
    138149            try {
    139150                // 1. Setup the Transport
     
    168179                ));
    169180                // 3. update the opportunity in db
    170             } catch( Swift_TransportException $e ) {
    171                 $message = $e->getMessage();
     181            } catch ( Exception $e ) {
     182
     183                if ( $e instanceof Swift_TransportException ) {
     184                    $message = $e->getMessage();
     185                } else {
     186                    $message = 'We could not send your email. This can be a result of invalid email addresses or email settings.';
     187                }
     188
    172189                return new WP_JSON_Response( array(
    173190                    'error' => $message,
    174                     'code' => $e->getCode(),
    175                     'settings' => $settings
     191                    'code' => $e->getCode()
    176192                ));
    177193            }
  • reach-seo/trunk/readme.txt

    r1334005 r1334054  
    44Requires at least: 3.5
    55Tested up to: 4.3.1
    6 Stable tag: 1.0.1
     6Stable tag: trunk
    77License: GPLv3 or later
    88License URI: http://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.