/**
     * Subscribe process for submit on confirmation email
     */
    public static function subscribe()
    {
        $site_domain = str_replace('https://', '', home_url());
        $site_domain = str_replace('http://', '', $site_domain);
        $general_settings = get_option('ws_main_option', array());
        if (!class_exists('Mailin')) {
            require_once 'mailin.php';
        }
        $mailin = new Mailin(self::sendinblue_api_url, $general_settings['access_key']);
        $code = esc_attr($_GET['code']);
        $list_id = intval($_GET['li']);
        $contact_info = SIB_Model_Contact::get_data_by_code($code);
        if ($contact_info != false) {
            $email = $contact_info['email'];
            $data = array('email' => $email);
            $response = $mailin->get_user($data);
            if ($response['code'] == 'success') {
                $listid = $response['data']['listid'];
                if (!isset($listid) || !is_array($listid)) {
                    $listid = array();
                }
            } else {
                $listid = array();
            }
            array_push($listid, $list_id);
            $attributes = maybe_unserialize($contact_info['info']);
            $data = array();
            $attribute_key = implode('|', array_keys($attributes));
            $attribute_val = implode('|', array_values($attributes));
            $ip = self::get_the_user_ip();
            $data['attributes_name'] = $attribute_key;
            $data['attributes_value'] = $attribute_val;
            $data['category'] = '';
            $data['email'] = $email;
            $data['listid'] = $list_id;
            $data['blacklisted'] = 0;
            $data['blacklisted_sms'] = 0;
            $data['source'] = 'Wordpress Woocommerce';
            $data['ip'] = $ip;
            $ret = $mailin->updateUser($data);
        }
        ?>
        <body style="margin:0; padding:0;">
        <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%">
            <tbody>
            <tr style="border-collapse:collapse;">
                <td style="border-collapse:collapse;" align="center">
                    <table cellpadding="0" cellspacing="0" border="0" width="540">
                        <tbody>
                        <tr>
                            <td style="line-height:0; font-size:0;" height="20"></td>
                        </tr>
                        </tbody>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" width="540">
                        <tbody>
                        <tr>
                            <td style="line-height:0; font-size:0;" height="20">
                                <div
                                    style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;">
                                    <?php 
        _e('Thank you for subscribing', 'wc_sendinblue');
        ?>
</div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" width="540">
                        <tbody>
                        <tr>
                            <td style="line-height:0; font-size:0;" height="20"></td>
                        </tr>
                        </tbody>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" width="540">
                        <tbody>
                        <tr>
                            <td align="left">

                                <div
                                    style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;">
                                    <br>
                                    <?php 
        echo __('You have just subscribed to the newsletter of ', 'wc_sendinblue') . $site_domain . ' .';
        ?>
                                    <br><br>
                                    <?php 
        _e('-SendinBlue', 'wc_sendinblue');
        ?>
</div>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <table cellpadding="0" cellspacing="0" border="0" width="540">
                        <tbody>
                        <tr>
                            <td style="line-height:0; font-size:0;" height="20">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            </tbody>
        </table>
        </body>
        <?php 
        exit;
    }
コード例 #2
0
        /**
         * Subscribe process
         */
        function subscribe()
        {
            $site_domain = str_replace('https://', '', home_url());
            $site_domain = str_replace('http://', '', $site_domain);
            $mailin = new Mailin(SIB_Manager::sendinblue_api_url, SIB_Manager::$access_key);
            $code = esc_attr($_GET['code']);
            $list_id = intval($_GET['li']);
            $contact_info = SIB_Model_Contact::get_data_by_code($code);
            if ($contact_info != false) {
                $email = $contact_info['email'];
                $data = array('email' => $email);
                $response = $mailin->get_user($data);
                if ($response['code'] == 'success') {
                    $listid = $response['data']['listid'];
                    if (!isset($listid) || !is_array($listid)) {
                        $listid = array();
                    }
                } else {
                    $listid = array();
                }
                if (SIB_Manager::$is_confirm_email == 'yes' && in_array($list_id, $listid) == false) {
                    $this->send_email('confirm', $email, $code, $list_id);
                }
                array_push($listid, $list_id);
                $info = maybe_unserialize($contact_info['info']);
                $data = array();
                $attribute_key = implode('|', array_keys($info));
                $attribute_val = implode('|', array_values($info));
                $ip = $this->get_the_user_ip();
                $data['attributes_name'] = $attribute_key;
                $data['attributes_value'] = $attribute_val;
                $data['category'] = '';
                $data['email'] = $email;
                $data['listid'] = $list_id;
                $data['blacklisted'] = 0;
                $data['blacklisted_sms'] = 0;
                $data['source'] = 'Wordpress';
                $data['ip'] = $ip;
                $response = $mailin->updateUser($data);
            }
            if (SIB_Manager::$redirect_url != '') {
                wp_redirect(SIB_Manager::$redirect_url);
                exit;
            }
            ?>
            <body style="margin:0; padding:0;">
            <table style="background-color:#ffffff" cellpadding="0" cellspacing="0" border="0" width="100%">
                <tbody>
                <tr style="border-collapse:collapse;">
                    <td style="border-collapse:collapse;" align="center">
                        <table cellpadding="0" cellspacing="0" border="0" width="540">
                            <tbody>
                            <tr>
                                <td style="line-height:0; font-size:0;" height="20"></td>
                            </tr>
                            </tbody>
                        </table>
                        <table cellpadding="0" cellspacing="0" border="0" width="540">
                            <tbody>
                            <tr>
                                <td style="line-height:0; font-size:0;" height="20">
                                    <div style="font-family:arial,sans-serif; color:#61a6f3; font-size:20px; font-weight:bold; line-height:28px;">
                                        <?php 
            _e('Thank you for subscribing', 'sib_lang');
            ?>
</div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <table cellpadding="0" cellspacing="0" border="0" width="540">
                            <tbody>
                            <tr>
                                <td style="line-height:0; font-size:0;" height="20"></td>
                            </tr>
                            </tbody>
                        </table>
                        <table cellpadding="0" cellspacing="0" border="0" width="540">
                            <tbody>
                            <tr>
                                <td align="left">

                                    <div style="font-family:arial,sans-serif; font-size:14px; margin:0; line-height:24px; color:#555555;">
                                        <br>
                                        <?php 
            echo __('You have just subscribed to the newsletter of ', 'sib_lang') . $site_domain . ' .';
            ?>
<br><br>
                                        <?php 
            _e('-SendinBlue', 'sib_lang');
            ?>
</div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <table cellpadding="0" cellspacing="0" border="0" width="540">
                            <tbody>
                            <tr>
                                <td style="line-height:0; font-size:0;" height="20">
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </td>
                </tr>
                </tbody>
            </table>
            </body>
            <?php 
            exit;
        }