close

Plugin Directory

Changeset 3255467


Ignore:
Timestamp:
03/13/2025 03:39:29 PM (14 months ago)
Author:
dueclic
Message:

Update to version 4.9.1 from GitHub

Location:
turbosmtp
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • turbosmtp/tags/4.9.1/README.md

    r3254931 r3255467  
    44Requires at least: 6.0
    55Tested up to: 6.7.1
    6 Stable tag: 4.9.0
     6Stable tag: 4.9.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2929
    3030== Changelog ==
     31
     32= 4.9.1 =
     33* Better handling of From / From name in API / SMTP sending
    3134
    3235= 4.9.0 =
  • turbosmtp/tags/4.9.1/admin/class-turbosmtp-admin.php

    r3254918 r3255467  
    7979            $turbosmtp_hosts = turbosmtp_valid_hosts();
    8080            $send_options    = get_option( "ts_send_options" );
     81
    8182            $user_config     = $this->api->get_user_config();
     83
     84            if (!isset($send_options['email'])){
     85                $send_options['email'] = $user_config['email'];
     86            }
     87
     88            if (!isset($send_options['host'])){
     89                $send_options['host'] = 'pro.turbo-smtp.com';
     90            }
     91
     92            if (!isset($send_options['smtpsecure'])){
     93                $send_options['smtpsecure'] = 'ssl';
     94            }
     95
     96            if (!isset($send_options['port'])){
     97                $send_options['port'] = 465;
     98            }
     99
     100            if (!isset($send_options['port'])){
     101                $send_options['port'] = 465;
     102            }
     103
    82104            $current_user    = wp_get_current_user();
    83105            require_once plugin_dir_path( TURBOSMTP_BASE_PATH ) . '/admin/partials/configuration.php';
     
    282304        }
    283305        require_once plugin_dir_path( TURBOSMTP_BASE_PATH ) . '/admin/partials/credentials.php';
     306    }
     307
     308    /**
     309     * Register the shortcut for the settings area.
     310     *
     311     * @since    1.0.0
     312     */
     313    public function settings_link( $links, $file ) {
     314        if ( is_network_admin() ) {
     315            $settings_url = network_admin_url( 'admin.php?page=turbosmtp_config' );
     316        } else {
     317            $settings_url = admin_url( 'admin.php?page=turbosmtp_config' );
     318        }
     319
     320        $settings_link = '<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'turbosmtp' ) . '</a>';
     321        array_unshift( $links, $settings_link );
     322
     323        return $links;
    284324    }
    285325
  • turbosmtp/tags/4.9.1/admin/partials/configuration.php

    r3254918 r3255467  
    1818 */
    1919
    20 ?>
    21 
    22 <?php
    2320
    2421$send_method = $send_options['is_smtp'] ? 'smtp' : 'api';
     
    203200                                    <p>
    204201                                        <input id="turboSMTP_mail_smtpsecure_none" name="ts_smtp_smtpsecure" type="radio"
    205                                                value=""<?php if ($send_options["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
     202                                               value="" <?php if ($send_options["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
    206203                                        <label for="ts_smtp_smtpsecure">
    207204                                            <?php _e("No encryption (non-SSL)", "turbosmtp"); ?>
  • turbosmtp/tags/4.9.1/common-api.php

    r3254918 r3255467  
    131131}
    132132
    133 function turbosmtp_get_header_content_type(
     133function turbosmtp_get_headers_data(
    134134    $headers
    135135) {
    136136
    137     $content_type = "text/plain";
     137    $data = [
     138        "content-type" => "text/plain",
     139        "from"         => "",
     140        "fromname"     => "",
     141        "cc" => [],
     142        "bcc" => [],
     143        "reply-to" => []
     144    ];
    138145
    139146    if ( ! is_array( $headers ) ) {
     
    150157            list( $name, $content ) = explode( ':', trim( $header ), 2 );
    151158
    152             if (strtolower($name) === 'content-type') {
    153 
    154                 if ( str_contains( $content, ';' ) ) {
    155                     list( $type ) = explode( ';', $content );
    156                     $content_type = trim( $type );
    157                 } elseif ( '' !== trim( $content ) ) {
    158                     $content_type = trim( $content );
    159                 }
    160 
     159            $name = strtolower( $name );
     160
     161            switch ( $name ) {
     162                case 'content-type':
     163
     164                    if ( str_contains( $content, ';' ) ) {
     165                        list( $type ) = explode( ';', $content );
     166                        $data['content-type'] = trim( $type );
     167                    } elseif ( '' !== trim( $content ) ) {
     168                        $data['content-type'] = trim( $content );
     169                    }
     170                    break;
     171
     172                case 'from':
     173                    $bracket_pos = strpos( $content, '<' );
     174                    if ( false !== $bracket_pos ) {
     175                        // Text before the bracketed email is the "From" name.
     176                        if ( $bracket_pos > 0 ) {
     177                            $from_name        = substr( $content, 0, $bracket_pos );
     178                            $from_name        = str_replace( '"', '', $from_name );
     179                            $from_name        = trim( $from_name );
     180                            $data['fromname'] = $from_name;
     181                        }
     182
     183                        $from_email   = substr( $content, $bracket_pos + 1 );
     184                        $from_email   = str_replace( '>', '', $from_email );
     185                        $from_email   = trim( $from_email );
     186                        $data['from'] = $from_email;
     187
     188                    } elseif ( '' !== trim( $content ) ) {
     189                        $from_email   = trim( $content );
     190                        $data['from'] = $from_email;
     191                    }
     192
     193                    break;
     194
     195                case 'cc':
     196                    $data['cc'] = array_merge( (array) $data['cc'], explode( ',', $content ) );
     197                    break;
     198                case 'bcc':
     199                    $data['bcc'] = array_merge( (array) $data['bcc'], explode( ',', $content ) );
     200                    break;
     201                case 'reply-to':
     202                    $data['reply-to'] = array_merge( (array) $data['reply-to'], explode( ',', $content ) );
     203                    break;
    161204            }
    162205
     
    164207    }
    165208
    166     return $content_type;
    167 
    168 }
     209    return $data;
     210
     211}
  • turbosmtp/tags/4.9.1/includes/class-turbosmtp.php

    r3254918 r3255467  
    155155            $this->get_version()
    156156        );
     157
     158        $prefix = is_network_admin() ? 'network_admin_' : '';
     159        $this->loader->add_filter("{$prefix}plugin_action_links_" . plugin_basename(TURBOSMTP_BASE_PATH), $plugin_admin, 'settings_link', 10, 2);
    157160
    158161        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
     
    201204        if ( turbosmtp_validapi() ) {
    202205            $this->loader->add_action('pre_wp_mail', $plugin_public, 'maybe_send_via_http', 10, 2 );
    203             $this->loader->add_action( 'phpmailer_init', $plugin_public,'phpmailer_init' );
     206            $this->loader->add_action( 'phpmailer_init', $plugin_public,'maybe_send_via_phpmailer' );
    204207        }
    205208
  • turbosmtp/tags/4.9.1/public/class-turbosmtp-public.php

    r3254918 r3255467  
    7070     */
    7171
    72     function phpmailer_init(
     72    function maybe_send_via_phpmailer(
    7373        $phpmailer
    7474    ) {
     
    8484            }
    8585
     86            $from = $phpmailer->From ?: $send_options['from'];
     87            $fromname = $phpmailer->FromName ?: $send_options['fromname'];
     88
    8689            $phpmailer->isSMTP();
    87             $phpmailer->setFrom( $send_options["from"], $send_options["fromname"] );
     90            $phpmailer->setFrom( $from, $fromname );
    8891            $phpmailer->Host       = $send_options["host"];
    8992            $phpmailer->SMTPAuth   = 'yes';
     
    105108        }
    106109
    107         $content_type = turbosmtp_get_header_content_type(
     110        $data = turbosmtp_get_headers_data(
    108111            $atts['headers']
    109112        );
    110113
     114        $content_type = $data['content-type'];
     115        $from         = $data['from'] ?: $send_options['from'];
     116        $fromname     = $data['fromname'] ?: $send_options['fromname'];
     117
    111118        $mail_atts = [
    112119            'to'          => $atts['to'],
    113             'from'        => $send_options['from'],
    114             'fromname'    => $send_options['fromname'],
     120            'from'        => $from,
     121            'fromname'    => $fromname,
    115122            'subject'     => $atts['subject'],
    116123            'message'     => $atts['message'],
     
    149156    public function turbosmtp_api_response( $response, $args ) {
    150157        $code = (int) $args['code'];
    151         if ( $code === 401 && apply_filters('turbosmtp_disconnect_if_api_response_401', true) ) {
     158        if ( $code === 401 && apply_filters( 'turbosmtp_disconnect_if_api_response_401', true ) ) {
    152159            $auth_options              = get_option( "ts_auth_options" );
    153160            $auth_options['valid_api'] = false;
  • turbosmtp/tags/4.9.1/turbosmtp.php

    r3254918 r3255467  
    1717 * Plugin URI:        https://www.serversmtp.com/en/smtp-wordpress-configure
    1818 * Description:       Easily send emails from your WordPress blog using turboSMTP's services
    19  * Version:           4.9.0
     19 * Version:           4.9.1
    2020 * Author:            dueclic
    2121 * Author URI:        https://www.dueclic.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'TURBOSMTP_VERSION', '4.9.0' );
     40define( 'TURBOSMTP_VERSION', '4.9.1' );
    4141define( 'TURBOSMTP_BASE_PATH', __FILE__ );
    4242
  • turbosmtp/trunk/README.md

    r3254931 r3255467  
    44Requires at least: 6.0
    55Tested up to: 6.7.1
    6 Stable tag: 4.9.0
     6Stable tag: 4.9.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    2929
    3030== Changelog ==
     31
     32= 4.9.1 =
     33* Better handling of From / From name in API / SMTP sending
    3134
    3235= 4.9.0 =
  • turbosmtp/trunk/admin/class-turbosmtp-admin.php

    r3254918 r3255467  
    7979            $turbosmtp_hosts = turbosmtp_valid_hosts();
    8080            $send_options    = get_option( "ts_send_options" );
     81
    8182            $user_config     = $this->api->get_user_config();
     83
     84            if (!isset($send_options['email'])){
     85                $send_options['email'] = $user_config['email'];
     86            }
     87
     88            if (!isset($send_options['host'])){
     89                $send_options['host'] = 'pro.turbo-smtp.com';
     90            }
     91
     92            if (!isset($send_options['smtpsecure'])){
     93                $send_options['smtpsecure'] = 'ssl';
     94            }
     95
     96            if (!isset($send_options['port'])){
     97                $send_options['port'] = 465;
     98            }
     99
     100            if (!isset($send_options['port'])){
     101                $send_options['port'] = 465;
     102            }
     103
    82104            $current_user    = wp_get_current_user();
    83105            require_once plugin_dir_path( TURBOSMTP_BASE_PATH ) . '/admin/partials/configuration.php';
     
    282304        }
    283305        require_once plugin_dir_path( TURBOSMTP_BASE_PATH ) . '/admin/partials/credentials.php';
     306    }
     307
     308    /**
     309     * Register the shortcut for the settings area.
     310     *
     311     * @since    1.0.0
     312     */
     313    public function settings_link( $links, $file ) {
     314        if ( is_network_admin() ) {
     315            $settings_url = network_admin_url( 'admin.php?page=turbosmtp_config' );
     316        } else {
     317            $settings_url = admin_url( 'admin.php?page=turbosmtp_config' );
     318        }
     319
     320        $settings_link = '<a href="' . esc_url( $settings_url ) . '">' . __( 'Settings', 'turbosmtp' ) . '</a>';
     321        array_unshift( $links, $settings_link );
     322
     323        return $links;
    284324    }
    285325
  • turbosmtp/trunk/admin/partials/configuration.php

    r3254918 r3255467  
    1818 */
    1919
    20 ?>
    21 
    22 <?php
    2320
    2421$send_method = $send_options['is_smtp'] ? 'smtp' : 'api';
     
    203200                                    <p>
    204201                                        <input id="turboSMTP_mail_smtpsecure_none" name="ts_smtp_smtpsecure" type="radio"
    205                                                value=""<?php if ($send_options["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
     202                                               value="" <?php if ($send_options["smtpsecure"] == '') { ?> checked="checked"<?php } ?> />
    206203                                        <label for="ts_smtp_smtpsecure">
    207204                                            <?php _e("No encryption (non-SSL)", "turbosmtp"); ?>
  • turbosmtp/trunk/common-api.php

    r3254918 r3255467  
    131131}
    132132
    133 function turbosmtp_get_header_content_type(
     133function turbosmtp_get_headers_data(
    134134    $headers
    135135) {
    136136
    137     $content_type = "text/plain";
     137    $data = [
     138        "content-type" => "text/plain",
     139        "from"         => "",
     140        "fromname"     => "",
     141        "cc" => [],
     142        "bcc" => [],
     143        "reply-to" => []
     144    ];
    138145
    139146    if ( ! is_array( $headers ) ) {
     
    150157            list( $name, $content ) = explode( ':', trim( $header ), 2 );
    151158
    152             if (strtolower($name) === 'content-type') {
    153 
    154                 if ( str_contains( $content, ';' ) ) {
    155                     list( $type ) = explode( ';', $content );
    156                     $content_type = trim( $type );
    157                 } elseif ( '' !== trim( $content ) ) {
    158                     $content_type = trim( $content );
    159                 }
    160 
     159            $name = strtolower( $name );
     160
     161            switch ( $name ) {
     162                case 'content-type':
     163
     164                    if ( str_contains( $content, ';' ) ) {
     165                        list( $type ) = explode( ';', $content );
     166                        $data['content-type'] = trim( $type );
     167                    } elseif ( '' !== trim( $content ) ) {
     168                        $data['content-type'] = trim( $content );
     169                    }
     170                    break;
     171
     172                case 'from':
     173                    $bracket_pos = strpos( $content, '<' );
     174                    if ( false !== $bracket_pos ) {
     175                        // Text before the bracketed email is the "From" name.
     176                        if ( $bracket_pos > 0 ) {
     177                            $from_name        = substr( $content, 0, $bracket_pos );
     178                            $from_name        = str_replace( '"', '', $from_name );
     179                            $from_name        = trim( $from_name );
     180                            $data['fromname'] = $from_name;
     181                        }
     182
     183                        $from_email   = substr( $content, $bracket_pos + 1 );
     184                        $from_email   = str_replace( '>', '', $from_email );
     185                        $from_email   = trim( $from_email );
     186                        $data['from'] = $from_email;
     187
     188                    } elseif ( '' !== trim( $content ) ) {
     189                        $from_email   = trim( $content );
     190                        $data['from'] = $from_email;
     191                    }
     192
     193                    break;
     194
     195                case 'cc':
     196                    $data['cc'] = array_merge( (array) $data['cc'], explode( ',', $content ) );
     197                    break;
     198                case 'bcc':
     199                    $data['bcc'] = array_merge( (array) $data['bcc'], explode( ',', $content ) );
     200                    break;
     201                case 'reply-to':
     202                    $data['reply-to'] = array_merge( (array) $data['reply-to'], explode( ',', $content ) );
     203                    break;
    161204            }
    162205
     
    164207    }
    165208
    166     return $content_type;
    167 
    168 }
     209    return $data;
     210
     211}
  • turbosmtp/trunk/includes/class-turbosmtp.php

    r3254918 r3255467  
    155155            $this->get_version()
    156156        );
     157
     158        $prefix = is_network_admin() ? 'network_admin_' : '';
     159        $this->loader->add_filter("{$prefix}plugin_action_links_" . plugin_basename(TURBOSMTP_BASE_PATH), $plugin_admin, 'settings_link', 10, 2);
    157160
    158161        $this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
     
    201204        if ( turbosmtp_validapi() ) {
    202205            $this->loader->add_action('pre_wp_mail', $plugin_public, 'maybe_send_via_http', 10, 2 );
    203             $this->loader->add_action( 'phpmailer_init', $plugin_public,'phpmailer_init' );
     206            $this->loader->add_action( 'phpmailer_init', $plugin_public,'maybe_send_via_phpmailer' );
    204207        }
    205208
  • turbosmtp/trunk/public/class-turbosmtp-public.php

    r3254918 r3255467  
    7070     */
    7171
    72     function phpmailer_init(
     72    function maybe_send_via_phpmailer(
    7373        $phpmailer
    7474    ) {
     
    8484            }
    8585
     86            $from = $phpmailer->From ?: $send_options['from'];
     87            $fromname = $phpmailer->FromName ?: $send_options['fromname'];
     88
    8689            $phpmailer->isSMTP();
    87             $phpmailer->setFrom( $send_options["from"], $send_options["fromname"] );
     90            $phpmailer->setFrom( $from, $fromname );
    8891            $phpmailer->Host       = $send_options["host"];
    8992            $phpmailer->SMTPAuth   = 'yes';
     
    105108        }
    106109
    107         $content_type = turbosmtp_get_header_content_type(
     110        $data = turbosmtp_get_headers_data(
    108111            $atts['headers']
    109112        );
    110113
     114        $content_type = $data['content-type'];
     115        $from         = $data['from'] ?: $send_options['from'];
     116        $fromname     = $data['fromname'] ?: $send_options['fromname'];
     117
    111118        $mail_atts = [
    112119            'to'          => $atts['to'],
    113             'from'        => $send_options['from'],
    114             'fromname'    => $send_options['fromname'],
     120            'from'        => $from,
     121            'fromname'    => $fromname,
    115122            'subject'     => $atts['subject'],
    116123            'message'     => $atts['message'],
     
    149156    public function turbosmtp_api_response( $response, $args ) {
    150157        $code = (int) $args['code'];
    151         if ( $code === 401 && apply_filters('turbosmtp_disconnect_if_api_response_401', true) ) {
     158        if ( $code === 401 && apply_filters( 'turbosmtp_disconnect_if_api_response_401', true ) ) {
    152159            $auth_options              = get_option( "ts_auth_options" );
    153160            $auth_options['valid_api'] = false;
  • turbosmtp/trunk/turbosmtp.php

    r3254918 r3255467  
    1717 * Plugin URI:        https://www.serversmtp.com/en/smtp-wordpress-configure
    1818 * Description:       Easily send emails from your WordPress blog using turboSMTP's services
    19  * Version:           4.9.0
     19 * Version:           4.9.1
    2020 * Author:            dueclic
    2121 * Author URI:        https://www.dueclic.com/
     
    3838 * Rename this for your plugin and update it as you release new versions.
    3939 */
    40 define( 'TURBOSMTP_VERSION', '4.9.0' );
     40define( 'TURBOSMTP_VERSION', '4.9.1' );
    4141define( 'TURBOSMTP_BASE_PATH', __FILE__ );
    4242
Note: See TracChangeset for help on using the changeset viewer.