SendinBlue Subscribe Form And WP SMTP - Version 1.0

Version Description

Download this release

Release Info

Developer neeraj_slit
Plugin Icon 128x128 SendinBlue Subscribe Form And WP SMTP
Version 1.0
Comparing to
See all releases

Version 1.0

api_form.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="mailin_row">
2
+ <form method="post" action="options-general.php?page=mailin_options">
3
+ <h3>
4
+ <?php esc_html_e( 'Please provide your login information' ,
5
+ 'mailin_i18n');?>
6
+ </h3>
7
+ <?php esc_html_e('To start using the Mailin plugin, please enter your Mailin API Key below.', 'mailin_i18n'); ?>
8
+ <br/>
9
+ <?php
10
+ echo esc_html_e( "Don't have a Mailin account?", "mailin_i18n").'&nbsp;';
11
+ echo '<a href="http://www.mailin.fr/#subscriptionform" target="_blank">'.__( "Sign up", "mailin_i18n"). '</a>';
12
+ ?>
13
+ <br/>
14
+ <table class="form-table">
15
+ <tr valign="top">
16
+ <td scope="row" width="50">
17
+ <?php esc_html_e( 'API Key', 'mailin_i18n'); ?>:</td>
18
+ <td>
19
+ <input name="mailin_apikey" type="text" id="mailin_apikey" class="code"
20
+ value="<?php echo esc_attr($api_key); ?>" size="32" />
21
+ </td>
22
+ </tr>
23
+ <tr>
24
+ <td colspan="2">
25
+ <input type="hidden" name="mailin_form_action" value="apikey_update" />
26
+ <input type="submit" name="Submit" value="<?php esc_attr_e('Validate & Save' , 'mailin_i18n');?>"
27
+ class="button" />
28
+ </td>
29
+ </tr>
30
+ </table>
31
+ </form>
32
+ </div>
compatibility.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /* Compatibility Functions */
4
+
5
+
6
+ /* Functions for < WP 3.0 Compat */
7
+ if (!function_exists('home_url')) {
8
+ /**
9
+ * Retrieve the home url for the current site.
10
+ *
11
+ * Returns the 'home' option with the appropriate protocol, 'https' if
12
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
13
+ * overridden.
14
+ *
15
+ * @package WordPress
16
+ * @since 3.0.0
17
+ *
18
+ * @uses get_home_url()
19
+ *
20
+ * @param string $path (optional) Path relative to the home url.
21
+ * @param string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
22
+ * @return string Home url link with optional path appended.
23
+ */
24
+ function home_url( $path = '', $scheme = null ) {
25
+ return get_home_url(null, $path, $scheme);
26
+ }
27
+
28
+ }
29
+
30
+ if (!function_exists('get_home_url')) {
31
+ /**
32
+ * Retrieve the home url for a given site.
33
+ *
34
+ * Returns the 'home' option with the appropriate protocol, 'https' if
35
+ * is_ssl() and 'http' otherwise. If $scheme is 'http' or 'https', is_ssl() is
36
+ * overridden.
37
+ *
38
+ * @package WordPress
39
+ * @since 3.0.0
40
+ *
41
+ * @param int $blog_id (optional) Blog ID. Defaults to current blog.
42
+ * @param string $path (optional) Path relative to the home url.
43
+ * @param string $scheme (optional) Scheme to give the home url context. Currently 'http','https'
44
+ * @return string Home url link with optional path appended.
45
+ */
46
+ function get_home_url( $blog_id = null, $path = '', $scheme = null ) {
47
+ $orig_scheme = $scheme;
48
+
49
+ if ( !in_array( $scheme, array( 'http', 'https' ) ) )
50
+ $scheme = is_ssl() && !is_admin() ? 'https' : 'http';
51
+ if ( empty( $blog_id ) || !is_multisite() )
52
+ $home = get_option( 'home' );
53
+ else
54
+ $home = get_blog_option( $blog_id, 'home' );
55
+
56
+ $url = str_replace( 'http://', "$scheme://", $home );
57
+
58
+ if ( !empty( $path ) && is_string( $path ) && strpos( $path, '..' ) === false )
59
+ $url .= '/' . ltrim( $path, '/' );
60
+
61
+ return apply_filters( 'home_url', $url, $path, $orig_scheme, $blog_id );
62
+ }
63
+ }
64
+
65
+ if (!function_exists('is_multisite')) {
66
+ /**
67
+ * Whether Multisite support is enabled
68
+ *
69
+ * @since 3.0.0
70
+ *
71
+ * @return bool True if multisite is enabled, false otherwise.
72
+ */
73
+ function is_multisite() {
74
+ if ( defined( 'MULTISITE' ) )
75
+ return MULTISITE;
76
+
77
+ if ( defined( 'VHOST' ) || defined( 'SUNRISE' ) )
78
+ return true;
79
+
80
+ return false;
81
+ }
82
+ }
83
+ ?>
cron.php ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Dummy CLI script that loads the WordPress environment
4
+ * Author: Thorsten Ott
5
+ * Author URI: http://hitchhackerguide.com
6
+ */
7
+ set_time_limit( 0 );
8
+ ini_set( "memory_limit", "64M" );
9
+ $_SERVER['HTTP_HOST'] = 'wp_trunk'; // set this to the apache vhost name of your WordPress install
10
+
11
+ ob_start();
12
+ $wp_load = '../../../wp-load.php';
13
+
14
+ //STOP CRON EXECUTION WHEN WORDPRESS IS NOT LOADED ON THIS FILE
15
+ if(!is_file($wp_load)){
16
+ exit;
17
+ }
18
+
19
+ require_once($wp_load); // you need to adjust this to your path
20
+ require_once( ABSPATH . 'wp-admin/includes/admin.php' );
21
+ ob_end_clean();
22
+
23
+
24
+ function curl_request($data) {
25
+
26
+ $url = 'http://ws.mailin.fr/'; //WS URL
27
+ $ch = curl_init();
28
+
29
+ $ndata='';
30
+
31
+ if(is_array($data)){
32
+
33
+ foreach($data AS $key=>$value){
34
+ $ndata .=$key.'='.urlencode($value).'&';
35
+ }
36
+
37
+ }else{
38
+
39
+ $ndata=$data;
40
+
41
+ }
42
+
43
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
44
+ curl_setopt($ch, CURLOPT_POST ,1);
45
+ curl_setopt ($ch, CURLOPT_POSTFIELDS,$ndata);
46
+ curl_setopt($ch, CURLOPT_HEADER, 0);
47
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
48
+ curl_setopt($ch, CURLOPT_URL, $url);
49
+ $data = curl_exec($ch);
50
+ curl_close($ch);
51
+ return $data;
52
+ }
53
+
54
+ $api_key = get_option('mailin_apikey');
55
+
56
+ if($api_key == ''){
57
+ exit;
58
+ }
59
+
60
+
61
+ function call_server($email, $api_key){
62
+
63
+ $data = array();
64
+ $data['webaction']='DISPLAYUSERDETAIL';
65
+ $data['key']= $api_key;
66
+ $data['email'] = $email;
67
+
68
+ $return = json_encode(curl_request($data));
69
+ $return = json_decode($return);
70
+ return $return;
71
+
72
+ }
73
+
74
+ function getListUsers($api_key, $list_ids){
75
+
76
+ if($api_key == '') {
77
+ return ;
78
+ }
79
+
80
+ $data = array();
81
+ $data['webaction']='DISPLAYLISTDATABLACK';
82
+ $data['key']=$api_key;
83
+
84
+ $data['listids']= $list_ids;
85
+
86
+ $return = curl_request($data);
87
+ $return = json_decode($return);
88
+
89
+ return $return;
90
+
91
+ }
92
+
93
+
94
+ global $wpdb;
95
+ $table = $wpdb->prefix."mailin_subscribers ";
96
+
97
+
98
+ $api_key = get_option('mailin_apikey');
99
+
100
+ $lists = get_option('mailin_lists');
101
+ $lists = unserialize($lists);
102
+
103
+ $final_data = array();
104
+ foreach($lists as $data){
105
+ $final_data[] = $data->id;
106
+ }
107
+
108
+ $list_ids = '';
109
+ if(!empty($final_data)){
110
+ $list_ids = implode('|' , $final_data);
111
+ }
112
+
113
+ if($list_ids == ''){
114
+ return ;
115
+ }
116
+
117
+ $list_users = getListUsers($api_key , $list_ids);
118
+
119
+
120
+ if(!empty($list_users->result)){
121
+
122
+ foreach($list_users->result as $key=>$lists){
123
+
124
+ if(!empty($lists)){
125
+
126
+ foreach($lists as $users){
127
+
128
+ if(isset($users->blacklisted)){
129
+
130
+ if($users->blacklisted == '1'){
131
+ $sql = "UPDATE ".$table." SET subscribed = '0' WHERE email = '".strtolower(trim($users->email))."' " ;
132
+ }else{
133
+ $sql = "UPDATE ".$table." SET subscribed = '1' WHERE email = '".strtolower(trim($users->email))."' " ;
134
+ }
135
+ $myrows = $wpdb->query($sql);
136
+ }
137
+ }
138
+ }
139
+ }
140
+ }
css/admin.css ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .mailin_error{
2
+ background-color: #F2DEDE;
3
+ border:1px solid #EED3D7;
4
+ color: #B94A48;border-radius:4px 4px 4px 4px;padding:8px;
5
+ margin-bottom:10px;
6
+ text-shadow:0 1px 0 rgba(255, 255, 255, 0.5)
7
+ }
8
+ .mailin_success{
9
+ background-color: #DFF0D8;
10
+ border:1px solid #D6E9C6;
11
+ margin-bottom:10px;
12
+ color: #468847;border-radius:4px 4px 4px 4px;padding:8px;
13
+ text-shadow:0 1px 0 rgba(255, 255, 255, 0.5)
14
+ }
15
+ .mailin_popup_box{
16
+ background-color: #FFFFFF;
17
+ border: 1px solid #DFDFDF;
18
+ border-radius: 5px 5px 5px 5px;
19
+ height: 157px;
20
+ margin-left: 632px;
21
+ padding: 7px;
22
+ position: absolute;
23
+ width: 400px;
24
+ z-index: 5;
25
+ display:none;
26
+ }
27
+ .mailin_popup_close{
28
+ background-image: url("close.png");
29
+ background-repeat: no-repeat;
30
+ float: right;
31
+ height: 50px;
32
+ position: relative;
33
+ width: 5%;
34
+ cursor:pointer;
35
+ }
36
+
37
+ .mailin_popup_loading{
38
+ position:absolute;
39
+ background-image: url("loading_anim.gif");
40
+ background-repeat: no-repeat;
41
+ float: left;
42
+ height: 50px;
43
+ width:50px;
44
+ margin-top: 50px;
45
+ margin-left:185px;
46
+ }
47
+
48
+ .mailin_admin_head{
49
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #ECECEC);
50
+ border: 1px solid #DFDFDF;
51
+ border-radius: 3px 3px 3px 3px;
52
+ padding:0 5px;
53
+ margin-bottom: 10px;
54
+ width: 670px;
55
+ }
56
+
57
+ .mailin_popup_inner{
58
+ float: left;
59
+ height: 157px;
60
+ width: 95%;
61
+ }
62
+
63
+ .mailin_row{float:left;width:670px}
css/close.png ADDED
Binary file
css/loading_anim.gif ADDED
Binary file
css/mailin_plugin.css ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #mailin_signup_box{background-color: #F5F5F5; border: 1px solid #E5E5E5; border-radius: 4px 4px 4px 4px;margin-bottom: 10px; padding: 5px; width: auto;}
2
+ .mailin_signup_box_row{width:auto;padding:0 0 4px;}
3
+ .mailin_signup_box_row input{font-size:12px;border:1px solid #CCCCCC;border-radius:3px;color:#555555;width:92%}
4
+ .mailin_signup_box_row .required{color:#FF0000}
5
+ .right{text-align:right}
6
+ .mailin_signup_box_row label{color:#000000;font-size:12px;}
7
+ #mailin_email{border:1px solid #cccccc;}
8
+ .mailin_success{color:green;margin:0;padding:0}
9
+ .mailin_error{color:red;margin:0;padding:0}
10
+ .mailin_widget_head{font-size:12px;font-weight:bold;text-shadow:0 1px 0 rgba(255, 255, 255, 0.5)}
11
+ #mailin_signup_submit{background-image:-moz-linear-gradient(center top , #0088CC, #0055CC);border-radius:3px;background-color:#0074CC;border-color:rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);color:#FFFFFF;padding:3px;margin:10px 0;width:auto;cursor:pointer}
12
+ .mailin_powered{background-color: #339AE1;border-radius: 5px 5px 5px 5px;color: #FFFFFF;font-family: Arial;font-weight: bold;padding: 2px;text-shadow:0 -1px 0 rgba(0, 0, 0, 0.25) }
lang/mailin_lang-fr_FR.mo ADDED
Binary file
lang/mailin_lang-fr_FR.po ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Mailin 1.0.0\n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/mailin\n"
5
+ "POT-Creation-Date: 2012-07-10 12:23-0400\n"
6
+ "PO-Revision-Date: 2012-08-30 16:40+0530\n"
7
+ "Last-Translator: sachin <sachinat911@gmail.com>\n"
8
+ "Language-Team: Contributed <sachinat911@gmail.com>\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+
13
+ msgid "Your Lists"
14
+ msgstr "Vos listes"
15
+
16
+ msgid "Mailin Setup"
17
+ msgstr "Paramètres de Mailin"
18
+
19
+ msgid "You are logged in"
20
+ msgstr "Vous êtes connecté"
21
+
22
+ msgid "Email already exists"
23
+ msgstr "Cette adresse email existe déjà"
24
+
25
+ msgid "Please check lists in which users will be added"
26
+ msgstr "Veuillez vérifier les listes dans lesquelles seront ajoutés les abonnés"
27
+
28
+ msgid "Update List"
29
+ msgstr "Mettre à jour la liste"
30
+
31
+ msgid "Logout"
32
+ msgstr "Déconnexion"
33
+
34
+ msgid "Please provide your login information"
35
+ msgstr "Veuillez renseigner vos identifiants"
36
+
37
+ msgid "To start using the Mailin plugin, please enter your Mailin API Key below."
38
+ msgstr "Pour commencer à utiliser le module de Mailin, veuillez saisir votre clé API ci-dessous"
39
+
40
+ msgid "Don't have a Mailin account?"
41
+ msgstr "Vous n'avez pas un compte Mailin?"
42
+
43
+ msgid "Sign up"
44
+ msgstr "Inscrivez-vous ici gratuitement"
45
+
46
+ msgid "API Key"
47
+ msgstr "Clé API"
48
+
49
+ msgid "Validate & Save"
50
+ msgstr "Valider et enregistrer"
51
+
52
+ msgid "Your API is valid, your lists are fetched and saved in the database."
53
+ msgstr "Votre clé API est valide, les listes ont été insérées et enregistrées dans votre base de données"
54
+
55
+ msgid "Key Not Found In Database"
56
+ msgstr "Clé non trouvée dans la base de données"
57
+
58
+ msgid "Unable to connect"
59
+ msgstr "Echec de connexion"
60
+
61
+ msgid "List updated successfully"
62
+ msgstr "Liste mise à jour avec succès"
63
+
64
+ msgid "Please select a list"
65
+ msgstr "Veuillez sélectionner une liste"
66
+
67
+ msgid "You have successfully subscribed Mailin newsletter!"
68
+ msgstr "Vous êtes abonné à la newsletter de Mailin"
69
+
70
+ msgid "Please enter valid email"
71
+ msgstr "Veuillez saisir une adresse email valide"
72
+
73
+ msgid "Subscribe to newsletter"
74
+ msgstr "Abonnez-vous à la newsletter"
75
+
76
+ msgid "powered by"
77
+ msgstr "effectué par"
78
+
79
+ msgid "Your Campaigns"
80
+ msgstr "Vos campagnes"
81
+
82
+ msgid "Following are your campaigns on Mailin"
83
+ msgstr "Ci-dessous, vos campagnes sur Mailin"
84
+
85
+ msgid "Update Campaigns"
86
+ msgstr "Mettre à jour vos campagnes"
87
+
88
+ msgid "Subscribers"
89
+ msgstr "Abonnés"
90
+
91
+ msgid "Following users have subscribed to Mailin newsletter"
92
+ msgstr "Les abonnés suivants sont inscrits à la newsletter de Mailin"
93
+
94
+ msgid "Synchronize Users"
95
+ msgstr "Synchroniser les abonnés"
96
+
97
+ msgid "No users have subscribed Mailin newsletter yet."
98
+ msgstr "Aucun utilisateur abonné à la newsletter de Mailin"
99
+
100
+ msgid "You have no campaigns on Mailin.fr, please update campaigns if you have added any campaign recently."
101
+ msgstr "Vous n'avez aucune campagne sur Mailin.fr, veuillez actualiser vos campagnes si vous en avez ajouté récemment "
102
+
103
+ msgid "Please enter first name"
104
+ msgstr "Veuillez saisir votre prénom"
105
+
106
+ msgid "Please enter last name"
107
+ msgstr "Veuillez saisir votre nom"
108
+
109
+ msgid "Campaigns updated successfully"
110
+ msgstr "Campagnes mise à jour avec succès"
111
+
112
+ msgid "Users synchronized successfully"
113
+ msgstr "Abonnés synchronisés avec succès"
114
+
115
+ msgid "Please enter API key"
116
+ msgstr "Veuillez saisir votre clé API"
117
+
118
+ msgid "First name"
119
+ msgstr "Prénom"
120
+
121
+ msgid "Last name"
122
+ msgstr "Nom"
123
+
124
+ msgid "Please enter valid e-mail"
125
+ msgstr "Veuillez saisir un e-mail valide"
126
+
127
+ msgid "Please enter your first name"
128
+ msgstr "Veuillez saisir votre prénom"
129
+
130
+ msgid "Please enter your last name"
131
+ msgstr "Veuillez saisir votre nom"
132
+
133
+ msgid "List Name"
134
+ msgstr "Nom de la liste"
135
+
136
+ msgid "Users"
137
+ msgstr "Utilisateurs"
138
+
139
+ msgid "Blacklisted"
140
+ msgstr "Blacklistés"
141
+
142
+ msgid "Campaign Name"
143
+ msgstr "Nom de la campagne"
144
+
145
+ msgid "Sent"
146
+ msgstr "Envoyés"
147
+
148
+ msgid "Remaining"
149
+ msgstr "Restant"
150
+
151
+ msgid "No of lists"
152
+ msgstr "Nombre de listes"
153
+
154
+ msgid "Username"
155
+ msgstr "Nom d'utilisateur"
156
+
157
+ msgid "Subscription date"
158
+ msgstr "Date de souscription"
159
+
160
+ msgid "Email"
161
+ msgstr "Email"
162
+
163
+ msgid "No."
164
+ msgstr "No."
165
+
166
+ msgid "Delivered"
167
+ msgstr "Reçus"
168
+
169
+ msgid "If you want to keep the users in selected list please click on the button Update List"
170
+ msgstr "Si vous souhaitez conserver les utilisateurs dans la liste sélectionnée, veuillez cliquez sur le bouton Mettre à jour la liste"
171
+
172
+ msgid "If you want to synchronise unsubscribed users from Mailin to your site now please click on the button Synchronize Users"
173
+ msgstr "Si vous voulez synchroniser les utilisateurs désinscrits à partir de Mailin à votre site maintenant, veuillez cliquer sur le bouton Synchroniser les utilisateurs"
174
+
175
+ msgid "Subscribe"
176
+ msgstr "S'abonner"
177
+
178
+ msgid "To synchronize the emails id of your subscribers from Mailin plateform to your e-commerce website, you should add this link {cron_link} as a cron job (using for example: cpanel or crontab) and this link should be executed each day. You can also synchronize the subscribers manually by clicking on the button Synchronize Users"
179
+ msgstr "Pour synchroniser les emails de vos abonnés de la plateforme Mailin vers votre site E-commerce, il faudra ajouter cette url {cron_link} à la liste de vos tâches planifiées (CRON) en utilisant par exemple crontab, cpanel, etc...Cette url doit être exécutée tous les jours. Vous pouvez aussi synchroniser vos abonnés en cliquant manuellement sur le bouton Synchroniser les abonnés."
180
+
listings.php ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="mailin_row">
2
+ <table class="mailin_admin_head">
3
+ <tbody>
4
+ <tr>
5
+ <td>
6
+ <h3 style="margin:0">
7
+ <?php echo esc_html_e('You are logged in', 'mailin_i18n'); ?>
8
+ </h3>
9
+ </td>
10
+ <td align="right">
11
+ <form action="options-general.php?page=mailin_options" method="post">
12
+ <input type="hidden" value="logout" name="mailin_form_action">
13
+ <input type="submit" class="button" value="<?php echo esc_html_e('Logout', 'mailin_i18n'); ?>"
14
+ name="Submit">
15
+ </form>
16
+ </td>
17
+ </tr>
18
+ </tbody>
19
+ </table>
20
+ </div>
21
+
22
+ <div class="mailin_row">
23
+ <h3>
24
+ <?php esc_html_e('Your Lists', 'mailin_i18n'); ?>
25
+ </h3>
26
+ </div>
27
+ <form action="options-general.php?page=mailin_options" method="post">
28
+ <div class="mailin_row">
29
+ <p>
30
+ <?php echo esc_html_e("Please check lists in which users will be added", 'mailin_i18n'). '&nbsp;'; ?>
31
+ </p>
32
+ </div>
33
+ <div class="mailin_row">
34
+ <table class="mailin_row">
35
+ <tbody>
36
+ <tr>
37
+ <td>
38
+ <input type="hidden" value="update_list" name="mailin_form_action">
39
+ <table class="widefat" width="600">
40
+ <thead style="float:left;width:100%">
41
+ <tr>
42
+ <th width="20">&nbsp;</th>
43
+ <th width="400">
44
+ <?php echo esc_html_e( 'List Name', 'mailin_i18n'); ?>
45
+ </th>
46
+ <th width="94">
47
+ <?php echo esc_html_e( 'Users', 'mailin_i18n'); ?>
48
+ </th>
49
+ <th width="90">
50
+ <?php echo esc_html_e( 'Blacklisted', 'mailin_i18n'); ?>
51
+ </th>
52
+ </tr>
53
+ </thead>
54
+ <tbody style="height:200px;overflow-y:scroll;float:left;width:100%">
55
+ <?php
56
+ $mailin_lists=get_option('mailin_lists');
57
+
58
+ if(!is_array($mailin_lists)){
59
+ $mailin_lists= unserialize($mailin_lists);
60
+ } if(!empty($mailin_lists)){
61
+ $selected_list= get_option( 'mailin_list_selected');
62
+ $selected_list= explode('|', $selected_list);
63
+
64
+ $i=1 ;
65
+
66
+ foreach($mailin_lists as $item){
67
+ $selected='' ;
68
+ if($selected_list !='' && in_array($item->id, $selected_list)){
69
+ $selected = 'checked="checked"';
70
+ } ?>
71
+
72
+ <tr id="mailin_list_row_<?php echo $item->id ?>">
73
+ <td width="20">
74
+ <input type="checkbox" <?php echo $selected ?>name="mailin_list[]" id="mailin_list" value="
75
+ <?php echo $item->id ?>" ></td>
76
+ <td width="400">
77
+ <?php echo $item->name?></td>
78
+ <td width="90">
79
+ <?php echo $item->count?></td>
80
+ <td width="90">
81
+ <?php echo $item->blacklisted?></td>
82
+ </tr>
83
+ <?php $i++;
84
+ } ?>
85
+ <?php
86
+ } ?>
87
+
88
+ </tbody>
89
+ </table>
90
+ </td>
91
+ </tr>
92
+ <tr>
93
+ <td></td>
94
+ </tr>
95
+ </tbody>
96
+ </table>
97
+ </div>
98
+ <div class="mailin_row" style="float:left;padding-top:5px">
99
+ <div style="float:left;">
100
+ (<?php echo esc_html_e("If you want to keep the users in selected list please click on the button Update List", 'mailin_i18n'); ?>)</div>
101
+ <div style="float:right;">
102
+ <input type="submit" class="button" value="<?php esc_html_e('Update List', 'mailin_i18n'); ?>"
103
+ name="Submit">
104
+ </div>
105
+ </div>
106
+ </form>
107
+
108
+ <div class="mailin_row">
109
+ <h3>
110
+ <?php esc_html_e( 'Your Campaigns', 'mailin_i18n'); ?>
111
+ </h3>
112
+ </div>
113
+ <form action="options-general.php?page=mailin_options" method="post">
114
+ <div class="mailin_row">
115
+ <div style="float:left;width:auto;">
116
+ <p>
117
+ <?php echo esc_html_e( "Following are your campaigns on Mailin",
118
+ 'mailin_i18n'). '&nbsp;'; ?>
119
+ </p>
120
+ </div>
121
+ </div>
122
+ <?php
123
+ $mailin_campaigns=get_option( 'mailin_campaigns'); if(!is_array($mailin_campaigns)){
124
+ $mailin_campaigns=unserialize($mailin_campaigns); } if(!empty($mailin_campaigns)){
125
+ ?>
126
+ <div class="mailin_row">
127
+ <table class="mailin_row">
128
+ <tbody>
129
+ <tr>
130
+ <td>
131
+ <input type="hidden" value="update_campaigns" name="mailin_form_action">
132
+ <table class="widefat" width="600">
133
+ <thead style="float:left;width:100%">
134
+ <tr>
135
+ <th width="50">
136
+ <?php echo esc_html_e( 'No.', 'mailin_i18n'); ?>
137
+ </th>
138
+ <th width="350">
139
+ <?php echo esc_html_e( 'Campaign Name', 'mailin_i18n'); ?>
140
+ </th>
141
+ <th width="70">
142
+ <?php echo esc_html_e( 'Sent', 'mailin_i18n'); ?>
143
+ </th>
144
+ <th width="70">
145
+ <?php echo esc_html_e( 'Delivered', 'mailin_i18n'); ?>
146
+ </th>
147
+ <th width="70">
148
+ <?php echo esc_html_e( 'Remaining', 'mailin_i18n'); ?>
149
+ </th>
150
+ <th width="90">
151
+ <?php echo esc_html_e( 'No of lists', 'mailin_i18n'); ?>
152
+ </th>
153
+ </tr>
154
+ </thead>
155
+ <tbody style="height:200px;overflow-y:scroll;float:left;width:100%">
156
+ <?php $i=1 ; foreach($mailin_campaigns as $item){ ?>
157
+ <tr id="mailin_list_row_<?php echo $item->id ?>">
158
+ <td width="50">
159
+ <?php echo $i ?>
160
+ </td>
161
+ <td width="350">
162
+ <?php echo $item->name != '' ? $item->name : ''?></td>
163
+ <th width="70">
164
+ <?php echo $item->sent?></th>
165
+ <th width="70">
166
+ <?php echo $item->delivered?></th>
167
+ <th width="70">
168
+ <?php echo $item->remaining?></th>
169
+ <td width="95">
170
+ <?php echo count($item->listid)?></td>
171
+ </tr>
172
+ <?php $i++; } ?>
173
+ <?php ?>
174
+ </tbody>
175
+ </table>
176
+ </td>
177
+ </tr>
178
+ <tr>
179
+ <td></td>
180
+ </tr>
181
+ </tbody>
182
+ </table>
183
+ <div class="mailin_row">
184
+ <?php }else{ ?>
185
+ <div style="float: left; width: 655px; padding: 5px; background-color:#FFF0FF; border: 1px solid #FF6860;">
186
+ <?php esc_html_e(
187
+ 'You have no campaigns on Mailin.fr, please update campaigns if you have added any campaign recently.', 'mailin_i18n'); ?>
188
+ </div>
189
+ <?php } ?>
190
+ </form>
191
+ <div class="mailin_row">
192
+ <h3>
193
+ <?php esc_html_e( 'Subscribers', 'mailin_i18n'); ?>
194
+ </h3>
195
+ </div>
196
+ <div class="mailin_row">
197
+ <p>
198
+ <?php echo esc_html_e("Following users have subscribed to Mailin newsletter", 'mailin_i18n'). '&nbsp;'; ?>
199
+ </p>
200
+ </div>
201
+ <?php $mObj=new mailin_API; $users=$mObj->getAllSubscribers(); if(!empty($users)) { ?>
202
+ <div class="mailin_row">
203
+ <table class="widefat">
204
+ <thead style="float:left;width:100%">
205
+ <tr>
206
+ <th width="40">
207
+ <?php echo esc_html_e( 'No.', 'mailin_i18n'); ?>
208
+ </th>
209
+ <th width="150">
210
+ <?php echo esc_html_e( 'Username', 'mailin_i18n'); ?>
211
+ </th>
212
+ <th width="300">
213
+ <?php echo esc_html_e( 'Email', 'mailin_i18n'); ?>
214
+ </th>
215
+ <th width="122">
216
+ <?php echo esc_html_e( 'Subscription date', 'mailin_i18n'); ?>
217
+ </th>
218
+ </tr>
219
+ </thead>
220
+ <tbody style="height:200px;overflow-y:scroll;float:left;width:100%">
221
+ <?php if(!empty($users)){ $i=1 ; foreach($users as $subs){ ?>
222
+ <tr>
223
+ <td width="40">
224
+ <?php echo $i?>
225
+ </td>
226
+ <td width="150">
227
+ <?php echo $subs->fname.' '.$subs->lname?></td>
228
+ <td width="300">
229
+ <?php echo $subs->email?></td>
230
+ <td width="122">
231
+ <?php echo date( 'd M Y H:i' , strtotime($subs->create_date))?></td>
232
+ </tr>
233
+ <?php $i++; } }?>
234
+ </tbody>
235
+ </table>
236
+ <?php }else{ ?>
237
+ <div style="float: left; width: 655px; padding: 5px; background-color:#FFF0FF; border: 1px solid #FF6860;">
238
+ <?php esc_html_e( 'No users have subscribed mailin newsletter yet.',
239
+ 'mailin_i18n'); ?>
240
+ </div>
241
+ <?php } ?>
242
+ <div style="float:left;padding-top:5px" class="mailin_row">
243
+ <div style="float:left;">(<?php
244
+
245
+ $cron_link = MAILIN_URL.'cron.php';
246
+
247
+ $printable_link = "<a target='_blank' href ='".$cron_link."'>".$cron_link."</a>";
248
+
249
+ $text = translate('To synchronize the emails id of your subscribers from Mailin plateform to your e-commerce website, you should add this link {cron_link} as a cron job (using for example: cpanel or crontab) and this link should be executed each day. You can also synchronize the subscribers manually by clicking on the button Synchronize Users', 'mailin_i18n');
250
+
251
+ echo str_replace('{cron_link}', $printable_link , $text);
252
+
253
+ ?>)</div>
254
+ <div style="float:right;">
255
+ <form name="" action="" method="post">
256
+ <input type="submit" name="Submit" value="<?php echo esc_html_e('Synchronize Users', 'mailin_i18n');?>"
257
+ class="button">
258
+ <input type="hidden" name="mailin_form_action" value="sync_users">
259
+ </form>
260
+ </div>
261
+ </div>
262
+ </div>
mailin.php ADDED
@@ -0,0 +1,440 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ Plugin Name: Mailin
5
+ Plugin URI: http://mailin.fr
6
+ Description: The Mailin plugin provides quick and easy way to synchronize subscribers from wordpress site to Mailin website account and vice versa.
7
+ Version: 1.0.0
8
+ Author: Mailin.fr
9
+ Author URI: http://www.mailin.fr
10
+ License: GPLv2 or later
11
+ */
12
+
13
+ /*
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+ */
28
+
29
+ //Mailin version
30
+ define('MAILIN_VER', '1.0.0');
31
+
32
+ //Initiallize mailin constants
33
+ Initiallize_mailin_constants();
34
+
35
+
36
+ // Get Mailin API class in application domain
37
+ if (!class_exists('mailin_API'))
38
+ {
39
+ require_once('mailinapi.class.php');
40
+ }
41
+
42
+ // Include Compatibility functions
43
+ require_once('compatibility.php');
44
+
45
+
46
+ /**
47
+ * Initillize mailin plugin
48
+ * @return void
49
+ */
50
+ function mailin_init()
51
+ {
52
+
53
+ mailin_load_resources();
54
+
55
+ //Internationalize the plugin
56
+ $i18n_file_name = 'mailin_lang';
57
+ $locale = apply_filters( 'plugin_locale', get_locale(), $i18n_file_name);
58
+
59
+ $filename = MAILIN_LANG_DIR.$i18n_file_name.'-'.$locale.'.mo';
60
+ load_textdomain('mailin_i18n', $filename);
61
+
62
+ }
63
+
64
+ add_action( 'init', 'mailin_init');
65
+
66
+
67
+ //Initilize Widget
68
+ include_once('mailin_widget.php');
69
+
70
+ /**
71
+ * Loads JS and CSS
72
+ * @return void
73
+ */
74
+ function mailin_load_resources()
75
+ {
76
+ wp_enqueue_style('mailin_wp_css', MAILIN_URL.'css/mailin_plugin.css');
77
+ }
78
+
79
+
80
+
81
+ /**
82
+ * Loads Mailin Admin page css
83
+ * @return void
84
+ */
85
+ function mailin_load_resources_admin()
86
+ {
87
+ wp_enqueue_style('mailin_admin_css', MAILIN_URL.'css/admin.css');
88
+ }
89
+
90
+ add_action('load-settings_page_mailin_options', 'mailin_load_resources_admin');
91
+
92
+
93
+
94
+ /**
95
+ * Update lists and campaigns on refreshing a page
96
+ *
97
+ */
98
+
99
+ $mObj = new mailin_API();
100
+ $api_key = get_option('mailin_apikey');
101
+
102
+
103
+ if(is_admin() && isset($_GET['page']) && $_GET['page'] == 'mailin_options' && $api_key != '' && $_SERVER['REQUEST_METHOD'] == 'GET'){
104
+
105
+ $mObj->updateUserLists($api_key);
106
+ $mObj->updateUserCampaigns($api_key);
107
+
108
+ }
109
+
110
+ /**
111
+ * Gets or sets error/success message
112
+ * @return string/bool depending on get/set
113
+ **/
114
+ function mailin_messages($msg = null)
115
+ {
116
+
117
+ global $mailin_msg;
118
+
119
+ if (!is_array($mailin_msg))
120
+ {
121
+ $mailin_msg = array();
122
+ }
123
+
124
+ if (is_null($msg))
125
+ {
126
+ return implode('', $mailin_msg);
127
+ }
128
+
129
+ $mailin_msg[] = $msg;
130
+ return true;
131
+ }
132
+
133
+
134
+ /**
135
+ * Handles forms submit
136
+ * @return void , sets error/success message
137
+ **/
138
+ function mailin_form_submit()
139
+ {
140
+
141
+ $action = '';
142
+
143
+ if(isset($_POST['mailin_form_action']))
144
+ {
145
+ $action = trim($_POST['mailin_form_action']);
146
+ if($action == '')
147
+ {
148
+ return;
149
+
150
+ }elseif($action == 'sync_users') {
151
+
152
+ $mObj = new mailin_API();
153
+ $mObj->syncUsers();
154
+
155
+ $message = '<p class="mailin_success" >'.__('Users synchronized successfully', 'mailin_i18n').'</p>';
156
+ mailin_messages($message);
157
+
158
+ }elseif($action == 'list_details') {
159
+
160
+ $mObj = new mailin_API();
161
+ $listDetails = $mObj->getListDetails($_POST['list_id']);
162
+
163
+ }elseif($action == 'apikey_update') {
164
+
165
+ $mObj = new mailin_API();
166
+ $mObj->handle_apikey_form_submit(strip_tags(stripslashes($_POST['mailin_apikey'])));
167
+
168
+ if(empty($mObj->_mailin_error))
169
+ {
170
+
171
+ $message = implode('<br/>', $mObj->_mailin_success);
172
+ $message = '<p class="mailin_success" >'.$message.'</p>';
173
+ mailin_messages($message);
174
+
175
+ }else{
176
+
177
+ $message = implode('<br/>', $mObj->_mailin_error);
178
+ $message = '<p class="mailin_error" >'.$message.'</p>';
179
+ mailin_messages($message);
180
+
181
+ }
182
+ }elseif($action == 'logout') {
183
+
184
+ $mObj = new mailin_API();
185
+ $mObj->handle_logout_form_submit();
186
+
187
+
188
+ }elseif($action == 'update_list'){
189
+
190
+ $mailin_list = isset($_POST['mailin_list']) ? $_POST['mailin_list'] : '' ;
191
+
192
+ $mObj = new mailin_API();
193
+ $mObj->handle_updatelist_form_submit($mailin_list);
194
+
195
+ if(!empty($mObj->_mailin_error))
196
+ {
197
+ $message = implode('<br/>', $mObj->_mailin_error);
198
+ $message = '<p class="mailin_error" >'.$message.'</p>';
199
+ mailin_messages($message);
200
+ }
201
+
202
+ if(!empty($mObj->_mailin_success))
203
+ {
204
+ $message = implode('<br/>', $mObj->_mailin_success);
205
+ $message = '<p class="mailin_success" >'.$message.'</p>';
206
+ mailin_messages($message);
207
+ }
208
+
209
+ }elseif($action == 'update_campaigns') {
210
+
211
+ $mailin_list = isset($_POST['mailin_list']) ? $_POST['mailin_list'] : '' ;
212
+
213
+ $mObj = new mailin_API();
214
+ $mObj->updateUserCampaigns();
215
+
216
+ $message = '<p class="mailin_success" >'.__('Campaigns updated successfully', 'mailin_i18n').'</p>';
217
+ mailin_messages($message);
218
+
219
+
220
+ }elseif($action == 'subscribe_form_submit'){
221
+
222
+ $mObj = new mailin_API();
223
+ $mObj->handle_newsletter_subscribe_submit();
224
+
225
+ if(!empty($mObj->_mailin_error))
226
+ {
227
+ $message = implode('<br/>', $mObj->_mailin_error);
228
+ $message = '<p class="mailin_error" >'.$message.'</p>';
229
+ mailin_messages($message);
230
+ }
231
+
232
+ if(!empty($mObj->_mailin_success))
233
+ {
234
+ $message = implode('<br/>', $mObj->_mailin_success);
235
+ $message = '<p class="mailin_success" >'.$message.'</p>';
236
+ mailin_messages($message);
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+
243
+ add_action('init', 'mailin_form_submit');
244
+
245
+ /**
246
+ * Loads the view of Mailin admin page
247
+ * @return void
248
+ **/
249
+ function mailin_settings_admin_page()
250
+ {
251
+
252
+ // CHECK IF API KEY EXISTS
253
+ $api_key = get_option('mailin_apikey');
254
+
255
+ ?>
256
+ <div class="wrap">
257
+ <div style="float:left;margin-bottom:10px;width:670px;">
258
+ <div class="icon32" id="icon-options-general"><br></div>
259
+ <h2><?php esc_html_e('Mailin Setup', 'mailin_i18n');?> </h2>
260
+ </div>
261
+
262
+ <?php
263
+ if (mailin_messages() != '')
264
+ {
265
+ ?>
266
+ <div id="mc_message" class="mailin_row"><?php echo mailin_messages(); ?></div>
267
+ <?php
268
+ }
269
+
270
+ if($api_key != '')
271
+ {
272
+ require "listings.php";
273
+ }else{
274
+ require "api_form.php";
275
+ }
276
+ ?>
277
+
278
+ </div>
279
+ <?php
280
+ }
281
+
282
+ add_action('admin_menu', 'admin_menu');
283
+
284
+
285
+ /**
286
+ * Adds setup navigation link under settings
287
+ * @return void
288
+ **/
289
+ function admin_menu()
290
+ {
291
+ add_options_page('Mailin Setup', 'Mailin setup', 'administrator', 'mailin_options', 'mailin_settings_admin_page');
292
+ }
293
+
294
+
295
+
296
+ /**
297
+ * Links Mailin setup page to URL
298
+ * @return setup page link
299
+ **/
300
+ function mailin_action_links($links)
301
+ {
302
+ $settings_page = add_query_arg(array('page' => 'mailin_options'), admin_url('options-general.php'));
303
+ $settings_link = '<a href="'.esc_url($settings_page).'">'.__('Settings', 'Mailin setup' ).'</a>';
304
+ array_unshift($links, $settings_link);
305
+ return $links;
306
+ }
307
+
308
+ add_filter('plugin_action_links_'.plugin_basename(__FILE__), 'mailin_action_links', 10, 1);
309
+
310
+
311
+ /**
312
+ * Sets up Plugin URL , Plugin directory , Plugin Language Directory
313
+ * SETUP subscriber table name
314
+ * @return setup page link
315
+ **/
316
+ function Initiallize_mailin_constants()
317
+ {
318
+
319
+ $locations = array(
320
+ 'plugins' => array(
321
+ 'dir' => WP_PLUGIN_DIR,
322
+ 'url' => plugins_url()
323
+ ),
324
+ 'template' => array(
325
+ 'dir' => trailingslashit(get_template_directory()).'plugins/',
326
+ 'url' => trailingslashit(get_template_directory_uri()).'plugins/',
327
+ )
328
+ );
329
+
330
+ $mailin_dirbase = trailingslashit(basename(dirname(__FILE__)));
331
+ $mailin_dir = trailingslashit(WP_PLUGIN_DIR).$mailin_dirbase;
332
+ $mailin_url = trailingslashit(WP_PLUGIN_URL).$mailin_dirbase;
333
+
334
+ foreach ($locations as $key => $loc)
335
+ {
336
+ $dir = trailingslashit($loc['dir']).$mailin_dirbase;
337
+ $url = trailingslashit($loc['url']).$mailin_dirbase;
338
+ if (is_file($dir.basename(__FILE__)))
339
+ {
340
+ $mailin_dir = $dir;
341
+ $mailin_url = $url;
342
+ break;
343
+ }
344
+ }
345
+
346
+ //MAILIN DIRECTORY PATH
347
+ define('MAILIN_DIR', $mailin_dir);
348
+
349
+ //MAILIN LANGUAGE DIRECTORY PATH
350
+ define('MAILIN_LANG_DIR', trailingslashit(MAILIN_DIR).'lang/');
351
+
352
+ //MAILIN PLUGIN DIRECTORY PATH
353
+ define('MAILIN_URL', $mailin_url);
354
+
355
+ global $wpdb;
356
+
357
+ //Subscribers table name
358
+ define('MAILIN_SUBSCRIBERS', $wpdb->prefix.'mailin_subscribers');
359
+
360
+ }
361
+
362
+ /*
363
+ * Create subscribers table upon installation
364
+ */
365
+ function mailin_install()
366
+ {
367
+
368
+ global $wpdb;
369
+ $sql = "CREATE TABLE ".MAILIN_SUBSCRIBERS." (
370
+ id int(11) NOT NULL AUTO_INCREMENT,
371
+ email VARCHAR(255) DEFAULT '' NOT NULL,
372
+ fname VARCHAR(55) DEFAULT '' NOT NULL,
373
+ lname VARCHAR(55) DEFAULT '' NOT NULL,
374
+ list VARCHAR(255) DEFAULT '' NOT NULL,
375
+ subscribed TINYINT(1) DEFAULT '1' NOT NULL,
376
+ create_date datetime DEFAULT '0000-00-00 00:00:00' NOT NULL,
377
+ UNIQUE KEY id (id)
378
+ );";
379
+
380
+ require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
381
+ dbDelta($sql);
382
+ }
383
+
384
+
385
+ /*
386
+ * Called plugin is removed
387
+ * We do not remove previous data
388
+ */
389
+ function mailin_remove()
390
+ {
391
+
392
+
393
+ }
394
+
395
+ /* Runs when plugin is activated */
396
+ register_activation_hook(__FILE__,'mailin_install');
397
+
398
+ /* Runs on plugin deactivation*/
399
+ register_deactivation_hook( __FILE__, 'mailin_remove' );
400
+
401
+
402
+ class siteUsers
403
+ {
404
+
405
+ static function init()
406
+ {
407
+ add_action( 'user_register', array( __CLASS__, 'register_newly_added_user' ) );
408
+ }
409
+
410
+ /*
411
+ * This function is called when a new user is created
412
+ * User is added in mailinlist
413
+ */
414
+ static function register_newly_added_user( $user_id = null )
415
+ {
416
+
417
+ if($user_id != null)
418
+ {
419
+ $info = get_userdata( $user_id );
420
+
421
+ if(is_object($info))
422
+ {
423
+ if(isset($info->data->user_email) && $info->data->user_email != '')
424
+ {
425
+ $user_nicename = isset($info->data->user_nicename) ? $info->data->user_nicename : '';
426
+ $selected_list = get_option('mailin_list_selected');
427
+ $mObj = new mailin_API();
428
+ $mObj->updateSubscribers($info->data->user_email , $selected_list, $user_nicename , '' );
429
+ }
430
+ }
431
+ }
432
+ wp_update_user( $args );
433
+ }
434
+
435
+ }
436
+
437
+ siteUsers::init();
438
+
439
+
440
+ ?>
mailin_widget.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Plugin Name: Foo Widget
5
+ Plugin URI: http://jamesbruce.me/
6
+ Description: Random Post Widget grabs a random post and the associated thumbnail to display on your sidebar
7
+ Author: sachin
8
+ Version: 1
9
+ Author URI: http://jamesbruce.me/
10
+ */
11
+
12
+
13
+ /**
14
+ * Adds Foo_Widget widget.
15
+ */
16
+
17
+ function getMailinSubscriptionForm(){
18
+
19
+ if(get_option('mailin_list_selected') != '') {
20
+ ?>
21
+ <div id="mailin_signup_box">
22
+ <form id="mailin_signup_form" action="#mailin_signup_box" method="post">
23
+ <input type="hidden" value="subscribe_form_submit" name="mailin_form_action">
24
+ <div class="mailin_signup_box_inside">
25
+
26
+ <div class="mailin_signup_box_row">
27
+ <span class="mailin_widget_head"><?php esc_html_e('Subscribe to newsletter', 'mailin_i18n'); ?></span>
28
+ </div>
29
+
30
+ <?php if(mailin_messages() != ''){ ?>
31
+ <div id="mailin_message" >
32
+ <?php echo mailin_messages(); ?>
33
+ </div>
34
+ <?php } ?>
35
+
36
+ <div class="mailin_signup_box_row">
37
+ <label ><?php echo esc_html_e('First name' , 'mailin_i18n')?><span class="required">*</span></label>
38
+ <input type="text" id="fname" name="fname" value="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '' ?>" size="21" maxlength="55">
39
+ </div>
40
+
41
+ <div class="mailin_signup_box_row">
42
+ <label ><?php echo esc_html_e('Last name' , 'mailin_i18n')?><span class="required">*</span></label>
43
+ <input type="text" id="lname" name="lname" value="<?php echo isset($_POST['lname']) ? $_POST['lname'] : '' ?>" size="21" maxlength="55">
44
+ </div>
45
+
46
+ <div class="mailin_signup_box_row">
47
+ <label ><?php echo esc_html_e('Email' , 'mailin_i18n')?><span class="required">*</span></label>
48
+ <input type="text" id="mailin_email" name="mailin_email" value="<?php echo isset($_POST['mailin_email']) ? $_POST['mailin_email'] : '' ?>" size="21">
49
+ </div>
50
+
51
+ <div class="mailin_signup_box_row right">
52
+ <input type="submit" class="button" value="<?php echo esc_html_e('Subscribe' , 'mailin_i18n')?>" id="mailin_signup_submit" name="mailin_signup_submit">
53
+ </div>
54
+ </div>
55
+ </form>
56
+ </div>
57
+ <?php
58
+ }
59
+ }
60
+
61
+
62
+ class Mailin_Widget extends WP_Widget {
63
+
64
+ /**
65
+ * Register widget with WordPress.
66
+ */
67
+ public function __construct() {
68
+ parent::__construct(
69
+ 'mailin_widget', // Base ID
70
+ 'Mailin_Widget', // Name
71
+ array('description' => __( 'Mailin Widget', 'mailin_i18n' ), ) // Args
72
+ );
73
+ }
74
+
75
+ /**
76
+ * Front-end display of widget.
77
+ *
78
+ * @see WP_Widget::widget()
79
+ *
80
+ * @param array $args Widget arguments.
81
+ * @param array $instance Saved values from database.
82
+ */
83
+ public function widget( $args, $instance ) {
84
+
85
+ extract( $args );
86
+
87
+ if (!is_array($instance)) {
88
+ $instance = array();
89
+ }
90
+ getMailinSubscriptionForm(array_merge($args, $instance));
91
+ }
92
+
93
+
94
+ } // class Foo_Widget
95
+
96
+ // register Foo_Widget widget
97
+
98
+ add_action( 'widgets_init', create_function( '', 'register_widget( "Mailin_Widget" );' ));
99
+
100
+ ?>
mailinapi.class.php ADDED
@@ -0,0 +1,516 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This class has functions that supports interaction with Mailin server
5
+ */
6
+
7
+ class mailin_API {
8
+
9
+ /**
10
+ error messages default set to blank
11
+ */
12
+ public $_mailin_error = array();
13
+
14
+ /**
15
+ success messages default set to blank
16
+ */
17
+ public $_mailin_success = array();
18
+
19
+ /**
20
+ * Returns all lists from databse
21
+ * @return Array
22
+ */
23
+ public function getListDetails($list_id){
24
+
25
+ $lists = get_option('mailin_lists');
26
+ $lists = unserialize($lists);
27
+
28
+ }
29
+
30
+ /**
31
+ * Updates lists in database after fetching from mailin
32
+ * @return Array
33
+ */
34
+ public function updateUserLists($api_key = null){
35
+
36
+ if($api_key == null){
37
+ $api_key = get_option('mailin_apikey');
38
+ }
39
+
40
+ if($api_key == ''){
41
+ return ;
42
+ }
43
+
44
+ $returnData = $this->getUserLists($api_key);
45
+
46
+ if(isset($returnData->result) && !empty($returnData->result)){
47
+ $listData = $returnData->result;
48
+ $lists = serialize($listData);
49
+ update_option('mailin_lists', $lists);
50
+ }
51
+
52
+ }
53
+
54
+ /**
55
+ * Updates user campaigns in database after fetching from mailin
56
+ * @return array of list
57
+ */
58
+ public function updateUserCampaigns($api_key = null){
59
+
60
+ if($api_key == null){
61
+ $api_key = get_option('mailin_apikey');
62
+ }
63
+
64
+ if($api_key == ''){
65
+ return ;
66
+ }
67
+
68
+ $returnData = $this->getUserCampaigns($api_key);
69
+
70
+ if(isset($returnData->result) && !empty($returnData->result)){
71
+ $campaigns = $returnData->result;
72
+ $campaigns = serialize($campaigns);
73
+ update_option('mailin_campaigns', $campaigns);
74
+ }
75
+
76
+ }
77
+
78
+
79
+ /**
80
+ * Validate API key entered by user
81
+ * @return array with error message (if invalid), user's lists (if valid)
82
+ */
83
+ public function validateAPIkey($api_key = null){
84
+
85
+ $isValid = false;
86
+ $error = '';
87
+ $listData = array();
88
+
89
+ if($api_key == ''){
90
+
91
+ $error = 'Please enter API key';
92
+
93
+ }else{
94
+
95
+ $returnData = $this->getUserLists($api_key);
96
+
97
+ if(!is_object($returnData)){
98
+
99
+ $error = 'Oops!, unable to connect!';
100
+
101
+ }else if(isset($returnData->errorMsg)){
102
+
103
+ $error = $returnData->errorMsg;
104
+
105
+ }else if(isset($returnData->result)){
106
+
107
+ $isValid = true;
108
+ if(!empty($returnData->result)){
109
+ $listData = $returnData->result;
110
+ }
111
+ }
112
+ }
113
+
114
+ $returnData = array('isValid' => $isValid , 'data' => $listData , 'error' => $error);
115
+ return $returnData;
116
+
117
+ }
118
+
119
+
120
+ /**
121
+ * Validate API key, saves API key in DB
122
+ * Saves users campaigns, Saves users lists
123
+ * @return void
124
+ */
125
+ public function handle_apikey_form_submit($api_key = null){
126
+
127
+ $api_key = strip_tags(trim($api_key));
128
+
129
+ $returnData = $this->validateAPIkey($api_key);
130
+
131
+ if($returnData['error'] != ''){
132
+
133
+ $this->_mailin_error[] = __( $returnData['error'] , 'mailin_i18n');
134
+
135
+ }else if(!$returnData['isValid']){
136
+
137
+ $this->_mailin_error[] = __( $returnData['error'], 'mailin_i18n');
138
+
139
+ }else{
140
+
141
+ $this->_mailin_success[] = __('Your API is valid, your lists are fetched and saved in the database.', 'mailin_i18n');
142
+
143
+ $this->updateUserLists($api_key);
144
+ $this->updateUserCampaigns($api_key);
145
+
146
+ if(!empty($returnData['data'])){
147
+
148
+ $lists = serialize($returnData['data']);
149
+ update_option('mailin_lists', $lists);
150
+
151
+ }
152
+ update_option('mailin_apikey', $api_key);
153
+ update_option('mailin_list_selected', '');
154
+
155
+ }
156
+
157
+ }
158
+
159
+
160
+ /**
161
+ * Saves selected lists (in which newsletter subscriptions will be added)
162
+ * @return void
163
+ */
164
+ public function handle_updatelist_form_submit($list_id){
165
+
166
+ if(!empty($list_id)){
167
+
168
+ $this->updateUserLists();
169
+ $list_id = implode('|', $list_id);
170
+ update_option('mailin_list_selected', $list_id);
171
+ $this->_mailin_success[] = __('List updated successfully', 'mailin_i18n');
172
+
173
+ }else{
174
+
175
+ $this->_mailin_error[] = __('Please select a list' , 'mailin_i18n');
176
+
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Removes api key, mailin lists and selected lists from DB
182
+ * @return void
183
+ */
184
+ public function handle_logout_form_submit(){
185
+
186
+ update_option('mailin_apikey', '');
187
+ update_option('mailin_lists', '');
188
+ update_option('mailin_list_selected', '');
189
+
190
+ }
191
+
192
+
193
+ /**
194
+ * Validate newsletter form and sets up error messages accordingly.
195
+ * @return void
196
+ */
197
+ function validate_newsletter_form($email, $fname , $lname) {
198
+
199
+ $result = true;
200
+
201
+ if(!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $email)) {
202
+ //$result = false;
203
+ $this->_mailin_error['email'] = __("Please enter valid e-mail" , 'mailin_i18n');
204
+ }
205
+
206
+ if($fname == ''){
207
+ $this->_mailin_error['fname'] = __("Please enter your first name" , 'mailin_i18n');
208
+ }
209
+
210
+ if($lname == ''){
211
+ $this->_mailin_error['lname'] = __("Please enter your last name" , 'mailin_i18n');
212
+ }
213
+ return $result;
214
+ }
215
+
216
+
217
+
218
+ /**
219
+ * Validate newsletter form and sets up error messages accordingly.
220
+ * @return void
221
+ */
222
+ public function handle_newsletter_subscribe_submit(){
223
+
224
+ $email = trim(strip_tags($_POST['mailin_email']));
225
+ $email = strtolower($email);
226
+
227
+ $fname = isset($_POST['fname']) ? trim(strip_tags($_POST['fname'])) : '';
228
+ $lname = isset($_POST['lname']) ? trim(strip_tags($_POST['lname'])) : '';
229
+
230
+ $this->validate_newsletter_form($email, $fname , $lname);
231
+
232
+ if(empty($this->_mailin_error)){
233
+
234
+ $api_key = get_option('mailin_apikey');
235
+ $selected_list = get_option('mailin_list_selected');
236
+
237
+ $returnData = $this->createUser($api_key ,$email , $selected_list);
238
+
239
+ if(!is_object($returnData)){
240
+
241
+ $error = 'Oops!, unable to connect!';
242
+
243
+ }else if((isset($returnData->msgTy) && $returnData->msgTy == 'success') || isset($returnData->result)){
244
+
245
+ $this-> updateUserLists($api_key);
246
+
247
+ $this-> updateSubscribers($email , $selected_list, $fname , $lname);
248
+
249
+ $this->_mailin_success[] = __('You have successfully subscribed Mailin newsletter!','mailin_i18n' );
250
+
251
+ }else if(isset($returnData->msgTy) && $returnData->msgTy == 'error'){
252
+
253
+ $this->_mailin_error[] = __($returnData->msg,'mailin_i18n');
254
+
255
+ }
256
+ }
257
+
258
+ }
259
+
260
+ public function add_subscription($email){
261
+
262
+ get_option('USERCREADIT');
263
+ //add user through ADD USER FUNCTION
264
+
265
+ }
266
+
267
+ /**
268
+ * Makes curl request to Mailin server with array of vars
269
+ * @return array returned by API
270
+ */
271
+ function curl_request($data) {
272
+
273
+ $url = 'http://ws.mailin.fr/'; //WS URL
274
+ $ch = curl_init();
275
+ // prepate data for curl post
276
+
277
+ $ndata='';
278
+ if(is_array($data)){
279
+ foreach($data AS $key=>$value){
280
+ $ndata .=$key.'='.urlencode($value).'&';
281
+ }
282
+ }else {
283
+ $ndata=$data;
284
+ }
285
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
286
+ curl_setopt($ch, CURLOPT_POST ,1);
287
+ curl_setopt ($ch, CURLOPT_POSTFIELDS,$ndata);
288
+ curl_setopt($ch, CURLOPT_HEADER, 0);
289
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
290
+ curl_setopt($ch, CURLOPT_URL, $url);
291
+ $data = curl_exec($ch);
292
+ curl_close($ch);
293
+ return $data;
294
+ }
295
+
296
+
297
+ /**
298
+ * Creates a user under the provided list id
299
+ * @return Array
300
+ */
301
+ public function createUser($api_key = null, $email, $list_id){
302
+
303
+ $data['key']= $api_key ;
304
+ $data['webaction']='USERCREADIT';
305
+ $data['email']= $email;
306
+ $data['id']='';
307
+ $data['blacklisted']='';
308
+ $data['attributes_name']='';
309
+ $data['attributes_value']='';
310
+ $data['listid']= $list_id;
311
+
312
+ $return = $this->curl_request($data);
313
+ $return = json_decode($return);
314
+ return $return;
315
+
316
+ }
317
+
318
+
319
+ /**
320
+ * Return list data from Mailin server
321
+ * @return Array
322
+ */
323
+ public function getUserLists($api_key = null , $list_id = null){
324
+
325
+ if($api_key == '') {
326
+ return ;
327
+ }
328
+
329
+ $data = array();
330
+ $data['key'] = $api_key;
331
+ $data['webaction']= 'DISPLAYLISTDATA';
332
+
333
+ if($list_id != null){
334
+ $data['listids'] = $list_id;
335
+ }
336
+
337
+ $return = $this->curl_request($data);
338
+ $return = json_decode($return);
339
+
340
+ return $return;
341
+ }
342
+
343
+
344
+
345
+ /**
346
+ * Returns user data of provided list Ids from Mailin server
347
+ * @return Array;
348
+ */
349
+ function getListUsers($api_key, $list_ids){
350
+
351
+
352
+ if($api_key == '') {
353
+ return ;
354
+ }
355
+
356
+ $data = array();
357
+ $data['webaction']='DISPLAYLISTDATABLACK';
358
+ $data['key']=$api_key;
359
+
360
+ $data['listids']= $list_ids;
361
+
362
+ $return = $this->curl_request($data);
363
+ $return = json_decode($return);
364
+
365
+ return $return;
366
+
367
+ }
368
+
369
+
370
+ /**
371
+ * Returns user's campaigns from Mailin
372
+ * @return Array;
373
+ */
374
+ public function getUserCampaigns($api_key = null){
375
+
376
+ if($api_key == '') {
377
+ return ;
378
+ }
379
+
380
+ $data = array();
381
+ $data['key'] = $api_key;
382
+ $data['webaction']= 'CAMPAIGNDETAIL';
383
+ $data['show']='ALL';
384
+
385
+ $return = $this->curl_request($data);
386
+ $return = json_decode($return);
387
+ return $return;
388
+ }
389
+
390
+
391
+
392
+ /**
393
+ * Returns user details of email provided from Mailin server
394
+ * @return Array;
395
+ */
396
+ public function validateUser($api_key, $email){
397
+
398
+ if($api_key == '') {
399
+ return ;
400
+ }
401
+
402
+ $data = array();
403
+ $data['key'] = $api_key;
404
+ $data['webaction']= 'DISPLAYUSERDETAIL';
405
+ $data['email']= $email;
406
+
407
+ $return = $this->curl_request($data);
408
+ $return = json_decode($return);
409
+ return $return;
410
+ }
411
+
412
+
413
+
414
+ /**
415
+ * Inserts/updates(user status) in subscription table
416
+ * @return void;
417
+ */
418
+ public function updateSubscribers($email , $selected_list, $fname , $lname){
419
+
420
+ $selected_list = explode('|', $selected_list);
421
+ $selected_list = implode(',', $selected_list);
422
+
423
+ global $wpdb;
424
+ $myrows = $wpdb->get_results( "SELECT id FROM ".MAILIN_SUBSCRIBERS." WHERE email = '".$email."' LIMIT 1");
425
+
426
+ if(empty($myrows)){
427
+
428
+ $sql = "INSERT INTO ".MAILIN_SUBSCRIBERS."
429
+ SET email= '".$email."', fname = '".$fname."' ,
430
+ lname = '".$lname."' , list = '".$selected_list."' , create_date= '".date('Y-m-d H:i:s')."' ";
431
+
432
+ $wpdb->query($sql);
433
+
434
+ }else{
435
+
436
+ $sql = "UPDATE ".MAILIN_SUBSCRIBERS." SET list = '".$selected_list."' , fname = '".$fname."' ,
437
+ lname = '".$lname."' , create_date= '".date('Y-m-d H:i:s')."' WHERE id = ".$myrows[0]->id." ";
438
+ $wpdb->query($sql);
439
+ }
440
+ }
441
+
442
+
443
+ /**
444
+ * Returns subscribers from subscription table
445
+ * @return void;
446
+ */
447
+ public function getAllSubscribers($subs = 1){
448
+
449
+ global $wpdb;
450
+
451
+ $sql = "SELECT * FROM ".MAILIN_SUBSCRIBERS." WHERE 1=1 ";
452
+
453
+ if($subs == 1){
454
+ $sql .= " AND subscribed = '1' ";
455
+ }
456
+
457
+ $myrows = $wpdb->get_results($sql);
458
+ return $myrows;
459
+ }
460
+
461
+
462
+ /**
463
+ * Synchronize the user's status in subscription table with user's status on Mailin
464
+ * @return bool;
465
+ */
466
+ public function syncUsers(){
467
+
468
+ global $wpdb;
469
+ $api_key = get_option('mailin_apikey');
470
+
471
+ $lists = get_option('mailin_lists');
472
+ $lists = unserialize($lists);
473
+
474
+ $final_data = array();
475
+ foreach($lists as $data){
476
+ $final_data[] = $data->id;
477
+ }
478
+
479
+ $list_ids = '';
480
+ if(!empty($final_data)){
481
+ $list_ids = implode('|' , $final_data);
482
+ }
483
+
484
+ if($list_ids == ''){
485
+ return ;
486
+ }
487
+
488
+ $list_users = $this->getListUsers($api_key , $list_ids);
489
+
490
+
491
+ if(!empty($list_users->result)){
492
+
493
+ foreach($list_users->result as $key=>$lists){
494
+
495
+ if(!empty($lists)){
496
+ foreach($lists as $users){
497
+
498
+ if(isset($users->blacklisted)){
499
+
500
+ if($users->blacklisted == '1'){
501
+ $sql = "UPDATE ".MAILIN_SUBSCRIBERS." SET subscribed = '0' WHERE email = '".strtolower(trim($users->email))."' " ;
502
+ }else{
503
+ $sql = "UPDATE ".MAILIN_SUBSCRIBERS." SET subscribed = '1' WHERE email = '".strtolower(trim($users->email))."' " ;
504
+
505
+ }
506
+ $myrows = $wpdb->query($sql);
507
+ }
508
+ }
509
+ }
510
+ }
511
+ }
512
+ return true;
513
+ }
514
+
515
+ }
516
+ ?>
readme.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === mailin ===
2
+ Contributors: mailin
3
+ Tags: mailin, email, signup, plugin, widget, newsletter
4
+ Requires at least: 2.8
5
+ Tested up to: 3.4.1
6
+ Stable tag: 1.2.9
7
+
8
+ The Mailin plugin provides quick and easy way to synchronize your customers with Mailin (www.mailin.fr) and it displays statistics of your marketing campaigns.
9
+
10
+
11
+ == Installation ==
12
+ 1. Unzip Mailin and upload the 'mailin' directory to your '/wp-content/plugins/' directory.
13
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
14
+ 3. Go to Settings and look for "Mailin Setup" in the menu.
15
+ 4. Enter your Mailin API Key and let the plugin verify it.
16
+ 5. Select One of your lists to in which subscribers will be added.
17
+ 6. Finally, go to Appearance->Widgets and drag the `Mailin Widget` widget into one of your Widget Areas
18
+ 7. And you are DONE!
19
+ 8. Additionaly if you want wordpress users to be synchronized with mailin users set cron on cron.php file using cpanel or crontab.
20
+
21
+
22
+ == Internationalization (i18n) ==
23
+ Mailin plugin can be easily translated and the following languages:
24
+ * en_US - English in the U.S.
25
+ * fr_FR - French in France