Exemplo n.º 1
0
    public function show_settings_menu()
    {
        if (!empty($_POST)) {
            $this->save_settings();
        }
        echo '<div class="wrap"><div class="icon32"><img src="' . plugin_dir_url(__FILE__) . '/images/mj_logo_med.png" /></div><h2>';
        echo __('Mailjet Settings', 'wp-mailjet');
        echo '</h2>';
        echo '<div class="postbox-container updated" style="width:25%;float:right">
		<h3>' . __('Share the love!', 'wp-mailjet') . '</h3>
		<div style="margin-bottom:10px">
		<iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2FMailjet&amp;send=false&amp;layout=button_count&amp;width=150&amp;show_faces=false&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=352489811497917" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:150px; height:21px;" allowTransparency="true"></iframe>
		</div>
		<div style="margin-bottom:10px">
		<a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.mailjet.com" data-text="' . __('Improve your email deliverability and monitor action in real time.', 'wp-mailjet') . '" data-via="mailjet">' . __('Tweet', 'wp-mailjet') . '</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
		</div>
		</div>
		<div style="width:70%;float:left;">';
        $form = new Mailjet_Options_Form('admin.php?page=wp_mailjet_options_top_menu&action=save_options');
        $desc = '<ol>';
        $desc .= '<li>' . __('<a href="https://www.mailjet.com/signup">Create your Mailjet account</a> or visit your <a href="https://fr.mailjet.com/account/api_keys">account page</a> to get your API keys.', 'wp-mailjet') . '</li>';
        $desc .= '<li>' . __('<a href="https://fr.mailjet.com/contacts/lists/add">Create a new list</a> if you don\'t have one or need a new one.', 'wp-mailjet') . '</li>';
        $desc .= '<li>' . __('<a href="widgets.php">Add</a> the email collection widget to your sidebar or footer.', 'wp-mailjet') . '</li>';
        $desc .= '<li>' . __('<a href="https://fr.mailjet.com/campaigns/create">Create a campaign</a> on mailjet.com to send your newsletter.', 'wp-mailjet') . '</li>';
        $desc .= '</ol>';
        $generalFieldset = new Options_Form_Fieldset(__('Mailjet Plugin', 'wp-mailjet'), array(), $desc);
        $form->addFieldset($generalFieldset);
        $generalOptions[] = new Options_Form_Option('mailjet_enabled', ' ' . __('Enabled', 'wp-mailjet'), 'checkbox', get_option('mailjet_enabled'), __('Enable email through <b>Mailjet</b>', 'wp-mailjet'));
        $generalOptions[] = new Options_Form_Option('mailjet_ssl', ' ' . __('SSL Enabled', 'wp-mailjet'), 'checkbox', get_option('mailjet_ssl'), __('Enable <b>SSL</b> communication with mailjet.com', 'wp-mailjet'));
        $ports = array(array('value' => 25, 'label' => 25), array('value' => 465, 'label' => 465), array('value' => 587, 'label' => 587), array('value' => 588, 'label' => 588), array('value' => 80, 'label' => 80));
        $generalOptions[] = new Options_Form_Option('mailjet_port', '', 'select', get_option('mailjet_port'), __('Port to use for SMTP communication', 'wp-mailjet'), false, $ports);
        $generalOptions[] = new Options_Form_Option('mailjet_test', ' ' . __('Send test email', 'wp-mailjet'), 'checkbox', get_option('mailjet_test'), __('Send test email now', 'wp-mailjet'));
        $test_email = get_option('mailjet_test_address') ? get_option('mailjet_test_address') : get_option('admin_email');
        $generalOptions[] = new Options_Form_Option('mailjet_test_address', __('Recipient of test email', 'wp-mailjet'), 'email', $test_email);
        $from_email = get_option('mailjet_from_email') ? get_option('mailjet_from_email') : get_option('admin_email');
        $generalOptions[] = new Options_Form_Option('mailjet_from_email', __('<code>From:</code> email address', 'wp-mailjet'), 'email', $from_email);
        if (get_option('mailjet_password') && get_option('mailjet_username')) {
            $MailjetApi = new Mailjet(get_option('mailjet_username'), get_option('mailjet_password'));
            $resp = $MailjetApi->listsAll();
            if ($resp->status == 'OK') {
                $lists = array(array('value' => '', 'label' => __('Disable autosubscribe', 'wp-mailjet')));
                foreach ($resp->lists as $list) {
                    $lists[] = array('value' => $list->id, 'label' => $list->label);
                }
            }
            $generalOptions[] = new Options_Form_Option('mailjet_auto_subscribe_list_id', '', 'select', get_option('mailjet_auto_subscribe_list_id'), __('Autosubscribe new users to this list', 'wp-mailjet'), false, $lists);
        }
        $generalFieldset = new Options_Form_Fieldset(__('General Settings', 'wp-mailjet'), $generalOptions, __('Enable or disable the sending of your emails through your Mailjet account', 'wp-mailjet'));
        $form->addFieldset($generalFieldset);
        $apiOptions[] = new Options_Form_Option('mailjet_username', __('API key', 'wp-mailjet'), 'text', get_option('mailjet_username'), null, true);
        $apiOptions[] = new Options_Form_Option('mailjet_password', __('API secret', 'wp-mailjet'), 'text', get_option('mailjet_password'), null, true);
        $apiFieldset = new Options_Form_Fieldset(__('API Settings', 'wp-mailjet'), $apiOptions, sprintf(__('You can get your API keys from <a href="https://www.mailjet.com/account/api_keys">your mailjet account</a>. Please also make sure the sender address %s is active in <a href="https://www.mailjet.com/account/sender">your account</a>', 'wp-mailjet'), get_option('admin_email')));
        $form->addFieldset($apiFieldset);
        $form->display();
        echo '</div></div>';
    }