コード例 #1
0
function WPED_WP_MAIL()
{
    if (function_exists('wp_mail')) {
        WPED()->wp_mail_error = __('The function wp_mail() is already in use by another plugin. WPED will not be able to send for you and has been disabled. ', 'wp-email-delivery');
        wped_set_option('enable_sending', false);
        return;
    }
    if (WPED()->connections->is_connected()) {
        function wp_mail($to, $subject, $message, $headers = '', $attachments = array())
        {
            try {
                $sent = WPED()->connections->mail($to, $subject, $message, $headers, $attachments);
                if (is_wp_error($sent)) {
                    return WPED()->connections->wp_mail($to, $subject, $message, $headers, $attachments);
                }
                return true;
            } catch (Exception $e) {
                return WPED()->connections->wp_mail($to, $subject, $message, $headers, $attachments);
            }
        }
    }
}
function wped_verify_spf()
{
    if (empty($_POST['domain'])) {
        die('-1');
    } else {
        $domain = $_POST['domain'];
    }
    if (!current_user_can('manage_options')) {
        die('-1');
    }
    $url = 'https://gateway.wped.co/';
    //$url = 'http://spnl.dev/';
    $verify_ssl = true;
    if (wped_get_option('enable_nossl')) {
        $verify_ssl = false;
        $url = 'http://api.wped.co/';
        $info['X-WPED'] = "nossl";
    }
    $url = $url . 'domain/spf/' . $domain;
    $response = wp_remote_get($url);
    $body = '';
    if (is_array($response)) {
        $header = $response['headers'];
        // array of http header lines
        $body = $response['body'];
        // use the content
        $b2 = json_decode($body);
    }
    if ($b2->success == true) {
        wped_set_option('spf_verified', $domain);
    } else {
        wped_set_option('spf_verified', false);
    }
    echo $body;
    die;
}
コード例 #3
0
 /**
  * Load settings page content
  * @return void
  */
 public function settings_page()
 {
     if (!WPED()->connections->is_setup()) {
         wped_set_option('enable_sending', false);
     }
     $button_text = esc_attr(__('Save Settings', 'wp-email-delivery'));
     // Build page HTML
     $html = '<div class="wrap" id="' . $this->parent->_token . '_settings">' . "\n";
     $html .= '<h2>' . __('WP Email Delivery', 'wp-email-delivery') . ' <small>v' . $this->parent->_version . '</small></h2>' . "\n";
     if (isset($this->parent->wp_mail_error)) {
         $html .= '</p>' . $this->parent->wp_mail_error . '</p>';
     }
     $tab = '';
     if (isset($_GET['tab']) && $_GET['tab']) {
         $tab .= $_GET['tab'];
     }
     // Show page tabs
     if (is_array($this->settings) && 1 < count($this->settings)) {
         $html .= '<h2 class="nav-tab-wrapper">' . "\n";
         $c = 0;
         foreach ($this->settings as $section => $data) {
             // Set tab class
             $class = 'nav-tab';
             if (!isset($_GET['tab'])) {
                 if (0 == $c) {
                     $class .= ' nav-tab-active';
                     $button_text = isset($data['custom_save']) ? $data['custom_save'] : esc_attr(__('Save Settings', 'wp-email-delivery'));
                 }
             } else {
                 if (isset($_GET['tab']) && $section == $_GET['tab']) {
                     $class .= ' nav-tab-active';
                     $button_text = isset($data['custom_save']) ? $data['custom_save'] : esc_attr(__('Save Settings', 'wp-email-delivery'));
                 }
             }
             // Set tab link
             $tab_link = add_query_arg(array('tab' => $section));
             if (isset($_GET['settings-updated'])) {
                 $tab_link = remove_query_arg('settings-updated', $tab_link);
             }
             // Output tab
             $html .= '<a href="' . $tab_link . '" class="' . esc_attr($class) . '">' . esc_html($data['title']) . '</a>' . "\n";
             ++$c;
         }
         $html .= '</h2>' . "\n";
     }
     $target = "options.php";
     if (wped_is_network_activated()) {
         $target = 'edit.php?action=' . $this->parent->_token . '_settings';
     }
     $html .= '<form method="post" action="' . $target . '" enctype="multipart/form-data">' . "\n";
     // Get settings fields
     ob_start();
     settings_fields($this->parent->_token . '_settings');
     do_settings_sections($this->parent->_token . '_settings');
     $html .= ob_get_clean();
     if ($button_text != 'none') {
         $html .= '<p class="submit">' . "\n";
         $html .= '<input type="hidden" name="tab" value="' . esc_attr($tab) . '" />' . "\n";
         $html .= '<input name="Submit" type="submit" class="button-primary" value="' . $button_text . '" />' . "\n";
         $html .= '</p>' . "\n";
     }
     $html .= '</form>' . "\n";
     if (!WPED()->connections->is_setup()) {
         $html .= "<div style='padding: 30px 40px; border: solid 1px #cdcdcd; background: #fff; margin-top: 5px;'><h2 style='margin-top: 0px; padding-top: 0px;'>Get WP Email Delivery for your site.</h2>";
         $html .= "<p>Try it for free with <strong>50 emails per month</strong>. Sign up at <a target='_blank' href='https://www.wpemaildelivery.com'>https://www.wpemaildelivery.com</a><br>Great for small sites and developers.</p>";
         $html .= '<p>Need more emails per month check out our monthly plans starting at <strong>$5.00 a month for 10,000 emails</strong>.<br>';
         $html .= 'We also have yearly plans starting at <strong>$18 per year for 500 monthly emails</strong>.</p>';
         $html .= "</div>";
     }
     $html .= '</div>' . "\n";
     echo $html;
     $this->templates();
 }